summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-18 13:55:14 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-18 13:55:14 -0800
commitfda902dce36c78fe358b48252af5e0e1e4b2ad75 (patch)
tree1ee39e091a7422d0c84f3b427548388ca1015bed
parent98c318e18c6fc43e851429a2a5e43bac16ae1ee1 (diff)
downloadbinaryen-fda902dce36c78fe358b48252af5e0e1e4b2ad75.tar.gz
binaryen-fda902dce36c78fe358b48252af5e0e1e4b2ad75.tar.bz2
binaryen-fda902dce36c78fe358b48252af5e0e1e4b2ad75.zip
handle debugger keyword in asm2wasm
-rw-r--r--src/asm2wasm.h20
-rw-r--r--src/js/post.js3
2 files changed, 22 insertions, 1 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 5d88b8f38..588754580 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -33,7 +33,8 @@ IString GLOBAL("global"), NAN_("NaN"), INFINITY_("Infinity"),
FROUND("fround"),
ASM2WASM("asm2wasm"),
F64_REM("f64-rem"),
- F64_TO_INT("f64-to-int");
+ F64_TO_INT("f64-to-int"),
+ DEBUGGER("debugger");
static void abort_on(std::string why) {
@@ -758,6 +759,23 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
ret->type = asmToWasmType(asmData.getType(name));
return ret;
}
+ if (name == DEBUGGER) {
+ CallImport *call = allocator.alloc<CallImport>();
+ call->target = DEBUGGER;
+ call->type = none;
+ static bool addedImport = false;
+ if (!addedImport) {
+ addedImport = true;
+ auto import = allocator.alloc<Import>(); // debugger = asm2wasm.debugger;
+ import->name = DEBUGGER;
+ import->module = ASM2WASM;
+ import->base = DEBUGGER;
+ import->type.name = DEBUGGER;
+ import->type.result = none;
+ wasm.addImport(import);
+ }
+ return call;
+ }
// global var, do a load from memory
assert(mappedGlobals.find(name) != mappedGlobals.end());
MappedGlobal global = mappedGlobals[name];
diff --git a/src/js/post.js b/src/js/post.js
index 5c854b3df..8e57c4a06 100644
--- a/src/js/post.js
+++ b/src/js/post.js
@@ -35,6 +35,9 @@
"f64-to-int": function(x) {
return x | 0;
},
+ "debugger": function() {
+ debugger;
+ },
},
parent: Module // Module inside wasm-js.cpp refers to wasm-js.cpp; this allows access to the outside program.
};