diff options
Diffstat (limited to 'libsolidity/codegen/CompilerContext.cpp')
-rw-r--r-- | libsolidity/codegen/CompilerContext.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index e52d14de..bc4de3ee 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -124,14 +124,15 @@ void CompilerContext::addVariable(VariableDeclaration const& _declaration, unsigned _offsetToCurrent) { solAssert(m_asm->deposit() >= 0 && unsigned(m_asm->deposit()) >= _offsetToCurrent, ""); - solAssert(m_localVariables.count(&_declaration) == 0, "Variable already present"); - m_localVariables[&_declaration] = unsigned(m_asm->deposit()) - _offsetToCurrent; + m_localVariables[&_declaration].push_back(unsigned(m_asm->deposit()) - _offsetToCurrent); } void CompilerContext::removeVariable(VariableDeclaration const& _declaration) { - solAssert(!!m_localVariables.count(&_declaration), ""); - m_localVariables.erase(&_declaration); + solAssert(m_localVariables.count(&_declaration) && !m_localVariables[&_declaration].empty(), ""); + m_localVariables[&_declaration].pop_back(); + if (m_localVariables[&_declaration].empty()) + m_localVariables.erase(&_declaration); } eth::Assembly const& CompilerContext::compiledContract(const ContractDefinition& _contract) const @@ -203,7 +204,8 @@ unsigned CompilerContext::baseStackOffsetOfVariable(Declaration const& _declarat { auto res = m_localVariables.find(&_declaration); solAssert(res != m_localVariables.end(), "Variable not found on stack."); - return res->second; + solAssert(!res->second.empty(), ""); + return res->second.back(); } unsigned CompilerContext::baseToCurrentStackOffset(unsigned _baseOffset) const |