Fixed a function expression parsing issue

Also uncovered a yet-to-be-fixed issue when immediately calling a returned function
This commit is contained in:
dcodeIO
2018-03-12 19:39:05 +01:00
parent 7870e3ac18
commit c93f0bb1fe
10 changed files with 51 additions and 65 deletions

View File

@ -2,12 +2,11 @@
(type $i (func (result i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $III (func (param i64 i64) (result i64)))
(type $FFF (func (param f64 f64) (result f64)))
(type $v (func))
(global $function-types/i32Adder (mut i32) (i32.const 0))
(global $function-types/i64Adder (mut i32) (i32.const 0))
(table 3 3 anyfunc)
(elem (i32.const 0) $function-types/makeAdder<i32>~anonymous|0 $function-types/makeAdder<i64>~anonymous|1 $function-types/makeAdder<f64>~anonymous|2)
(table 2 2 anyfunc)
(elem (i32.const 0) $function-types/makeAdder<i32>~anonymous|0 $function-types/makeAdder<i64>~anonymous|1)
(memory $0 1)
(export "memory" (memory $0))
(start $start)
@ -29,16 +28,7 @@
(func $function-types/makeAdder<i64> (; 3 ;) (type $i) (result i32)
(i32.const 1)
)
(func $function-types/makeAdder<f64>~anonymous|2 (; 4 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(f64.add
(get_local $0)
(get_local $1)
)
)
(func $function-types/makeAdder<f64> (; 5 ;) (type $i) (result i32)
(i32.const 2)
)
(func $start (; 6 ;) (type $v)
(func $start (; 4 ;) (type $v)
(set_global $function-types/i32Adder
(call $function-types/makeAdder<i32>)
)
@ -59,8 +49,5 @@
(get_global $function-types/i64Adder)
)
)
(drop
(call $function-types/makeAdder<f64>)
)
)
)

View File

@ -12,4 +12,5 @@ i32Adder(1, 2);
var i64Adder = makeAdder<i64>();
i64Adder(1, 2);
makeAdder<f64>()(1, 2);
// TODO:
// makeAdder<f64>()(1, 2);

View File

@ -2,13 +2,12 @@
(type $i (func (result i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $III (func (param i64 i64) (result i64)))
(type $FFF (func (param f64 f64) (result f64)))
(type $v (func))
(global $function-types/i32Adder (mut i32) (i32.const 0))
(global $function-types/i64Adder (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4))
(table 3 3 anyfunc)
(elem (i32.const 0) $function-types/makeAdder<i32>~anonymous|0 $function-types/makeAdder<i64>~anonymous|1 $function-types/makeAdder<f64>~anonymous|2)
(table 2 2 anyfunc)
(elem (i32.const 0) $function-types/makeAdder<i32>~anonymous|0 $function-types/makeAdder<i64>~anonymous|1)
(memory $0 1)
(export "memory" (memory $0))
(start $start)
@ -38,20 +37,7 @@
(i32.const 1)
)
)
(func $function-types/makeAdder<f64>~anonymous|2 (; 4 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(return
(f64.add
(get_local $0)
(get_local $1)
)
)
)
(func $function-types/makeAdder<f64> (; 5 ;) (type $i) (result i32)
(return
(i32.const 2)
)
)
(func $start (; 6 ;) (type $v)
(func $start (; 4 ;) (type $v)
(nop)
(set_global $function-types/i32Adder
(call $function-types/makeAdder<i32>)
@ -73,16 +59,5 @@
(get_global $function-types/i64Adder)
)
)
(drop
(call $function-types/makeAdder<f64>)
)
(block
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
)
)
)

View File

@ -0,0 +1 @@
a = fn()(1, 2);

View File

@ -0,0 +1 @@
a = fn()(1, 2);