@@ -297,6 +297,19 @@ enum class TypeEntryKind {
297
297
Array,
298
298
};
299
299
300
+ struct TypeEntryGCTypeExtension {
301
+ TypeEntryGCTypeExtension (bool is_final_sub_type)
302
+ : is_final_sub_type(is_final_sub_type) {}
303
+
304
+ void InitSubTypes (Index* sub_type_list, Index sub_type_count);
305
+
306
+ bool is_final_sub_type;
307
+ // The binary/text format allows any number of subtypes,
308
+ // so parsers must handle them. The validator rejects
309
+ // lists which size is greater than 1.
310
+ VarVector sub_types;
311
+ };
312
+
300
313
class TypeEntry {
301
314
public:
302
315
WABT_DISALLOW_COPY_AND_ASSIGN (TypeEntry);
@@ -307,12 +320,17 @@ class TypeEntry {
307
320
308
321
Location loc;
309
322
std::string name;
323
+ TypeEntryGCTypeExtension gc_ext;
310
324
311
325
protected:
312
326
explicit TypeEntry (TypeEntryKind kind,
327
+ bool is_final_sub_type,
313
328
std::string_view name = std::string_view(),
314
329
const Location& loc = Location())
315
- : loc(loc), name(name), kind_(kind) {}
330
+ : loc(loc),
331
+ name(name),
332
+ gc_ext(is_final_sub_type),
333
+ kind_(kind) {}
316
334
317
335
TypeEntryKind kind_;
318
336
};
@@ -323,8 +341,8 @@ class FuncType : public TypeEntry {
323
341
return entry->kind () == TypeEntryKind::Func;
324
342
}
325
343
326
- explicit FuncType (std::string_view name = std::string_view())
327
- : TypeEntry(TypeEntryKind::Func, name) {}
344
+ explicit FuncType (bool is_final_sub_type, std::string_view name = std::string_view())
345
+ : TypeEntry(TypeEntryKind::Func, is_final_sub_type, name) {}
328
346
329
347
Index GetNumParams () const { return sig.GetNumParams (); }
330
348
Index GetNumResults () const { return sig.GetNumResults (); }
@@ -353,8 +371,8 @@ class StructType : public TypeEntry {
353
371
return entry->kind () == TypeEntryKind::Struct;
354
372
}
355
373
356
- explicit StructType (std::string_view name = std::string_view())
357
- : TypeEntry(TypeEntryKind::Struct) {}
374
+ explicit StructType (bool is_final_sub_type, std::string_view name = std::string_view())
375
+ : TypeEntry(TypeEntryKind::Struct, is_final_sub_type, name ) {}
358
376
359
377
std::vector<Field> fields;
360
378
};
@@ -365,12 +383,19 @@ class ArrayType : public TypeEntry {
365
383
return entry->kind () == TypeEntryKind::Array;
366
384
}
367
385
368
- explicit ArrayType (std::string_view name = std::string_view())
369
- : TypeEntry(TypeEntryKind::Array) {}
386
+ explicit ArrayType (bool is_final_sub_type, std::string_view name = std::string_view())
387
+ : TypeEntry(TypeEntryKind::Array, is_final_sub_type, name ) {}
370
388
371
389
Field field;
372
390
};
373
391
392
+ struct RecursiveRange {
393
+ Index first_type_index;
394
+ Index type_count;
395
+
396
+ Index EndTypeIndex () const { return first_type_index + type_count; }
397
+ };
398
+
374
399
struct FuncDeclaration {
375
400
Index GetNumParams () const { return sig.GetNumParams (); }
376
401
Index GetNumResults () const { return sig.GetNumResults (); }
@@ -1107,7 +1132,8 @@ enum class ModuleFieldType {
1107
1132
Memory,
1108
1133
DataSegment,
1109
1134
Start,
1110
- Tag
1135
+ Tag,
1136
+ EmptyRec
1111
1137
};
1112
1138
1113
1139
class ModuleField : public intrusive_list_base <ModuleField> {
@@ -1234,6 +1260,12 @@ class TagModuleField : public ModuleFieldMixin<ModuleFieldType::Tag> {
1234
1260
Tag tag;
1235
1261
};
1236
1262
1263
+ class EmptyRecModuleField : public ModuleFieldMixin <ModuleFieldType::EmptyRec> {
1264
+ public:
1265
+ explicit EmptyRecModuleField (const Location& loc = Location())
1266
+ : ModuleFieldMixin<ModuleFieldType::EmptyRec>(loc) {}
1267
+ };
1268
+
1237
1269
class StartModuleField : public ModuleFieldMixin <ModuleFieldType::Start> {
1238
1270
public:
1239
1271
explicit StartModuleField (Var start = Var(), const Location& loc = Location())
@@ -1293,6 +1325,7 @@ struct Module {
1293
1325
void AppendField (std::unique_ptr<ExportModuleField>);
1294
1326
void AppendField (std::unique_ptr<FuncModuleField>);
1295
1327
void AppendField (std::unique_ptr<TypeModuleField>);
1328
+ void AppendField (std::unique_ptr<EmptyRecModuleField>);
1296
1329
void AppendField (std::unique_ptr<GlobalModuleField>);
1297
1330
void AppendField (std::unique_ptr<ImportModuleField>);
1298
1331
void AppendField (std::unique_ptr<MemoryModuleField>);
@@ -1319,6 +1352,8 @@ struct Module {
1319
1352
std::vector<Import*> imports;
1320
1353
std::vector<Export*> exports;
1321
1354
std::vector<TypeEntry*> types;
1355
+ // Ordered list of recursive ranges.
1356
+ std::vector<RecursiveRange> recursive_ranges;
1322
1357
std::vector<Table*> tables;
1323
1358
std::vector<ElemSegment*> elem_segments;
1324
1359
std::vector<Memory*> memories;
0 commit comments