aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityExpressionCompiler.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-12-05 10:09:47 +0800
committerchriseth <c@ethdev.com>2015-12-10 02:09:24 +0800
commit7cb7818ceaf8f2e50cdd66b33a4e0d17c2a0e879 (patch)
treed6ac5e5fe041afc29dcea2aafa97d60dca82a991 /test/libsolidity/SolidityExpressionCompiler.cpp
parente510e7e7929326de3a556d6d2e66b8b4376af7a9 (diff)
downloaddexon-solidity-7cb7818ceaf8f2e50cdd66b33a4e0d17c2a0e879.tar.gz
dexon-solidity-7cb7818ceaf8f2e50cdd66b33a4e0d17c2a0e879.tar.zst
dexon-solidity-7cb7818ceaf8f2e50cdd66b33a4e0d17c2a0e879.zip
Source units are independent scopes.
Diffstat (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp')
-rw-r--r--test/libsolidity/SolidityExpressionCompiler.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp
index a622c738..0e814e56 100644
--- a/test/libsolidity/SolidityExpressionCompiler.cpp
+++ b/test/libsolidity/SolidityExpressionCompiler.cpp
@@ -71,18 +71,21 @@ private:
};
Declaration const& resolveDeclaration(
- vector<string> const& _namespacedName, NameAndTypeResolver const& _resolver)
+ SourceUnit const& _sourceUnit,
+ vector<string> const& _namespacedName,
+ NameAndTypeResolver const& _resolver
+)
{
- Declaration const* declaration = nullptr;
+ ASTNode const* scope = &_sourceUnit;
// bracers are required, cause msvc couldnt handle this macro in for statement
for (string const& namePart: _namespacedName)
{
- auto declarations = _resolver.resolveName(namePart, declaration);
+ auto declarations = _resolver.resolveName(namePart, scope);
BOOST_REQUIRE(!declarations.empty());
- BOOST_REQUIRE(declaration = *declarations.begin());
+ BOOST_REQUIRE(scope = *declarations.begin());
}
- BOOST_REQUIRE(declaration);
- return *declaration;
+ BOOST_REQUIRE(scope);
+ return dynamic_cast<Declaration const&>(*scope);
}
bytes compileFirstExpression(
@@ -140,13 +143,17 @@ bytes compileFirstExpression(
unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack
context.adjustStackOffset(parametersSize);
for (vector<string> const& variable: _localVariables)
- context.addVariable(dynamic_cast<VariableDeclaration const&>(resolveDeclaration(variable, resolver)),
- parametersSize--);
+ context.addVariable(
+ dynamic_cast<VariableDeclaration const&>(resolveDeclaration(*sourceUnit, variable, resolver)),
+ parametersSize--
+ );
ExpressionCompiler(context).compile(*extractor.expression());
for (vector<string> const& function: _functions)
- context << context.functionEntryLabel(dynamic_cast<FunctionDefinition const&>(resolveDeclaration(function, resolver)));
+ context << context.functionEntryLabel(dynamic_cast<FunctionDefinition const&>(
+ resolveDeclaration(*sourceUnit, function, resolver)
+ ));
bytes instructions = context.assembledObject().bytecode;
// debug
// cout << eth::disassemble(instructions) << endl;