summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 4082fbf5f..2abb32837 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -4223,6 +4223,9 @@ BinaryConsts::ASTNodes WasmBinaryReader::readExpression(Expression*& curr) {
if (maybeVisitTableCopy(curr, opcode)) {
break;
}
+ if (maybeVisitTableInit(curr, opcode)) {
+ break;
+ }
if (maybeVisitLoad(curr, opcode, BinaryConsts::MiscPrefix)) {
break;
}
@@ -5646,6 +5649,23 @@ bool WasmBinaryReader::maybeVisitTableCopy(Expression*& out, uint32_t code) {
return true;
}
+bool WasmBinaryReader::maybeVisitTableInit(Expression*& out, uint32_t code) {
+ if (code != BinaryConsts::TableInit) {
+ return false;
+ }
+ auto* curr = allocator.alloc<TableInit>();
+ curr->size = popNonVoidExpression();
+ curr->offset = popNonVoidExpression();
+ curr->dest = popNonVoidExpression();
+ Index segIdx = getU32LEB();
+ elemRefs[segIdx].push_back(&curr->segment);
+ Index memIdx = getU32LEB();
+ tableRefs[memIdx].push_back(&curr->table);
+ curr->finalize();
+ out = curr;
+ return true;
+}
+
bool WasmBinaryReader::maybeVisitBinary(Expression*& out, uint8_t code) {
Binary* curr;
#define INT_TYPED_CODE(code) \