mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-24 20:21:48 +00:00
Flow improvements
Makes the internal API for working with flows more explicit in an attempt to avoid further issues. Also tackles remaining issues with 'continue' statements in 'for' loops.
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
(start $start)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(block $break|0
|
||||
(set_global $for/i
|
||||
(i32.const 0)
|
||||
@ -153,5 +154,53 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(block $break|6
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $repeat|6
|
||||
(br_if $break|6
|
||||
(i32.ge_s
|
||||
(get_local $0)
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(block $break|7
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $repeat|7
|
||||
(block $continue|7
|
||||
(br_if $break|7
|
||||
(i32.ge_s
|
||||
(get_local $1)
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(br_if $continue|7
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|7)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|6)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -17,3 +17,9 @@ for (;;) if (--i == 0) break;
|
||||
|
||||
for (var k: i32 = 0; k < 10; ++k) continue;
|
||||
assert(k == 10);
|
||||
|
||||
for (let i = 0; i < 10; i++) { // without continue block
|
||||
for (let j = 0; j < 10; j++) { // with continue block
|
||||
if (i === j) continue;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(block $break|0
|
||||
(set_global $for/i
|
||||
(i32.const 0)
|
||||
@ -201,5 +203,58 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(block $break|6
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $repeat|6
|
||||
(br_if $break|6
|
||||
(i32.eqz
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|7
|
||||
(set_local $3
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $repeat|7
|
||||
(block $continue|7
|
||||
(br_if $break|7
|
||||
(i32.eqz
|
||||
(i32.lt_s
|
||||
(get_local $3)
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(br $continue|7)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|7)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $repeat|6)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user