diff options
author | chriseth <chris@ethereum.org> | 2017-05-27 03:46:02 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-05-29 22:18:16 +0800 |
commit | 4af55c78ebcacb5cfda1b573253cac6e6824d67a (patch) | |
tree | e03445356136f0186cd37eb1fb1b9b5b4e6b66c4 /libsolidity/inlineasm/AsmAnalysis.cpp | |
parent | 002df12d13fb423be641878a20b73bd10f90a6df (diff) | |
download | dexon-solidity-4af55c78ebcacb5cfda1b573253cac6e6824d67a.tar.gz dexon-solidity-4af55c78ebcacb5cfda1b573253cac6e6824d67a.tar.zst dexon-solidity-4af55c78ebcacb5cfda1b573253cac6e6824d67a.zip |
Introduce virtual blocks for function arguments.
Diffstat (limited to 'libsolidity/inlineasm/AsmAnalysis.cpp')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index eeb7d0a6..9f512f87 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -46,7 +46,7 @@ set<string> const builtinTypes{"bool", "u8", "s8", "u32", "s32", "u64", "s64", " bool AsmAnalyzer::analyze(Block const& _block) { - if (!(ScopeFiller(m_info.scopes, m_errors))(_block)) + if (!(ScopeFiller(m_info, m_errors))(_block)) return false; return (*this)(_block); @@ -206,16 +206,17 @@ bool AsmAnalyzer::operator()(assembly::VariableDeclaration const& _varDecl) bool AsmAnalyzer::operator()(assembly::FunctionDefinition const& _funDef) { - Scope& bodyScope = scope(&_funDef.body); + Block const* virtualBlock = m_info.virtualBlocks.at(&_funDef).get(); + solAssert(virtualBlock, ""); + Scope& varScope = scope(virtualBlock); for (auto const& var: _funDef.arguments + _funDef.returns) { expectValidType(var.type, var.location); - boost::get<Scope::Variable>(bodyScope.identifiers.at(var.name)).active = true; + boost::get<Scope::Variable>(varScope.identifiers.at(var.name)).active = true; } int const stackHeight = m_stackHeight; m_stackHeight = _funDef.arguments.size() + _funDef.returns.size(); - m_virtualVariablesInNextBlock = m_stackHeight; bool success = (*this)(_funDef.body); @@ -337,10 +338,10 @@ bool AsmAnalyzer::operator()(Switch const& _switch) bool AsmAnalyzer::operator()(Block const& _block) { bool success = true; + auto previousScope = m_currentScope; m_currentScope = &scope(&_block); - int const initialStackHeight = m_stackHeight - m_virtualVariablesInNextBlock; - m_virtualVariablesInNextBlock = 0; + int const initialStackHeight = m_stackHeight; for (auto const& s: _block.statements) if (!boost::apply_visitor(*this, s)) @@ -366,8 +367,8 @@ bool AsmAnalyzer::operator()(Block const& _block) success = false; } - m_currentScope = m_currentScope->superScope; m_info.stackHeightInfo[&_block] = m_stackHeight; + m_currentScope = previousScope; return success; } |