Specify default type for word size transform externally.

This commit is contained in:
chriseth 2020-01-30 19:40:22 +01:00
parent 8a7e1d651a
commit 9f0cef97c2
4 changed files with 15 additions and 6 deletions

View File

@ -1232,7 +1232,7 @@ Object EVMToEwasmTranslator::run(Object const& _object)
MainFunction{}(ast); MainFunction{}(ast);
ForLoopConditionIntoBody::run(context, ast); ForLoopConditionIntoBody::run(context, ast);
ExpressionSplitter::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); NameDisplacer{nameDispenser, m_polyfillFunctions}(ast);
for (auto const& st: m_polyfill->statements) for (auto const& st: m_polyfill->statements)

View File

@ -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`. // Free the name `or_bool`.
NameDisplacer{_nameDispenser, {"or_bool"_yulstring}}(_ast); NameDisplacer{_nameDispenser, {"or_bool"_yulstring}}(_ast);
YulString defaultType; // should be i64 at some point. WordSizeTransform{_inputDialect, _nameDispenser, _targetDefaultType}(_ast);
WordSizeTransform{_inputDialect, _nameDispenser, defaultType}(_ast);
} }
void WordSizeTransform::rewriteVarDeclList(TypedNameList& _nameList) void WordSizeTransform::rewriteVarDeclList(TypedNameList& _nameList)

View File

@ -67,7 +67,12 @@ public:
void operator()(ForLoop&) override; void operator()(ForLoop&) override;
void operator()(Block& _block) 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: private:
explicit WordSizeTransform( explicit WordSizeTransform(

View File

@ -349,7 +349,7 @@ TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _line
{ {
disambiguate(); disambiguate();
ExpressionSplitter::run(*m_context, *m_ast); 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") else if (m_optimizerStep == "fullSuite")
{ {