mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Add trapMode option to asc; Disable flatten/ssa passes for now
This commit is contained in:
parent
6d8de50565
commit
732068e981
24
README.md
24
README.md
@ -69,16 +69,20 @@ Syntax: asc [options] [file ...]
|
||||
Examples: asc hello.ts
|
||||
|
||||
Options:
|
||||
-v, --version Prints the compiler's version.
|
||||
-h, --help Prints this message.
|
||||
-O, --optimize Optimizes the module.
|
||||
-c, --validate Validates the module.
|
||||
-o, --outFile Specifies the output file.
|
||||
-b, --binaryFile Specifies the binary format output file.
|
||||
-t, --textFile Specifies the text format output file.
|
||||
-a, --asmjsFile Specifies the asm.js format output file.
|
||||
--noTreeShaking Disables tree-shaking.
|
||||
--noDebug Disables assertions.
|
||||
-v, --version Prints the compiler's version.
|
||||
-h, --help Prints this message.
|
||||
-O, --optimize Optimizes the module.
|
||||
-c, --validate Validates the module.
|
||||
-o, --outFile Specifies the output file. Format is determined by file extension.
|
||||
-b, --binaryFile Specifies the binary format output file (.wasm).
|
||||
-t, --textFile Specifies the text format output file (.wast).
|
||||
-a, --asmjsFile Specifies the asm.js format output file (.js).
|
||||
--noTreeShaking Disables tree-shaking.
|
||||
--noDebug Disables assertions.
|
||||
--trapMode Sets the trap mode to use.
|
||||
none Do not modify trapping operations. This is the default.
|
||||
clamp Replace trapping operations with clamping semantics.
|
||||
js Replace trapping operations with JS semantics.
|
||||
```
|
||||
|
||||
Unless a bundle has been built to `dist/`, `asc` runs the TypeScript sources directly via [ts-node](https://www.npmjs.com/package/ts-node). Useful for development.
|
||||
|
17
bin/asc.js
17
bin/asc.js
@ -31,6 +31,7 @@ Object.keys(conf).forEach(key => {
|
||||
|
||||
var args = minimist(process.argv.slice(2), opts);
|
||||
var version = require("../package.json").version;
|
||||
var indent = 20;
|
||||
if (isDev) version += "-dev";
|
||||
|
||||
if (args.version) {
|
||||
@ -48,9 +49,16 @@ if (args.help || args._.length < 1) {
|
||||
if (option.aliases && option.aliases[0].length === 1)
|
||||
text += "-" + option.aliases[0] + ", ";
|
||||
text += "--" + name;
|
||||
while (text.length < 24)
|
||||
while (text.length < indent)
|
||||
text += " ";
|
||||
options.push(text + option.desc);
|
||||
if (Array.isArray(option.desc)) {
|
||||
options.push(text + option.desc[0] + option.desc.slice(1).map(line => {
|
||||
for (var i = 0; i < indent; ++i)
|
||||
line = " " + line;
|
||||
return "\n" + line;
|
||||
}).join(""));
|
||||
} else
|
||||
options.push(text + option.desc);
|
||||
});
|
||||
console.log([
|
||||
"Version " + version,
|
||||
@ -135,6 +143,11 @@ if (args.validate)
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (args.trapMode === "clamp")
|
||||
module.runPasses([ "trap-mode-clamp" ]);
|
||||
else if (args.trapMode === "js")
|
||||
module.runPasses([ "trap-mode-js" ]);
|
||||
|
||||
if (args.optimize)
|
||||
module.optimize();
|
||||
|
||||
|
18
bin/asc.json
18
bin/asc.json
@ -20,22 +20,22 @@
|
||||
"aliases": [ "c", "check" ]
|
||||
},
|
||||
"outFile": {
|
||||
"desc": "Specifies the output file.",
|
||||
"desc": "Specifies the output file. Format is determined by file extension.",
|
||||
"type": "string",
|
||||
"aliases": [ "o" ]
|
||||
},
|
||||
"binaryFile": {
|
||||
"desc": "Specifies the binary format output file.",
|
||||
"desc": "Specifies the binary format output file (.wasm).",
|
||||
"type": "string",
|
||||
"aliases": [ "b" ]
|
||||
},
|
||||
"textFile": {
|
||||
"desc": "Specifies the text format output file.",
|
||||
"desc": "Specifies the text format output file (.wast).",
|
||||
"type": "string",
|
||||
"aliases": [ "t" ]
|
||||
},
|
||||
"asmjsFile": {
|
||||
"desc": "Specifies the asm.js format output file.",
|
||||
"desc": "Specifies the asm.js format output file (.js).",
|
||||
"type": "string",
|
||||
"aliases": [ "a" ]
|
||||
},
|
||||
@ -46,5 +46,15 @@
|
||||
"noDebug": {
|
||||
"desc": "Disables assertions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"trapMode": {
|
||||
"desc": [
|
||||
"Sets the trap mode to use.",
|
||||
"none Do not modify trapping operations. This is the default.",
|
||||
"clamp Replace trapping operations with clamping semantics.",
|
||||
"js Replace trapping operations with JS semantics."
|
||||
],
|
||||
"type": "string",
|
||||
"default": "none"
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +393,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (getExpressionId(initializer) != ExpressionId.Const) {
|
||||
initializer = this.precomputeExpressionRef(initializer);
|
||||
if (getExpressionId(initializer) != ExpressionId.Const) {
|
||||
this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, declaration.range);
|
||||
if (element.isConstant)
|
||||
this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, declaration.range);
|
||||
initializeInStart = true;
|
||||
}
|
||||
}
|
||||
@ -407,7 +408,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
this.module.createGetGlobal(previousValue.internalName, NativeType.I32),
|
||||
this.module.createI32(1)
|
||||
);
|
||||
this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, val.declaration.range);
|
||||
if (element.isConstant)
|
||||
this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, val.declaration.range);
|
||||
initializeInStart = true;
|
||||
}
|
||||
if (initializeInStart) {
|
||||
|
@ -702,7 +702,7 @@ export class Module {
|
||||
|
||||
optimize(func: FunctionRef = 0): void {
|
||||
// see: https://github.com/WebAssembly/binaryen/issues/1331#issuecomment-350328175
|
||||
this.runPasses([ "flatten", "ssa" ], func);
|
||||
// this.runPasses([ "flatten", "ssa" ], func);
|
||||
if (func) {
|
||||
_BinaryenFunctionOptimize(func, this.ref);
|
||||
} else {
|
||||
|
@ -1,13 +0,0 @@
|
||||
var binaryen = require("binaryen");
|
||||
|
||||
// "unexpected false: module function exports must be found"
|
||||
|
||||
var mod = new binaryen.Module();
|
||||
|
||||
var funcType = mod.addFunctionType("v", binaryen.none, []);
|
||||
var func = mod.addImport("test", "env", "test", funcType);
|
||||
mod.addExport("test", "test");
|
||||
|
||||
console.log(mod.emitText());
|
||||
if (!mod.validate())
|
||||
console.log("-> does not validate");
|
@ -1,5 +1,7 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(import "env" "external" (func $declare/external))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08")
|
||||
(export "external" (func $declare/external))
|
||||
(export "memory" (memory $0))
|
||||
)
|
||||
|
@ -1,5 +1,3 @@
|
||||
declare function external(): void;
|
||||
|
||||
// "unexpected false: module function exports must be found"
|
||||
// see: https://github.com/WebAssembly/binaryen/issues/1325
|
||||
export { external };
|
||||
|
@ -5,15 +5,11 @@
|
||||
(export "loopDoInDo" (func $do/loopDoInDo))
|
||||
(export "memory" (memory $0))
|
||||
(func $do/loopDo (; 0 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(br_if $continue|0
|
||||
(tee_local $1
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -21,10 +17,8 @@
|
||||
)
|
||||
)
|
||||
(func $do/loopDoInDo (; 1 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(loop $continue|0
|
||||
(set_local $1
|
||||
(set_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
@ -32,20 +26,16 @@
|
||||
)
|
||||
(loop $continue|1
|
||||
(br_if $continue|1
|
||||
(tee_local $2
|
||||
(tee_local $1
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br_if $continue|0
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -100,7 +100,7 @@
|
||||
(get_local $4)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(tee_local $3
|
||||
(tee_local $2
|
||||
(select
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
@ -128,7 +128,7 @@
|
||||
(get_local $4)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(tee_local $2
|
||||
(tee_local $3
|
||||
(select
|
||||
(i32.const 0)
|
||||
(i32.add
|
||||
@ -150,7 +150,7 @@
|
||||
(get_local $0)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -160,7 +160,7 @@
|
||||
(get_local $0)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -170,7 +170,7 @@
|
||||
(get_local $5)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -190,7 +190,7 @@
|
||||
(get_local $5)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -205,38 +205,32 @@
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $3
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(get_local $3)
|
||||
(i32.store8
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $game-of-life/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(get_global $game-of-life/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $game-of-life/w)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
|
@ -44,48 +44,46 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $0
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(tee_local $1
|
||||
(f64.const 1)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $1
|
||||
(f64.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(f64.eq
|
||||
(get_local $1)
|
||||
(if (result f64)
|
||||
(f64.ne
|
||||
(tee_local $1
|
||||
(f64.const 1)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(tee_local $1
|
||||
(f64.const 2)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(set_global $logical/i
|
||||
(get_local $0)
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
@ -94,19 +92,15 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(set_global $logical/i
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $logical/i
|
||||
(get_local $0)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $logical/i)
|
||||
@ -114,40 +108,36 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i64.ne
|
||||
(tee_local $2
|
||||
(i64.const 1)
|
||||
)
|
||||
(i64.const 0)
|
||||
)
|
||||
(set_local $2
|
||||
(i64.const 2)
|
||||
)
|
||||
)
|
||||
(set_global $logical/I
|
||||
(get_local $2)
|
||||
)
|
||||
(if
|
||||
(i64.ne
|
||||
(get_global $logical/I)
|
||||
(i64.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i64.eq
|
||||
(tee_local $2
|
||||
(if (result i64)
|
||||
(i64.ne
|
||||
(tee_local $2
|
||||
(i64.const 1)
|
||||
)
|
||||
(i64.const 0)
|
||||
)
|
||||
(i64.const 0)
|
||||
)
|
||||
(set_local $2
|
||||
(i64.const 1)
|
||||
(i64.const 2)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i64.ne
|
||||
(get_global $logical/I)
|
||||
(i64.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $logical/I
|
||||
(get_local $2)
|
||||
(if (result i64)
|
||||
(i64.ne
|
||||
(tee_local $2
|
||||
(i64.const 0)
|
||||
)
|
||||
(i64.const 0)
|
||||
)
|
||||
(get_local $2)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i64.ne
|
||||
@ -156,40 +146,36 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f32.ne
|
||||
(tee_local $3
|
||||
(f32.const 1)
|
||||
)
|
||||
(f32.const 0)
|
||||
)
|
||||
(set_local $3
|
||||
(f32.const 2)
|
||||
)
|
||||
)
|
||||
(set_global $logical/f
|
||||
(get_local $3)
|
||||
)
|
||||
(if
|
||||
(f32.ne
|
||||
(get_global $logical/f)
|
||||
(f32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f32.eq
|
||||
(tee_local $3
|
||||
(if (result f32)
|
||||
(f32.ne
|
||||
(tee_local $3
|
||||
(f32.const 1)
|
||||
)
|
||||
(f32.const 0)
|
||||
)
|
||||
(f32.const 0)
|
||||
)
|
||||
(set_local $3
|
||||
(f32.const 1)
|
||||
(f32.const 2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(f32.ne
|
||||
(get_global $logical/f)
|
||||
(f32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $logical/f
|
||||
(get_local $3)
|
||||
(if (result f32)
|
||||
(f32.ne
|
||||
(tee_local $3
|
||||
(f32.const 0)
|
||||
)
|
||||
(f32.const 0)
|
||||
)
|
||||
(get_local $3)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(f32.ne
|
||||
@ -198,19 +184,17 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(tee_local $1
|
||||
(f64.const 1)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $1
|
||||
(f64.const 2)
|
||||
)
|
||||
)
|
||||
(set_global $logical/F
|
||||
(get_local $1)
|
||||
(if (result f64)
|
||||
(f64.ne
|
||||
(tee_local $1
|
||||
(f64.const 1)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(f64.const 2)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
@ -219,20 +203,18 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.eq
|
||||
(tee_local $1
|
||||
(set_global $logical/F
|
||||
(if (result f64)
|
||||
(f64.ne
|
||||
(tee_local $1
|
||||
(f64.const 0)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $1
|
||||
(get_local $1)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $logical/F
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(get_global $logical/F)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,36 +6,15 @@
|
||||
(export "doSwitchDefaultOmitted" (func $switch/doSwitchDefaultOmitted))
|
||||
(export "memory" (memory $0))
|
||||
(func $switch/doSwitch (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $case4|0
|
||||
(block $case2|0
|
||||
(if
|
||||
(i32.ne
|
||||
(tee_local $1
|
||||
(block $case0|0
|
||||
(block $tablify|0
|
||||
(br_table $case2|0 $case0|0 $case4|0 $case4|0 $tablify|0
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(br_if $case2|0
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(br_if $case4|0
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br_if $case4|0
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(br $case2|0)
|
||||
)
|
||||
(br $case2|0)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
@ -48,31 +27,18 @@
|
||||
(i32.const 23)
|
||||
)
|
||||
(func $switch/doSwitchDefaultFirst (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $case3|0
|
||||
(if
|
||||
(i32.ne
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
(block $case1|0
|
||||
(block $tablify|0
|
||||
(br_table $case1|0 $case3|0 $case3|0 $tablify|0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(br_if $case3|0
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br_if $case3|0
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(return
|
||||
@ -82,31 +48,18 @@
|
||||
(i32.const 23)
|
||||
)
|
||||
(func $switch/doSwitchDefaultOmitted (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $break|0
|
||||
(block $case2|0
|
||||
(if
|
||||
(i32.ne
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(br_if $case2|0
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
(block $case0|0
|
||||
(block $tablify|0
|
||||
(br_table $case0|0 $case2|0 $case2|0 $tablify|0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br_if $case2|0
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(br $break|0)
|
||||
)
|
||||
(br $break|0)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
|
@ -5,28 +5,14 @@
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(set_global $ternary/a
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $ternary/a
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $ternary/a
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -66,38 +66,52 @@
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(tee_local $0
|
||||
(get_global $unary/i)
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(get_local $0)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(tee_local $0
|
||||
(get_global $unary/i)
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
(get_global $unary/i)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(get_local $0)
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(tee_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(tee_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
@ -155,38 +169,52 @@
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(tee_local $1
|
||||
(get_global $unary/I)
|
||||
(block (result i64)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(i64.const 1)
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(get_local $1)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(tee_local $1
|
||||
(get_global $unary/I)
|
||||
(block (result i64)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(i64.const 1)
|
||||
(get_global $unary/I)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(get_local $1)
|
||||
(block (result i64)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(tee_local $1
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(block (result i64)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(tee_local $1
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
@ -233,38 +261,52 @@
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(tee_local $2
|
||||
(get_global $unary/f)
|
||||
(block (result f32)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(f32.const 1)
|
||||
(get_global $unary/f)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(get_local $2)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(tee_local $2
|
||||
(get_global $unary/f)
|
||||
(block (result f32)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(f32.const 1)
|
||||
(get_global $unary/f)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(get_local $2)
|
||||
(block (result f32)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(tee_local $2
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(block (result f32)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(tee_local $2
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
@ -313,38 +355,52 @@
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(tee_local $3
|
||||
(get_global $unary/F)
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(f64.const 1)
|
||||
(get_global $unary/F)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(get_local $3)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(tee_local $3
|
||||
(get_global $unary/F)
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(f64.const 1)
|
||||
(get_global $unary/F)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(get_local $3)
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(tee_local $3
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(tee_local $3
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -5,20 +5,14 @@
|
||||
(export "loopWhileInWhile" (func $while/loopWhileInWhile))
|
||||
(export "memory" (memory $0))
|
||||
(func $while/loopWhile (; 0 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
(block
|
||||
(set_local $0
|
||||
(tee_local $1
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
@ -27,32 +21,24 @@
|
||||
)
|
||||
)
|
||||
(func $while/loopWhileInWhile (; 1 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
(block
|
||||
(set_local $0
|
||||
(tee_local $1
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
(block
|
||||
(set_local $0
|
||||
(tee_local $1
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user