mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6241 from ethereum/yul-bc-codegen
Yul codegen for break & continue statements
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f() public returns (uint i) {
|
||||
assembly {
|
||||
for {} lt(i, 10) { i := add(i, 1) }
|
||||
{
|
||||
if eq(i, 6) { break }
|
||||
i := add(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 6
|
||||
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f() public returns (uint k) {
|
||||
assembly {
|
||||
for {let i := 0} lt(i, 10) { i := add(i, 1) }
|
||||
{
|
||||
if eq(mod(i, 2), 0) { continue }
|
||||
k := add(k, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 5
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function f(uint x) public returns (uint i) {
|
||||
assembly {
|
||||
for {} lt(i, 10) { i := add(i, 1) }
|
||||
{
|
||||
if eq(x, 0) { i := 2 break }
|
||||
for {} lt(x, 3) { i := 17 x := 9 } {
|
||||
if eq(x, 1) { continue }
|
||||
if eq(x, 2) { break }
|
||||
}
|
||||
if eq(x, 4) { i := 90 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f(uint256): 0 -> 2
|
||||
// f(uint256): 1 -> 18
|
||||
// f(uint256): 2 -> 10
|
||||
// f(uint256): 4 -> 91
|
||||
Reference in New Issue
Block a user