@@ -46,6 +46,8 @@ class Type {
46
46
FuncRef = -0x10 , // 0x70
47
47
ExternRef = -0x11 , // 0x6f
48
48
Reference = -0x15 , // 0x6b
49
+ HeapRef = -0x1c , // 0x64
50
+ HeapNullRef = -0x1d , // 0x63
49
51
Func = -0x20 , // 0x60
50
52
Struct = -0x21 , // 0x5f
51
53
Array = -0x22 , // 0x5e
@@ -63,20 +65,24 @@ class Type {
63
65
: enum_(static_cast <Enum>(code)), type_index_(kInvalidIndex ) {}
64
66
Type (Enum e) : enum_(e), type_index_(kInvalidIndex ) {}
65
67
Type (Enum e, Index type_index) : enum_(e), type_index_(type_index) {
66
- assert (e == Enum::Reference);
68
+ assert (e == Enum::Reference || e == Enum::HeapRef ||
69
+ e == Enum::HeapNullRef || type_index == kInvalidIndex );
67
70
}
68
71
constexpr operator Enum () const { return enum_; }
69
72
70
- bool IsRef () const {
73
+ bool IsNullableRef () const {
71
74
return enum_ == Type::ExternRef || enum_ == Type::FuncRef ||
72
- enum_ == Type::Reference || enum_ == Type::ExnRef;
75
+ enum_ == Type::Reference || enum_ == Type::ExnRef ||
76
+ enum_ == Type::HeapNullRef;
73
77
}
74
78
75
- bool IsReferenceWithIndex () const { return enum_ == Type::Reference; }
79
+ bool IsRef () const {
80
+ return IsNullableRef () || enum_ == Type::HeapRef;
81
+ }
76
82
77
- bool IsNullableRef () const {
78
- // Currently all reftypes are nullable
79
- return IsRef () ;
83
+ bool IsReferenceWithIndex () const {
84
+ return enum_ == Type::Reference || enum_ == Type::HeapRef ||
85
+ enum_ == Type::HeapNullRef ;
80
86
}
81
87
82
88
std::string GetName () const {
@@ -95,7 +101,10 @@ class Type {
95
101
case Type::Any: return " any" ;
96
102
case Type::ExternRef: return " externref" ;
97
103
case Type::Reference:
104
+ case Type::HeapRef:
98
105
return StringPrintf (" (ref %d)" , type_index_);
106
+ case Type::HeapNullRef:
107
+ return StringPrintf (" (ref null %d)" , type_index_);
99
108
default :
100
109
return StringPrintf (" <type_index[%d]>" , enum_);
101
110
}
@@ -132,7 +141,7 @@ class Type {
132
141
}
133
142
134
143
Index GetReferenceIndex () const {
135
- assert (enum_ == Enum::Reference );
144
+ assert (IsReferenceWithIndex () );
136
145
return type_index_;
137
146
}
138
147
@@ -151,6 +160,8 @@ class Type {
151
160
case Type::ExnRef:
152
161
case Type::ExternRef:
153
162
case Type::Reference:
163
+ case Type::HeapRef:
164
+ case Type::HeapNullRef:
154
165
return TypeVector (this , this + 1 );
155
166
156
167
default :
0 commit comments