diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-25 17:40:14 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-25 17:40:14 +0800 |
commit | 71b0d8107aae500a5301e675aef3515539efe02f (patch) | |
tree | 8a844d94ef6c66b7c82610f5a966e64f4b9cf8d5 | |
parent | 54121a0d787df1b730fa523b21040c312dda4bf6 (diff) | |
download | dexon-solidity-71b0d8107aae500a5301e675aef3515539efe02f.tar dexon-solidity-71b0d8107aae500a5301e675aef3515539efe02f.tar.gz dexon-solidity-71b0d8107aae500a5301e675aef3515539efe02f.tar.bz2 dexon-solidity-71b0d8107aae500a5301e675aef3515539efe02f.tar.lz dexon-solidity-71b0d8107aae500a5301e675aef3515539efe02f.tar.xz dexon-solidity-71b0d8107aae500a5301e675aef3515539efe02f.tar.zst dexon-solidity-71b0d8107aae500a5301e675aef3515539efe02f.zip |
LocationSetter in some extra places during Compiling
- Also adjusted the test, and fixed its error reporting
-rw-r--r-- | Compiler.cpp | 4 | ||||
-rw-r--r-- | CompilerContext.cpp | 4 | ||||
-rw-r--r-- | CompilerContext.h | 2 | ||||
-rw-r--r-- | ExpressionCompiler.cpp | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/Compiler.cpp b/Compiler.cpp index 9cef1f2a..23591d1a 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<ASTPointer<Expression>> 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<ModifierInvocation> 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 8bb6cb00..18be337f 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 6e1dbfbc..94d6443e 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 90a3f3ac..94c71fc0 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; |