From 9470f99ae20f3688a6967221164ba989568d59a8 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Fri, 5 Dec 2025 20:02:56 -0500 Subject: [PATCH] feat: Add `Binaryen.arrayref` and `module.arrayref.pop()` to js api This pr implements `Binaryen.arrayref` and `module.arrayref.pop()` in the js api following the same pattern I see used for the various other types. --- src/js/binaryen.js-post.js | 7 +++++++ test/binaryen.js/kitchen-sink.js | 1 + test/binaryen.js/kitchen-sink.js.txt | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 1743c97388e..c938f6c3bc4 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -39,6 +39,7 @@ function initializeConstants() { ['eqref', 'Eqref'], ['i31ref', 'I31ref'], ['structref', 'Structref'], + ['arrayref', 'Arrayref'], ['stringref', 'Stringref'], ['nullref', 'Nullref'], ['nullexternref', 'NullExternref'], @@ -2381,6 +2382,12 @@ function wrapModule(module, self = {}) { } }; + self['arrayref'] = { + 'pop'() { + return Module['_BinaryenPop'](module, Module['arrayref']); + } + }; + self['stringref'] = { 'pop'() { return Module['_BinaryenPop'](module, Module['stringref']); diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 556749059b7..e2764e19abf 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -660,6 +660,7 @@ function test_core() { module.eqref.pop(), module.i31ref.pop(), module.structref.pop(), + module.arrayref.pop(), module.stringref.pop(), // Memory diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 2802300c194..d28f6381f48 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -2184,6 +2184,9 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (drop (pop structref) ) + (drop + (pop arrayref) + ) (drop (pop stringref) )