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

Function parseAndReturnFirstError

test/libsolidity/InlineAssembly.cpp:55–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53{
54
55std::optional<Error> parseAndReturnFirstError(
56 std::string const& _source,
57 bool _assemble = false,
58 bool _allowWarnings = true,
59 YulStack::Machine _machine = YulStack::Machine::EVM
60)
61{
62 YulStack stack(
63 solidity::test::CommonOptions::get().evmVersion(),
64 solidity::test::CommonOptions::get().eofVersion(),
65 solidity::frontend::OptimiserSettings::none(),
66 DebugInfoSelection::None()
67 );
68 bool success = stack.parseAndAnalyze("", _source);
69 if (success && _assemble)
70 stack.assemble(_machine);
71 std::shared_ptr<Error const> error;
72 for (auto const& e: stack.errors())
73 {
74 if (_allowWarnings && e->type() == Error::Type::Warning)
75 continue;
76 if (error)
77 BOOST_FAIL(
78 "Found more than one error:\n" +
79 SourceReferenceFormatter::formatErrorInformation(stack.errors(), stack)
80 );
81 error = e;
82 }
83 if (!success)
84 BOOST_REQUIRE(error);
85 if (error)
86 return *error;
87 return {};
88}
89
90bool successParse(
91 std::string const& _source,

Callers 2

successParseFunction · 0.70
expectErrorFunction · 0.70

Calls 6

getFunction · 0.85
evmVersionMethod · 0.45
eofVersionMethod · 0.45
parseAndAnalyzeMethod · 0.45
assembleMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected