Skip to content

Commit b73c285

Browse files
authored
add tableName for indirect calls (#2125)
1 parent e231d19 commit b73c285

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/builtins.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3288,7 +3288,7 @@ function builtin_call_indirect(ctx: BuiltinContext): ExpressionRef {
32883288
paramTypeRefs[i] = compiler.currentType.toRef();
32893289
}
32903290
compiler.currentType = returnType;
3291-
return module.call_indirect(indexArg, operandExprs, createType(paramTypeRefs), returnType.toRef());
3291+
return module.call_indirect(null /* TODO */, indexArg, operandExprs, createType(paramTypeRefs), returnType.toRef());
32923292
}
32933293
builtins.set(BuiltinNames.call_indirect, builtin_call_indirect);
32943294

src/compiler.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7375,6 +7375,7 @@ export class Compiler extends DiagnosticEmitter {
73757375
}
73767376
if (operands) this.operandsTostack(signature, operands);
73777377
var expr = module.call_indirect(
7378+
null, // TODO: handle multiple tables
73787379
module.load(4, false, functionArg, TypeRef.I32), // ._index
73797380
operands,
73807381
signature.paramRefs,

src/module.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1567,13 +1567,14 @@ export class Module {
15671567
}
15681568

15691569
call_indirect(
1570+
tableName: string | null,
15701571
index: ExpressionRef,
15711572
operands: ExpressionRef[] | null,
15721573
params: TypeRef,
15731574
results: TypeRef,
15741575
isReturn: bool = false
15751576
): ExpressionRef {
1576-
var cStr = this.allocStringCached("0"); // TODO: multiple tables
1577+
var cStr = this.allocStringCached(tableName !== null ? tableName : "0");
15771578
var cArr = allocPtrArray(operands);
15781579
var ret = isReturn
15791580
? binaryen._BinaryenReturnCallIndirect(
@@ -1587,13 +1588,13 @@ export class Module {
15871588
}
15881589

15891590
return_call_indirect(
1590-
tableName: string,
1591+
tableName: string | null,
15911592
index: ExpressionRef,
15921593
operands: ExpressionRef[] | null,
15931594
params: TypeRef,
15941595
results: TypeRef
15951596
): ExpressionRef {
1596-
return this.call_indirect(index, operands, params, results, true);
1597+
return this.call_indirect(tableName, index, operands, params, results, true);
15971598
}
15981599

15991600
unreachable(): ExpressionRef {

0 commit comments

Comments
 (0)