[isoltest] Add support for builtin functions.

This commit is contained in:
Alexander Arlt
2021-03-04 08:49:59 -05:00
parent be5647735e
commit 94895822d2
6 changed files with 75 additions and 18 deletions
+12 -2
View File
@@ -55,7 +55,7 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
vector<FunctionCall> calls;
if (!accept(Token::EOS))
{
assert(m_scanner.currentToken() == Token::Unknown);
soltestAssert(m_scanner.currentToken() == Token::Unknown, "");
m_scanner.scanNextToken();
while (!accept(Token::EOS))
@@ -106,6 +106,8 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
tie(call.signature, lowLevelCall) = parseFunctionSignature();
if (lowLevelCall)
call.kind = FunctionCall::Kind::LowLevel;
else if (isBuiltinFunction(call.signature))
call.kind = FunctionCall::Kind::Builtin;
if (accept(Token::Comma, true))
call.value = parseFunctionCallValue();
@@ -195,6 +197,9 @@ pair<string, bool> TestFileParser::parseFunctionSignature()
expect(Token::Identifier);
}
if (isBuiltinFunction(signature))
return {signature, false};
signature += formatToken(Token::LParen);
expect(Token::LParen);
@@ -488,7 +493,7 @@ void TestFileParser::Scanner::readStream(istream& _stream)
void TestFileParser::Scanner::scanNextToken()
{
// Make code coverage happy.
assert(formatToken(Token::NUM_TOKENS) == "");
soltestAssert(formatToken(Token::NUM_TOKENS).empty(), "");
auto detectKeyword = [](std::string const& _literal = "") -> std::pair<Token, std::string> {
if (_literal == "true") return {Token::Boolean, "true"};
@@ -712,3 +717,8 @@ char TestFileParser::Scanner::scanHexPart()
return static_cast<char>(value);
}
bool TestFileParser::isBuiltinFunction(std::string const& signature)
{
return m_builtins.count(signature) > 0;
}