diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-05-05 23:46:26 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-13 21:18:18 +0800 |
commit | cee93d946d798a4076ab5df5f32c5687608defe8 (patch) | |
tree | cb18f5535430049f7474f0e777a82cff9cf8a713 /libsolidity | |
parent | 2b33e0bcecdb2afe6a7ea242bce83480bb50a071 (diff) | |
download | dexon-solidity-cee93d946d798a4076ab5df5f32c5687608defe8.tar dexon-solidity-cee93d946d798a4076ab5df5f32c5687608defe8.tar.gz dexon-solidity-cee93d946d798a4076ab5df5f32c5687608defe8.tar.bz2 dexon-solidity-cee93d946d798a4076ab5df5f32c5687608defe8.tar.lz dexon-solidity-cee93d946d798a4076ab5df5f32c5687608defe8.tar.xz dexon-solidity-cee93d946d798a4076ab5df5f32c5687608defe8.tar.zst dexon-solidity-cee93d946d798a4076ab5df5f32c5687608defe8.zip |
Support parsing let statements without a value
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 16 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 13 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmPrinter.cpp | 7 |
3 files changed, 25 insertions, 11 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index 7e00ffae..d8aca725 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -174,14 +174,20 @@ bool AsmAnalyzer::operator()(assembly::Assignment const& _assignment) bool AsmAnalyzer::operator()(assembly::VariableDeclaration const& _varDecl) { + bool success = true; int const expectedItems = _varDecl.variables.size(); - int const stackHeight = m_stackHeight; - bool success = boost::apply_visitor(*this, *_varDecl.value); - if ((m_stackHeight - stackHeight) != expectedItems) + if (_varDecl.value) { - m_errorReporter.declarationError(_varDecl.location, "Variable count mismatch."); - return false; + int const stackHeight = m_stackHeight; + success = boost::apply_visitor(*this, *_varDecl.value); + if ((m_stackHeight - stackHeight) != expectedItems) + { + m_errorReporter.declarationError(_varDecl.location, "Variable count mismatch."); + return false; + } } + else + m_stackHeight += expectedItems; for (auto const& variable: _varDecl.variables) { diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index d282a30d..133f70b1 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -347,10 +347,15 @@ assembly::VariableDeclaration Parser::parseVariableDeclaration() else break; } - expectToken(Token::Colon); - expectToken(Token::Assign); - varDecl.value.reset(new Statement(parseExpression())); - varDecl.location.end = locationOf(*varDecl.value).end; + if (currentToken() == Token::Colon) + { + expectToken(Token::Colon); + expectToken(Token::Assign); + varDecl.value.reset(new Statement(parseExpression())); + varDecl.location.end = locationOf(*varDecl.value).end; + } + else + varDecl.location.end = varDecl.variables.back().location.end; return varDecl; } diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp index 062ff453..4f96a3e9 100644 --- a/libsolidity/inlineasm/AsmPrinter.cpp +++ b/libsolidity/inlineasm/AsmPrinter.cpp @@ -128,8 +128,11 @@ string AsmPrinter::operator()(assembly::VariableDeclaration const& _variableDecl ), ", " ); - out += " := "; - out += boost::apply_visitor(*this, *_variableDeclaration.value); + if (_variableDeclaration.value) + { + out += " := "; + out += boost::apply_visitor(*this, *_variableDeclaration.value); + } return out; } |