diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-01-15 01:00:08 +0100 |
---|---|---|
committer | Alon Zakai <azakai@google.com> | 2020-01-14 16:00:08 -0800 |
commit | 5ca79a71b2a2379083093d4d9136b2ae4095dfe8 (patch) | |
tree | 80263fb09290b896362a36d3ae062ee6cb64fb8c /test/binaryen.js/sourcemap.js | |
parent | a43b533b0778a1daf47178a3d3d9e559f3d390ed (diff) | |
download | binaryen-5ca79a71b2a2379083093d4d9136b2ae4095dfe8.tar.gz binaryen-5ca79a71b2a2379083093d4d9136b2ae4095dfe8.tar.bz2 binaryen-5ca79a71b2a2379083093d4d9136b2ae4095dfe8.zip |
Align binaryen.js with the npm package (#2551)
Binaryen.js now uses binaryen (was Binaryen) as its global
name to align with the npm package. Also fixes issues with
emitting and testing both the JS and Wasm builds.
Diffstat (limited to 'test/binaryen.js/sourcemap.js')
-rw-r--r-- | test/binaryen.js/sourcemap.js | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/test/binaryen.js/sourcemap.js b/test/binaryen.js/sourcemap.js index f8deecf3f..90f41c720 100644 --- a/test/binaryen.js/sourcemap.js +++ b/test/binaryen.js/sourcemap.js @@ -1,46 +1,38 @@ -function assert(x) { - if (!x) throw 'error!'; -} - -function test() { - var module = new Binaryen.Module(); +var module = new binaryen.Module(); - var fileIndex = module.addDebugInfoFileName("module.c"); +var fileIndex = module.addDebugInfoFileName("module.c"); - console.log(module.getDebugInfoFileName(fileIndex)); - console.log(); +console.log(module.getDebugInfoFileName(fileIndex)); +console.log(); - var expr = module.i32.const(1); - var body = module.block("", [ - expr - ], Binaryen.i32); +var expr = module.i32.const(1); +var body = module.block("", [ + expr +], binaryen.i32); - var func = module.addFunction("main", Binaryen.none, Binaryen.i32, [], body); +var func = module.addFunction("main", binaryen.none, binaryen.i32, [], body); - module.setDebugLocation(func, expr, fileIndex, 1, 2); - module.setDebugLocation(func, body, fileIndex, 0, 3); +module.setDebugLocation(func, expr, fileIndex, 1, 2); +module.setDebugLocation(func, body, fileIndex, 0, 3); - var output = module.emitBinary("module.wasm.map"); - assert(module.validate()); +var output = module.emitBinary("module.wasm.map"); +assert(module.validate()); - function dumpBinary(buffer) { - var hex = [], o, b, h; - for (var i = 0; i < buffer.length; ++i) { - o = i.toString(16); - while (o.length < 3) o = "0" + o; - if ((i & 15) === 0) hex.push((i ? "\n" : "") + o + ":"); - if ((b = buffer[i]) >= 0x21 && b <= 0x7e) - h = String.fromCharCode(b) + ' '; - else if ((h = b.toString(16)).length < 2) - h = "0" + h; - hex.push(h); - } - console.log(hex.join(" ")); +function dumpBinary(buffer) { + var hex = [], o, b, h; + for (var i = 0; i < buffer.length; ++i) { + o = i.toString(16); + while (o.length < 3) o = "0" + o; + if ((i & 15) === 0) hex.push((i ? "\n" : "") + o + ":"); + if ((b = buffer[i]) >= 0x21 && b <= 0x7e) + h = String.fromCharCode(b) + ' '; + else if ((h = b.toString(16)).length < 2) + h = "0" + h; + hex.push(h); } - - dumpBinary(output.binary); - console.log(); - console.log(output.sourceMap); + console.log(hex.join(" ")); } -Binaryen.ready.then(test); +dumpBinary(output.binary); +console.log(); +console.log(output.sourceMap); |