diff options
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r-- | src/s2wasm.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index 4811632b1..9d50693e9 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -552,12 +552,6 @@ private: 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; @@ -585,6 +579,15 @@ private: } else { call->fullType = wasm.functionTypesMap[typeName]; } + } else if (curr->is<CallImport>()) { + auto target = curr->cast<CallImport>()->target; + if (wasm.importsMap.count(target) == 0) { + auto import = allocator.alloc<Import>(); + import->name = import->base = target; + import->module = ENV; + import->type = sigToFunctionType(getSig(curr)); + wasm.addImport(import); + } } }; auto handleTyped = [&](WasmType type) { @@ -1070,6 +1073,7 @@ public: auto import = parent->allocator.alloc<Import>(); import->name = import->base = curr->target; import->module = ENV; + import->type = sigToFunctionType(getSig(curr)); parent->wasm.addImport(import); } } |