MCPcopy Create free account
hub / github.com/argotorg/solidity / parseFunctionCalls

Method parseFunctionCalls

test/libsolidity/util/TestFileParser.cpp:56–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56std::vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCalls(size_t _lineOffset)
57{
58 std::vector<FunctionCall> calls;
59 if (!accept(Token::EOS))
60 {
61 soltestAssert(m_scanner.currentToken() == Token::Unknown, "");
62 m_scanner.scanNextToken();
63
64 while (!accept(Token::EOS))
65 {
66 if (!accept(Token::Whitespace))
67 {
68 /// If this is not the first call in the test,
69 /// the last call to parseParameter could have eaten the
70 /// new line already. This could only be fixed with a one
71 /// token lookahead that checks parseParameter
72 /// if the next token is an identifier.
73 if (calls.empty())
74 expect(Token::Newline);
75 else
76 if (accept(Token::Newline, true))
77 m_lineNumber++;
78
79 try
80 {
81 if (accept(Token::Gas, true))
82 {
83 if (calls.empty())
84 BOOST_THROW_EXCEPTION(TestParserError("Expected function call before gas usage filter."));
85
86 std::string runType = m_scanner.currentLiteral();
87 if (std::set<std::string>{"ir", "irOptimized", "legacy", "legacyOptimized", "ssaCFG", "ssaCFGOptimized"}.count(runType) == 0)
88 BOOST_THROW_EXCEPTION(TestParserError(
89 "Expected \"ir\", \"irOptimized\", \"legacy\", \"legacyOptimized\", \"ssaCFG\", or \"ssaCFGOptimized\"."
90 ));
91 m_scanner.scanNextToken();
92
93 bool isCodeDepositCost = false;
94 if (accept(Token::Identifier))
95 {
96 if (m_scanner.currentLiteral() != "code")
97 BOOST_THROW_EXCEPTION(TestParserError("Expected \"code\" or \":\"."));
98 isCodeDepositCost = true;
99 m_scanner.scanNextToken();
100 }
101
102 expect(Token::Colon);
103
104 std::map<std::string, u256>& gasExpectationMap = (isCodeDepositCost ?
105 calls.back().expectations.gasUsedForCodeDeposit :
106 calls.back().expectations.gasUsedExcludingCode
107 );
108 if (gasExpectationMap.count(runType) > 0)
109 throw TestParserError("Gas usage expectation set multiple times.");
110
111 gasExpectationMap[runType] = u256(parseDecimalNumber());
112 }
113 else

Callers 2

parseExpectationsMethod · 0.80
parseFunction · 0.80

Calls 8

TestParserErrorClass · 0.85
scanNextTokenMethod · 0.80
whatMethod · 0.80
to_stringFunction · 0.50
currentTokenMethod · 0.45
emptyMethod · 0.45
currentLiteralMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected