diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 221f3414d..8b0561378 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -98,12 +99,24 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename) file.exceptions(ios::badbit); m_source = parseSourceAndSettings(file); - if (m_settings.count("yul")) + if (m_settings.count("dialect")) { - m_yul = true; - m_validatedSettings["yul"] = "true"; - m_settings.erase("yul"); + auto dialectName = m_settings["dialect"]; + if (dialectName == "yul") + m_dialect = &Dialect::yul(); + else if (dialectName == "ewasm") + m_dialect = &WasmDialect::instance(); + else if (dialectName == "evm") + m_dialect = &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); + else + BOOST_THROW_EXCEPTION(runtime_error("Invalid dialect " + dialectName)); + + m_validatedSettings["dialect"] = dialectName; + m_settings.erase("dialect"); } + else + m_dialect = &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); + if (m_settings.count("step")) { m_validatedSettings["step"] = m_settings["step"]; @@ -350,7 +363,7 @@ TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _line return TestResult::FatalError; } - m_obtainedResult = AsmPrinter{m_yul}(*m_ast) + "\n"; + m_obtainedResult = AsmPrinter{m_dialect->flavour == AsmFlavour::Yul}(*m_ast) + "\n"; if (m_optimizerStep != m_validatedSettings["step"]) { @@ -406,7 +419,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c { AssemblyStack stack( dev::test::Options::get().evmVersion(), - m_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, + m_dialect->flavour == AsmFlavour::Yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, dev::solidity::OptimiserSettings::none() ); if (!stack.parseAndAnalyze("", m_source) || !stack.errors().empty()) @@ -415,7 +428,6 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c printErrors(_stream, stack.errors()); return false; } - m_dialect = m_yul ? &Dialect::yul() : &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); m_ast = stack.parserResult()->code; m_analysisInfo = stack.parserResult()->analysisInfo; return true; diff --git a/test/libyul/YulOptimizerTest.h b/test/libyul/YulOptimizerTest.h index a9cc04ab1..d74e3fc16 100644 --- a/test/libyul/YulOptimizerTest.h +++ b/test/libyul/YulOptimizerTest.h @@ -71,7 +71,6 @@ private: static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors); std::string m_source; - bool m_yul = false; std::string m_optimizerStep; std::string m_expectation; diff --git a/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul b/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul index ae7c0e114..79b372972 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/for_statement.yul @@ -8,7 +8,7 @@ } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { let a:u256, b:u256 } diff --git a/test/libyul/yulOptimizerTests/disambiguator/funtion_call.yul b/test/libyul/yulOptimizerTests/disambiguator/funtion_call.yul index b081ebe6f..fe54227d3 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/funtion_call.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/funtion_call.yul @@ -8,7 +8,7 @@ } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { diff --git a/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul b/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul index 5dd6ac3bf..2dee55ae7 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/if_statement.yul @@ -7,7 +7,7 @@ } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { let a:u256, b:u256, c:u256 } diff --git a/test/libyul/yulOptimizerTests/disambiguator/long_names.yul b/test/libyul/yulOptimizerTests/disambiguator/long_names.yul index 2b9f3e522..b5db97637 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/long_names.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/long_names.yul @@ -1,7 +1,7 @@ { { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { diff --git a/test/libyul/yulOptimizerTests/disambiguator/smoke_yul.yul b/test/libyul/yulOptimizerTests/disambiguator/smoke_yul.yul index d0702de6f..2ed2b9ad1 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/smoke_yul.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/smoke_yul.yul @@ -1,6 +1,6 @@ { } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { } diff --git a/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul b/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul index 497f4985c..647c78fda 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/switch_statement.yul @@ -9,7 +9,7 @@ } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { let a:u256, b:u256, c:u256 } diff --git a/test/libyul/yulOptimizerTests/disambiguator/variables.yul b/test/libyul/yulOptimizerTests/disambiguator/variables.yul index 2d3318702..319809706 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/variables.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/variables.yul @@ -1,7 +1,7 @@ { { let a:u256 } { let a:u256 } } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { let a:u256 } diff --git a/test/libyul/yulOptimizerTests/disambiguator/variables_clash.yul b/test/libyul/yulOptimizerTests/disambiguator/variables_clash.yul index 9501b8a1c..9474dfc86 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/variables_clash.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/variables_clash.yul @@ -1,7 +1,7 @@ { { let a:u256 let a_1:u256 } { let a:u256 } } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { diff --git a/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul b/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul index b160f032c..66d36e431 100644 --- a/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul +++ b/test/libyul/yulOptimizerTests/disambiguator/variables_inside_functions.yul @@ -7,7 +7,7 @@ } // ==== // step: disambiguator -// yul: true +// dialect: yul // ---- // { // { diff --git a/test/libyul/yulOptimizerTests/expressionInliner/simple.yul b/test/libyul/yulOptimizerTests/expressionInliner/simple.yul index 4302da79f..c1a1c147e 100644 --- a/test/libyul/yulOptimizerTests/expressionInliner/simple.yul +++ b/test/libyul/yulOptimizerTests/expressionInliner/simple.yul @@ -4,7 +4,7 @@ } // ==== // step: expressionInliner -// yul: true +// dialect: yul // ---- // { // function f() -> x:u256 diff --git a/test/libyul/yulOptimizerTests/expressionInliner/with_args.yul b/test/libyul/yulOptimizerTests/expressionInliner/with_args.yul index 2bdd8ffd8..8dd694aec 100644 --- a/test/libyul/yulOptimizerTests/expressionInliner/with_args.yul +++ b/test/libyul/yulOptimizerTests/expressionInliner/with_args.yul @@ -4,7 +4,7 @@ } // ==== // step: expressionInliner -// yul: true +// dialect: yul // ---- // { // function f(a:u256) -> x:u256 diff --git a/test/libyul/yulOptimizerTests/functionGrouper/empty_block.yul b/test/libyul/yulOptimizerTests/functionGrouper/empty_block.yul index 51699b7a8..950118647 100644 --- a/test/libyul/yulOptimizerTests/functionGrouper/empty_block.yul +++ b/test/libyul/yulOptimizerTests/functionGrouper/empty_block.yul @@ -1,7 +1,7 @@ { let a:u256 { } function f() -> x:bool { let b:u256 := 4:u256 {} for {} f() {} {} } } // ==== // step: functionGrouper -// yul: true +// dialect: yul // ---- // { // { diff --git a/test/libyul/yulOptimizerTests/functionGrouper/multi_fun_mixed.yul b/test/libyul/yulOptimizerTests/functionGrouper/multi_fun_mixed.yul index 73af943aa..559452a98 100644 --- a/test/libyul/yulOptimizerTests/functionGrouper/multi_fun_mixed.yul +++ b/test/libyul/yulOptimizerTests/functionGrouper/multi_fun_mixed.yul @@ -6,7 +6,7 @@ } // ==== // step: functionGrouper -// yul: true +// dialect: yul // ---- // { // { diff --git a/test/libyul/yulOptimizerTests/functionGrouper/nested_fun.yul b/test/libyul/yulOptimizerTests/functionGrouper/nested_fun.yul index ac67a4461..14b28fbab 100644 --- a/test/libyul/yulOptimizerTests/functionGrouper/nested_fun.yul +++ b/test/libyul/yulOptimizerTests/functionGrouper/nested_fun.yul @@ -10,7 +10,7 @@ } // ==== // step: functionGrouper -// yul: true +// dialect: yul // ---- // { // { let a:u256 } diff --git a/test/libyul/yulOptimizerTests/functionGrouper/single_fun.yul b/test/libyul/yulOptimizerTests/functionGrouper/single_fun.yul index ec72697a7..94af92287 100644 --- a/test/libyul/yulOptimizerTests/functionGrouper/single_fun.yul +++ b/test/libyul/yulOptimizerTests/functionGrouper/single_fun.yul @@ -3,7 +3,7 @@ } // ==== // step: functionGrouper -// yul: true +// dialect: yul // ---- // { // { let a:u256 } diff --git a/test/libyul/yulOptimizerTests/functionHoister/empty_block.yul b/test/libyul/yulOptimizerTests/functionHoister/empty_block.yul index 4d3b90d45..4a7c0a7a2 100644 --- a/test/libyul/yulOptimizerTests/functionHoister/empty_block.yul +++ b/test/libyul/yulOptimizerTests/functionHoister/empty_block.yul @@ -9,7 +9,7 @@ } // ==== // step: functionHoister -// yul: true +// dialect: yul // ---- // { // let a:u256 diff --git a/test/libyul/yulOptimizerTests/functionHoister/multi_mixed.yul b/test/libyul/yulOptimizerTests/functionHoister/multi_mixed.yul index 7d41d59e7..78e4b49ab 100644 --- a/test/libyul/yulOptimizerTests/functionHoister/multi_mixed.yul +++ b/test/libyul/yulOptimizerTests/functionHoister/multi_mixed.yul @@ -7,7 +7,7 @@ } // ==== // step: functionHoister -// yul: true +// dialect: yul // ---- // { // let a:u256 diff --git a/test/libyul/yulOptimizerTests/functionHoister/nested.yul b/test/libyul/yulOptimizerTests/functionHoister/nested.yul index 50d962907..813598503 100644 --- a/test/libyul/yulOptimizerTests/functionHoister/nested.yul +++ b/test/libyul/yulOptimizerTests/functionHoister/nested.yul @@ -8,7 +8,7 @@ } // ==== // step: functionHoister -// yul: true +// dialect: yul // ---- // { // let a:u256 diff --git a/test/libyul/yulOptimizerTests/functionHoister/single.yul b/test/libyul/yulOptimizerTests/functionHoister/single.yul index 70c3ecb3d..70ecfdb8e 100644 --- a/test/libyul/yulOptimizerTests/functionHoister/single.yul +++ b/test/libyul/yulOptimizerTests/functionHoister/single.yul @@ -4,7 +4,7 @@ } // ==== // step: functionHoister -// yul: true +// dialect: yul // ---- // { // let a:u256 diff --git a/test/libyul/yulOptimizerTests/mainFunction/empty_block.yul b/test/libyul/yulOptimizerTests/mainFunction/empty_block.yul index efe904d89..09a04e1d3 100644 --- a/test/libyul/yulOptimizerTests/mainFunction/empty_block.yul +++ b/test/libyul/yulOptimizerTests/mainFunction/empty_block.yul @@ -9,7 +9,7 @@ } // ==== // step: mainFunction -// yul: true +// dialect: yul // ---- // { // function main() diff --git a/test/libyul/yulOptimizerTests/mainFunction/multi_fun_mixed.yul b/test/libyul/yulOptimizerTests/mainFunction/multi_fun_mixed.yul index 2f4de38b6..7aaab11e5 100644 --- a/test/libyul/yulOptimizerTests/mainFunction/multi_fun_mixed.yul +++ b/test/libyul/yulOptimizerTests/mainFunction/multi_fun_mixed.yul @@ -7,7 +7,7 @@ } // ==== // step: mainFunction -// yul: true +// dialect: yul // ---- // { // function main() diff --git a/test/libyul/yulOptimizerTests/mainFunction/nested_fun.yul b/test/libyul/yulOptimizerTests/mainFunction/nested_fun.yul index 2c9d120b3..61cb67233 100644 --- a/test/libyul/yulOptimizerTests/mainFunction/nested_fun.yul +++ b/test/libyul/yulOptimizerTests/mainFunction/nested_fun.yul @@ -8,7 +8,7 @@ } // ==== // step: mainFunction -// yul: true +// dialect: yul // ---- // { // function main() diff --git a/test/libyul/yulOptimizerTests/mainFunction/sigle_fun.yul b/test/libyul/yulOptimizerTests/mainFunction/sigle_fun.yul index c7de43441..63154e8c3 100644 --- a/test/libyul/yulOptimizerTests/mainFunction/sigle_fun.yul +++ b/test/libyul/yulOptimizerTests/mainFunction/sigle_fun.yul @@ -4,7 +4,7 @@ } // ==== // step: mainFunction -// yul: true +// dialect: yul // ---- // { // function main() diff --git a/test/libyul/yulOptimizerTests/mainFunction/smoke.yul b/test/libyul/yulOptimizerTests/mainFunction/smoke.yul index 3ae7cb5f7..54ad2d843 100644 --- a/test/libyul/yulOptimizerTests/mainFunction/smoke.yul +++ b/test/libyul/yulOptimizerTests/mainFunction/smoke.yul @@ -1,7 +1,7 @@ {} // ==== // step: mainFunction -// yul: true +// dialect: yul // ---- // { // function main()