diff options
author | Christian Parpart <christian@ethereum.org> | 2018-11-30 21:34:08 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-12-06 21:01:01 +0800 |
commit | 073b03d90c8f0648ba135f0b30d8e72fd871478f (patch) | |
tree | b38bf2ef623bb1ac85bf9ca929ba61f76c05bd0d /test/libyul | |
parent | 6efe2a526691f42e83b11cf670ec3e7f51927b3e (diff) | |
download | dexon-solidity-073b03d90c8f0648ba135f0b30d8e72fd871478f.tar.gz dexon-solidity-073b03d90c8f0648ba135f0b30d8e72fd871478f.tar.zst dexon-solidity-073b03d90c8f0648ba135f0b30d8e72fd871478f.zip |
liblangutil: refactor SourceReferenceFormatter, splitting out retrieval and making use of new SourceLocation's CharStream knowledge
Diffstat (limited to 'test/libyul')
-rw-r--r-- | test/libyul/Common.cpp | 6 | ||||
-rw-r--r-- | test/libyul/Common.h | 3 | ||||
-rw-r--r-- | test/libyul/YulOptimizerTest.cpp | 8 | ||||
-rw-r--r-- | test/libyul/YulOptimizerTest.h | 2 |
4 files changed, 9 insertions, 10 deletions
diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp index e2462eb7..0f2529de 100644 --- a/test/libyul/Common.cpp +++ b/test/libyul/Common.cpp @@ -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. diff --git a/test/libyul/Common.h b/test/libyul/Common.h index a1c64ca5..01fc416a 100644 --- a/test/libyul/Common.h +++ b/test/libyul/Common.h @@ -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); diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index d1d22fd0..96b9d263 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -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( diff --git a/test/libyul/YulOptimizerTest.h b/test/libyul/YulOptimizerTest.h index 90026e24..5648e995 100644 --- a/test/libyul/YulOptimizerTest.h +++ b/test/libyul/YulOptimizerTest.h @@ -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; |