diff options
Diffstat (limited to 'test/binaryen.js/reloc.js')
-rw-r--r-- | test/binaryen.js/reloc.js | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/test/binaryen.js/reloc.js b/test/binaryen.js/reloc.js index e9fdd6012..bb011916d 100644 --- a/test/binaryen.js/reloc.js +++ b/test/binaryen.js/reloc.js @@ -1,29 +1,21 @@ -function assert(x) { - if (!x) throw 'error!'; -} +var module = new binaryen.Module(); -function test() { - var module = new Binaryen.Module(); +// memory with offset - // memory with offset +module.addGlobalImport("memory_base", "env", "memory_base", binaryen.i32, false); +module.setMemory(1, -1, null, [ + { + offset: module.global.get("memory_base", binaryen.i32), + data: "data data".split('').map(function(x) { return x.charCodeAt(0) }) + } +]); - module.addGlobalImport("memory_base", "env", "memory_base", Binaryen.i32, false); - module.setMemory(1, -1, null, [ - { - offset: module.global.get("memory_base", Binaryen.i32), - data: "data data".split('').map(function(x) { return x.charCodeAt(0) }) - } - ]); +// table with offset - // table with offset +var func = module.addFunction("func", binaryen.none, binaryen.none, [], module.nop()); - var func = module.addFunction("func", Binaryen.none, Binaryen.none, [], module.nop()); +module.addGlobalImport("table_base", "env", "table_base", binaryen.i32, false); +module.setFunctionTable(1, -1, [ "func", "func" ], module.global.get("table_base", binaryen.i32)); - module.addGlobalImport("table_base", "env", "table_base", Binaryen.i32, false); - module.setFunctionTable(1, -1, [ "func", "func" ], module.global.get("table_base", Binaryen.i32)); - - assert(module.validate()); - console.log(module.emitText()); -} - -Binaryen.ready.then(test); +assert(module.validate()); +console.log(module.emitText()); |