summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-03-26 16:33:35 -0700
committerGitHub <noreply@github.com>2020-03-26 16:33:35 -0700
commit9101f65c7b18ab607c472a3d50b52db66497402f (patch)
tree9ffa1174a01162e750966ba39e7a3ca86c2e18ec /src/js
parentce6ae49863d7d2da54aabf9637ee299659f4bd0c (diff)
downloadbinaryen-9101f65c7b18ab607c472a3d50b52db66497402f.tar.gz
binaryen-9101f65c7b18ab607c472a3d50b52db66497402f.tar.bz2
binaryen-9101f65c7b18ab607c472a3d50b52db66497402f.zip
Tuple operations in C and JS APIs (#2711)
Adds functions for creating and inspecting tuple.make and tuple.extract expressions in the C and JS APIs.
Diffstat (limited to 'src/js')
-rw-r--r--src/js/binaryen.js-post.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 49b02d336..44dc7174b 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -95,6 +95,8 @@ function initializeConstants() {
'Throw',
'Rethrow',
'BrOnExn',
+ 'TupleMake',
+ 'TupleExtract',
'Push',
'Pop'
].forEach(function(name) {
@@ -2091,6 +2093,17 @@ function wrapModule(module, self) {
return Module['_BinaryenPush'](module, value);
};
+ self['tuple'] = {
+ 'make': function(elements) {
+ return preserveStack(function() {
+ return Module['_BinaryenTupleMake'](module, i32sToStack(elements), elements.length);
+ });
+ },
+ 'extract': function(tuple, index) {
+ return Module['_BinaryenTupleExtract'](module, tuple, index);
+ }
+ };
+
// 'Module' operations
self['addFunction'] = function(name, params, results, varTypes, body) {
return preserveStack(function() {
@@ -2790,6 +2803,19 @@ Module['getExpressionInfo'] = function(expr) {
'event': UTF8ToString(Module['_BinaryenBrOnExnGetEvent'](expr)),
'exnref': Module['_BinaryenBrOnExnGetExnref'](expr)
};
+ case Module['TupleMakeId']:
+ return {
+ 'id': id,
+ 'type': type,
+ 'operands': getAllNested(expr, Module['_BinaryenTupleMakeGetNumOperands'], Module['_BinaryenTupleMakeGetOperand'])
+ };
+ case Module['TupleExtractId']:
+ return {
+ 'id': id,
+ 'type': type,
+ 'tuple': Module['_BinaryenTupleExtractGetTuple'](expr),
+ 'index': Module['_BinaryenTupleExtractGetIndex'](expr)
+ };
case Module['PushId']:
return {
'id': id,