diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-09 03:40:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 03:40:09 +0200 |
commit | 916ce6f1a9f7c85102a8c69f593b301c8df5d19d (patch) | |
tree | 93b22be9f2c0718248528d140b05221cb6878600 /src/wasm-builder.h | |
parent | 0fdcf5b51a0c8c379b2d3ad8262aa22bb234f0e9 (diff) | |
download | binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.tar.gz binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.tar.bz2 binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.zip |
Update reference types (#3084)
Align with the current state of the reference types proposal:
* Remove `nullref`
* Remove `externref` and `funcref` subtyping
* A `Literal` of a nullable reference type can now represent `null` (previously was type `nullref`)
* Update the tests and temporarily comment out those tests relying on subtyping
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r-- | src/wasm-builder.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 4e94da090..1ce3a507c 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -528,9 +528,9 @@ public: ret->finalize(); return ret; } - RefNull* makeRefNull() { + RefNull* makeRefNull(Type type) { auto* ret = allocator.alloc<RefNull>(); - ret->finalize(); + ret->finalize(type); return ret; } RefIsNull* makeRefIsNull(Expression* value) { @@ -624,13 +624,15 @@ public: Expression* makeConstantExpression(Literal value) { TODO_SINGLE_COMPOUND(value.type); switch (value.type.getBasic()) { - case Type::nullref: - return makeRefNull(); case Type::funcref: - if (value.getFunc()[0] != 0) { + if (!value.isNull()) { return makeRefFunc(value.getFunc()); } - return makeRefNull(); + return makeRefNull(value.type); + case Type::externref: + case Type::exnref: // TODO: ExceptionPackage? + assert(value.isNull()); + return makeRefNull(value.type); default: assert(value.type.isNumber()); return makeConst(value); @@ -822,9 +824,8 @@ public: } case Type::funcref: case Type::externref: - case Type::nullref: case Type::exnref: - return ExpressionManipulator::refNull(curr); + return ExpressionManipulator::refNull(curr, curr->type); case Type::none: return ExpressionManipulator::nop(curr); case Type::unreachable: |