aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm/AsmParser.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-04-27 06:58:34 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-06 05:31:22 +0800
commitd6396ee85fd21424568074c41a131e8c52961983 (patch)
treecc0fa48f71be625bc40f67ee15ca0ef903f84fbc /libsolidity/inlineasm/AsmParser.cpp
parentb0f2a5c162480ab6ecdc5e1397567242a137768a (diff)
downloaddexon-solidity-d6396ee85fd21424568074c41a131e8c52961983.tar.gz
dexon-solidity-d6396ee85fd21424568074c41a131e8c52961983.tar.zst
dexon-solidity-d6396ee85fd21424568074c41a131e8c52961983.zip
Parse types in Julia mode
Diffstat (limited to 'libsolidity/inlineasm/AsmParser.cpp')
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp34
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();