mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-23 11:41:45 +00:00
More tests and fixes (unary, binary, globals)
This commit is contained in:
161
tests/compiler/binary.ts
Normal file
161
tests/compiler/binary.ts
Normal file
@ -0,0 +1,161 @@
|
||||
let b: bool = false;
|
||||
|
||||
let i: i32 = 0;
|
||||
|
||||
i < 1;
|
||||
i > 1;
|
||||
i <= 1;
|
||||
i >= 1;
|
||||
i == 1;
|
||||
i === 1;
|
||||
i + 1;
|
||||
i - 1;
|
||||
i * 1;
|
||||
i / 1;
|
||||
i % 1;
|
||||
i << 1;
|
||||
i >> 1;
|
||||
i >>> 1;
|
||||
i & 1;
|
||||
i | 1;
|
||||
i ^ 1;
|
||||
|
||||
b = i < 1;
|
||||
b = i > 1;
|
||||
b = i <= 1;
|
||||
b = i >= 1;
|
||||
b = i == 1;
|
||||
b = i === 1;
|
||||
i = i + 1;
|
||||
i = i - 1;
|
||||
i = i * 1;
|
||||
i = i / 1;
|
||||
i = i % 1;
|
||||
i = i << 1;
|
||||
i = i >> 1;
|
||||
i = i >>> 1;
|
||||
i = i & 1;
|
||||
i = i | 1;
|
||||
i = i ^ 1;
|
||||
|
||||
i += 1;
|
||||
i -= 1;
|
||||
i *= 1;
|
||||
i %= 1;
|
||||
i <<= 1;
|
||||
i >>= 1;
|
||||
i >>>= 1;
|
||||
i &= 1;
|
||||
i |= 1;
|
||||
i ^= 1;
|
||||
|
||||
let I: i64 = 0;
|
||||
|
||||
I < 1;
|
||||
I > 1;
|
||||
I <= 1;
|
||||
I >= 1;
|
||||
I == 1;
|
||||
I === 1;
|
||||
I + 1;
|
||||
I - 1;
|
||||
I * 1;
|
||||
I / 1;
|
||||
I % 1;
|
||||
I << 1;
|
||||
I >> 1;
|
||||
I >>> 1;
|
||||
I & 1;
|
||||
I | 1;
|
||||
I ^ 1;
|
||||
|
||||
b = I < 1;
|
||||
b = I > 1;
|
||||
b = I <= 1;
|
||||
b = I >= 1;
|
||||
b = I == 1;
|
||||
b = I === 1;
|
||||
I = I + 1;
|
||||
I = I - 1;
|
||||
I = I * 1;
|
||||
I = I / 1;
|
||||
I = I % 1;
|
||||
I = I << 1;
|
||||
I = I >> 1;
|
||||
I = I >>> 1;
|
||||
I = I & 1;
|
||||
I = I | 1;
|
||||
I = I ^ 1;
|
||||
|
||||
I += 1;
|
||||
I -= 1;
|
||||
I *= 1;
|
||||
I %= 1;
|
||||
I <<= 1;
|
||||
I >>= 1;
|
||||
I >>>= 1;
|
||||
I &= 1;
|
||||
I |= 1;
|
||||
I ^= 1;
|
||||
|
||||
let f: f32 = 0;
|
||||
|
||||
f < 1;
|
||||
f > 1;
|
||||
f <= 1;
|
||||
f >= 1;
|
||||
f == 1;
|
||||
f === 1;
|
||||
f + 1;
|
||||
f - 1;
|
||||
f * 1;
|
||||
f / 1;
|
||||
// f % 1;
|
||||
|
||||
b = f < 1;
|
||||
b = f > 1;
|
||||
b = f <= 1;
|
||||
b = f >= 1;
|
||||
b = f == 1;
|
||||
b = f === 1;
|
||||
f = f + 1;
|
||||
f = f - 1;
|
||||
f = f * 1;
|
||||
f = f / 1;
|
||||
// f = f % 1;
|
||||
|
||||
f += 1;
|
||||
f -= 1;
|
||||
f *= 1;
|
||||
// f %= 1;
|
||||
|
||||
let F: f64 = 0;
|
||||
|
||||
F < 1;
|
||||
F > 1;
|
||||
F <= 1;
|
||||
F >= 1;
|
||||
F == 1;
|
||||
F === 1;
|
||||
F + 1;
|
||||
F - 1;
|
||||
F * 1;
|
||||
F / 1;
|
||||
// f % 1;
|
||||
|
||||
b = F < 1;
|
||||
b = F > 1;
|
||||
b = F <= 1;
|
||||
b = F >= 1;
|
||||
b = F == 1;
|
||||
b = F === 1;
|
||||
F = F + 1;
|
||||
F = F - 1;
|
||||
F = F * 1;
|
||||
F = F / 1;
|
||||
// F = F % 1;
|
||||
|
||||
F += 1;
|
||||
F -= 1;
|
||||
F *= 1;
|
||||
// F %= 1;
|
847
tests/compiler/binary.wast
Normal file
847
tests/compiler/binary.wast
Normal file
@ -0,0 +1,847 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(global $binary/i (mut i32) (i32.const 0))
|
||||
(global $binary/b (mut i32) (i32.const -1))
|
||||
(global $binary/I (mut i64) (i64.const 0))
|
||||
(global $binary/f (mut f32) (f32.const 0))
|
||||
(global $binary/F (mut f64) (f64.const 0))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(drop
|
||||
(i32.lt_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.gt_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.le_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.ge_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.eq
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.eq
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.add
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.sub
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.mul
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.div_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.rem_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.shl
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.shr_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.shr_u
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.and
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.or
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.xor
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i32.lt_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i32.gt_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i32.le_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i32.ge_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i32.eq
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i32.eq
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.add
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.sub
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.mul
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.div_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.rem_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.shl
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.shr_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.shr_u
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.and
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.or
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.xor
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.add
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.sub
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.mul
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.rem_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.shl
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.shr_s
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.shr_u
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.and
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.or
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/i
|
||||
(i32.xor
|
||||
(get_global $binary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.lt_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.gt_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.le_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.ge_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.eq
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.eq
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.add
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.sub
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.mul
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.div_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.rem_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.shl
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.shr_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.shr_u
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.and
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.or
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.xor
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i64.lt_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i64.gt_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i64.le_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i64.ge_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i64.eq
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(i64.eq
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.add
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.sub
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.mul
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.div_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.rem_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.shl
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.shr_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.shr_u
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.and
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.or
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.xor
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.add
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.sub
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.mul
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.rem_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.shl
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.shr_s
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.shr_u
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.and
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.or
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/I
|
||||
(i64.xor
|
||||
(get_global $binary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.lt
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.gt
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.le
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.ge
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.eq
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.eq
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.add
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.sub
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.mul
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.div
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f32.lt
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f32.gt
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f32.le
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f32.ge
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f32.eq
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f32.eq
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/f
|
||||
(f32.add
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/f
|
||||
(f32.sub
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/f
|
||||
(f32.mul
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/f
|
||||
(f32.div
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/f
|
||||
(f32.add
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/f
|
||||
(f32.sub
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/f
|
||||
(f32.mul
|
||||
(get_global $binary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.lt
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.gt
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.le
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.ge
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.eq
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.eq
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.add
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.sub
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.mul
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.div
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f64.lt
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f64.gt
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f64.le
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f64.ge
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f64.eq
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/b
|
||||
(f64.eq
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/F
|
||||
(f64.add
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/F
|
||||
(f64.sub
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/F
|
||||
(f64.mul
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/F
|
||||
(f64.div
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/F
|
||||
(f64.add
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/F
|
||||
(f64.sub
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $binary/F
|
||||
(f64.mul
|
||||
(get_global $binary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
clz
|
||||
ctz
|
||||
popcnt
|
||||
rotl
|
||||
rotr
|
||||
abs
|
||||
ceil
|
||||
copysign
|
||||
floor
|
||||
max
|
||||
min
|
||||
nearest
|
||||
sqrt
|
||||
trunc
|
||||
isNaN
|
||||
isFinite
|
||||
binary/b
|
||||
binary/i
|
||||
binary/I
|
||||
binary/f
|
||||
binary/F
|
||||
[program.exports]
|
||||
|
||||
;)
|
14
tests/compiler/do.ts
Normal file
14
tests/compiler/do.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export function loopDo(n: i32): void {
|
||||
do {
|
||||
n = n - 1;
|
||||
} while (n);
|
||||
}
|
||||
|
||||
export function loopDoInDo(n: i32): void {
|
||||
do {
|
||||
n = n - 1;
|
||||
do {
|
||||
n = n - 1;
|
||||
} while (n);
|
||||
} while (n);
|
||||
}
|
79
tests/compiler/do.wast
Normal file
79
tests/compiler/do.wast
Normal file
@ -0,0 +1,79 @@
|
||||
(module
|
||||
(type $iv (func (param i32)))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
(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)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br_if $continue$1.1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $do/loopDoInDo (; 1 ;) (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)
|
||||
)
|
||||
)
|
||||
(block $break$1.2
|
||||
(loop $continue$1.2
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br_if $continue$1.2
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br_if $continue$1.1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
clz
|
||||
ctz
|
||||
popcnt
|
||||
rotl
|
||||
rotr
|
||||
abs
|
||||
ceil
|
||||
copysign
|
||||
floor
|
||||
max
|
||||
min
|
||||
nearest
|
||||
sqrt
|
||||
trunc
|
||||
isNaN
|
||||
isFinite
|
||||
do/loopDo
|
||||
do/loopDoInDo
|
||||
[program.exports]
|
||||
do/loopDo
|
||||
do/loopDoInDo
|
||||
;)
|
@ -1,7 +1,7 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(global $export/a (mut i32) (i32.const 1))
|
||||
(global $export/b (mut i32) (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
|
22
tests/compiler/if.ts
Normal file
22
tests/compiler/if.ts
Normal file
@ -0,0 +1,22 @@
|
||||
export function ifThenElse(n: i32): bool {
|
||||
if (n)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
export function ifThen(n: i32): bool {
|
||||
if (n)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function ifThenElseBlock(n: i32): bool {
|
||||
if (n) {
|
||||
; // nop
|
||||
return true;
|
||||
} else {
|
||||
; // nop
|
||||
return false;
|
||||
}
|
||||
}
|
71
tests/compiler/if.wast
Normal file
71
tests/compiler/if.wast
Normal file
@ -0,0 +1,71 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
(func $if/ifThenElse (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if
|
||||
(get_local $0)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $if/ifThen (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if
|
||||
(get_local $0)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(func $if/ifThenElseBlock (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
(nop)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(nop)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
clz
|
||||
ctz
|
||||
popcnt
|
||||
rotl
|
||||
rotr
|
||||
abs
|
||||
ceil
|
||||
copysign
|
||||
floor
|
||||
max
|
||||
min
|
||||
nearest
|
||||
sqrt
|
||||
trunc
|
||||
isNaN
|
||||
isFinite
|
||||
if/ifThenElse
|
||||
if/ifThen
|
||||
if/ifThenElseBlock
|
||||
[program.exports]
|
||||
if/ifThenElse
|
||||
if/ifThen
|
||||
if/ifThenElseBlock
|
||||
;)
|
@ -1,8 +1,8 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $export/a i32 (i32.const 1))
|
||||
(global $export/b i32 (i32.const 2))
|
||||
(global $export/a (mut i32) (i32.const 1))
|
||||
(global $export/b (mut i32) (i32.const 2))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
|
46
tests/compiler/literals.ts
Normal file
46
tests/compiler/literals.ts
Normal file
@ -0,0 +1,46 @@
|
||||
0;
|
||||
1;
|
||||
2;
|
||||
3;
|
||||
4;
|
||||
5;
|
||||
6;
|
||||
7;
|
||||
8;
|
||||
9;
|
||||
0x0;
|
||||
0x1;
|
||||
0x2;
|
||||
0x3;
|
||||
0x4;
|
||||
0x5;
|
||||
0x6;
|
||||
0x7;
|
||||
0x8;
|
||||
0x9;
|
||||
0xA;
|
||||
0xB;
|
||||
0xC;
|
||||
0xD;
|
||||
0xE;
|
||||
0xF;
|
||||
0xa;
|
||||
0xb;
|
||||
0xc;
|
||||
0xd;
|
||||
0xe;
|
||||
0xf;
|
||||
0o0;
|
||||
0o1;
|
||||
0o2;
|
||||
0o3;
|
||||
0o4;
|
||||
0o5;
|
||||
0o6;
|
||||
0o7;
|
||||
0b0;
|
||||
0b1;
|
||||
true;
|
||||
false;
|
||||
NaN;
|
||||
Infinity;
|
168
tests/compiler/literals.wast
Normal file
168
tests/compiler/literals.wast
Normal file
@ -0,0 +1,168 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(drop
|
||||
(i32.const 0)
|
||||
)
|
||||
(drop
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(i32.const 2)
|
||||
)
|
||||
(drop
|
||||
(i32.const 3)
|
||||
)
|
||||
(drop
|
||||
(i32.const 4)
|
||||
)
|
||||
(drop
|
||||
(i32.const 5)
|
||||
)
|
||||
(drop
|
||||
(i32.const 6)
|
||||
)
|
||||
(drop
|
||||
(i32.const 7)
|
||||
)
|
||||
(drop
|
||||
(i32.const 8)
|
||||
)
|
||||
(drop
|
||||
(i32.const 9)
|
||||
)
|
||||
(drop
|
||||
(i32.const 0)
|
||||
)
|
||||
(drop
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(i32.const 2)
|
||||
)
|
||||
(drop
|
||||
(i32.const 3)
|
||||
)
|
||||
(drop
|
||||
(i32.const 4)
|
||||
)
|
||||
(drop
|
||||
(i32.const 5)
|
||||
)
|
||||
(drop
|
||||
(i32.const 6)
|
||||
)
|
||||
(drop
|
||||
(i32.const 7)
|
||||
)
|
||||
(drop
|
||||
(i32.const 8)
|
||||
)
|
||||
(drop
|
||||
(i32.const 9)
|
||||
)
|
||||
(drop
|
||||
(i32.const 10)
|
||||
)
|
||||
(drop
|
||||
(i32.const 11)
|
||||
)
|
||||
(drop
|
||||
(i32.const 12)
|
||||
)
|
||||
(drop
|
||||
(i32.const 13)
|
||||
)
|
||||
(drop
|
||||
(i32.const 14)
|
||||
)
|
||||
(drop
|
||||
(i32.const 15)
|
||||
)
|
||||
(drop
|
||||
(i32.const 10)
|
||||
)
|
||||
(drop
|
||||
(i32.const 11)
|
||||
)
|
||||
(drop
|
||||
(i32.const 12)
|
||||
)
|
||||
(drop
|
||||
(i32.const 13)
|
||||
)
|
||||
(drop
|
||||
(i32.const 14)
|
||||
)
|
||||
(drop
|
||||
(i32.const 15)
|
||||
)
|
||||
(drop
|
||||
(i32.const 0)
|
||||
)
|
||||
(drop
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(i32.const 2)
|
||||
)
|
||||
(drop
|
||||
(i32.const 3)
|
||||
)
|
||||
(drop
|
||||
(i32.const 4)
|
||||
)
|
||||
(drop
|
||||
(i32.const 5)
|
||||
)
|
||||
(drop
|
||||
(i32.const 6)
|
||||
)
|
||||
(drop
|
||||
(i32.const 7)
|
||||
)
|
||||
(drop
|
||||
(i32.const 0)
|
||||
)
|
||||
(drop
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(i32.const 0)
|
||||
)
|
||||
(drop
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
(drop
|
||||
(f64.const inf)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
clz
|
||||
ctz
|
||||
popcnt
|
||||
rotl
|
||||
rotr
|
||||
abs
|
||||
ceil
|
||||
copysign
|
||||
floor
|
||||
max
|
||||
min
|
||||
nearest
|
||||
sqrt
|
||||
trunc
|
||||
isNaN
|
||||
isFinite
|
||||
[program.exports]
|
||||
|
||||
;)
|
88
tests/compiler/unary.ts
Normal file
88
tests/compiler/unary.ts
Normal file
@ -0,0 +1,88 @@
|
||||
+1;
|
||||
-1;
|
||||
!1;
|
||||
~1;
|
||||
+1.25;
|
||||
-1.25;
|
||||
!1.25;
|
||||
// ~1.25;
|
||||
|
||||
let i: i32 = 0;
|
||||
|
||||
+i;
|
||||
-i;
|
||||
!i;
|
||||
~i;
|
||||
++i;
|
||||
--i;
|
||||
|
||||
i = +1;
|
||||
i = -1;
|
||||
i = !1;
|
||||
i = ~1;
|
||||
i = +i;
|
||||
i = -i;
|
||||
i = !i;
|
||||
i = ~i;
|
||||
i = ++i;
|
||||
i = --i;
|
||||
|
||||
let I: i64 = 0;
|
||||
|
||||
+I;
|
||||
-I;
|
||||
!I;
|
||||
~I;
|
||||
++I;
|
||||
--I;
|
||||
|
||||
I = +1;
|
||||
I = -1;
|
||||
I = !1;
|
||||
I = ~1;
|
||||
I = +I;
|
||||
I = -I;
|
||||
I = !I;
|
||||
I = ~I;
|
||||
I = ++I;
|
||||
I = --I;
|
||||
|
||||
let f: f32 = 0;
|
||||
|
||||
+f;
|
||||
-f;
|
||||
!f;
|
||||
// ~f;
|
||||
++f;
|
||||
--f;
|
||||
|
||||
f = +1.25;
|
||||
f = -1.25;
|
||||
i = !1.25;
|
||||
// i = ~1.25;
|
||||
f = +f;
|
||||
f = -f;
|
||||
i = !f;
|
||||
// i = ~f;
|
||||
f = ++f;
|
||||
f = --f;
|
||||
|
||||
let F: f64 = 0;
|
||||
|
||||
+F;
|
||||
-F;
|
||||
!F;
|
||||
// ~F;
|
||||
++F;
|
||||
--F;
|
||||
|
||||
F = +1.25;
|
||||
F = -1.25;
|
||||
I = !1.25;
|
||||
// I = ~1.25;
|
||||
F = +F;
|
||||
F = -F;
|
||||
I = !F;
|
||||
// I = ~F;
|
||||
F = ++F;
|
||||
F = --F;
|
420
tests/compiler/unary.wast
Normal file
420
tests/compiler/unary.wast
Normal file
@ -0,0 +1,420 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(global $unary/i (mut i32) (i32.const 0))
|
||||
(global $unary/I (mut i64) (i64.const 0))
|
||||
(global $unary/f (mut f32) (f32.const 0))
|
||||
(global $unary/F (mut f64) (f64.const 0))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(drop
|
||||
(i32.const 1)
|
||||
)
|
||||
(drop
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.eqz
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.xor
|
||||
(i32.const 1)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.const 1.25)
|
||||
)
|
||||
(drop
|
||||
(f64.neg
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.eq
|
||||
(f64.const 1.25)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(drop
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.eqz
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.xor
|
||||
(get_global $unary/i)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.eqz
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.xor
|
||||
(i32.const 1)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.eqz
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.xor
|
||||
(get_global $unary/i)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(drop
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.eqz
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.xor
|
||||
(get_global $unary/I)
|
||||
(i64.const -1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.const 1)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.extend_s/i32
|
||||
(i32.eqz
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.xor
|
||||
(i64.const 1)
|
||||
(i64.const -1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.extend_s/i32
|
||||
(i64.eqz
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.xor
|
||||
(get_global $unary/I)
|
||||
(i64.const -1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(block (result i64)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(block (result i64)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(drop
|
||||
(f32.neg
|
||||
(get_global $unary/f)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.eq
|
||||
(get_global $unary/f)
|
||||
(f32.const 0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.const 1.25)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.neg
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(f64.eq
|
||||
(f64.const 1.25)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.neg
|
||||
(get_global $unary/f)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(f32.eq
|
||||
(get_global $unary/f)
|
||||
(f32.const 0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(block (result f32)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/f)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(block (result f32)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/f)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(drop
|
||||
(f64.neg
|
||||
(get_global $unary/F)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.eq
|
||||
(get_global $unary/F)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.const 1.25)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.neg
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.extend_s/i32
|
||||
(f64.eq
|
||||
(f64.const 1.25)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.neg
|
||||
(get_global $unary/F)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.extend_s/i32
|
||||
(f64.eq
|
||||
(get_global $unary/F)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/F)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $unary/F)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
clz
|
||||
ctz
|
||||
popcnt
|
||||
rotl
|
||||
rotr
|
||||
abs
|
||||
ceil
|
||||
copysign
|
||||
floor
|
||||
max
|
||||
min
|
||||
nearest
|
||||
sqrt
|
||||
trunc
|
||||
isNaN
|
||||
isFinite
|
||||
unary/i
|
||||
unary/I
|
||||
unary/f
|
||||
unary/F
|
||||
[program.exports]
|
||||
|
||||
;)
|
14
tests/compiler/while.ts
Normal file
14
tests/compiler/while.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export function loopWhile(n: i32): void {
|
||||
while (n) {
|
||||
n = n - 1;
|
||||
}
|
||||
}
|
||||
|
||||
export function loopWhileInWhile(n: i32): void {
|
||||
while (n) {
|
||||
n = n - 1;
|
||||
while (n) {
|
||||
n = n - 1;
|
||||
}
|
||||
}
|
||||
}
|
88
tests/compiler/while.wast
Normal file
88
tests/compiler/while.wast
Normal file
@ -0,0 +1,88 @@
|
||||
(module
|
||||
(type $iv (func (param i32)))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
(func $while/loopWhile (; 0 ;) (type $iv) (param $0 i32)
|
||||
(block $break$1.1
|
||||
(loop $continue$1.1
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $while/loopWhileInWhile (; 1 ;) (type $iv) (param $0 i32)
|
||||
(block $break$1.1
|
||||
(loop $continue$1.1
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block $break$1.2
|
||||
(loop $continue$1.2
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue$1.2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue$1.1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
clz
|
||||
ctz
|
||||
popcnt
|
||||
rotl
|
||||
rotr
|
||||
abs
|
||||
ceil
|
||||
copysign
|
||||
floor
|
||||
max
|
||||
min
|
||||
nearest
|
||||
sqrt
|
||||
trunc
|
||||
isNaN
|
||||
isFinite
|
||||
while/loopWhile
|
||||
while/loopWhileInWhile
|
||||
[program.exports]
|
||||
while/loopWhile
|
||||
while/loopWhileInWhile
|
||||
;)
|
Reference in New Issue
Block a user