@@ -297,6 +297,20 @@ 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 format allows more subtypes, although
308
+ // the validator limits the list to maximum 1 value.
309
+ // Furthermore the text parser must allow future
310
+ // references although the validator also disallows this.
311
+ std::vector<Var> sub_types;
312
+ };
313
+
300
314
class TypeEntry {
301
315
public:
302
316
WABT_DISALLOW_COPY_AND_ASSIGN (TypeEntry);
@@ -307,12 +321,17 @@ class TypeEntry {
307
321
308
322
Location loc;
309
323
std::string name;
324
+ TypeEntryGCTypeExtension gc_ext;
310
325
311
326
protected:
312
327
explicit TypeEntry (TypeEntryKind kind,
328
+ bool is_final_sub_type,
313
329
std::string_view name = std::string_view(),
314
330
const Location& loc = Location())
315
- : loc(loc), name(name), kind_(kind) {}
331
+ : loc(loc),
332
+ name(name),
333
+ gc_ext(is_final_sub_type),
334
+ kind_(kind) {}
316
335
317
336
TypeEntryKind kind_;
318
337
};
@@ -323,8 +342,8 @@ class FuncType : public TypeEntry {
323
342
return entry->kind () == TypeEntryKind::Func;
324
343
}
325
344
326
- explicit FuncType (std::string_view name = std::string_view())
327
- : TypeEntry(TypeEntryKind::Func, name) {}
345
+ explicit FuncType (bool is_final_sub_type, std::string_view name = std::string_view())
346
+ : TypeEntry(TypeEntryKind::Func, is_final_sub_type, name) {}
328
347
329
348
Index GetNumParams () const { return sig.GetNumParams (); }
330
349
Index GetNumResults () const { return sig.GetNumResults (); }
@@ -353,8 +372,8 @@ class StructType : public TypeEntry {
353
372
return entry->kind () == TypeEntryKind::Struct;
354
373
}
355
374
356
- explicit StructType (std::string_view name = std::string_view())
357
- : TypeEntry(TypeEntryKind::Struct) {}
375
+ explicit StructType (bool is_final_sub_type, std::string_view name = std::string_view())
376
+ : TypeEntry(TypeEntryKind::Struct, is_final_sub_type, name ) {}
358
377
359
378
std::vector<Field> fields;
360
379
};
@@ -365,12 +384,17 @@ class ArrayType : public TypeEntry {
365
384
return entry->kind () == TypeEntryKind::Array;
366
385
}
367
386
368
- explicit ArrayType (std::string_view name = std::string_view())
369
- : TypeEntry(TypeEntryKind::Array) {}
387
+ explicit ArrayType (bool is_final_sub_type, std::string_view name = std::string_view())
388
+ : TypeEntry(TypeEntryKind::Array, is_final_sub_type, name ) {}
370
389
371
390
Field field;
372
391
};
373
392
393
+ struct RecursiveRange {
394
+ Index start_index;
395
+ Index type_count;
396
+ };
397
+
374
398
struct FuncDeclaration {
375
399
Index GetNumParams () const { return sig.GetNumParams (); }
376
400
Index GetNumResults () const { return sig.GetNumResults (); }
@@ -1319,6 +1343,8 @@ struct Module {
1319
1343
std::vector<Import*> imports;
1320
1344
std::vector<Export*> exports;
1321
1345
std::vector<TypeEntry*> types;
1346
+ // Ordered list of recursive ranges. Needed for binary search.
1347
+ std::vector<RecursiveRange> recursive_ranges;
1322
1348
std::vector<Table*> tables;
1323
1349
std::vector<ElemSegment*> elem_segments;
1324
1350
std::vector<Memory*> memories;
0 commit comments