diff options
Diffstat (limited to 'src/ir')
-rw-r--r-- | src/ir/gc-type-utils.h | 13 | ||||
-rw-r--r-- | src/ir/subtypes.h | 21 |
2 files changed, 23 insertions, 11 deletions
diff --git a/src/ir/gc-type-utils.h b/src/ir/gc-type-utils.h index 7c530e179..6ac6db3ba 100644 --- a/src/ir/gc-type-utils.h +++ b/src/ir/gc-type-utils.h @@ -149,10 +149,15 @@ inline EvaluationResult evaluateCastCheck(Type refType, Type castType) { // // TODO: use in more places inline std::optional<Field> getField(HeapType type, Index index = 0) { - if (type.isStruct()) { - return type.getStruct().fields[index]; - } else if (type.isArray()) { - return type.getArray().element; + switch (type.getKind()) { + case HeapTypeKind::Struct: + return type.getStruct().fields[index]; + case HeapTypeKind::Array: + return type.getArray().element; + case HeapTypeKind::Func: + case HeapTypeKind::Cont: + case HeapTypeKind::Basic: + break; } return {}; } diff --git a/src/ir/subtypes.h b/src/ir/subtypes.h index 767c79fd7..203772055 100644 --- a/src/ir/subtypes.h +++ b/src/ir/subtypes.h @@ -125,13 +125,20 @@ struct SubTypes { for (auto type : types) { HeapType basic; auto share = type.getShared(); - if (type.isStruct()) { - basic = HeapTypes::struct_.getBasic(share); - } else if (type.isArray()) { - basic = HeapTypes::array.getBasic(share); - } else { - assert(type.isSignature()); - basic = HeapTypes::func.getBasic(share); + switch (type.getKind()) { + case HeapTypeKind::Func: + basic = HeapTypes::func.getBasic(share); + break; + case HeapTypeKind::Struct: + basic = HeapTypes::struct_.getBasic(share); + break; + case HeapTypeKind::Array: + basic = HeapTypes::array.getBasic(share); + break; + case HeapTypeKind::Cont: + WASM_UNREACHABLE("TODO: cont"); + case HeapTypeKind::Basic: + WASM_UNREACHABLE("unexpected kind"); } auto& basicDepth = depths[basic]; basicDepth = std::max(basicDepth, depths[type] + 1); |