diff options
author | Thomas Lively <tlively@google.com> | 2024-06-14 14:46:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-14 14:46:47 -0700 |
commit | 027128dccf76692ca4e000c6dbb489b348b12c73 (patch) | |
tree | 00cbc09eccc2248e1939fa7d9d09c13d8ca769f8 /src/wasm-type.h | |
parent | 0fa99fb09b881985cf94e74b8c0b339bdef61be6 (diff) | |
download | binaryen-027128dccf76692ca4e000c6dbb489b348b12c73.tar.gz binaryen-027128dccf76692ca4e000c6dbb489b348b12c73.tar.bz2 binaryen-027128dccf76692ca4e000c6dbb489b348b12c73.zip |
[NFC] Add constexpr HeapTypes for basic heap types (#6662)
Since the BasicHeapTypes are in an enum, calling HeapType methods on them
requires something like `HeapType(HeapType::func).someMethod()`. This is
unnecessarily verbose, so add a new `HeapTypes` namespace that contains
constexpr HeapType globals that can be used instead, shorting this to
`HeapTypes::func.someMethod()`.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r-- | src/wasm-type.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index 3e9fa4db3..2a74e4a60 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -458,6 +458,26 @@ public: inline bool Type::isNull() const { return isRef() && getHeapType().isBottom(); } +namespace HeapTypes { + +constexpr HeapType ext = HeapType::ext; +constexpr HeapType func = HeapType::func; +constexpr HeapType cont = HeapType::cont; +constexpr HeapType any = HeapType::any; +constexpr HeapType eq = HeapType::eq; +constexpr HeapType i31 = HeapType::i31; +constexpr HeapType struct_ = HeapType::struct_; +constexpr HeapType array = HeapType::array; +constexpr HeapType exn = HeapType::exn; +constexpr HeapType string = HeapType::string; +constexpr HeapType none = HeapType::none; +constexpr HeapType noext = HeapType::noext; +constexpr HeapType nofunc = HeapType::nofunc; +constexpr HeapType nocont = HeapType::nocont; +constexpr HeapType noexn = HeapType::noexn; + +} // namespace HeapTypes + // A recursion group consisting of one or more HeapTypes. HeapTypes with single // members are encoded without using any additional memory, which is why // `getHeapTypes` has to return a vector by value; it might have to create one |