diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-05-06 01:35:40 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-05-23 01:45:34 +0800 |
commit | 15b4d4def23bcf0feb93c67dccc137baa59d5102 (patch) | |
tree | b684d5e478bde7d69021fd2f2235fa569d457f40 /libsolidity/inlineasm/AsmAnalysis.cpp | |
parent | 74d2e7311aed67e3bb6fcf1f0fa138bc3d304095 (diff) | |
download | dexon-solidity-15b4d4def23bcf0feb93c67dccc137baa59d5102.tar dexon-solidity-15b4d4def23bcf0feb93c67dccc137baa59d5102.tar.gz dexon-solidity-15b4d4def23bcf0feb93c67dccc137baa59d5102.tar.bz2 dexon-solidity-15b4d4def23bcf0feb93c67dccc137baa59d5102.tar.lz dexon-solidity-15b4d4def23bcf0feb93c67dccc137baa59d5102.tar.xz dexon-solidity-15b4d4def23bcf0feb93c67dccc137baa59d5102.tar.zst dexon-solidity-15b4d4def23bcf0feb93c67dccc137baa59d5102.zip |
Support multiple variables in a variable declaration in inline assembly
Diffstat (limited to 'libsolidity/inlineasm/AsmAnalysis.cpp')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index e03eea2e..8d3d1fd2 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -181,12 +181,32 @@ bool AsmAnalyzer::operator()(FunctionalAssignment const& _assignment) bool AsmAnalyzer::operator()(assembly::VariableDeclaration const& _varDecl) { + // The number of variable names and values must match. One exception + // is a single value, where a tuple assignment is assumed from a function. + if (_varDecl.variables.size() != _varDecl.values.size()) + { + if (_varDecl.values.size() != 1) + { + m_errors.push_back(make_shared<Error>( + Error::Type::DeclarationError, + "Variable declaration name and value count mismatch.", + _varDecl.location + )); + return false; + } + } + + int const expectedItems = _varDecl.variables.size(); int const stackHeight = m_stackHeight; - bool success = boost::apply_visitor(*this, *_varDecl.value); - solAssert(m_stackHeight - stackHeight == 1, "Invalid value size."); - boost::get<Scope::Variable>(m_currentScope->identifiers.at(_varDecl.variable.name)).active = true; + for (auto const& value: _varDecl.values) + if (!boost::apply_visitor(*this, value)) + return false; + solAssert(m_stackHeight - stackHeight == expectedItems, "Invalid value size."); + + for (auto const& variable: _varDecl.variables) + boost::get<Scope::Variable>(m_currentScope->identifiers.at(variable.name)).active = true; m_info.stackHeightInfo[&_varDecl] = m_stackHeight; - return success; + return true; } bool AsmAnalyzer::operator()(assembly::FunctionDefinition const& _funDef) |