aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm/AsmAnalysis.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-05-29 22:52:51 +0800
committerGitHub <noreply@github.com>2017-05-29 22:52:51 +0800
commit8b29cc55357b4eec12c771707ed4025d11ca4365 (patch)
tree7474badc8dfe8d7685b560ab9e9d5be1e50323dc /libsolidity/inlineasm/AsmAnalysis.cpp
parent9822deeed9d0be1324d6b6bdbdf83ae7ebca9b69 (diff)
parent4af55c78ebcacb5cfda1b573253cac6e6824d67a (diff)
downloaddexon-solidity-8b29cc55357b4eec12c771707ed4025d11ca4365.tar
dexon-solidity-8b29cc55357b4eec12c771707ed4025d11ca4365.tar.gz
dexon-solidity-8b29cc55357b4eec12c771707ed4025d11ca4365.tar.bz2
dexon-solidity-8b29cc55357b4eec12c771707ed4025d11ca4365.tar.lz
dexon-solidity-8b29cc55357b4eec12c771707ed4025d11ca4365.tar.xz
dexon-solidity-8b29cc55357b4eec12c771707ed4025d11ca4365.tar.zst
dexon-solidity-8b29cc55357b4eec12c771707ed4025d11ca4365.zip
Merge pull request #2319 from ethereum/virtualBlocks
Introduce virtual blocks for function arguments.
Diffstat (limited to 'libsolidity/inlineasm/AsmAnalysis.cpp')
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp15
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;
}