aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/AsmParser.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-04 00:47:29 +0800
committerchriseth <chris@ethereum.org>2018-12-04 21:49:16 +0800
commit1746366bb6f769ab68acbcedf3b03037ea19173c (patch)
treeb06cb62204efb3ebe59680540a3933b699f25436 /libyul/AsmParser.cpp
parent8654f8f6d4cb8f609d5b43df217aff1406acbe6a (diff)
downloaddexon-solidity-1746366bb6f769ab68acbcedf3b03037ea19173c.tar.gz
dexon-solidity-1746366bb6f769ab68acbcedf3b03037ea19173c.tar.zst
dexon-solidity-1746366bb6f769ab68acbcedf3b03037ea19173c.zip
Use builtin functions in the yul parser.
Diffstat (limited to 'libyul/AsmParser.cpp')
-rw-r--r--libyul/AsmParser.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp
index 5f393b29..33bb42f9 100644
--- a/libyul/AsmParser.cpp
+++ b/libyul/AsmParser.cpp
@@ -114,7 +114,9 @@ Statement Parser::parseStatement()
expectToken(Token::Colon);
assignment.variableName.location = location();
assignment.variableName.name = YulString(currentLiteral());
- if (instructions().count(assignment.variableName.name.str()))
+ if (m_dialect.builtins->query(assignment.variableName.name))
+ fatalParserError("Identifier expected, got builtin symbol.");
+ else if (instructions().count(assignment.variableName.name.str()))
fatalParserError("Identifier expected, got instruction name.");
assignment.location.end = endPosition();
expectToken(Token::Identifier);
@@ -174,7 +176,9 @@ Statement Parser::parseStatement()
if (currentToken() == Token::Assign && peekNextToken() != Token::Colon)
{
Assignment assignment = createWithLocation<Assignment>(identifier.location);
- if (m_dialect.flavour != AsmFlavour::Yul && instructions().count(identifier.name.str()))
+ if (m_dialect.builtins->query(identifier.name))
+ fatalParserError("Cannot assign to builtin function \"" + identifier.name.str() + "\".");
+ else if (m_dialect.flavour != AsmFlavour::Yul && instructions().count(identifier.name.str()))
fatalParserError("Cannot use instruction names for identifier names.");
advance();
assignment.variableNames.emplace_back(identifier);
@@ -357,8 +361,10 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
literal = YulString{"address"};
else
literal = YulString{currentLiteral()};
- // first search the set of instructions.
- if (m_dialect.flavour != AsmFlavour::Yul && instructions().count(literal.str()))
+ // first search the set of builtins, then the instructions.
+ if (m_dialect.builtins->query(literal))
+ ret = Identifier{location(), literal};
+ else if (m_dialect.flavour != AsmFlavour::Yul && instructions().count(literal.str()))
{
dev::solidity::Instruction const& instr = instructions().at(literal.str());
ret = Instruction{location(), instr};
@@ -592,6 +598,8 @@ YulString Parser::expectAsmIdentifier()
break;
}
}
+ else if (m_dialect.builtins->query(name))
+ fatalParserError("Cannot use builtin function name \"" + name.str() + "\" as identifier name.");
else if (instructions().count(name.str()))
fatalParserError("Cannot use instruction names for identifier names.");
expectToken(Token::Identifier);