From 192757772adce7568fc1f3f3e733a4263b6392c6 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Fri, 11 Sep 2020 03:04:17 +0200 Subject: Add anyref feature and type (#3109) Adds `anyref` type, which is enabled by a new feature `--enable-anyref`. This type is primarily used for testing that passes correctly handle subtype relationships so that the codebase will continue to be prepared for future subtyping. Since `--enable-anyref` is meaningless without also using `--enable-reference-types`, this PR also makes it a validation error to pass only the former (and similarly makes it a validation error to enable exception handling without enabling reference types). --- src/wasm/literal.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/wasm/literal.cpp') diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index ffb98abe4..39a4cea3c 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -69,6 +69,7 @@ Literal::Literal(const Literal& other) : type(other.type) { case Type::none: break; case Type::externref: + case Type::anyref: break; // null case Type::funcref: case Type::exnref: @@ -221,6 +222,7 @@ void Literal::getBits(uint8_t (&buf)[16]) const { break; case Type::externref: case Type::exnref: + case Type::anyref: if (isNull()) { break; } @@ -384,6 +386,10 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { o << "exnref(" << literal.getExceptionPackage() << ")"; } break; + case Type::anyref: + assert(literal.isNull() && "TODO: non-null anyref values"); + o << "anyref(null)"; + break; case Type::externref: assert(literal.isNull() && "TODO: non-null externref values"); o << "externref(null)"; @@ -612,6 +618,7 @@ Literal Literal::eqz() const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -633,6 +640,7 @@ Literal Literal::neg() const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -654,6 +662,7 @@ Literal Literal::abs() const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -758,6 +767,7 @@ Literal Literal::add(const Literal& other) const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -779,6 +789,7 @@ Literal Literal::sub(const Literal& other) const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -896,6 +907,7 @@ Literal Literal::mul(const Literal& other) const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -1141,6 +1153,7 @@ Literal Literal::eq(const Literal& other) const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -1162,6 +1175,7 @@ Literal Literal::ne(const Literal& other) const { case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); -- cgit v1.2.3