diff options
Diffstat (limited to 'src/binaryen-c.cpp')
-rw-r--r-- | src/binaryen-c.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index dfdca516f..2aa0633af 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -29,6 +29,7 @@ #include "wasm-printing.h" #include "wasm-s-parser.h" #include "wasm-validator.h" +#include "wasm2asm.h" #include "cfg/Relooper.h" #include "ast_utils.h" #include "shell-interface.h" @@ -651,7 +652,7 @@ BinaryenExpressionRef BinaryenDrop(BinaryenModuleRef module, BinaryenExpressionR } BinaryenExpressionRef BinaryenReturn(BinaryenModuleRef module, BinaryenExpressionRef value) { auto* ret = Builder(*((Module*)module)).makeReturn((Expression*)value); - + if (tracing) { auto id = noteExpression(ret); std::cout << " expressions[" << id << "] = BinaryenReturn(the_module, expressions[" << expressions[value] << "]);\n"; @@ -932,6 +933,21 @@ void BinaryenModulePrint(BinaryenModuleRef module) { WasmPrinter::printModule((Module*)module); } +void BinaryenModulePrintAsmjs(BinaryenModuleRef module) { + if (tracing) { + std::cout << " BinaryenModulePrintAsmjs(the_module);\n"; + } + + Module* wasm = (Module*)module; + Wasm2AsmBuilder::Flags builderFlags; + Wasm2AsmBuilder wasm2asm(builderFlags); + Ref asmjs = wasm2asm.processWasm(wasm); + JSPrinter jser(true, true, asmjs); + jser.printAst(); + + std::cout << jser.buffer; +} + int BinaryenModuleValidate(BinaryenModuleRef module) { if (tracing) { std::cout << " BinaryenModuleValidate(the_module);\n"; |