From da5035f893ce9e046f99cf3ede92b576024aa9da Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Wed, 20 Jul 2022 20:13:18 -0700 Subject: Remove basic reference types (#4802) Basic reference types like `Type::funcref`, `Type::anyref`, etc. made it easy to accidentally forget to handle reference types with the same basic HeapTypes but the opposite nullability. In principle there is nothing special about the types with shorthands except in the binary and text formats. Removing these shorthands from the internal type representation by removing all basic reference types makes some code more complicated locally, but simplifies code globally and encourages properly handling both nullable and non-nullable reference types. --- test/gtest/possible-contents.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test/gtest/possible-contents.cpp') diff --git a/test/gtest/possible-contents.cpp b/test/gtest/possible-contents.cpp index 2994a6221..2bed9a882 100644 --- a/test/gtest/possible-contents.cpp +++ b/test/gtest/possible-contents.cpp @@ -59,6 +59,9 @@ protected: wasm::setTypeSystem(TypeSystem::Nominal); } + Type anyref = Type(HeapType::any, Nullable); + Type funcref = Type(HeapType::func, Nullable); + PossibleContents none = PossibleContents::none(); PossibleContents i32Zero = PossibleContents::literal(Literal(int32_t(0))); @@ -74,15 +77,14 @@ protected: PossibleContents i32Global2 = PossibleContents::global("i32Global2", Type::i32); PossibleContents f64Global = PossibleContents::global("f64Global", Type::f64); - PossibleContents anyGlobal = - PossibleContents::global("anyGlobal", Type::anyref); + PossibleContents anyGlobal = PossibleContents::global("anyGlobal", anyref); PossibleContents nonNullFunc = PossibleContents::literal( Literal("func", Type(Signature(Type::none, Type::none), NonNullable))); PossibleContents exactI32 = PossibleContents::exactType(Type::i32); - PossibleContents exactAnyref = PossibleContents::exactType(Type::anyref); - PossibleContents exactFuncref = PossibleContents::exactType(Type::funcref); + PossibleContents exactAnyref = PossibleContents::exactType(anyref); + PossibleContents exactFuncref = PossibleContents::exactType(funcref); PossibleContents exactNonNullAnyref = PossibleContents::exactType(Type(HeapType::any, NonNullable)); PossibleContents exactNonNullFuncref = -- cgit v1.2.3