diff --git a/src/builtins.ts b/src/builtins.ts index d6e8120e3a..bc01631145 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -3288,7 +3288,7 @@ function builtin_call_indirect(ctx: BuiltinContext): ExpressionRef { paramTypeRefs[i] = compiler.currentType.toRef(); } compiler.currentType = returnType; - return module.call_indirect(indexArg, operandExprs, createType(paramTypeRefs), returnType.toRef()); + return module.call_indirect(null /* TODO */, indexArg, operandExprs, createType(paramTypeRefs), returnType.toRef()); } builtins.set(BuiltinNames.call_indirect, builtin_call_indirect); diff --git a/src/compiler.ts b/src/compiler.ts index 9ad5925ab3..22984120ae 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -7366,6 +7366,7 @@ export class Compiler extends DiagnosticEmitter { } if (operands) this.operandsTostack(signature, operands); var expr = module.call_indirect( + null, // TODO: handle multiple tables module.load(4, false, functionArg, TypeRef.I32), // ._index operands, signature.paramRefs, diff --git a/src/module.ts b/src/module.ts index 17e5597fe8..c4fa254979 100644 --- a/src/module.ts +++ b/src/module.ts @@ -1560,13 +1560,14 @@ export class Module { } call_indirect( + tableName: string | null, index: ExpressionRef, operands: ExpressionRef[] | null, params: TypeRef, results: TypeRef, isReturn: bool = false ): ExpressionRef { - var cStr = this.allocStringCached("0"); // TODO: multiple tables + var cStr = this.allocStringCached(tableName !== null ? tableName : "0"); var cArr = allocPtrArray(operands); var ret = isReturn ? binaryen._BinaryenReturnCallIndirect( @@ -1580,13 +1581,13 @@ export class Module { } return_call_indirect( - tableName: string, + tableName: string | null, index: ExpressionRef, operands: ExpressionRef[] | null, params: TypeRef, results: TypeRef ): ExpressionRef { - return this.call_indirect(index, operands, params, results, true); + return this.call_indirect(tableName, index, operands, params, results, true); } unreachable(): ExpressionRef {