summaryrefslogtreecommitdiff
path: root/test/example
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2022-07-20 20:13:18 -0700
committerGitHub <noreply@github.com>2022-07-20 20:13:18 -0700
commitda5035f893ce9e046f99cf3ede92b576024aa9da (patch)
tree9db48e77502a646d74ef1a9d11f9b8f0967ff856 /test/example
parent1c53f7dd29e79bc1894959cad817b22f087689f7 (diff)
downloadbinaryen-da5035f893ce9e046f99cf3ede92b576024aa9da.tar.gz
binaryen-da5035f893ce9e046f99cf3ede92b576024aa9da.tar.bz2
binaryen-da5035f893ce9e046f99cf3ede92b576024aa9da.zip
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.
Diffstat (limited to 'test/example')
-rw-r--r--test/example/c-api-kitchen-sink.c18
-rw-r--r--test/example/c-api-kitchen-sink.txt12
-rw-r--r--test/example/stack-utils.cpp38
-rw-r--r--test/example/type-builder-nominal.cpp42
-rw-r--r--test/example/type-builder.cpp100
-rw-r--r--test/example/typeinfo.cpp10
-rw-r--r--test/example/typeinfo.txt8
7 files changed, 118 insertions, 110 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 28e784a05..90ea43e8a 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -229,37 +229,43 @@ void test_types() {
assert(valueType == v128);
BinaryenType funcref = BinaryenTypeFuncref();
- printf("BinaryenTypeFuncref: %d\n", funcref);
+ printf("BinaryenTypeFuncref: (ptr)\n", funcref);
+ assert(funcref == BinaryenTypeFuncref());
assert(BinaryenTypeArity(funcref) == 1);
BinaryenTypeExpand(funcref, &valueType);
assert(valueType == funcref);
BinaryenType externref = BinaryenTypeExternref();
- printf("BinaryenTypeExternref: %d\n", externref);
+ printf("BinaryenTypeExternref: (ptr)\n", externref);
+ assert(externref == BinaryenTypeExternref());
assert(BinaryenTypeArity(externref) == 1);
BinaryenTypeExpand(externref, &valueType);
assert(valueType == externref);
BinaryenType anyref = BinaryenTypeAnyref();
- printf("BinaryenTypeAnyref: %d\n", anyref);
+ printf("BinaryenTypeAnyref: (ptr)\n", anyref);
+ assert(anyref == BinaryenTypeAnyref());
assert(BinaryenTypeArity(anyref) == 1);
BinaryenTypeExpand(anyref, &valueType);
assert(valueType == anyref);
BinaryenType eqref = BinaryenTypeEqref();
- printf("BinaryenTypeEqref: %d\n", eqref);
+ printf("BinaryenTypeEqref: (ptr)\n", eqref);
+ assert(eqref == BinaryenTypeEqref());
assert(BinaryenTypeArity(eqref) == 1);
BinaryenTypeExpand(eqref, &valueType);
assert(valueType == eqref);
BinaryenType i31ref = BinaryenTypeI31ref();
- printf("BinaryenTypeI31ref: %d\n", i31ref);
+ printf("BinaryenTypeI31ref: (ptr)\n", i31ref);
+ assert(i31ref == BinaryenTypeI31ref());
assert(BinaryenTypeArity(i31ref) == 1);
BinaryenTypeExpand(i31ref, &valueType);
assert(valueType == i31ref);
BinaryenType dataref = BinaryenTypeDataref();
- printf("BinaryenTypeDataref: %d\n", dataref);
+ printf("BinaryenTypeDataref: (ptr)\n", dataref);
+ assert(dataref == BinaryenTypeDataref());
assert(BinaryenTypeArity(dataref) == 1);
BinaryenTypeExpand(dataref, &valueType);
assert(valueType == dataref);
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index 9f8324d48..e3a8e5676 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -5,12 +5,12 @@ BinaryenTypeInt64: 3
BinaryenTypeFloat32: 4
BinaryenTypeFloat64: 5
BinaryenTypeVec128: 6
-BinaryenTypeFuncref: 7
-BinaryenTypeExternref: 8
-BinaryenTypeAnyref: 8
-BinaryenTypeEqref: 9
-BinaryenTypeI31ref: 10
-BinaryenTypeDataref: 11
+BinaryenTypeFuncref: (ptr)
+BinaryenTypeExternref: (ptr)
+BinaryenTypeAnyref: (ptr)
+BinaryenTypeEqref: (ptr)
+BinaryenTypeI31ref: (ptr)
+BinaryenTypeDataref: (ptr)
BinaryenTypeAuto: -1
BinaryenPackedTypeNotPacked: 0
BinaryenPackedTypeInt8: 1
diff --git a/test/example/stack-utils.cpp b/test/example/stack-utils.cpp
index 8709396f9..c54040251 100644
--- a/test/example/stack-utils.cpp
+++ b/test/example/stack-utils.cpp
@@ -250,6 +250,9 @@ void test_signature_composition() {
}
void test_signature_subtype() {
+ Type funcref = Type(HeapType::func, Nullable);
+ Type anyref = Type(HeapType::any, Nullable);
+
std::cout << ";; Test stack signature subtyping\n";
// Differences in unreachability only
{
@@ -260,15 +263,15 @@ void test_signature_subtype() {
}
// Covariance of results
{
- StackSignature a(Type::none, Type::funcref, StackSignature::Fixed);
- StackSignature b(Type::none, Type::anyref, StackSignature::Fixed);
+ StackSignature a(Type::none, funcref, StackSignature::Fixed);
+ StackSignature b(Type::none, anyref, StackSignature::Fixed);
assert(StackSignature::isSubType(a, b));
assert(!StackSignature::isSubType(b, a));
}
// Contravariance of params
{
- StackSignature a(Type::anyref, Type::none, StackSignature::Fixed);
- StackSignature b(Type::funcref, Type::none, StackSignature::Fixed);
+ StackSignature a(anyref, Type::none, StackSignature::Fixed);
+ StackSignature b(funcref, Type::none, StackSignature::Fixed);
assert(StackSignature::isSubType(a, b));
assert(!StackSignature::isSubType(b, a));
}
@@ -355,6 +358,9 @@ void test_signature_subtype() {
}
void test_signature_lub() {
+ Type funcref = Type(HeapType::func, Nullable);
+ Type anyref = Type(HeapType::any, Nullable);
+
std::cout << ";; Test stack signature lub\n";
{
StackSignature a{Type::none, Type::none, StackSignature::Fixed};
@@ -392,30 +398,28 @@ void test_signature_lub() {
(StackSignature{Type::i32, Type::i32, StackSignature::Polymorphic}));
}
{
- StackSignature a{Type::none, Type::anyref, StackSignature::Polymorphic};
- StackSignature b{Type::none, Type::funcref, StackSignature::Polymorphic};
+ StackSignature a{Type::none, anyref, StackSignature::Polymorphic};
+ StackSignature b{Type::none, funcref, StackSignature::Polymorphic};
assert(StackSignature::haveLeastUpperBound(a, b));
- assert(
- StackSignature::getLeastUpperBound(a, b) ==
- (StackSignature{Type::none, Type::anyref, StackSignature::Polymorphic}));
+ assert(StackSignature::getLeastUpperBound(a, b) ==
+ (StackSignature{Type::none, anyref, StackSignature::Polymorphic}));
}
{
- StackSignature a{Type::anyref, Type::none, StackSignature::Polymorphic};
- StackSignature b{Type::funcref, Type::none, StackSignature::Polymorphic};
+ StackSignature a{anyref, Type::none, StackSignature::Polymorphic};
+ StackSignature b{funcref, Type::none, StackSignature::Polymorphic};
// assert(StackSignature::haveLeastUpperBound(a, b));
// assert(StackSignature::getLeastUpperBound(a, b) ==
- // (StackSignature{Type::funcref, Type::none,
+ // (StackSignature{funcref, Type::none,
// StackSignature::Polymorphic}));
}
{
StackSignature a{
- {Type::i32, Type::funcref}, Type::funcref, StackSignature::Polymorphic};
- StackSignature b{
- Type::funcref, {Type::f32, Type::anyref}, StackSignature::Polymorphic};
+ {Type::i32, funcref}, funcref, StackSignature::Polymorphic};
+ StackSignature b{funcref, {Type::f32, anyref}, StackSignature::Polymorphic};
assert(StackSignature::haveLeastUpperBound(a, b));
assert(StackSignature::getLeastUpperBound(a, b) ==
- (StackSignature{{Type::i32, Type::funcref},
- {Type::f32, Type::anyref},
+ (StackSignature{{Type::i32, funcref},
+ {Type::f32, anyref},
StackSignature::Polymorphic}));
}
// No LUB
diff --git a/test/example/type-builder-nominal.cpp b/test/example/type-builder-nominal.cpp
index 8dbbfcf30..cbda43f1f 100644
--- a/test/example/type-builder-nominal.cpp
+++ b/test/example/type-builder-nominal.cpp
@@ -123,21 +123,24 @@ void test_canonicalization() {
void test_basic() {
std::cout << ";; Test basic\n";
+ Type canonAnyref = Type(HeapType::any, Nullable);
+ Type canonI31ref = Type(HeapType::i31, NonNullable);
+
TypeBuilder builder(6);
Type anyref = builder.getTempRefType(builder[4], Nullable);
Type i31ref = builder.getTempRefType(builder[5], NonNullable);
- builder[0] = Signature(Type::anyref, Type::i31ref);
- builder[1] = Signature(anyref, Type::i31ref);
- builder[2] = Signature(Type::anyref, i31ref);
+ builder[0] = Signature(canonAnyref, canonI31ref);
+ builder[1] = Signature(anyref, canonI31ref);
+ builder[2] = Signature(canonAnyref, i31ref);
builder[3] = Signature(anyref, i31ref);
builder[4] = HeapType::any;
builder[5] = HeapType::i31;
std::vector<HeapType> built = *builder.build();
- assert(built[0].getSignature() == Signature(Type::anyref, Type::i31ref));
+ assert(built[0].getSignature() == Signature(canonAnyref, canonI31ref));
assert(built[1].getSignature() == built[0].getSignature());
assert(built[2].getSignature() == built[1].getSignature());
assert(built[3].getSignature() == built[2].getSignature());
@@ -150,16 +153,18 @@ void test_basic() {
void test_signatures(bool warm) {
std::cout << ";; Test canonical signatures\n";
+ Type canonAnyref = Type(HeapType::any, Nullable);
+ Type canonI31ref = Type(HeapType::i31, NonNullable);
+
TypeBuilder builder(2);
Type tempRef = builder.getTempRefType(builder[0], Nullable);
- builder[0] = Signature(Type::i31ref, Type::anyref);
+ builder[0] = Signature(canonI31ref, canonAnyref);
builder[1] = Signature(tempRef, tempRef);
std::vector<HeapType> built = *builder.build();
- HeapType small = Signature(Type::i31ref, Type::anyref);
- HeapType big =
- Signature(Type(Signature(Type::i31ref, Type::anyref), Nullable),
- Type(Signature(Type::i31ref, Type::anyref), Nullable));
+ HeapType small = Signature(canonI31ref, canonAnyref);
+ HeapType big = Signature(Type(Signature(canonI31ref, canonAnyref), Nullable),
+ Type(Signature(canonI31ref, canonAnyref), Nullable));
if (warm) {
assert(built[0] != small);
assert(built[1] != big);
@@ -306,6 +311,9 @@ void test_recursive() {
void test_subtypes() {
std::cout << ";; Test subtyping\n";
+ Type anyref = Type(HeapType::any, Nullable);
+ Type funcref = Type(HeapType::func, Nullable);
+
auto LUB = [&](HeapType a, HeapType b) {
Type refA = Type(a, Nullable);
Type refB = Type(b, Nullable);
@@ -362,7 +370,7 @@ void test_subtypes() {
Type structRef1 = builder.getTempRefType(builder[1], Nullable);
builder[0] = Struct{};
builder[1] = Struct{};
- builder[2] = Signature(Type::none, Type::anyref);
+ builder[2] = Signature(Type::none, anyref);
builder[3] = Signature(Type::none, structRef0);
builder[4] = Signature(Type::none, structRef1);
built = *builder.build();
@@ -394,12 +402,10 @@ void test_subtypes() {
builder[0].subTypeOf(builder[1]);
builder[2].subTypeOf(builder[3]);
builder[4].subTypeOf(builder[5]);
- builder[0] =
- Struct({Field(Type::i32, Mutable), Field(Type::anyref, Mutable)});
- builder[1] =
- Struct({Field(Type::i32, Mutable), Field(Type::anyref, Mutable)});
- builder[2] = Signature(Type::i32, Type::anyref);
- builder[3] = Signature(Type::i32, Type::anyref);
+ builder[0] = Struct({Field(Type::i32, Mutable), Field(anyref, Mutable)});
+ builder[1] = Struct({Field(Type::i32, Mutable), Field(anyref, Mutable)});
+ builder[2] = Signature(Type::i32, anyref);
+ builder[3] = Signature(Type::i32, anyref);
builder[4] = Array(Field(Type::i32, Mutable));
builder[5] = Array(Field(Type::i32, Mutable));
built = *builder.build();
@@ -428,8 +434,8 @@ void test_subtypes() {
std::vector<HeapType> built;
{
TypeBuilder builder(2);
- builder[0] = Struct({Field(Type::anyref, Immutable)});
- builder[1] = Struct({Field(Type::funcref, Immutable)});
+ builder[0] = Struct({Field(anyref, Immutable)});
+ builder[1] = Struct({Field(funcref, Immutable)});
builder[1].subTypeOf(builder[0]);
built = *builder.build();
}
diff --git a/test/example/type-builder.cpp b/test/example/type-builder.cpp
index ce7b74841..219282ea8 100644
--- a/test/example/type-builder.cpp
+++ b/test/example/type-builder.cpp
@@ -44,21 +44,24 @@ void test_canonicalization() {
void test_basic() {
std::cout << ";; Test basic\n";
+ Type canonAnyref = Type(HeapType::any, Nullable);
+ Type canonI31ref = Type(HeapType::i31, NonNullable);
+
TypeBuilder builder(6);
Type anyref = builder.getTempRefType(builder[4], Nullable);
Type i31ref = builder.getTempRefType(builder[5], NonNullable);
- builder[0] = Signature(Type::anyref, Type::i31ref);
- builder[1] = Signature(anyref, Type::i31ref);
- builder[2] = Signature(Type::anyref, i31ref);
+ builder[0] = Signature(canonAnyref, canonI31ref);
+ builder[1] = Signature(anyref, canonI31ref);
+ builder[2] = Signature(canonAnyref, i31ref);
builder[3] = Signature(anyref, i31ref);
builder[4] = HeapType::any;
builder[5] = HeapType::i31;
std::vector<HeapType> built = *builder.build();
- assert(built[0] == Signature(Type::anyref, Type::i31ref));
+ assert(built[0] == Signature(canonAnyref, canonI31ref));
assert(built[1] == built[0]);
assert(built[2] == built[1]);
assert(built[3] == built[2]);
@@ -210,8 +213,8 @@ void test_recursive() {
std::cout << print(built[1]) << "\n\n";
assert(built[0].getSignature().results.getHeapType() == built[0]);
assert(built[1].getSignature().results.getHeapType() == built[0]);
- assert(built[0].getSignature().params == Type::anyref);
- assert(built[1].getSignature().params == Type::anyref);
+ assert(built[0].getSignature().params == Type(HeapType::any, Nullable));
+ assert(built[1].getSignature().params == Type(HeapType::any, Nullable));
assert(built[0] == built[1]);
assert(built[2] == HeapType::any);
}
@@ -220,6 +223,12 @@ void test_recursive() {
void test_lub() {
std::cout << ";; Test LUBs\n";
+ Type func = Type(HeapType::func, Nullable);
+ Type any = Type(HeapType::any, Nullable);
+ Type eq = Type(HeapType::eq, Nullable);
+ Type i31 = Type(HeapType::i31, Nullable);
+ Type data = Type(HeapType::data, Nullable);
+
auto LUB = [&](Type a, Type b) {
Type lubAB = Type::getLeastUpperBound(a, b);
Type lubBA = Type::getLeastUpperBound(b, a);
@@ -238,15 +247,11 @@ void test_lub() {
{
// Basic Types
- for (auto other : {Type::funcref,
- Type::anyref,
- Type::eqref,
- Type::i31ref,
- Type::dataref}) {
- assert(LUB(Type::anyref, other) == Type::anyref);
+ for (auto other : {func, any, eq, i31, data}) {
+ assert(LUB(any, other) == any);
}
- assert(LUB(Type::eqref, Type::funcref) == Type::anyref);
- assert(LUB(Type::i31ref, Type::dataref) == Type(HeapType::eq, NonNullable));
+ assert(LUB(eq, func) == any);
+ assert(LUB(i31, data) == eq);
}
{
@@ -260,22 +265,21 @@ void test_lub() {
{
// Funcref with specific signature
- assert(LUB(Type::funcref, Type(Signature(), Nullable)) == Type::funcref);
+ assert(LUB(func, Type(Signature(), Nullable)) == func);
}
{
// Incompatible signatures
- Type a(Signature(Type::none, Type::anyref), Nullable);
- Type b(Signature(Type::anyref, Type::none), Nullable);
- assert(LUB(a, b) == Type::funcref);
+ Type a(Signature(Type::none, any), Nullable);
+ Type b(Signature(any, Type::none), Nullable);
+ assert(LUB(a, b) == Type(HeapType::func, Nullable));
}
{
// Signatures incompatible in tuple size
- Type a(Signature(Type::none, {Type::anyref, Type::anyref}), Nullable);
- Type b(Signature(Type::none, {Type::anyref, Type::anyref, Type::anyref}),
- Nullable);
- assert(LUB(a, b) == Type::funcref);
+ Type a(Signature(Type::none, {any, any}), Nullable);
+ Type b(Signature(Type::none, {any, any, any}), Nullable);
+ assert(LUB(a, b) == Type(HeapType::func, Nullable));
}
// {
@@ -303,24 +307,24 @@ void test_lub() {
{
// Mutable fields are invariant
- Type a(Array(Field(Type::eqref, Mutable)), Nullable);
- Type b(Array(Field(Type::funcref, Mutable)), Nullable);
- assert(LUB(a, b) == Type(HeapType::data, Nullable));
+ Type a(Array(Field(eq, Mutable)), Nullable);
+ Type b(Array(Field(func, Mutable)), Nullable);
+ assert(LUB(a, b) == data);
}
{
// Immutable fields are covariant
- Type a(Array(Field(Type::eqref, Immutable)), Nullable);
- Type b(Array(Field(Type::funcref, Immutable)), Nullable);
- Type lub(Array(Field(Type::anyref, Immutable)), Nullable);
+ Type a(Array(Field(eq, Immutable)), Nullable);
+ Type b(Array(Field(func, Immutable)), Nullable);
+ Type lub(Array(Field(any, Immutable)), Nullable);
assert(LUB(a, b) == lub);
}
{
// Depth subtyping
- Type a(Struct({Field(Type::eqref, Immutable)}), Nullable);
- Type b(Struct({Field(Type::funcref, Immutable)}), Nullable);
- Type lub(Struct({Field(Type::anyref, Immutable)}), Nullable);
+ Type a(Struct({Field(eq, Immutable)}), Nullable);
+ Type b(Struct({Field(func, Immutable)}), Nullable);
+ Type lub(Struct({Field(any, Immutable)}), Nullable);
assert(LUB(a, b) == lub);
}
@@ -344,32 +348,29 @@ void test_lub() {
{
// Width and depth subtyping with different suffixes
- Type a(Struct({Field(Type::eqref, Immutable), Field(Type::i64, Immutable)}),
+ Type a(Struct({Field(eq, Immutable), Field(Type::i64, Immutable)}),
Nullable);
- Type b(
- Struct({Field(Type::funcref, Immutable), Field(Type::f32, Immutable)}),
- Nullable);
- Type lub(Struct({Field(Type::anyref, Immutable)}), Nullable);
+ Type b(Struct({Field(func, Immutable), Field(Type::f32, Immutable)}),
+ Nullable);
+ Type lub(Struct({Field(any, Immutable)}), Nullable);
assert(LUB(a, b) == lub);
}
{
// No common prefix
- Type a(
- Struct({Field(Type::i32, Immutable), Field(Type::anyref, Immutable)}),
- Nullable);
- Type b(
- Struct({Field(Type::f32, Immutable), Field(Type::anyref, Immutable)}),
- Nullable);
+ Type a(Struct({Field(Type::i32, Immutable), Field(any, Immutable)}),
+ Nullable);
+ Type b(Struct({Field(Type::f32, Immutable), Field(any, Immutable)}),
+ Nullable);
Type lub(Struct(), Nullable);
assert(LUB(a, b) == lub);
}
{
// Nested structs
- Type innerA(Struct({Field(Type::eqref, Immutable)}), Nullable);
- Type innerB(Struct({Field(Type::funcref, Immutable)}), Nullable);
- Type innerLub(Struct({Field(Type::anyref, Immutable)}), Nullable);
+ Type innerA(Struct({Field(eq, Immutable)}), Nullable);
+ Type innerB(Struct({Field(func, Immutable)}), Nullable);
+ Type innerLub(Struct({Field(any, Immutable)}), Nullable);
Type a(Struct({Field(innerA, Immutable)}), Nullable);
Type b(Struct({Field(innerB, Immutable)}), Nullable);
Type lub(Struct({Field(innerLub, Immutable)}), Nullable);
@@ -381,18 +382,15 @@ void test_lub() {
TypeBuilder builder(2);
Type tempA = builder.getTempRefType(builder[0], Nullable);
Type tempB = builder.getTempRefType(builder[1], Nullable);
- builder[0] =
- Struct({Field(tempB, Immutable), Field(Type::eqref, Immutable)});
- builder[1] =
- Struct({Field(tempA, Immutable), Field(Type::funcref, Immutable)});
+ builder[0] = Struct({Field(tempB, Immutable), Field(eq, Immutable)});
+ builder[1] = Struct({Field(tempA, Immutable), Field(func, Immutable)});
auto built = *builder.build();
Type a(built[0], Nullable);
Type b(built[1], Nullable);
TypeBuilder lubBuilder(1);
Type tempLub = builder.getTempRefType(lubBuilder[0], Nullable);
- lubBuilder[0] =
- Struct({Field(tempLub, Immutable), Field(Type::anyref, Immutable)});
+ lubBuilder[0] = Struct({Field(tempLub, Immutable), Field(any, Immutable)});
built = *lubBuilder.build();
Type lub(built[0], Nullable);
diff --git a/test/example/typeinfo.cpp b/test/example/typeinfo.cpp
index ed5637bd9..55e7b9082 100644
--- a/test/example/typeinfo.cpp
+++ b/test/example/typeinfo.cpp
@@ -8,7 +8,6 @@ using namespace wasm;
void test_compound() {
{
HeapType func(HeapType::func);
- assert(Type(func, Nullable).getID() == Type::funcref);
assert(Type(func, NonNullable).getID() == Type(func, NonNullable).getID());
assert(Type(func, NonNullable).getID() != Type(func, Nullable).getID());
HeapType sameFunc(HeapType::func);
@@ -16,7 +15,6 @@ void test_compound() {
Type(sameFunc, NonNullable).getID());
HeapType any(HeapType::any);
- assert(Type(any, Nullable).getID() == Type::anyref);
assert(Type(any, NonNullable).getID() == Type(any, NonNullable).getID());
assert(Type(any, NonNullable).getID() != Type(any, Nullable).getID());
HeapType sameAny(HeapType::any);
@@ -24,14 +22,12 @@ void test_compound() {
Type(sameAny, NonNullable).getID());
HeapType eq(HeapType::eq);
- // assert(Type(eq, Nullable).getID() == Type::eqref);
assert(Type(eq, NonNullable).getID() == Type(eq, NonNullable).getID());
assert(Type(eq, NonNullable).getID() != Type(eq, Nullable).getID());
HeapType sameEq(HeapType::eq);
assert(Type(eq, NonNullable).getID() == Type(sameEq, NonNullable).getID());
HeapType i31(HeapType::i31);
- // assert(Type(i31, NonNullable).getID() == Type::i31ref);
assert(Type(i31, NonNullable).getID() == Type(i31, NonNullable).getID());
assert(Type(i31, NonNullable).getID() != Type(i31, Nullable).getID());
HeapType sameI31(HeapType::i31);
@@ -92,7 +88,7 @@ void test_compound() {
Tuple sameTuple({Type::i32, Type::f64});
assert(Type(tuple).getID() == Type(sameTuple).getID());
- Tuple otherTuple({Type::f64, Type::anyref});
+ Tuple otherTuple({Type::f64, Type::i64});
assert(Type(tuple).getID() != Type(otherTuple).getID());
}
{
@@ -165,7 +161,6 @@ void test_printing() {
{Type::i64, Immutable},
{Type::f32, Mutable},
{Type::f64, Mutable},
- {Type::anyref, Immutable},
});
std::cout << struct_ << "\n";
std::cout << Type(struct_, NonNullable) << "\n";
@@ -177,7 +172,7 @@ void test_printing() {
std::cout << array << "\n";
std::cout << Type(array, NonNullable) << "\n";
std::cout << Type(array, Nullable) << "\n";
- Array arrayMut({Type::anyref, Mutable});
+ Array arrayMut({Type::i64, Mutable});
std::cout << arrayMut << "\n";
std::cout << Type(arrayMut, NonNullable) << "\n";
std::cout << Type(arrayMut, Nullable) << "\n";
@@ -190,7 +185,6 @@ void test_printing() {
Tuple tuple({
Type::i32,
Type::f64,
- Type::anyref,
});
std::cout << tuple << "\n";
std::cout << Type(tuple) << "\n";
diff --git a/test/example/typeinfo.txt b/test/example/typeinfo.txt
index 924fcb3ec..838fd34a3 100644
--- a/test/example/typeinfo.txt
+++ b/test/example/typeinfo.txt
@@ -27,7 +27,7 @@ i31ref
(struct)
(ref $struct.0)
(ref null $struct.0)
-(struct (field i32 i64 (mut f32) (mut f64) anyref))
+(struct (field i32 i64 (mut f32) (mut f64)))
(ref $struct.0)
(ref null $struct.0)
@@ -35,15 +35,15 @@ i31ref
(array i32)
(ref $array.0)
(ref null $array.0)
-(array (mut anyref))
+(array (mut i64))
(ref $array.0)
(ref null $array.0)
;; Tuple
()
none
-(i32 f64 anyref)
-(i32 f64 anyref)
+(i32 f64)
+(i32 f64)
;; Rtt
(rtt 0 func)