diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index a85fd4676..5167ad70f 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -401,9 +401,9 @@ private: } void fixCallType(Expression* call, WasmType type) { - if (call->is<Call>()) call->type = type; - if (call->is<CallImport>()) call->type = type; - else if (call->is<CallIndirect>()) call->type = type; + if (call->is<Call>()) call->cast<Call>()->type = type; + if (call->is<CallImport>()) call->cast<CallImport>()->type = type; + else if (call->is<CallIndirect>()) call->cast<CallIndirect>()->type = type; } FunctionType* getBuiltinFunctionType(Name module, Name base, ExpressionList* operands = nullptr) { @@ -736,7 +736,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { wasm.removeImport(curr); } - // Finalize indirect calls and import calls + // Finalize calls now that everything is known and generated struct FinalizeCalls : public WalkerPass<PostWalker<FinalizeCalls, Visitor<FinalizeCalls>>> { bool isFunctionParallel() override { return true; } @@ -747,6 +747,10 @@ void Asm2WasmBuilder::processAsm(Ref ast) { FinalizeCalls(Asm2WasmBuilder* parent) : parent(parent) {} + void visitCall(Call* curr) { + curr->type = getModule()->getFunction(curr->target)->result; + } + void visitCallImport(CallImport* curr) { // fill out call_import - add extra params as needed, etc. asm tolerates ffi overloading, wasm does not auto iter = parent->importedFunctionTypes.find(curr->target); @@ -768,6 +772,8 @@ void Asm2WasmBuilder::processAsm(Ref ast) { } } } + + curr->type = getModule()->getImport(curr->target)->functionType->result; } void visitCallIndirect(CallIndirect* curr) { // we already call into target = something + offset, where offset is a callImport with the name of the table. replace that with the table offset |