diff options
Diffstat (limited to 'libsolidity/inlineasm/AsmParser.cpp')
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index d9b0b3e0..7ecad5ea 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -201,16 +201,26 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher) } else ret = Identifier{location(), literal}; + m_scanner->next(); break; } case Token::StringLiteral: case Token::Number: { - ret = Literal{ + Literal literal{ location(), m_scanner->currentToken() == Token::Number, - m_scanner->currentLiteral() + m_scanner->currentLiteral(), + "" }; + m_scanner->next(); + if (m_julia) + { + expectToken(Token::Colon); + literal.location.end = endPosition(); + literal.type = expectAsmIdentifier(); + } + ret = std::move(literal); break; } default: @@ -220,7 +230,6 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher) "Expected elementary inline assembly operation." ); } - m_scanner->next(); return ret; } @@ -228,7 +237,7 @@ assembly::VariableDeclaration Parser::parseVariableDeclaration() { VariableDeclaration varDecl = createWithLocation<VariableDeclaration>(); expectToken(Token::Let); - varDecl.name = expectAsmIdentifier(); + varDecl.variable = parseTypedName(); expectToken(Token::Colon); expectToken(Token::Assign); varDecl.value.reset(new Statement(parseExpression())); @@ -244,7 +253,7 @@ assembly::FunctionDefinition Parser::parseFunctionDefinition() expectToken(Token::LParen); while (m_scanner->currentToken() != Token::RParen) { - funDef.arguments.push_back(expectAsmIdentifier()); + funDef.arguments.emplace_back(parseTypedName()); if (m_scanner->currentToken() == Token::RParen) break; expectToken(Token::Comma); @@ -256,7 +265,7 @@ assembly::FunctionDefinition Parser::parseFunctionDefinition() expectToken(Token::GreaterThan); while (true) { - funDef.returns.push_back(expectAsmIdentifier()); + funDef.returns.emplace_back(parseTypedName()); if (m_scanner->currentToken() == Token::LBrace) break; expectToken(Token::Comma); @@ -335,6 +344,19 @@ assembly::Statement Parser::parseFunctionalInstruction(assembly::Statement&& _in return {}; } +TypedName Parser::parseTypedName() +{ + TypedName typedName = createWithLocation<TypedName>(); + typedName.name = expectAsmIdentifier(); + if (m_julia) + { + expectToken(Token::Colon); + typedName.location.end = endPosition(); + typedName.type = expectAsmIdentifier(); + } + return typedName; +} + string Parser::expectAsmIdentifier() { string name = m_scanner->currentLiteral(); |