diff options
author | chriseth <chris@ethereum.org> | 2017-05-25 00:34:19 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-06-08 21:52:44 +0800 |
commit | 97cc968a133247e729ed1d189d35ef2b7b53b3d4 (patch) | |
tree | c2aa552abea75a732e36e0c6b357ea879f35de54 /libsolidity/inlineasm/AsmAnalysis.cpp | |
parent | 21e0b69dcb189fb52ac4e38959801582e02ca8fd (diff) | |
download | dexon-solidity-97cc968a133247e729ed1d189d35ef2b7b53b3d4.tar.gz dexon-solidity-97cc968a133247e729ed1d189d35ef2b7b53b3d4.tar.zst dexon-solidity-97cc968a133247e729ed1d189d35ef2b7b53b3d4.zip |
Initial EVM1.5 assembly implementation.
Diffstat (limited to 'libsolidity/inlineasm/AsmAnalysis.cpp')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index 3edc01ad..b59a8527 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -25,7 +25,7 @@ #include <libsolidity/inlineasm/AsmScope.h> #include <libsolidity/inlineasm/AsmAnalysisInfo.h> -#include <libsolidity/interface/Exceptions.h> +#include <libsolidity/interface/ErrorReporter.h> #include <libsolidity/interface/Utils.h> #include <boost/range/adaptor/reversed.hpp> @@ -120,7 +120,10 @@ bool AsmAnalyzer::operator()(assembly::Identifier const& _identifier) { size_t stackSize(-1); if (m_resolver) - stackSize = m_resolver(_identifier, julia::IdentifierContext::RValue); + { + bool insideFunction = m_currentScope->insideFunction(); + stackSize = m_resolver(_identifier, julia::IdentifierContext::RValue, insideFunction); + } if (stackSize == size_t(-1)) { // Only add an error message if the callback did not do it. @@ -200,7 +203,8 @@ bool AsmAnalyzer::operator()(assembly::FunctionDefinition const& _funDef) } int const stackHeight = m_stackHeight; - m_stackHeight = _funDef.arguments.size() + _funDef.returns.size(); + // 1 for return label, depends on VM version + m_stackHeight = 1 + _funDef.arguments.size() + _funDef.returns.size(); bool success = (*this)(_funDef.body); @@ -254,10 +258,11 @@ bool AsmAnalyzer::operator()(assembly::FunctionCall const& _funCall) success = false; } } + m_stackHeight += 1; // Return label, but depends on backend for (auto const& arg: _funCall.arguments | boost::adaptors::reversed) if (!expectExpression(arg)) success = false; - m_stackHeight += int(returns) - int(arguments); + m_stackHeight += int(returns) - int(arguments) - 1; // Return label, but depends on backend m_info.stackHeightInfo[&_funCall] = m_stackHeight; return success; } @@ -295,6 +300,7 @@ bool AsmAnalyzer::operator()(Switch const& _switch) } m_stackHeight--; + m_info.stackHeightInfo[&_switch] = m_stackHeight; return success; } @@ -378,7 +384,10 @@ bool AsmAnalyzer::checkAssignment(assembly::Identifier const& _variable, size_t variableSize = 1; } else if (m_resolver) - variableSize = m_resolver(_variable, julia::IdentifierContext::LValue); + { + bool insideFunction = m_currentScope->insideFunction(); + variableSize = m_resolver(_variable, julia::IdentifierContext::LValue, insideFunction); + } if (variableSize == size_t(-1)) { // Only add message if the callback did not. |