mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 14:31:28 +00:00
Implement array functions with just an expression body
This commit is contained in:
@ -2,12 +2,14 @@
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(type $i (func (result i32)))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $function-expression/f1 (mut i32) (i32.const 0))
|
||||
(global $function-expression/f2 (mut i32) (i32.const 1))
|
||||
(global $function-expression/f3 (mut i32) (i32.const 2))
|
||||
(table 3 3 anyfunc)
|
||||
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|0 $start~someName|2)
|
||||
(global $function-expression/f4 (mut i32) (i32.const 3))
|
||||
(table 4 4 anyfunc)
|
||||
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|0 $start~someName|2 $start~anonymous|3)
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
@ -18,7 +20,10 @@
|
||||
(func $start~someName|2 (; 2 ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
(func $start (; 3 ;) (type $v)
|
||||
(func $start~anonymous|3 (; 3 ;) (type $i) (result i32)
|
||||
(i32.const 1)
|
||||
)
|
||||
(func $start (; 4 ;) (type $v)
|
||||
(if
|
||||
(i32.ne
|
||||
(call_indirect (type $ii)
|
||||
@ -58,5 +63,22 @@
|
||||
(call_indirect (type $v)
|
||||
(get_global $function-expression/f3)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call_indirect (type $i)
|
||||
(get_global $function-expression/f4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 16)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -11,3 +11,6 @@ assert(f2(2) == 2);
|
||||
var f3 = function someName(): void {
|
||||
};
|
||||
f3();
|
||||
|
||||
var f4 = (): i32 => 1;
|
||||
assert(f4() == 1);
|
||||
|
@ -2,13 +2,15 @@
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(type $i (func (result i32)))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $function-expression/f1 (mut i32) (i32.const 0))
|
||||
(global $function-expression/f2 (mut i32) (i32.const 1))
|
||||
(global $function-expression/f3 (mut i32) (i32.const 2))
|
||||
(global $function-expression/f4 (mut i32) (i32.const 3))
|
||||
(global $HEAP_BASE i32 (i32.const 52))
|
||||
(table 3 3 anyfunc)
|
||||
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|1 $start~someName|2)
|
||||
(table 4 4 anyfunc)
|
||||
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|1 $start~someName|2 $start~anonymous|3)
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
@ -25,7 +27,10 @@
|
||||
)
|
||||
(func $start~someName|2 (; 3 ;) (type $v)
|
||||
)
|
||||
(func $start (; 4 ;) (type $v)
|
||||
(func $start~anonymous|3 (; 4 ;) (type $i) (result i32)
|
||||
(i32.const 1)
|
||||
)
|
||||
(func $start (; 5 ;) (type $v)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
@ -69,5 +74,24 @@
|
||||
(call_indirect (type $v)
|
||||
(get_global $function-expression/f3)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call_indirect (type $i)
|
||||
(get_global $function-expression/f4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 16)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user