diff options
Diffstat (limited to 'src/wasm/wasm-stack.cpp')
-rw-r--r-- | src/wasm/wasm-stack.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index a6a4ce171..4791c4a23 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -1910,7 +1910,19 @@ void BinaryInstWriter::visitStructNew(StructNew* curr) { } void BinaryInstWriter::visitStructGet(StructGet* curr) { - WASM_UNREACHABLE("TODO (gc): struct.get"); + const auto& heapType = curr->value->type.getHeapType(); + const auto& field = heapType.getStruct().fields[curr->index]; + int8_t op; + if (field.type != Type::i32 || field.packedType == Field::not_packed) { + op = BinaryConsts::StructGet; + } else if (curr->signed_) { + op = BinaryConsts::StructGetS; + } else { + op = BinaryConsts::StructGetU; + } + o << int8_t(BinaryConsts::GCPrefix) << int8_t(op); + parent.writeHeapType(heapType); + o << U32LEB(curr->index); } void BinaryInstWriter::visitStructSet(StructSet* curr) { |