summaryrefslogtreecommitdiff
path: root/src/js/binaryen.js-post.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/binaryen.js-post.js')
-rw-r--r--src/js/binaryen.js-post.js53
1 files changed, 51 insertions, 2 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 8cddc61c7..2993573d1 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -38,7 +38,9 @@ function initializeConstants() {
['f32', 'Float32'],
['f64', 'Float64'],
['v128', 'Vec128'],
+ ['funcref', 'Funcref'],
['anyref', 'Anyref'],
+ ['nullref', 'Nullref'],
['exnref', 'Exnref'],
['unreachable', 'Unreachable'],
['auto', 'Auto']
@@ -86,6 +88,9 @@ function initializeConstants() {
'DataDrop',
'MemoryCopy',
'MemoryFill',
+ 'RefNull',
+ 'RefIsNull',
+ 'RefFunc',
'Try',
'Throw',
'Rethrow',
@@ -1952,20 +1957,47 @@ function wrapModule(module, self) {
},
};
+ self['funcref'] = {
+ 'pop': function() {
+ return Module['_BinaryenPop'](module, Module['funcref']);
+ }
+ };
+
self['anyref'] = {
'pop': function() {
return Module['_BinaryenPop'](module, Module['anyref']);
}
};
+ self['nullref'] = {
+ 'pop': function() {
+ return Module['_BinaryenPop'](module, Module['nullref']);
+ }
+ };
+
self['exnref'] = {
'pop': function() {
return Module['_BinaryenPop'](module, Module['exnref']);
}
};
- self['select'] = function(condition, ifTrue, ifFalse) {
- return Module['_BinaryenSelect'](module, condition, ifTrue, ifFalse);
+ self['ref'] = {
+ 'null': function() {
+ return Module['_BinaryenRefNull'](module);
+ },
+ 'is_null': function(value) {
+ return Module['_BinaryenRefIsNull'](module, value);
+ },
+ 'func': function(func) {
+ return preserveStack(function() {
+ return Module['_BinaryenRefFunc'](module, strToStack(func));
+ });
+ }
+ };
+
+ self['select'] = function(condition, ifTrue, ifFalse, type) {
+ return Module['_BinaryenSelect'](
+ module, condition, ifTrue, ifFalse, typeof type !== 'undefined' ? type : Module['auto']);
};
self['drop'] = function(value) {
return Module['_BinaryenDrop'](module, value);
@@ -2651,6 +2683,23 @@ Module['getExpressionInfo'] = function(expr) {
'value': Module['_BinaryenMemoryFillGetValue'](expr),
'size': Module['_BinaryenMemoryFillGetSize'](expr)
};
+ case Module['RefNullId']:
+ return {
+ 'id': id,
+ 'type': type
+ };
+ case Module['RefIsNullId']:
+ return {
+ 'id': id,
+ 'type': type,
+ 'value': Module['_BinaryenRefIsNullGetValue'](expr)
+ };
+ case Module['RefFuncId']:
+ return {
+ 'id': id,
+ 'type': type,
+ 'func': UTF8ToString(Module['_BinaryenRefFuncGetFunc'](expr)),
+ };
case Module['TryId']:
return {
'id': id,