diff options
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index ee3c1a6fa..b6a5daf14 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -3574,6 +3574,9 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { if (maybeVisitArrayNew(curr, opcode)) { break; } + if (maybeVisitArrayInit(curr, opcode)) { + break; + } if (maybeVisitArrayGet(curr, opcode)) { break; } @@ -6508,6 +6511,22 @@ bool WasmBinaryBuilder::maybeVisitArrayNew(Expression*& out, uint32_t code) { return true; } +bool WasmBinaryBuilder::maybeVisitArrayInit(Expression*& out, uint32_t code) { + if (code != BinaryConsts::ArrayInit) { + return false; + } + auto heapType = getIndexedHeapType(); + auto size = getU32LEB(); + auto* rtt = popNonVoidExpression(); + validateHeapTypeUsingChild(rtt, heapType); + std::vector<Expression*> values(size); + for (size_t i = 0; i < size; i++) { + values[size - i - 1] = popNonVoidExpression(); + } + out = Builder(wasm).makeArrayInit(rtt, values); + return true; +} + bool WasmBinaryBuilder::maybeVisitArrayGet(Expression*& out, uint32_t code) { bool signed_ = false; switch (code) { |