mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-26 21:21:54 +00:00
Integrate examples into tests
This commit is contained in:
277
tests/compiler/game-of-life.optimized.wast
Normal file
277
tests/compiler/game-of-life.optimized.wast
Normal file
@ -0,0 +1,277 @@
|
||||
(module
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $v (func))
|
||||
(global $../../examples/game-of-life/assembly/game-of-life/w (mut i32) (i32.const 0))
|
||||
(global $../../examples/game-of-life/assembly/game-of-life/h (mut i32) (i32.const 0))
|
||||
(global $../../examples/game-of-life/assembly/game-of-life/s (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(export "init" (func $../../examples/game-of-life/assembly/game-of-life/init))
|
||||
(export "step" (func $../../examples/game-of-life/assembly/game-of-life/step))
|
||||
(export "memory" (memory $0))
|
||||
(func $../../examples/game-of-life/assembly/game-of-life/init (; 0 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(set_global $../../examples/game-of-life/assembly/game-of-life/w
|
||||
(get_local $0)
|
||||
)
|
||||
(set_global $../../examples/game-of-life/assembly/game-of-life/h
|
||||
(get_local $1)
|
||||
)
|
||||
(set_global $../../examples/game-of-life/assembly/game-of-life/s
|
||||
(i32.mul
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $../../examples/game-of-life/assembly/game-of-life/step (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(set_local $6
|
||||
(i32.sub
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.sub
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(select
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $6)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(select
|
||||
(i32.const 0)
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(tee_local $2
|
||||
(select
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $7)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(tee_local $3
|
||||
(select
|
||||
(i32.const 0)
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $5)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $5)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $5)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.gt_u
|
||||
(get_local $2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $2)
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
1
tests/compiler/game-of-life.ts
Normal file
1
tests/compiler/game-of-life.ts
Normal file
@ -0,0 +1 @@
|
||||
export { init, step } from "../../examples/game-of-life/assembly/game-of-life";
|
351
tests/compiler/game-of-life.wast
Normal file
351
tests/compiler/game-of-life.wast
Normal file
@ -0,0 +1,351 @@
|
||||
(module
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $v (func))
|
||||
(global $../../examples/game-of-life/assembly/game-of-life/w (mut i32) (i32.const 0))
|
||||
(global $../../examples/game-of-life/assembly/game-of-life/h (mut i32) (i32.const 0))
|
||||
(global $../../examples/game-of-life/assembly/game-of-life/s (mut i32) (i32.const 0))
|
||||
(global $HEAP_START i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "init" (func $../../examples/game-of-life/assembly/game-of-life/init))
|
||||
(export "step" (func $../../examples/game-of-life/assembly/game-of-life/step))
|
||||
(export "memory" (memory $0))
|
||||
(func $../../examples/game-of-life/assembly/game-of-life/init (; 0 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(set_global $../../examples/game-of-life/assembly/game-of-life/w
|
||||
(get_local $0)
|
||||
)
|
||||
(set_global $../../examples/game-of-life/assembly/game-of-life/h
|
||||
(get_local $1)
|
||||
)
|
||||
(set_global $../../examples/game-of-life/assembly/game-of-life/s
|
||||
(i32.mul
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $../../examples/game-of-life/assembly/game-of-life/step (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(local $9 i32)
|
||||
(local $10 i32)
|
||||
(local $11 i32)
|
||||
(nop)
|
||||
(nop)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.sub
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.sub
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $10
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/h)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(set_local $1
|
||||
(select
|
||||
(get_local $6)
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(select
|
||||
(i32.const 0)
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|1
|
||||
(set_local $3
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(set_local $4
|
||||
(select
|
||||
(get_local $7)
|
||||
(i32.sub
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(select
|
||||
(i32.const 0)
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $3)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $2)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $2)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $2)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $9
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(get_local $9)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $11
|
||||
(i32.lt_u
|
||||
(get_local $8)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $11)
|
||||
(i32.gt_u
|
||||
(get_local $8)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $8)
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[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
|
||||
changetype
|
||||
isNaN
|
||||
isFinite
|
||||
assert
|
||||
parseInt
|
||||
parseFloat
|
||||
../../examples/game-of-life/assembly/game-of-life/w
|
||||
../../examples/game-of-life/assembly/game-of-life/h
|
||||
../../examples/game-of-life/assembly/game-of-life/s
|
||||
../../examples/game-of-life/assembly/game-of-life/init
|
||||
../../examples/game-of-life/assembly/game-of-life/step
|
||||
[program.exports]
|
||||
../../examples/game-of-life/assembly/game-of-life/init
|
||||
../../examples/game-of-life/assembly/game-of-life/step
|
||||
game-of-life/init
|
||||
game-of-life/step
|
||||
;)
|
1057
tests/compiler/i64.optimized.wast
Normal file
1057
tests/compiler/i64.optimized.wast
Normal file
File diff suppressed because it is too large
Load Diff
34
tests/compiler/i64.ts
Normal file
34
tests/compiler/i64.ts
Normal file
@ -0,0 +1,34 @@
|
||||
export {
|
||||
getHi,
|
||||
getLo,
|
||||
|
||||
clz,
|
||||
ctz,
|
||||
popcnt,
|
||||
eqz,
|
||||
add,
|
||||
sub,
|
||||
mul,
|
||||
div_s,
|
||||
div_u,
|
||||
rem_s,
|
||||
rem_u,
|
||||
and,
|
||||
or,
|
||||
xor,
|
||||
shl,
|
||||
shr_s,
|
||||
shr_u,
|
||||
rotl,
|
||||
rotr,
|
||||
eq,
|
||||
ne,
|
||||
lt_s,
|
||||
lt_u,
|
||||
le_s,
|
||||
le_u,
|
||||
gt_s,
|
||||
gt_u,
|
||||
ge_s,
|
||||
ge_u
|
||||
} from "../../examples/i64-polyfill/assembly/i64";
|
1318
tests/compiler/i64.wast
Normal file
1318
tests/compiler/i64.wast
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user