mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 00:11:28 +00:00
Always add a null function at table index zero
This allows function references (a table index internally) to be nullable
This commit is contained in:
@ -11,39 +11,39 @@
|
||||
(global $function-types/i32Adder (mut i32) (i32.const 0))
|
||||
(global $~argc (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)
|
||||
(table 5 5 anyfunc)
|
||||
(elem (i32.const 0) $null $function-types/makeAdder<i32>~anonymous|1 $function-types/makeAdder<i64>~anonymous|2 $function-types/makeAdder<f64>~anonymous|3 $function-types/makeAdder<i32>~anonymous|1)
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\11\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00t\00y\00p\00e\00s\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
(func $function-types/makeAdder<i32>~anonymous|0 (; 1 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $function-types/makeAdder<i32>~anonymous|1 (; 1 ;) (; has Stack IR ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $function-types/makeAdder<i32> (; 2 ;) (; has Stack IR ;) (type $i) (result i32)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(func $function-types/makeAdder<i64>~anonymous|1 (; 3 ;) (; has Stack IR ;) (type $III) (param $0 i64) (param $1 i64) (result i64)
|
||||
(func $function-types/makeAdder<i64>~anonymous|2 (; 3 ;) (; has Stack IR ;) (type $III) (param $0 i64) (param $1 i64) (result i64)
|
||||
(i64.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $function-types/makeAdder<i64> (; 4 ;) (; has Stack IR ;) (type $i) (result i32)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(func $function-types/makeAdder<f64>~anonymous|2 (; 5 ;) (; has Stack IR ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
(func $function-types/makeAdder<f64>~anonymous|3 (; 5 ;) (; has Stack IR ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
(f64.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $function-types/makeAdder<f64> (; 6 ;) (; has Stack IR ;) (type $i) (result i32)
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
(func $function-types/doAddWithFn<i32> (; 7 ;) (; has Stack IR ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(set_global $~argc
|
||||
@ -201,7 +201,7 @@
|
||||
(call $function-types/doAddWithFn<i32>
|
||||
(i32.const 4)
|
||||
(i32.const 5)
|
||||
(i32.const 3)
|
||||
(i32.const 4)
|
||||
)
|
||||
(i32.const 9)
|
||||
)
|
||||
@ -253,4 +253,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $null (; 11 ;) (; has Stack IR ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user