mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[ewasm] Fix infinite loops.
This commit is contained in:
parent
e419e904d3
commit
86be0fbc2f
@ -12,6 +12,7 @@ Bugfixes:
|
|||||||
* NatSpec: Do not consider ``////`` and ``/***`` as NatSpec comments.
|
* NatSpec: Do not consider ``////`` and ``/***`` as NatSpec comments.
|
||||||
* Type Checker: Fix internal error related to ``using for`` applied to non-libraries.
|
* Type Checker: Fix internal error related to ``using for`` applied to non-libraries.
|
||||||
* Type Checker: Do not disallow assigning to calldata variables.
|
* Type Checker: Do not disallow assigning to calldata variables.
|
||||||
|
* Wasm backend: Fix code generation for for-loops with pre statements.
|
||||||
* Yul: Fix source location of variable multi-assignment.
|
* Yul: Fix source location of variable multi-assignment.
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,9 +257,10 @@ wasm::Expression WasmCodeTransform::operator()(ForLoop const& _for)
|
|||||||
YulString eqz_instruction = YulString(conditionType.str() + ".eqz");
|
YulString eqz_instruction = YulString(conditionType.str() + ".eqz");
|
||||||
yulAssert(WasmDialect::instance().builtin(eqz_instruction), "");
|
yulAssert(WasmDialect::instance().builtin(eqz_instruction), "");
|
||||||
|
|
||||||
|
std::vector<wasm::Expression> statements = visit(_for.pre.statements);
|
||||||
|
|
||||||
wasm::Loop loop;
|
wasm::Loop loop;
|
||||||
loop.labelName = newLabel();
|
loop.labelName = newLabel();
|
||||||
loop.statements = visit(_for.pre.statements);
|
|
||||||
loop.statements.emplace_back(wasm::BranchIf{wasm::Label{breakLabel}, make_unique<wasm::Expression>(
|
loop.statements.emplace_back(wasm::BranchIf{wasm::Label{breakLabel}, make_unique<wasm::Expression>(
|
||||||
wasm::BuiltinCall{eqz_instruction.str(), make_vector<wasm::Expression>(
|
wasm::BuiltinCall{eqz_instruction.str(), make_vector<wasm::Expression>(
|
||||||
visitReturnByValue(*_for.condition)
|
visitReturnByValue(*_for.condition)
|
||||||
@ -269,7 +270,8 @@ wasm::Expression WasmCodeTransform::operator()(ForLoop const& _for)
|
|||||||
loop.statements += visit(_for.post.statements);
|
loop.statements += visit(_for.post.statements);
|
||||||
loop.statements.emplace_back(wasm::Branch{wasm::Label{loop.labelName}});
|
loop.statements.emplace_back(wasm::Branch{wasm::Label{loop.labelName}});
|
||||||
|
|
||||||
return { wasm::Block{breakLabel, make_vector<wasm::Expression>(move(loop))} };
|
statements += make_vector<wasm::Expression>(move(loop));
|
||||||
|
return wasm::Block{breakLabel, move(statements)};
|
||||||
}
|
}
|
||||||
|
|
||||||
wasm::Expression WasmCodeTransform::operator()(Break const&)
|
wasm::Expression WasmCodeTransform::operator()(Break const&)
|
||||||
|
Loading…
Reference in New Issue
Block a user