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.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index e70dc4a29..25c1eea8c 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1034,29 +1034,29 @@ void WasmBinaryWriter::writeHeapType(HeapType type) {
return;
}
int ret = 0;
- switch (type.kind) {
- case HeapType::FuncKind:
- ret = BinaryConsts::EncodedHeapType::func;
- break;
- case HeapType::ExternKind:
- ret = BinaryConsts::EncodedHeapType::extern_;
- break;
- case HeapType::ExnKind:
- ret = BinaryConsts::EncodedHeapType::exn;
- break;
- case HeapType::AnyKind:
- ret = BinaryConsts::EncodedHeapType::any;
- break;
- case HeapType::EqKind:
- ret = BinaryConsts::EncodedHeapType::eq;
- break;
- case HeapType::I31Kind:
- ret = BinaryConsts::EncodedHeapType::i31;
- break;
- case HeapType::SignatureKind:
- case HeapType::StructKind:
- case HeapType::ArrayKind:
- WASM_UNREACHABLE("TODO: compound GC types");
+ if (type.isBasic()) {
+ switch (type.getBasic()) {
+ case HeapType::func:
+ ret = BinaryConsts::EncodedHeapType::func;
+ break;
+ case HeapType::ext:
+ ret = BinaryConsts::EncodedHeapType::extern_;
+ break;
+ case HeapType::exn:
+ ret = BinaryConsts::EncodedHeapType::exn;
+ break;
+ case HeapType::any:
+ ret = BinaryConsts::EncodedHeapType::any;
+ break;
+ case HeapType::eq:
+ ret = BinaryConsts::EncodedHeapType::eq;
+ break;
+ case HeapType::i31:
+ ret = BinaryConsts::EncodedHeapType::i31;
+ break;
+ }
+ } else {
+ WASM_UNREACHABLE("TODO: compound GC types");
}
o << S64LEB(ret); // TODO: Actually s33
}
@@ -1401,17 +1401,17 @@ HeapType WasmBinaryBuilder::getHeapType() {
}
switch (type) {
case BinaryConsts::EncodedHeapType::func:
- return HeapType::FuncKind;
+ return HeapType::func;
case BinaryConsts::EncodedHeapType::extern_:
- return HeapType::ExternKind;
+ return HeapType::ext;
case BinaryConsts::EncodedHeapType::exn:
- return HeapType::ExnKind;
+ return HeapType::exn;
case BinaryConsts::EncodedHeapType::any:
- return HeapType::AnyKind;
+ return HeapType::any;
case BinaryConsts::EncodedHeapType::eq:
- return HeapType::EqKind;
+ return HeapType::eq;
case BinaryConsts::EncodedHeapType::i31:
- return HeapType::I31Kind;
+ return HeapType::i31;
default:
throwError("invalid wasm heap type: " + std::to_string(type));
}
@@ -5630,7 +5630,8 @@ bool WasmBinaryBuilder::maybeVisitStructGet(Expression*& out, uint32_t code) {
default:
return false;
}
- auto type = getHeapType();
+ // This type annotation is unused. Beware it needing to be used in the future!
+ getHeapType();
curr->index = getU32LEB();
curr->ref = popNonVoidExpression();
curr->finalize();
@@ -5643,7 +5644,8 @@ bool WasmBinaryBuilder::maybeVisitStructSet(Expression*& out, uint32_t code) {
return false;
}
auto* curr = allocator.alloc<StructSet>();
- auto type = getHeapType();
+ // This type annotation is unused. Beware it needing to be used in the future!
+ getHeapType();
curr->index = getU32LEB();
curr->ref = popNonVoidExpression();
curr->value = popNonVoidExpression();