From 7d3ddd09d5f68945160cda3f3749a217a13928bf Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Wed, 31 Oct 2018 19:22:48 +0100 Subject: Add Module#emitStackIR to the JS-API (#1717) Related to #1716 (comment) --- src/js/binaryen.js-post.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/js/binaryen.js-post.js') diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index e34273a2a..8e4d67482 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -1162,6 +1162,16 @@ Module['Module'] = function(module) { out = old; return ret; }; + this['emitStackIR'] = function(optimize) { + this['runPasses'](['generate-stack-ir']); + if (optimize) this['runPasses'](['optimize-stack-ir']); + var old = out; + var ret = ''; + out = function(x) { ret += x + '\n' }; + this['runPasses'](['print-stack-ir']); + out = old; + return ret; + }; this['emitAsmjs'] = function() { var old = out; var ret = ''; -- cgit v1.2.3