From bae0da03af8f4f240d659d016b6e4ee998551059 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 6 Aug 2024 13:22:38 -0400 Subject: [NFC] Add HeapType::getKind returning a new HeapTypeKind enum (#6804) The HeapType API has functions like `isBasic()`, `isStruct()`, `isSignature()`, etc. to test the classification of a heap type. Many users have to call these functions in sequence and handle all or most of the possible classifications. When we add a new kind of heap type, finding and updating all these sites is a manual and error-prone process. To make adding new heap type kinds easier, introduce a new API that returns an enum classifying the heap type. The enum can be used in switch statements and the compiler's exhaustiveness checker will flag use sites that need to be updated when we add a new kind of heap type. This commit uses the new enum internally in the type system, but follow-on commits will add new uses and convert uses of the existing APIs to use `getKind` instead. --- src/wasm/literal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wasm/literal.cpp') diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index f2100ea71..3dcf9e350 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -439,7 +439,7 @@ bool Literal::operator==(const Literal& other) const { assert(func.is() && other.func.is()); return func == other.func; } - if (type.isString()) { + if (type.getHeapType().isMaybeShared(HeapType::string)) { return gcData->values == other.gcData->values; } if (type.isData()) { -- cgit v1.2.3