diff options
-rw-r--r-- | src/s2wasm.h | 24 | ||||
-rw-r--r-- | test/dot_s/basics.wast | 1 | ||||
-rw-r--r-- | test/dot_s/call.wast | 7 | ||||
-rw-r--r-- | test/dot_s/cfg-stackify.wast | 3 | ||||
-rw-r--r-- | test/dot_s/exit.wast | 1 | ||||
-rw-r--r-- | test/dot_s/f32.wast | 1 | ||||
-rw-r--r-- | test/dot_s/f64.wast | 1 | ||||
-rw-r--r-- | test/dot_s/frem.wast | 2 | ||||
-rw-r--r-- | test/dot_s/global.wast | 1 | ||||
-rw-r--r-- | test/dot_s/import.wast | 6 | ||||
-rw-r--r-- | test/dot_s/returned.wast | 3 | ||||
-rw-r--r-- | test/dot_s/switch.wast | 6 | ||||
-rw-r--r-- | test/dot_s/unreachable.wast | 1 | ||||
-rw-r--r-- | test/dot_s/unused-argument.wast | 1 | ||||
-rw-r--r-- | test/dot_s/varargs.wast | 1 |
15 files changed, 50 insertions, 9 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index 1c3568aff..c21a8b0f8 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -449,21 +449,27 @@ private: CallBase* curr; Name assign; if (match("_indirect")) { - auto indirect = allocator.alloc<CallIndirect>(); + auto specific = allocator.alloc<CallIndirect>(); assign = getAssign(); - indirect->target = getInput(); - curr = indirect; + specific->target = getInput(); + curr = specific; } else { assign = getAssign(); Name target = getCommaSeparated(); if (implementedFunctions.count(target) > 0) { - auto plain = allocator.alloc<Call>(); - plain->target = target; - curr = plain; + auto specific = allocator.alloc<Call>(); + specific->target = target; + curr = specific; } else { - auto import = allocator.alloc<CallImport>(); - import->target = target; - curr = import; + auto specific = allocator.alloc<CallImport>(); + specific->target = target; + curr = specific; + if (wasm.importsMap.count(target) == 0) { + auto import = allocator.alloc<Import>(); + import->name = import->base = target; + import->module = ENV; + wasm.addImport(import); + } } } curr->type = type; diff --git a/test/dot_s/basics.wast b/test/dot_s/basics.wast index 3c5836bb1..ddae9af5e 100644 --- a/test/dot_s/basics.wast +++ b/test/dot_s/basics.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295 (segment 16 "hello, world!\n\00")) + (import $puts "env" "puts") (export "main" $main) (func $main (param $$0 i32) (param $$1 i32) (result i32) (block $fake_return_waka123 diff --git a/test/dot_s/call.wast b/test/dot_s/call.wast index 5462e8fd5..da72e6a48 100644 --- a/test/dot_s/call.wast +++ b/test/dot_s/call.wast @@ -2,6 +2,13 @@ (memory 0 4294967295) (type $FUNCSIG_v (func)) (type $FUNCSIG_i (func)) + (import $i32_nullary "env" "i32_nullary") + (import $i64_nullary "env" "i64_nullary") + (import $float_nullary "env" "float_nullary") + (import $double_nullary "env" "double_nullary") + (import $void_nullary "env" "void_nullary") + (import $i32_unary "env" "i32_unary") + (import $i32_binary "env" "i32_binary") (export "call_i32_nullary" $call_i32_nullary) (export "call_i64_nullary" $call_i64_nullary) (export "call_float_nullary" $call_float_nullary) diff --git a/test/dot_s/cfg-stackify.wast b/test/dot_s/cfg-stackify.wast index 8a5f3e720..8f583aa90 100644 --- a/test/dot_s/cfg-stackify.wast +++ b/test/dot_s/cfg-stackify.wast @@ -1,5 +1,8 @@ (module (memory 0 4294967295) + (import $something "env" "something") + (import $bar "env" "bar") + (import $a "env" "a") (export "test0" $test0) (export "test1" $test1) (export "test2" $test2) diff --git a/test/dot_s/exit.wast b/test/dot_s/exit.wast index 6c646cd7c..423dcfa7b 100644 --- a/test/dot_s/exit.wast +++ b/test/dot_s/exit.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295) + (import $exit "env" "exit") (export "main" $main) (func $main (result i32) (local $$0 i32) diff --git a/test/dot_s/f32.wast b/test/dot_s/f32.wast index 7a83b3211..c51a57de7 100644 --- a/test/dot_s/f32.wast +++ b/test/dot_s/f32.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295) + (import $fmaf "env" "fmaf") (export "fadd32" $fadd32) (export "fsub32" $fsub32) (export "fmul32" $fmul32) diff --git a/test/dot_s/f64.wast b/test/dot_s/f64.wast index bfc267fb2..093b276af 100644 --- a/test/dot_s/f64.wast +++ b/test/dot_s/f64.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295) + (import $fma "env" "fma") (export "fadd64" $fadd64) (export "fsub64" $fsub64) (export "fmul64" $fmul64) diff --git a/test/dot_s/frem.wast b/test/dot_s/frem.wast index 07a9d417c..5a300f8e3 100644 --- a/test/dot_s/frem.wast +++ b/test/dot_s/frem.wast @@ -1,5 +1,7 @@ (module (memory 0 4294967295) + (import $fmodf "env" "fmodf") + (import $fmod "env" "fmod") (export "frem32" $frem32) (export "frem64" $frem64) (func $frem32 (param $$0 f32) (param $$1 f32) (result f32) diff --git a/test/dot_s/global.wast b/test/dot_s/global.wast index 8fe08b1b0..2ae897647 100644 --- a/test/dot_s/global.wast +++ b/test/dot_s/global.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295 (segment 2 "9\05\00\00") (segment 6 "\00\00\00\00") (segment 10 "\01\00\00\00") (segment 14 "*\00\00\00") (segment 18 "\ff\ff\ff\ff") (segment 24 "\00\00\00\00\00\00\00\00") (segment 33 "\00\00\00\00\00\00\00\00") (segment 42 "\ff\ff\ff\ff\ff\ff\ff\ff") (segment 50 "\00\00\00\00") (segment 54 "\00\00\00\80") (segment 58 "\00\00\00@") (segment 63 "\00\00\00\00\00\00\00\00") (segment 72 "\00\00\00\00\00\00\00\00") (segment 81 "\00\00\00\00\00\00\00\00")) + (import $memcpy "env" "memcpy") (export "foo" $foo) (export "call_memcpy" $call_memcpy) (func $foo (result i32) diff --git a/test/dot_s/import.wast b/test/dot_s/import.wast index 004d05dc1..f3760ca81 100644 --- a/test/dot_s/import.wast +++ b/test/dot_s/import.wast @@ -1,5 +1,11 @@ (module (memory 0 4294967295) + (import $printi "env" "printi") + (import $printf "env" "printf") + (import $printv "env" "printv") + (import $split_arg "env" "split_arg") + (import $expanded_arg "env" "expanded_arg") + (import $lowered_result "env" "lowered_result") (export "f" $f) (func $f (param $$0 i32) (param $$1 f32) (param $$2 i64) (param $$3 i64) (param $$4 i32) (block $fake_return_waka123 diff --git a/test/dot_s/returned.wast b/test/dot_s/returned.wast index 8426e8ea3..d85228de9 100644 --- a/test/dot_s/returned.wast +++ b/test/dot_s/returned.wast @@ -1,5 +1,8 @@ (module (memory 0 4294967295) + (import $_Znwm "env" "_Znwm") + (import $_ZN5AppleC1Ev "env" "_ZN5AppleC1Ev") + (import $memcpy "env" "memcpy") (export "_Z3foov" $_Z3foov) (export "_Z3barPvS_l" $_Z3barPvS_l) (func $_Z3foov (result i32) diff --git a/test/dot_s/switch.wast b/test/dot_s/switch.wast index 6d7be38bb..a34266478 100644 --- a/test/dot_s/switch.wast +++ b/test/dot_s/switch.wast @@ -1,5 +1,11 @@ (module (memory 0 4294967295) + (import $foo0 "env" "foo0") + (import $foo1 "env" "foo1") + (import $foo2 "env" "foo2") + (import $foo3 "env" "foo3") + (import $foo4 "env" "foo4") + (import $foo5 "env" "foo5") (export "bar32" $bar32) (export "bar64" $bar64) (func $bar32 (param $$0 i32) diff --git a/test/dot_s/unreachable.wast b/test/dot_s/unreachable.wast index 3dfa0c091..93063828e 100644 --- a/test/dot_s/unreachable.wast +++ b/test/dot_s/unreachable.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295) + (import $abort "env" "abort") (export "f1" $f1) (export "f2" $f2) (export "f3" $f3) diff --git a/test/dot_s/unused-argument.wast b/test/dot_s/unused-argument.wast index 8a71571f7..2c93e0f52 100644 --- a/test/dot_s/unused-argument.wast +++ b/test/dot_s/unused-argument.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295) + (import $return_something "env" "return_something") (export "unused_first" $unused_first) (export "unused_second" $unused_second) (export "call_something" $call_something) diff --git a/test/dot_s/varargs.wast b/test/dot_s/varargs.wast index 8e252997c..691b82dee 100644 --- a/test/dot_s/varargs.wast +++ b/test/dot_s/varargs.wast @@ -1,5 +1,6 @@ (module (memory 0 4294967295) + (import $callee "env" "callee") (export "end" $end) (export "copy" $copy) (export "arg_i8" $arg_i8) |