From 39670abe4d00c53bb22abeb04b363806266ad1cc Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 17 May 2019 14:13:43 +0200 Subject: [PATCH] Use make_vector in EWasmCodeTransform. --- libyul/backends/wasm/EWasmCodeTransform.cpp | 27 +++++++++------------ 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/libyul/backends/wasm/EWasmCodeTransform.cpp b/libyul/backends/wasm/EWasmCodeTransform.cpp index ea8447f33..c25e5a1c9 100644 --- a/libyul/backends/wasm/EWasmCodeTransform.cpp +++ b/libyul/backends/wasm/EWasmCodeTransform.cpp @@ -169,9 +169,10 @@ wasm::Expression EWasmCodeTransform::operator()(Switch const& _switch) Case const& c = _switch.cases.at(i); if (c.value) { - wasm::BuiltinCall comparison{"i64.eq", {}}; - comparison.arguments.emplace_back(wasm::LocalVariable{condition}); - comparison.arguments.emplace_back(visitReturnByValue(*c.value)); + wasm::BuiltinCall comparison{"i64.eq", make_vector( + wasm::LocalVariable{condition}, + visitReturnByValue(*c.value) + )}; wasm::If ifStmnt{ make_unique(move(comparison)), visit(c.body.statements), @@ -207,24 +208,18 @@ wasm::Expression EWasmCodeTransform::operator()(ForLoop const& _for) string continueLabel = newLabel(); m_breakContinueLabelNames.push({breakLabel, continueLabel}); - // The AST is constructed in this weird way because of some strange - // problem with move semantics. - wasm::BuiltinCall loopCondition{"i64.eqz", {}}; - loopCondition.arguments.emplace_back(visitReturnByValue(*_for.condition)); - - wasm::BuiltinCall conditionCheck{"br_if", {}}; - conditionCheck.arguments.emplace_back(wasm::Label{breakLabel}); - conditionCheck.arguments.emplace_back(move(loopCondition)); - wasm::Loop loop; loop.statements = visit(_for.pre.statements); - loop.statements.emplace_back(move(conditionCheck)); + loop.statements.emplace_back(wasm::BuiltinCall{"br_if", make_vector( + wasm::Label{breakLabel}, + wasm::BuiltinCall{"i64.eqz", make_vector( + visitReturnByValue(*_for.condition) + )} + )}); loop.statements.emplace_back(wasm::Block{continueLabel, visit(_for.body.statements)}); loop.statements += visit(_for.post.statements); - wasm::Block breakBlock{breakLabel, {}}; - breakBlock.statements.emplace_back(move(loop)); - return { std::move(breakBlock) }; + return { wasm::Block{breakLabel, make_vector(move(loop))} }; } wasm::Expression EWasmCodeTransform::operator()(Break const&)