aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm/AsmScopeFiller.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/AsmScopeFiller.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/AsmScopeFiller.cpp')
-rw-r--r--libsolidity/inlineasm/AsmScopeFiller.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/libsolidity/inlineasm/AsmScopeFiller.cpp b/libsolidity/inlineasm/AsmScopeFiller.cpp
index 7eb6a9ed..3fade842 100644
--- a/libsolidity/inlineasm/AsmScopeFiller.cpp
+++ b/libsolidity/inlineasm/AsmScopeFiller.cpp
@@ -22,6 +22,7 @@
#include <libsolidity/inlineasm/AsmData.h>
#include <libsolidity/inlineasm/AsmScope.h>
+#include <libsolidity/inlineasm/AsmAnalysisInfo.h>
#include <libsolidity/interface/Exceptions.h>
#include <libsolidity/interface/Utils.h>
@@ -36,8 +37,8 @@ using namespace dev;
using namespace dev::solidity;
using namespace dev::solidity::assembly;
-ScopeFiller::ScopeFiller(ScopeFiller::Scopes& _scopes, ErrorList& _errors):
- m_scopes(_scopes), m_errors(_errors)
+ScopeFiller::ScopeFiller(AsmAnalysisInfo& _info, ErrorList& _errors):
+ m_info(_info), m_errors(_errors)
{
m_currentScope = &scope(nullptr);
}
@@ -84,16 +85,22 @@ bool ScopeFiller::operator()(assembly::FunctionDefinition const& _funDef)
));
success = false;
}
- Scope& body = scope(&_funDef.body);
- body.superScope = m_currentScope;
- body.functionScope = true;
+
+ auto virtualBlock = m_info.virtualBlocks[&_funDef] = make_shared<Block>();
+ Scope& varScope = scope(virtualBlock.get());
+ varScope.superScope = m_currentScope;
+ m_currentScope = &varScope;
+ varScope.functionScope = true;
for (auto const& var: _funDef.arguments + _funDef.returns)
- if (!registerVariable(var, _funDef.location, body))
+ if (!registerVariable(var, _funDef.location, varScope))
success = false;
if (!(*this)(_funDef.body))
success = false;
+ solAssert(m_currentScope == &varScope, "");
+ m_currentScope = m_currentScope->superScope;
+
return success;
}
@@ -137,7 +144,7 @@ bool ScopeFiller::registerVariable(TypedName const& _name, SourceLocation const&
Scope& ScopeFiller::scope(Block const* _block)
{
- auto& scope = m_scopes[_block];
+ auto& scope = m_info.scopes[_block];
if (!scope)
scope = make_shared<Scope>();
return *scope;