aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm/AsmParser.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-20 00:06:26 +0800
committerchriseth <chris@ethereum.org>2017-09-20 17:16:23 +0800
commit3b813ed29569dde02b965c97c9fdd60469876f66 (patch)
tree20a5ea09ab0bc99d48acabb0e567affb6c381ca4 /libsolidity/inlineasm/AsmParser.cpp
parentc0b3e5b0785efd1b601cff470d3e3d4a71b2c283 (diff)
downloaddexon-solidity-3b813ed29569dde02b965c97c9fdd60469876f66.tar.gz
dexon-solidity-3b813ed29569dde02b965c97c9fdd60469876f66.tar.zst
dexon-solidity-3b813ed29569dde02b965c97c9fdd60469876f66.zip
Support multiple assignment in inline assembly
Diffstat (limited to 'libsolidity/inlineasm/AsmParser.cpp')
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp
index d84fe999..3087ad86 100644
--- a/libsolidity/inlineasm/AsmParser.cpp
+++ b/libsolidity/inlineasm/AsmParser.cpp
@@ -122,6 +122,34 @@ assembly::Statement Parser::parseStatement()
{
case Token::LParen:
return parseCall(std::move(statement));
+ case Token::Comma:
+ {
+ // if a comma follows, a multiple assignment is assumed
+
+ if (statement.type() != typeid(assembly::Identifier))
+ fatalParserError("Label name / variable name must precede \",\" (multiple assignment).");
+ assembly::Identifier const& identifier = boost::get<assembly::Identifier>(statement);
+
+ Assignment assignment = createWithLocation<Assignment>(identifier.location);
+ assignment.variableNames.emplace_back(identifier);
+
+ do
+ {
+ expectToken(Token::Comma);
+ statement = parseElementaryOperation(false);
+ if (statement.type() != typeid(assembly::Identifier))
+ fatalParserError("Variable name expected in multiple assignemnt.");
+ assignment.variableNames.emplace_back(boost::get<assembly::Identifier>(statement));
+ }
+ while (currentToken() == Token::Comma);
+
+ expectToken(Token::Colon);
+ expectToken(Token::Assign);
+
+ assignment.value.reset(new Statement(parseExpression()));
+ assignment.location.end = locationOf(*assignment.value).end;
+ return assignment;
+ }
case Token::Colon:
{
if (statement.type() != typeid(assembly::Identifier))
@@ -136,7 +164,7 @@ assembly::Statement Parser::parseStatement()
if (!m_julia && instructions().count(identifier.name))
fatalParserError("Cannot use instruction names for identifier names.");
advance();
- assignment.variableName = identifier;
+ assignment.variableNames.emplace_back(identifier);
assignment.value.reset(new Statement(parseExpression()));
assignment.location.end = locationOf(*assignment.value).end;
return assignment;