summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorCOFFEETALES <46571757+COFFEETALES@users.noreply.github.com>2019-10-21 23:39:48 +0200
committerThomas Lively <7121787+tlively@users.noreply.github.com>2019-10-21 14:39:48 -0700
commit29da5c9909249ea18d67a00c276e586199b7c945 (patch)
tree50209cc1da242d07df160d067bb02354bacdd8be /src/js
parent87d12c2dc788e49f82e3bc91b825a40b8d1c2efc (diff)
downloadbinaryen-29da5c9909249ea18d67a00c276e586199b7c945.tar.gz
binaryen-29da5c9909249ea18d67a00c276e586199b7c945.tar.bz2
binaryen-29da5c9909249ea18d67a00c276e586199b7c945.zip
Ability to list each item on Exports/Data Segments/Functions (#2386)
Adds functionality to the C API for getting the number of items in a module and fetching them out by index.
Diffstat (limited to 'src/js')
-rw-r--r--src/js/binaryen.js-post.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 7c99ded15..0da3f2df4 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -2096,6 +2096,23 @@ function wrapModule(module, self) {
);
});
};
+ self['getNumMemorySegments'] = function() {
+ return Module['_BinaryenGetNumMemorySegments'](module);
+ }
+ self['getMemorySegmentInfoByIndex'] = function(id) {
+ return {
+ 'byteOffset': Module['_BinaryenGetMemorySegmentByteOffset'](module, id),
+ 'data': (function(){
+ var size = Module['_BinaryenGetMemorySegmentByteLength'](module, id);
+ var ptr = _malloc(size);
+ Module['_BinaryenCopyMemorySegmentData'](module, id, ptr);
+ var res = new Uint8Array(size);
+ res.set(new Uint8Array(buffer, ptr, size));
+ _free(ptr);
+ return res.buffer;
+ })()
+ };
+ }
self['setStart'] = function(start) {
return Module['_BinaryenSetStart'](module, start);
};
@@ -2110,6 +2127,18 @@ function wrapModule(module, self) {
return Module['_BinaryenAddCustomSection'](module, strToStack(name), i8sToStack(contents), contents.length);
});
};
+ self['getNumExports'] = function() {
+ return Module['_BinaryenGetNumExports'](module);
+ }
+ self['getExportByIndex'] = function(id) {
+ return Module['_BinaryenGetExportByIndex'](module, id);
+ }
+ self['getNumFunctions'] = function() {
+ return Module['_BinaryenGetNumFunctions'](module);
+ }
+ self['getFunctionByIndex'] = function(id) {
+ return Module['_BinaryenGetFunctionByIndex'](module, id);
+ }
self['emitText'] = function() {
var old = out;
var ret = '';