diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-11 03:04:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 18:04:17 -0700 |
commit | 192757772adce7568fc1f3f3e733a4263b6392c6 (patch) | |
tree | 922fec8709cf9008d239a1fcbce7280e6ab46deb /src/wasm/literal.cpp | |
parent | cd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595 (diff) | |
download | binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.gz binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.bz2 binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.zip |
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).
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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"); |