mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5554 from ethereum/cp-SourceReferenceFormatter-refactor
[2/3] Refactor SourceReferenceFormatter (split-out data extraction & make use of new SourceLocation knowledge)
This commit is contained in:
@@ -40,9 +40,9 @@ using namespace langutil;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void yul::test::printErrors(ErrorList const& _errors, Scanner const& _scanner)
|
||||
void yul::test::printErrors(ErrorList const& _errors)
|
||||
{
|
||||
SourceReferenceFormatter formatter(cout, [&](std::string const&) -> Scanner const& { return _scanner; });
|
||||
SourceReferenceFormatter formatter(cout);
|
||||
|
||||
for (auto const& error: _errors)
|
||||
formatter.printExceptionInformation(
|
||||
@@ -76,7 +76,7 @@ pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(strin
|
||||
return make_pair(parserResult, analysisInfo);
|
||||
}
|
||||
}
|
||||
printErrors(errors, *scanner);
|
||||
printErrors(errors);
|
||||
BOOST_FAIL("Invalid source.");
|
||||
|
||||
// Unreachable.
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
namespace langutil
|
||||
{
|
||||
class Scanner;
|
||||
class Error;
|
||||
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
||||
}
|
||||
@@ -44,7 +43,7 @@ namespace yul
|
||||
namespace test
|
||||
{
|
||||
|
||||
void printErrors(langutil::ErrorList const& _errors, langutil::Scanner const& _scanner);
|
||||
void printErrors(langutil::ErrorList const& _errors);
|
||||
std::pair<std::shared_ptr<Block>, std::shared_ptr<AsmAnalysisInfo>>
|
||||
parse(std::string const& _source, bool _yul = true);
|
||||
Block disambiguate(std::string const& _source, bool _yul = true);
|
||||
|
||||
@@ -264,7 +264,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c
|
||||
if (!m_ast || !errorReporter.errors().empty())
|
||||
{
|
||||
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
|
||||
printErrors(_stream, errorReporter.errors(), *scanner);
|
||||
printErrors(_stream, errorReporter.errors());
|
||||
return false;
|
||||
}
|
||||
m_analysisInfo = make_shared<yul::AsmAnalysisInfo>();
|
||||
@@ -278,7 +278,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c
|
||||
if (!analyzer.analyze(*m_ast) || !errorReporter.errors().empty())
|
||||
{
|
||||
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error analyzing source." << endl;
|
||||
printErrors(_stream, errorReporter.errors(), *scanner);
|
||||
printErrors(_stream, errorReporter.errors());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -290,9 +290,9 @@ void YulOptimizerTest::disambiguate()
|
||||
m_analysisInfo.reset();
|
||||
}
|
||||
|
||||
void YulOptimizerTest::printErrors(ostream& _stream, ErrorList const& _errors, Scanner const& _scanner)
|
||||
void YulOptimizerTest::printErrors(ostream& _stream, ErrorList const& _errors)
|
||||
{
|
||||
SourceReferenceFormatter formatter(_stream, [&](string const&) -> Scanner const& { return _scanner; });
|
||||
SourceReferenceFormatter formatter(_stream);
|
||||
|
||||
for (auto const& error: _errors)
|
||||
formatter.printExceptionInformation(
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
bool parse(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted);
|
||||
void disambiguate();
|
||||
|
||||
static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors, langutil::Scanner const& _scanner);
|
||||
static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors);
|
||||
|
||||
std::string m_source;
|
||||
bool m_yul = false;
|
||||
|
||||
Reference in New Issue
Block a user