Skip to content

Commit 040954b

Browse files
committed
[wa-info] Show function type and tbl index for call.indirect
1 parent 493c7d7 commit 040954b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/mono/wasm/tools/wa-info/WasmReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ public string FunctionName(UInt32 idx)
795795
{
796796
return functionNames[idx];
797797
}
798+
public string FunctionType(UInt32 idx)
799+
{
800+
return functionTypes[idx].ToString();
801+
}
798802

799803
public string GlobalName(UInt32 idx)
800804
{

src/mono/wasm/tools/wa-info/WasmStucts.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public string ToString(WasmReader? reader)
4343
return $"{opStr} {GlobalName(Idx, reader)}";
4444
case Opcode.Call:
4545
return $"{opStr} {FunctionName(Idx, reader)}";
46+
case Opcode.Call_Indirect:
47+
var table = Idx2 == 0 ? "" : $" table:{Idx2}";
48+
return $"{opStr} {FunctionType(Idx, reader)}{table}";
4649
case Opcode.I32_Const:
4750
return $"{opStr} {I32}";
4851
case Opcode.I64_Const:
@@ -92,6 +95,14 @@ static string FunctionName(UInt32 idx, WasmReader? reader)
9295
return reader.FunctionName(idx);
9396
}
9497

98+
static string FunctionType(UInt32 idx, WasmReader? reader)
99+
{
100+
if (reader == null)
101+
return $"[{idx.ToString()}]";
102+
103+
return reader.FunctionType(idx);
104+
}
105+
95106
static string GlobalName(UInt32 idx, WasmReader? reader)
96107
{
97108
if (reader == null)

0 commit comments

Comments
 (0)