diff options
author | chriseth <c@ethdev.com> | 2015-03-08 06:08:39 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-03-09 20:28:29 +0800 |
commit | 94c51caf89a86e29dab21141d76eae0c73292b01 (patch) | |
tree | 2d11b97c706515895836a6b2130f24d723136517 /CompilerContext.h | |
parent | 67ffc3db714bf1a4930a9e340e500285e985222f (diff) | |
download | dexon-solidity-94c51caf89a86e29dab21141d76eae0c73292b01.tar.gz dexon-solidity-94c51caf89a86e29dab21141d76eae0c73292b01.tar.zst dexon-solidity-94c51caf89a86e29dab21141d76eae0c73292b01.zip |
Fixed: Some instructions did not have source locations.
Diffstat (limited to 'CompilerContext.h')
-rw-r--r-- | CompilerContext.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/CompilerContext.h b/CompilerContext.h index e42e7c76..3f31a160 100644 --- a/CompilerContext.h +++ b/CompilerContext.h @@ -108,15 +108,15 @@ public: /// Resets the stack of visited nodes with a new stack having only @c _node void resetVisitedNodes(ASTNode const* _node); /// Pops the stack of visited nodes - void popVisitedNodes() { m_visitedNodes.pop(); } + void popVisitedNodes() { m_visitedNodes.pop(); updateSourceLocation(); } /// Pushes an ASTNode to the stack of visited nodes - void pushVisitedNodes(ASTNode const* _node) { m_visitedNodes.push(_node); } + void pushVisitedNodes(ASTNode const* _node) { m_visitedNodes.push(_node); updateSourceLocation(); } /// Append elements to the current instruction list and adjust @a m_stackOffset. - CompilerContext& operator<<(eth::AssemblyItem const& _item); - CompilerContext& operator<<(eth::Instruction _instruction); - CompilerContext& operator<<(u256 const& _value); - CompilerContext& operator<<(bytes const& _data); + CompilerContext& operator<<(eth::AssemblyItem const& _item) { m_asm.append(_item); return *this; } + CompilerContext& operator<<(eth::Instruction _instruction) { m_asm.append(_instruction); return *this; } + CompilerContext& operator<<(u256 const& _value) { m_asm.append(_value); return *this; } + CompilerContext& operator<<(bytes const& _data) { m_asm.append(_data); return *this; } eth::Assembly const& getAssembly() const { return m_asm; } /// @arg _sourceCodes is the map of input files to source code strings @@ -130,12 +130,15 @@ public: class LocationSetter: public ScopeGuard { public: - LocationSetter(CompilerContext& _compilerContext, ASTNode const* _node): - ScopeGuard(std::bind(&CompilerContext::popVisitedNodes, _compilerContext)) { _compilerContext.pushVisitedNodes(_node); } + LocationSetter(CompilerContext& _compilerContext, ASTNode const& _node): + ScopeGuard([&]{ _compilerContext.popVisitedNodes(); }) + { _compilerContext.pushVisitedNodes(&_node); } }; private: std::vector<ContractDefinition const*>::const_iterator getSuperContract(const ContractDefinition &_contract) const; + /// Updates source location set in the assembly. + void updateSourceLocation(); eth::Assembly m_asm; /// Magic global variables like msg, tx or this, distinguished by type. |