mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Parse optimiser output in yulOptimiserTests
This commit is contained in:
parent
a21c8e18f1
commit
e77ae3f06e
@ -111,7 +111,8 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename):
|
||||
|
||||
TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
||||
{
|
||||
if (!parse(_stream, _linePrefix, _formatted))
|
||||
std::tie(m_object, m_analysisInfo) = parse(_stream, _linePrefix, _formatted, m_source);
|
||||
if (!m_object)
|
||||
return TestResult::FatalError;
|
||||
|
||||
soltestAssert(m_dialect, "Dialect not set.");
|
||||
@ -354,26 +355,42 @@ TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _line
|
||||
return TestResult::FatalError;
|
||||
}
|
||||
|
||||
m_obtainedResult =
|
||||
"step: " + m_optimizerStep + "\n\n" +
|
||||
(m_object->subObjects.empty() ? AsmPrinter{ *m_dialect }(*m_object->code) : m_object->toString(m_dialect)) +
|
||||
"\n";
|
||||
auto const printed = (m_object->subObjects.empty() ? AsmPrinter{ *m_dialect }(*m_object->code) : m_object->toString(m_dialect));
|
||||
|
||||
// Re-parse new code for compilability
|
||||
// TODO: support for wordSizeTransform which needs different input and output dialects
|
||||
if (m_optimizerStep != "wordSizeTransform" && !std::get<0>(parse(_stream, _linePrefix, _formatted, printed)))
|
||||
{
|
||||
util::AnsiColorized(_stream, _formatted, {util::formatting::BOLD, util::formatting::CYAN})
|
||||
<< _linePrefix << "Result after the optimiser:" << endl;
|
||||
printIndented(_stream, printed, _linePrefix + " ");
|
||||
return TestResult::FatalError;
|
||||
}
|
||||
|
||||
m_obtainedResult = "step: " + m_optimizerStep + "\n\n" + printed + "\n";
|
||||
|
||||
return checkResult(_stream, _linePrefix, _formatted);
|
||||
}
|
||||
|
||||
bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
|
||||
std::pair<std::shared_ptr<Object>, std::shared_ptr<AsmAnalysisInfo>> YulOptimizerTest::parse(
|
||||
ostream& _stream,
|
||||
string const& _linePrefix,
|
||||
bool const _formatted,
|
||||
string const& _source
|
||||
)
|
||||
{
|
||||
ErrorList errors;
|
||||
soltestAssert(m_dialect, "");
|
||||
std::tie(m_object, m_analysisInfo) = yul::test::parse(m_source, *m_dialect, errors);
|
||||
if (!m_object || !m_analysisInfo || !Error::containsOnlyWarnings(errors))
|
||||
shared_ptr<Object> object;
|
||||
shared_ptr<AsmAnalysisInfo> analysisInfo;
|
||||
std::tie(object, analysisInfo) = yul::test::parse(_source, *m_dialect, errors);
|
||||
if (!object || !analysisInfo || !Error::containsOnlyWarnings(errors))
|
||||
{
|
||||
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
|
||||
printErrors(_stream, errors);
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
return true;
|
||||
return {std::move(object), std::move(analysisInfo)};
|
||||
}
|
||||
|
||||
void YulOptimizerTest::disambiguate()
|
||||
|
@ -58,7 +58,9 @@ public:
|
||||
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
||||
|
||||
private:
|
||||
bool parse(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted);
|
||||
std::pair<std::shared_ptr<Object>, std::shared_ptr<AsmAnalysisInfo>> parse(
|
||||
std::ostream& _stream, std::string const& _linePrefix, bool const _formatted, std::string const& _source
|
||||
);
|
||||
void disambiguate();
|
||||
void updateContext();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user