diff options
author | chriseth <chris@ethereum.org> | 2017-11-28 22:00:23 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-12-05 19:09:55 +0800 |
commit | 30d7afc2e3fd27333e463a9127011ec1f7470d3e (patch) | |
tree | 8ce2d4115ec56f61770f8dfea3383a437e89c010 /test/libjulia | |
parent | cba58629d24404ed7553d16bb2ad064f95f9fe37 (diff) | |
download | dexon-solidity-30d7afc2e3fd27333e463a9127011ec1f7470d3e.tar dexon-solidity-30d7afc2e3fd27333e463a9127011ec1f7470d3e.tar.gz dexon-solidity-30d7afc2e3fd27333e463a9127011ec1f7470d3e.tar.bz2 dexon-solidity-30d7afc2e3fd27333e463a9127011ec1f7470d3e.tar.lz dexon-solidity-30d7afc2e3fd27333e463a9127011ec1f7470d3e.tar.xz dexon-solidity-30d7afc2e3fd27333e463a9127011ec1f7470d3e.tar.zst dexon-solidity-30d7afc2e3fd27333e463a9127011ec1f7470d3e.zip |
Simplify disambiguator.
Diffstat (limited to 'test/libjulia')
-rw-r--r-- | test/libjulia/Common.cpp | 13 | ||||
-rw-r--r-- | test/libjulia/Common.h | 7 | ||||
-rw-r--r-- | test/libjulia/Disambiguator.cpp | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/test/libjulia/Common.cpp b/test/libjulia/Common.cpp index 30bb22ea..da1538f3 100644 --- a/test/libjulia/Common.cpp +++ b/test/libjulia/Common.cpp @@ -55,12 +55,12 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test: ErrorList errors; ErrorReporter errorReporter(errors); auto scanner = make_shared<Scanner>(CharStream(_source), ""); - auto parserResult = assembly::Parser(errorReporter, true).parse(scanner); + auto parserResult = assembly::Parser(errorReporter, _julia).parse(scanner); if (parserResult) { BOOST_REQUIRE(errorReporter.errors().empty()); auto analysisInfo = make_shared<assembly::AsmAnalysisInfo>(); - assembly::AsmAnalyzer analyzer(*analysisInfo, errorReporter, true); + assembly::AsmAnalyzer analyzer(*analysisInfo, errorReporter, _julia); if (analyzer.analyze(*parserResult)) { BOOST_REQUIRE(errorReporter.errors().empty()); @@ -74,14 +74,13 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test: return {}; } -shared_ptr<assembly::Block> dev::julia::test::disambiguate(string const& _source) +assembly::Block dev::julia::test::disambiguate(string const& _source, bool _julia) { - auto result = parse(_source); - Disambiguator disambiguator(*result.first, *result.second); - return disambiguator.run(); + auto result = parse(_source, _julia); + return boost::get<Block>(Disambiguator(*result.second)(*result.first)); } -string dev::julia::test::format(string const& _source) +string dev::julia::test::format(string const& _source, bool _julia) { return assembly::AsmPrinter(_julia)(*parse(_source, _julia).first); } diff --git a/test/libjulia/Common.h b/test/libjulia/Common.h index 55fa03da..1371101c 100644 --- a/test/libjulia/Common.h +++ b/test/libjulia/Common.h @@ -45,9 +45,10 @@ namespace test { void printErrors(solidity::ErrorList const& _errors, solidity::Scanner const& _scanner); -std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>> parse(std::string const& _source); -std::shared_ptr<solidity::assembly::Block> disambiguate(std::string const& _source); -std::string format(std::string const& _source); +std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>> +parse(std::string const& _source, bool _julia = true); +solidity::assembly::Block disambiguate(std::string const& _source, bool _julia = true); +std::string format(std::string const& _source, bool _julia = true); } } diff --git a/test/libjulia/Disambiguator.cpp b/test/libjulia/Disambiguator.cpp index f5f883ba..a6338449 100644 --- a/test/libjulia/Disambiguator.cpp +++ b/test/libjulia/Disambiguator.cpp @@ -33,9 +33,9 @@ using namespace dev::solidity; do\ {\ assembly::AsmPrinter p(true);\ - string result = p(*disambiguate(_original));\ + string result = p(disambiguate(_original));\ BOOST_CHECK_EQUAL(result, format(_expectation));\ - BOOST_CHECK_EQUAL(result, p(*disambiguate(result)));\ + BOOST_CHECK_EQUAL(result, p(disambiguate(result)));\ }\ while(false) |