diff options
author | dcode <dcode@dcode.io> | 2022-10-19 19:57:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 10:57:07 -0700 |
commit | 3b1df7e5c329d9600cfadd513b557af618c007aa (patch) | |
tree | 4186b20d32b46294d2862fe945fc5c574359e6ac | |
parent | ded21cf0c1c09dd4e025406c759e3d4bb08d31cc (diff) | |
download | binaryen-3b1df7e5c329d9600cfadd513b557af618c007aa.tar.gz binaryen-3b1df7e5c329d9600cfadd513b557af618c007aa.tar.bz2 binaryen-3b1df7e5c329d9600cfadd513b557af618c007aa.zip |
[C API] Align I31ref and Dataref to be nullable (#5153)
The C API still returned non nullable types for `dataref` (`ref data` instead of `ref null data`) and `i31ref` (`ref i31` instead of `ref null i31`). This PR aligns with the current state of the GC proposal, making them nullable when obtained via the C API.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/binaryen-c.cpp | 4 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js | 4 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 8 |
4 files changed, 9 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d79c1c0f8..876a96032 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Current Trunk - Implemented bottom heap types: `none`, `nofunc`, and `noextern`. RefNull expressions and null `Literal`s must now have type `nullref`, `nullfuncref`, or `nullexternref`. +* The C-API's `BinaryenTypeI31ref` and `BinaryenTypeDataref` now return nullable types. v110 ---- diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index cd3806810..4501a67e0 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -197,10 +197,10 @@ BinaryenType BinaryenTypeEqref(void) { return Type(HeapType::eq, Nullable).getID(); } BinaryenType BinaryenTypeI31ref(void) { - return Type(HeapType::i31, NonNullable).getID(); + return Type(HeapType::i31, Nullable).getID(); } BinaryenType BinaryenTypeDataref(void) { - return Type(HeapType::data, NonNullable).getID(); + return Type(HeapType::data, Nullable).getID(); } BinaryenType BinaryenTypeArrayref(void) { return Type(HeapType::array, Nullable).getID(); diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js index 71846f3c6..c0bc402a0 100644 --- a/test/binaryen.js/expressions.js +++ b/test/binaryen.js/expressions.js @@ -1814,13 +1814,13 @@ console.log("# I31New"); assert(theI31New instanceof binaryen.I31New); assert(theI31New instanceof binaryen.Expression); assert(theI31New.value === value); - assert(theI31New.type === binaryen.i31ref); + // assert(theI31New.type === binaryen.?); // TODO: (ref i31) theI31New.value = value = module.local.get(2, binaryen.i32); assert(theI31New.value === value); theI31New.type = binaryen.f64; theI31New.finalize(); - assert(theI31New.type === binaryen.i31ref); + // assert(theI31New.type === binaryen.?); // TODO: (ref i31) console.log(theI31New.toText()); assert( diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 104405c8a..89c49f2d5 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -2176,10 +2176,10 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop eqref) ) (drop - (pop (ref i31)) + (pop i31ref) ) (drop - (pop (ref data)) + (pop dataref) ) (drop (pop stringref) @@ -4280,10 +4280,10 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop eqref) ) (drop - (pop (ref i31)) + (pop i31ref) ) (drop - (pop (ref data)) + (pop dataref) ) (drop (pop stringref) |