From 9f0cef97c249d6bdf980992a1cb7ef99e178262d Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 30 Jan 2020 19:40:22 +0100 Subject: [PATCH] Specify default type for word size transform externally. --- libyul/backends/wasm/EVMToEwasmTranslator.cpp | 2 +- libyul/backends/wasm/WordSizeTransform.cpp | 10 +++++++--- libyul/backends/wasm/WordSizeTransform.h | 7 ++++++- test/libyul/YulOptimizerTest.cpp | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index 004f29092..2090dd2f5 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -1232,7 +1232,7 @@ Object EVMToEwasmTranslator::run(Object const& _object) MainFunction{}(ast); ForLoopConditionIntoBody::run(context, ast); ExpressionSplitter::run(context, ast); - WordSizeTransform::run(m_dialect, ast, nameDispenser); + WordSizeTransform::run(m_dialect, WasmDialect::instance().defaultType, ast, nameDispenser); NameDisplacer{nameDispenser, m_polyfillFunctions}(ast); for (auto const& st: m_polyfill->statements) diff --git a/libyul/backends/wasm/WordSizeTransform.cpp b/libyul/backends/wasm/WordSizeTransform.cpp index 47d91b7d1..3aac84870 100644 --- a/libyul/backends/wasm/WordSizeTransform.cpp +++ b/libyul/backends/wasm/WordSizeTransform.cpp @@ -204,12 +204,16 @@ void WordSizeTransform::operator()(Block& _block) ); } -void WordSizeTransform::run(Dialect const& _inputDialect, Block& _ast, NameDispenser& _nameDispenser) +void WordSizeTransform::run( + Dialect const& _inputDialect, + YulString _targetDefaultType, + Block& _ast, + NameDispenser& _nameDispenser +) { // Free the name `or_bool`. NameDisplacer{_nameDispenser, {"or_bool"_yulstring}}(_ast); - YulString defaultType; // should be i64 at some point. - WordSizeTransform{_inputDialect, _nameDispenser, defaultType}(_ast); + WordSizeTransform{_inputDialect, _nameDispenser, _targetDefaultType}(_ast); } void WordSizeTransform::rewriteVarDeclList(TypedNameList& _nameList) diff --git a/libyul/backends/wasm/WordSizeTransform.h b/libyul/backends/wasm/WordSizeTransform.h index 75afa279e..71e526b7f 100644 --- a/libyul/backends/wasm/WordSizeTransform.h +++ b/libyul/backends/wasm/WordSizeTransform.h @@ -67,7 +67,12 @@ public: void operator()(ForLoop&) override; void operator()(Block& _block) override; - static void run(Dialect const& _inputDialect, Block& _ast, NameDispenser& _nameDispenser); + static void run( + Dialect const& _inputDialect, + YulString _targetDefaultType, + Block& _ast, + NameDispenser& _nameDispenser + ); private: explicit WordSizeTransform( diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index c4a6a48d6..f3906aead 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -349,7 +349,7 @@ TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _line { disambiguate(); ExpressionSplitter::run(*m_context, *m_ast); - WordSizeTransform::run(*m_dialect, *m_ast, *m_nameDispenser); + WordSizeTransform::run(*m_dialect, ""_yulstring, *m_ast, *m_nameDispenser); } else if (m_optimizerStep == "fullSuite") {