diff --git a/Compiler.cpp b/Compiler.cpp index 9cef1f2ac..23591d1a5 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -129,6 +129,7 @@ void Compiler::packIntoContractCreator(ContractDefinition const& _contract, Comp void Compiler::appendBaseConstructorCall(FunctionDefinition const& _constructor, vector> const& _arguments) { + CompilerContext::LocationSetter locationSetter(m_context, &_constructor); FunctionType constructorType(_constructor); eth::AssemblyItem returnLabel = m_context.pushNewTag(); for (unsigned i = 0; i < _arguments.size(); ++i) @@ -139,6 +140,7 @@ void Compiler::appendBaseConstructorCall(FunctionDefinition const& _constructor, void Compiler::appendConstructorCall(FunctionDefinition const& _constructor) { + CompilerContext::LocationSetter locationSetter(m_context, &_constructor); eth::AssemblyItem returnTag = m_context.pushNewTag(); // copy constructor arguments from code to memory and then to stack, they are supplied after the actual program unsigned argumentSize = 0; @@ -513,8 +515,8 @@ void Compiler::appendModifierOrFunctionCode() else { ASTPointer const& modifierInvocation = m_currentFunction->getModifiers()[m_modifierDepth]; - ModifierDefinition const& modifier = m_context.getFunctionModifier(modifierInvocation->getName()->getName()); + CompilerContext::LocationSetter locationSetter(m_context, &modifier); solAssert(modifier.getParameters().size() == modifierInvocation->getArguments().size(), ""); for (unsigned i = 0; i < modifier.getParameters().size(); ++i) { diff --git a/CompilerContext.cpp b/CompilerContext.cpp index 8bb6cb005..18be337fa 100644 --- a/CompilerContext.cpp +++ b/CompilerContext.cpp @@ -65,8 +65,8 @@ void CompilerContext::addVariable(VariableDeclaration const& _declaration, void CompilerContext::addAndInitializeVariable(VariableDeclaration const& _declaration) { + LocationSetter locationSetter(*this, &_declaration); addVariable(_declaration); - int const size = _declaration.getType()->getSizeOnStack(); for (int i = 0; i < size; ++i) *this << u256(0); @@ -173,7 +173,7 @@ void CompilerContext::resetVisitedNodes(ASTNode const* _node) std::swap(m_visitedNodes, newStack); } -CompilerContext& CompilerContext::operator<<(eth::AssemblyItem _item) +CompilerContext& CompilerContext::operator<<(eth::AssemblyItem const& _item) { solAssert(!m_visitedNodes.empty(), "No node on the visited stack"); m_asm.append(_item, m_visitedNodes.top()->getLocation()); diff --git a/CompilerContext.h b/CompilerContext.h index 6e1dbfbce..94d6443e9 100644 --- a/CompilerContext.h +++ b/CompilerContext.h @@ -108,7 +108,7 @@ public: void pushVisitedNodes(ASTNode const* _node) { m_visitedNodes.push(_node); } /// Append elements to the current instruction list and adjust @a m_stackOffset. - CompilerContext& operator<<(eth::AssemblyItem _item); + CompilerContext& operator<<(eth::AssemblyItem const& _item); CompilerContext& operator<<(eth::Instruction _instruction); CompilerContext& operator<<(u256 const& _value); CompilerContext& operator<<(bytes const& _data); diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 90a3f3ac0..94c71fc03 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -68,6 +68,7 @@ void ExpressionCompiler::appendStateVariableInitialization(CompilerContext& _con void ExpressionCompiler::appendStateVariableInitialization(VariableDeclaration const& _varDecl) { + CompilerContext::LocationSetter locationSetter(m_context, &_varDecl); LValue var = LValue(m_context); var.fromDeclaration(_varDecl, _varDecl.getValue()->getLocation()); var.storeValue(*_varDecl.getType(), _varDecl.getLocation()); @@ -999,6 +1000,7 @@ void ExpressionCompiler::appendExpressionCopyToMemory(Type const& _expectedType, void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& _varDecl) { + CompilerContext::LocationSetter locationSetter(m_context, &_varDecl); FunctionType accessorType(_varDecl); unsigned length = 0;