aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm/AsmParser.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-05-16 22:59:15 +0800
committerGitHub <noreply@github.com>2017-05-16 22:59:15 +0800
commitd9b5ff0b43b4dcaccb43dfc89efef6d610476557 (patch)
tree5773b307c4a612562bd05abd2c8d71009cc53372 /libsolidity/inlineasm/AsmParser.cpp
parent2ba87fe80486e996a3fbcfe79da2ab527c1ee406 (diff)
parent6706932d7c7cd0a4d1b99e806b8f80cf8fe6cb91 (diff)
downloaddexon-solidity-d9b5ff0b43b4dcaccb43dfc89efef6d610476557.tar
dexon-solidity-d9b5ff0b43b4dcaccb43dfc89efef6d610476557.tar.gz
dexon-solidity-d9b5ff0b43b4dcaccb43dfc89efef6d610476557.tar.bz2
dexon-solidity-d9b5ff0b43b4dcaccb43dfc89efef6d610476557.tar.lz
dexon-solidity-d9b5ff0b43b4dcaccb43dfc89efef6d610476557.tar.xz
dexon-solidity-d9b5ff0b43b4dcaccb43dfc89efef6d610476557.tar.zst
dexon-solidity-d9b5ff0b43b4dcaccb43dfc89efef6d610476557.zip
Merge pull request #2222 from ethereum/julia-types
Add support for types in Julia
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();