summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/s2wasm.h24
1 files changed, 15 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;