From 84daeca1d7bfa805825771611d563920f3ebf846 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 18 Jul 2024 16:43:16 -0400 Subject: [NFC] Add HeapType::isMaybeShared(BasicHeapType) utility (#6773) This abbreviates a common pattern where we first had to check whether a heap type was basic, then if it was, get its unshared version and compare it to some expected BasicHeapType. Suggested in https://github.com/WebAssembly/binaryen/pull/6771#discussion_r1683005495. --- src/wasm/wasm-binary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wasm/wasm-binary.cpp') diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 20815b701..0a65fbadb 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1521,7 +1521,7 @@ void WasmBinaryWriter::writeType(Type type) { // those more refined types. if (!wasm->features.hasGC()) { auto ht = type.getHeapType(); - if (ht.isBasic() && ht.getBasic(Unshared) == HeapType::string) { + if (ht.isMaybeShared(HeapType::string)) { // Do not overgeneralize stringref to anyref. We have tests that when a // stringref is expected, we actually get a stringref. If we see a // string, the stringref feature must be enabled. -- cgit v1.2.3