summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/binaryen.js-post.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index e6d248715..c6313f2d7 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -1019,6 +1019,16 @@
return Module['_BinaryenAddFunction'](module, strToStack(name), functionType, i32sToStack(varTypes), varTypes.length, body);
});
};
+ this['getFunction'] = function(name) {
+ return preserveStack(function() {
+ return Module['_BinaryenGetFunction'](module, strToStack(name));
+ });
+ };
+ this['removeFunction'] = function(name) {
+ return preserveStack(function() {
+ return Module['_BinaryenRemoveFunction'](module, strToStack(name));
+ });
+ };
this['addGlobal'] = function(name, type, mutable, init) {
return preserveStack(function() {
return Module['_BinaryenAddGlobal'](module, strToStack(name), type, mutable, init);
@@ -1098,13 +1108,25 @@
this['optimize'] = function() {
return Module['_BinaryenModuleOptimize'](module);
};
+ this['optimizeFunction'] = function(func) {
+ if (typeof func === "string") func = this['getFunction'](func);
+ return Module['_BinaryenFunctionOptimize'](func, module);
+ };
this['runPasses'] = function(passes) {
return preserveStack(function() {
return Module['_BinaryenModuleRunPasses'](module, i32sToStack(
passes.map(strToStack)
), passes.length);
});
- }
+ };
+ this['runPassesOnFunction'] = function(func, passes) {
+ if (typeof func === "string") func = this['getFunction'](func);
+ return preserveStack(function() {
+ return Module['_BinaryenFunctionRunPasses'](func, module, i32sToStack(
+ passes.map(strToStack)
+ ), passes.length);
+ });
+ };
this['autoDrop'] = function() {
return Module['_BinaryenModuleAutoDrop'](module);
};
@@ -1172,6 +1194,10 @@
return Module['_BinaryenConstGetValueF64'](expr);
};
+ Module['getFunctionBody'] = function(func) {
+ return Module['_BinaryenFunctionGetBody'](func);
+ };
+
// emit text of an expression or a module
Module['emitText'] = function(expr) {
if (typeof expr === 'object') {