mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-17 08:51:34 +00:00
Support indirect calls with omitted arguments
This commit is contained in:
@ -5,10 +5,10 @@
|
||||
(type $III (func (param i64 i64) (result i64)))
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $function-types/i32Adder (mut i32) (i32.const 0))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $function-types/i64Adder (mut i32) (i32.const 0))
|
||||
(table 4 4 anyfunc)
|
||||
(elem (i32.const 0) $function-types/makeAdder<i32>~anonymous|0 $function-types/makeAdder<i64>~anonymous|1 $function-types/makeAdder<f64>~anonymous|2 $function-types/makeAdder<i32>~anonymous|0)
|
||||
@ -45,6 +45,9 @@
|
||||
(i32.const 2)
|
||||
)
|
||||
(func $function-types/doAddWithFn<i32> (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(set_global $argumentCount
|
||||
(i32.const 2)
|
||||
)
|
||||
(call_indirect (type $iii)
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
@ -52,19 +55,22 @@
|
||||
)
|
||||
)
|
||||
(func $function-types/doAdd<i32> (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(set_global $argumentCount
|
||||
(i32.const 2)
|
||||
)
|
||||
(call_indirect (type $iii)
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(call $function-types/makeAdder<i32>)
|
||||
)
|
||||
)
|
||||
(func $function-types/makeAndAdd<i32>|trampoline (; 9 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
|
||||
(block $N=1
|
||||
(block $N=0
|
||||
(block $N=invalid
|
||||
(br_table $N=0 $N=1 $N=invalid
|
||||
(func $function-types/makeAndAdd<i32>|trampoline (; 9 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(block $1of1
|
||||
(block $0of1
|
||||
(block $oob
|
||||
(br_table $0of1 $1of1 $oob
|
||||
(i32.sub
|
||||
(get_local $3)
|
||||
(get_global $argumentCount)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
@ -86,13 +92,18 @@
|
||||
(call $function-types/makeAdder<i32>)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call_indirect (type $iii)
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(set_global $argumentCount
|
||||
(i32.const 2)
|
||||
(get_global $function-types/i32Adder)
|
||||
)
|
||||
(i32.const 3)
|
||||
(i32.ne
|
||||
(call_indirect (type $iii)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
(get_global $function-types/i32Adder)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
@ -108,13 +119,18 @@
|
||||
(call $function-types/makeAdder<i64>)
|
||||
)
|
||||
(if
|
||||
(i64.ne
|
||||
(call_indirect (type $III)
|
||||
(i64.const 10)
|
||||
(i64.const 20)
|
||||
(get_global $function-types/i64Adder)
|
||||
(block (result i32)
|
||||
(set_global $argumentCount
|
||||
(i32.const 2)
|
||||
)
|
||||
(i64.ne
|
||||
(call_indirect (type $III)
|
||||
(i64.const 10)
|
||||
(i64.const 20)
|
||||
(get_global $function-types/i64Adder)
|
||||
)
|
||||
(i64.const 30)
|
||||
)
|
||||
(i64.const 30)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
@ -127,13 +143,18 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(call_indirect (type $FFF)
|
||||
(f64.const 1.5)
|
||||
(f64.const 2.5)
|
||||
(call $function-types/makeAdder<f64>)
|
||||
(block (result i32)
|
||||
(set_global $argumentCount
|
||||
(i32.const 2)
|
||||
)
|
||||
(f64.ne
|
||||
(call_indirect (type $FFF)
|
||||
(f64.const 1.5)
|
||||
(f64.const 2.5)
|
||||
(call $function-types/makeAdder<f64>)
|
||||
)
|
||||
(f64.const 4)
|
||||
)
|
||||
(f64.const 4)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
@ -202,14 +223,18 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $function-types/makeAndAdd<i32>|trampoline
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
(i32.const 0)
|
||||
(block (result i32)
|
||||
(set_global $argumentCount
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const 3)
|
||||
(i32.ne
|
||||
(call $function-types/makeAndAdd<i32>|trampoline
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
@ -221,5 +246,24 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $function-types/doAddWithFn<i32>
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
(call $function-types/makeAdder<i32>)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 42)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user