summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-05-11 20:48:51 +0200
committerGitHub <noreply@github.com>2020-05-11 11:48:51 -0700
commit655fd6b5cd1e3dd7441139cfca95a905004d2209 (patch)
tree58c688490493b5beb2ba3b273d13668cb4888065 /src/js
parent3de8c98b682e1347e5c50c58eaddc4b01f3e26ab (diff)
downloadbinaryen-655fd6b5cd1e3dd7441139cfca95a905004d2209.tar.gz
binaryen-655fd6b5cd1e3dd7441139cfca95a905004d2209.tar.bz2
binaryen-655fd6b5cd1e3dd7441139cfca95a905004d2209.zip
Add C/JS APIs to copy expressions (#2840)
This API enables use cases where we want to keep the original expression, yet utilize passes like `vacuum` or `precompute` to evaluate it without implicitly modifying the original. C-API: **BinaryenExpressionCopy**(expr, module) JS-API: **Module#copyExpression**(expr)
Diffstat (limited to 'src/js')
-rw-r--r--src/js/binaryen.js-post.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 75d6bf401..1706d2b97 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -2407,6 +2407,9 @@ function wrapModule(module, self) {
self['setDebugLocation'] = function(func, expr, fileIndex, lineNumber, columnNumber) {
return Module['_BinaryenFunctionSetDebugLocation'](func, expr, fileIndex, lineNumber, columnNumber);
};
+ self['copyExpression'] = function(expr) {
+ return Module['_BinaryenExpressionCopy'](expr, module);
+ };
return self;
}