mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-19 18:01:31 +00:00
Rename memory instructions; Rework constant handling
This commit is contained in:
18
tests/binaryen/const-global.js
Normal file
18
tests/binaryen/const-global.js
Normal file
@ -0,0 +1,18 @@
|
||||
var binaryen = require("binaryen");
|
||||
|
||||
var mod = new binaryen.Module();
|
||||
|
||||
mod.addGlobal("testGlobal", binaryen.i32, false, mod.i32.const(2));
|
||||
var funcType = mod.addFunctionType("i", binaryen.i32, []);
|
||||
mod.addFunction("test", funcType, [],
|
||||
mod.get_global("testGlobal", binaryen.i32)
|
||||
);
|
||||
mod.addFunctionExport("test", "test");
|
||||
|
||||
binaryen.setOptimizeLevel(4);
|
||||
binaryen.setShrinkLevel(0);
|
||||
binaryen.setDebugInfo(false);
|
||||
mod.optimize();
|
||||
if (!mod.validate())
|
||||
console.log("-> does not validate");
|
||||
console.log(mod.emitText());
|
8
tests/binaryen/const-global.wat
Normal file
8
tests/binaryen/const-global.wat
Normal file
@ -0,0 +1,8 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(global $testGlobal i32 (i32.const 2))
|
||||
(export "test" (func $test))
|
||||
(func $test (; 0 ;) (type $i) (result i32)
|
||||
(get_global $testGlobal)
|
||||
)
|
||||
)
|
18
tests/binaryen/const-local.js
Normal file
18
tests/binaryen/const-local.js
Normal file
@ -0,0 +1,18 @@
|
||||
var binaryen = require("binaryen");
|
||||
|
||||
var mod = new binaryen.Module();
|
||||
|
||||
var funcType = mod.addFunctionType("i", binaryen.i32, [ binaryen.i32 ]);
|
||||
mod.addFunction("test", funcType, [], mod.block("", [
|
||||
mod.setLocal(0, mod.i32.const(2)),
|
||||
mod.getLocal(0, binaryen.i32)
|
||||
], binaryen.i32));
|
||||
mod.addFunctionExport("test", "test");
|
||||
|
||||
binaryen.setOptimizeLevel(4);
|
||||
binaryen.setShrinkLevel(0);
|
||||
binaryen.setDebugInfo(false);
|
||||
mod.optimize();
|
||||
if (!mod.validate())
|
||||
console.log("-> does not validate");
|
||||
console.log(mod.emitText());
|
Reference in New Issue
Block a user