Implement asc in js for dist

This commit is contained in:
dcodeIO
2017-12-05 15:06:44 +01:00
parent df212653a8
commit 330752908a
12 changed files with 348 additions and 173 deletions

View File

@ -8,12 +8,10 @@
(func $do/loopDo (; 0 ;) (type $iv) (param $0 i32)
(block $break$1.1
(loop $continue$1.1
(block
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
)
(br_if $continue$1.1
@ -34,12 +32,10 @@
)
(block $break$1.2
(loop $continue$1.2
(block
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
)
(br_if $continue$1.2

View File

@ -0,0 +1,37 @@
(module
(type $v (func))
(global $for/i (mut i32) (i32.const 0))
(memory $0 1)
(data (i32.const 4) "\08")
(export "memory" (memory $0))
(start $start)
(func $start (; 0 ;) (type $v)
(set_global $for/i
(i32.const 0)
)
(loop $continue$1.1
(if
(i32.lt_s
(get_global $for/i)
(i32.const 10)
)
(block
(set_global $for/i
(i32.add
(get_global $for/i)
(i32.const 1)
)
)
(br $continue$1.1)
)
)
)
(if
(i32.ne
(get_global $for/i)
(i32.const 10)
)
(unreachable)
)
)
)

6
tests/compiler/for.ts Normal file
View File

@ -0,0 +1,6 @@
let i: i32;
for (i = 0; i < 10; ++i) {
;
}
if (i != 10)
unreachable();

71
tests/compiler/for.wast Normal file
View File

@ -0,0 +1,71 @@
(module
(type $v (func))
(global $for/i (mut i32) (i32.const 0))
(memory $0 1)
(data (i32.const 4) "\08\00\00\00")
(export "memory" (memory $0))
(start $start)
(func $start (; 0 ;) (type $v)
(block $break$1.1
(set_global $for/i
(i32.const 0)
)
(loop $continue$1.1
(if
(i32.lt_s
(get_global $for/i)
(i32.const 10)
)
(block
(nop)
(set_global $for/i
(i32.add
(get_global $for/i)
(i32.const 1)
)
)
(br $continue$1.1)
)
)
)
)
(if
(i32.ne
(get_global $for/i)
(i32.const 10)
)
(unreachable)
)
)
)
(;
[program.elements]
clz
ctz
popcnt
rotl
rotr
abs
ceil
copysign
floor
max
min
nearest
sqrt
trunc
current_memory
grow_memory
unreachable
load
store
reinterpret
select
sizeof
isNaN
isFinite
assert
for/i
[program.exports]
;)

View File

@ -11,12 +11,10 @@
(if
(get_local $0)
(block
(block
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
)
(br $continue$1.1)
@ -43,12 +41,10 @@
(if
(get_local $0)
(block
(block
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
)
)
(br $continue$1.2)