summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r--src/wasm-binary.h35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index ab9ee5152..865a882df 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -347,8 +347,6 @@ enum EncodedType {
funcref = -0x10, // 0x70
// opaque host reference type
externref = -0x11, // 0x6f
- // null reference type
- nullref = -0x12, // 0x6e
// exception reference type
exnref = -0x18, // 0x68
// func_type form
@@ -357,6 +355,12 @@ enum EncodedType {
Empty = -0x40 // 0x40
};
+enum EncodedHeapType {
+ func = -0x10, // 0x70
+ extern_ = -0x11, // 0x6f
+ exn = -0x18, // 0x68
+};
+
namespace UserSections {
extern const char* Name;
extern const char* SourceMapUrl;
@@ -968,9 +972,6 @@ inline S32LEB binaryType(Type type) {
case Type::externref:
ret = BinaryConsts::EncodedType::externref;
break;
- case Type::nullref:
- ret = BinaryConsts::EncodedType::nullref;
- break;
case Type::exnref:
ret = BinaryConsts::EncodedType::exnref;
break;
@@ -980,6 +981,29 @@ inline S32LEB binaryType(Type type) {
return S32LEB(ret);
}
+inline S32LEB binaryHeapType(HeapType type) {
+ 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:
+ case HeapType::EqKind:
+ case HeapType::I31Kind:
+ case HeapType::SignatureKind:
+ case HeapType::StructKind:
+ case HeapType::ArrayKind:
+ WASM_UNREACHABLE("TODO: GC types");
+ }
+ return S32LEB(ret); // TODO: Actually encoded as s33
+}
+
// Writes out wasm to the binary format
class WasmBinaryWriter {
@@ -1209,6 +1233,7 @@ public:
int32_t getS32LEB();
int64_t getS64LEB();
Type getType();
+ HeapType getHeapType();
Type getConcreteType();
Name getInlineString();
void verifyInt8(int8_t x);