mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 06:21:29 +00:00
Builtins rewrite with type parameter inference; Small integer math optimizations; Switchify
This commit is contained in:
@ -17,13 +17,17 @@ var filter = process.argv.length > 2 && !isCreate ? "**/" + process.argv[2] + ".
|
||||
|
||||
var stdFiles = glob.sync("*.ts", { cwd: __dirname + "/../std/assembly" });
|
||||
|
||||
var success = 0;
|
||||
var failures = 0;
|
||||
|
||||
glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
if (filename.charAt(0) == "_")
|
||||
return;
|
||||
|
||||
console.log(chalk.default.whiteBright("Testing compiler/" + filename));
|
||||
console.log(chalk.whiteBright("Testing compiler/" + filename));
|
||||
|
||||
var fixture = path.basename(filename, ".ts");
|
||||
var startTime = process.hrtime();
|
||||
var parser = new Parser();
|
||||
if (filename.startsWith("std/")) {
|
||||
stdFiles.forEach(file => {
|
||||
@ -45,18 +49,24 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
parser.parseFile(nextSourceText, nextFile, false);
|
||||
}
|
||||
var program = parser.finish();
|
||||
var parseTime = process.hrtime(startTime);
|
||||
startTime = process.hrtime();
|
||||
var module = Compiler.compile(program);
|
||||
var compileTime = process.hrtime(startTime);
|
||||
var actual = module.toText() + "(;\n[program.elements]\n " + elements(program.elements)
|
||||
+ "\n[program.exports]\n " + elements(program.exports)
|
||||
+ "\n;)\n";
|
||||
var actualOptimized = null;
|
||||
var actualInlined = null;
|
||||
|
||||
console.log("parse incl. I/O: " + ((parseTime[0] * 1e9 + parseTime[1]) / 1e6).toFixed(3) + "ms / compile: " + ((compileTime[0] * 1e9 + compileTime[1]) / 1e6).toFixed(3) + "ms");
|
||||
|
||||
var failed = false;
|
||||
if (module.validate()) {
|
||||
console.log(chalk.default.green("validate OK"));
|
||||
console.log(chalk.green("validate OK"));
|
||||
try {
|
||||
module.interpret();
|
||||
console.log(chalk.default.green("interpret OK"));
|
||||
console.log(chalk.green("interpret OK"));
|
||||
try {
|
||||
var binary = module.toBinary();
|
||||
var wasmModule = new WebAssembly.Module(binary);
|
||||
@ -70,22 +80,22 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
externalConst: 2
|
||||
}
|
||||
});
|
||||
console.log(chalk.default.green("instantiate OK"));
|
||||
console.log(chalk.green("instantiate OK"));
|
||||
} catch (e) {
|
||||
process.exitCode = 1;
|
||||
console.log(chalk.default.red("instantiate ERROR: ") + e);
|
||||
failed = true;
|
||||
console.log(chalk.red("instantiate ERROR: ") + e);
|
||||
}
|
||||
} catch (e) {
|
||||
process.exitCode = 1;
|
||||
console.log(chalk.default.red("interpret ERROR:") + e);
|
||||
failed = true;
|
||||
console.log(chalk.red("interpret ERROR:") + e);
|
||||
}
|
||||
module.optimize();
|
||||
actualOptimized = module.toText();
|
||||
module.runPasses([ "inlining" ]);
|
||||
actualInlined = module.toText();
|
||||
} else {
|
||||
process.exitCode = 1;
|
||||
console.log(chalk.default.red("validate ERROR"));
|
||||
failed = true;
|
||||
console.log(chalk.red("validate ERROR"));
|
||||
}
|
||||
|
||||
if (isCreate) {
|
||||
@ -107,25 +117,25 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var expected;
|
||||
try {
|
||||
var expected = fs.readFileSync(__dirname + "/compiler/" + fixture + ".wast", { encoding: "utf8" });
|
||||
var diffs = diff(filename + ".wast", expected, actual);
|
||||
if (diffs !== null) {
|
||||
process.exitCode = 1;
|
||||
console.log(diffs);
|
||||
console.log(chalk.default.red("diff ERROR"));
|
||||
} else {
|
||||
console.log(chalk.default.green("diff OK"));
|
||||
}
|
||||
expected = fs.readFileSync(__dirname + "/compiler/" + fixture + ".wast", { encoding: "utf8" });
|
||||
} catch (e) {
|
||||
process.exitCode = 1;
|
||||
console.log(e.message);
|
||||
console.log(chalk.default.red("diff ERROR"));
|
||||
expected = e.message + "\n";
|
||||
}
|
||||
var diffs = diff(filename + ".wast", expected, actual);
|
||||
if (diffs !== null) {
|
||||
console.log(diffs);
|
||||
console.log(chalk.red("diff ERROR"));
|
||||
failed = true;
|
||||
} else
|
||||
console.log(chalk.green("diff OK"));
|
||||
}
|
||||
|
||||
module.dispose();
|
||||
console.log();
|
||||
if (failed)
|
||||
++failures;
|
||||
});
|
||||
|
||||
function elements(map) {
|
||||
@ -135,3 +145,9 @@ function elements(map) {
|
||||
});
|
||||
return arr.join("\n ");
|
||||
}
|
||||
|
||||
if (failures) {
|
||||
process.exitCode = 1;
|
||||
console.log(chalk.red("ERROR: ") + failures + " compiler tests failed");
|
||||
} else
|
||||
console.log(chalk.whiteBright("SUCCESS"));
|
||||
|
@ -4,6 +4,18 @@
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(nop)
|
||||
(local $0 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $0)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -1,3 +1,11 @@
|
||||
assert(true);
|
||||
assert(1 == 1);
|
||||
assert(1);
|
||||
assert(1 > 0);
|
||||
assert(0.5);
|
||||
assert(0.5 > 0.4);
|
||||
assert(0x100000000);
|
||||
assert(0x100000000 > 1);
|
||||
|
||||
// can be used as an expression
|
||||
if (!assert(true, "must be true"))
|
||||
unreachable();
|
||||
|
@ -5,6 +5,7 @@
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.const 1)
|
||||
@ -13,13 +14,26 @@
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.gt_s
|
||||
(i32.const 1)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.eq
|
||||
(f64.const 0.5)
|
||||
(f64.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(f64.gt
|
||||
@ -29,6 +43,35 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i64.eqz
|
||||
(i64.const 4294967296)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.gt_s
|
||||
(i64.const 4294967296)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(i32.eqz
|
||||
(tee_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
@ -59,8 +102,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -844,8 +844,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -65,14 +65,14 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const -42)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(tee_local $2
|
||||
(i32.const -42)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.lt_s
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -144,14 +144,14 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(tee_local $4
|
||||
(i64.const -42)
|
||||
)
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $4
|
||||
(i64.const -42)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(get_local $4)
|
||||
(i64.lt_s
|
||||
(i64.gt_s
|
||||
(get_local $4)
|
||||
(i64.const 0)
|
||||
)
|
||||
|
@ -77,17 +77,17 @@
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(i32.lt_s
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -150,17 +150,17 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(i32.lt_s
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -250,17 +250,17 @@
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $2
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
(tee_local $2
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i64.lt_s
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i64.gt_s
|
||||
(get_local $2)
|
||||
(i64.const 0)
|
||||
)
|
||||
@ -295,17 +295,17 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $2
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
(tee_local $2
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(i64.lt_s
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i64.gt_s
|
||||
(get_local $2)
|
||||
(i64.const 0)
|
||||
)
|
||||
@ -1370,8 +1370,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -53,8 +53,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -25,8 +25,8 @@ export function test(animal: Animal<f64>): Animal<f64> {
|
||||
animal.three;
|
||||
|
||||
animal.one = 0 + 1;
|
||||
animal.two = 1 + 1;
|
||||
animal.three = 1 + 1 + 1;
|
||||
animal.two = 1 + 1; // checks overflow
|
||||
animal.three = 1 + 1 + 1; // checks overflow (once)
|
||||
|
||||
var ptr = changetype<usize>(animal);
|
||||
var cls = changetype<Animal<f64>>(ptr);
|
||||
|
@ -100,19 +100,31 @@
|
||||
)
|
||||
(i32.store16 offset=4
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=6
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 1)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(block
|
||||
@ -184,8 +196,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -47,18 +47,10 @@
|
||||
(unreachable)
|
||||
)
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $comma/a)
|
||||
)
|
||||
(set_global $comma/a
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $comma/a
|
||||
(i32.add
|
||||
(get_global $comma/a)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $comma/b
|
||||
@ -93,18 +85,10 @@
|
||||
)
|
||||
(set_global $comma/b
|
||||
(block (result i32)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $comma/a)
|
||||
)
|
||||
(set_global $comma/a
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $comma/a
|
||||
(i32.add
|
||||
(get_global $comma/a)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_global $comma/a)
|
||||
@ -130,18 +114,10 @@
|
||||
)
|
||||
(set_global $comma/a
|
||||
(block (result i32)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $comma/a)
|
||||
)
|
||||
(set_global $comma/a
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $comma/a
|
||||
(i32.add
|
||||
(get_global $comma/a)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block (result i32)
|
||||
@ -185,32 +161,16 @@
|
||||
(block
|
||||
(nop)
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $comma/a)
|
||||
)
|
||||
(set_global $comma/a
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $comma/a
|
||||
(i32.sub
|
||||
(get_global $comma/a)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -269,8 +229,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -47,8 +47,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -12,32 +12,16 @@
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $do/n)
|
||||
)
|
||||
(set_global $do/n
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $do/n
|
||||
(i32.sub
|
||||
(get_global $do/n)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $do/m)
|
||||
)
|
||||
(set_global $do/m
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $do/m
|
||||
(i32.add
|
||||
(get_global $do/m)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -107,63 +91,31 @@
|
||||
(block $break|2
|
||||
(loop $continue|2
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $do/n)
|
||||
)
|
||||
(set_global $do/n
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $do/n
|
||||
(i32.sub
|
||||
(get_global $do/n)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $do/m)
|
||||
)
|
||||
(set_global $do/m
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $do/m
|
||||
(i32.add
|
||||
(get_global $do/m)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block $break|3
|
||||
(loop $continue|3
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $do/n)
|
||||
)
|
||||
(set_global $do/n
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $do/n
|
||||
(i32.sub
|
||||
(get_global $do/n)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $do/o)
|
||||
)
|
||||
(set_global $do/o
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $do/o
|
||||
(i32.add
|
||||
(get_global $do/o)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -253,8 +205,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -31,8 +31,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -76,8 +76,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -64,8 +64,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -174,14 +174,14 @@
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -231,14 +231,14 @@
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $5)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -372,14 +372,14 @@
|
||||
)
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -188,14 +188,14 @@
|
||||
(set_local $2
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -265,14 +265,14 @@
|
||||
(set_local $3
|
||||
(i64.shl
|
||||
(get_local $3)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $5)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -348,18 +348,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $8
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $8)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $8)
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|2)
|
||||
@ -455,14 +447,14 @@
|
||||
(set_local $2
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -1076,8 +1068,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -175,8 +175,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -193,8 +193,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -87,28 +87,39 @@
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(tee_local $2
|
||||
(select
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $6)
|
||||
(get_local $1)
|
||||
(i32.add
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(tee_local $2
|
||||
(select
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $6)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -118,29 +129,29 @@
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $1)
|
||||
(tee_local $7
|
||||
(select
|
||||
(i32.const 0)
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(tee_local $7
|
||||
(select
|
||||
(i32.const 0)
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -150,17 +161,17 @@
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $7)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -170,7 +181,7 @@
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -180,19 +191,11 @@
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $1)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(if
|
||||
|
@ -133,20 +133,31 @@
|
||||
)
|
||||
(block
|
||||
(set_local $8
|
||||
(i32.add
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
(i32.add
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
@ -155,17 +166,17 @@
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $5)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $7)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -175,17 +186,17 @@
|
||||
(get_local $2)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $6)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $7)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -195,7 +206,7 @@
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -205,19 +216,11 @@
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $5)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $4)
|
||||
(get_global $../../examples/game-of-life/assembly/game-of-life/w)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -334,8 +337,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -83,8 +83,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -1217,8 +1217,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -74,8 +74,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -72,8 +72,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -1,10 +1,10 @@
|
||||
const i = 10;
|
||||
const i = 10; // infers i32 because
|
||||
i;
|
||||
|
||||
const I = 0x100000000;
|
||||
const I = 0x100000000; // infers i64 because the value doesn't fit into 32 bits
|
||||
I;
|
||||
|
||||
const F = 1.5;
|
||||
const F = 1.5; // infers f64 because of float notation
|
||||
F;
|
||||
|
||||
function locals(): void {
|
||||
|
@ -168,8 +168,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -56,8 +56,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -135,8 +135,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -167,8 +167,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -253,8 +253,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -64,18 +64,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $7
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $7)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $7)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2079,8 +2071,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -62,8 +62,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -357,8 +357,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -60,8 +60,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -77,8 +77,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
731
tests/compiler/retain-i32.optimized.wast
Normal file
731
tests/compiler/retain-i32.optimized.wast
Normal file
@ -0,0 +1,731 @@
|
||||
(module
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $v (func))
|
||||
(global $retain-i32/si (mut i32) (i32.const 0))
|
||||
(global $retain-i32/ui (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $retain-i32/test (; 0 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.sub
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.mul
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.and
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.or
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.or
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.xor
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.xor
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.sub
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.mul
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.or
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.xor
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(call $retain-i32/test
|
||||
(i32.const 0)
|
||||
(i32.const 127)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 127)
|
||||
(i32.const 0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 1)
|
||||
(i32.const 127)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 127)
|
||||
(i32.const 1)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -1)
|
||||
(i32.const 127)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 127)
|
||||
(i32.const -1)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 0)
|
||||
(i32.const -128)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -128)
|
||||
(i32.const 0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 1)
|
||||
(i32.const -128)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -128)
|
||||
(i32.const 1)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -1)
|
||||
(i32.const -128)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -128)
|
||||
(i32.const -1)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 127)
|
||||
(i32.const 127)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -128)
|
||||
(i32.const -128)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 127)
|
||||
(i32.const -128)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -128)
|
||||
(i32.const 127)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 255)
|
||||
(i32.const 0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 1)
|
||||
(i32.const 255)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 255)
|
||||
(i32.const 1)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -1)
|
||||
(i32.const 255)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 255)
|
||||
(i32.const -1)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 255)
|
||||
(i32.const 255)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const -128)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.le_s
|
||||
(get_local $0)
|
||||
(i32.const 255)
|
||||
)
|
||||
(block
|
||||
(call $retain-i32/test
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 1)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -1)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -128)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 127)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 255)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -32768)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 32767)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 65535)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const 2147483647)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -2147483648)
|
||||
(get_local $0)
|
||||
)
|
||||
(call $retain-i32/test
|
||||
(i32.const -1)
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const -1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const -1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const -1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const -1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const -2)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const -2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const -128)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const -128)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const -128)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const -128)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const -127)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const -127)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const -128)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const -128)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const 1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const 1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const 0)
|
||||
)
|
||||
(if
|
||||
(get_global $retain-i32/si)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/si
|
||||
(i32.const 1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/si)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/ui
|
||||
(i32.const 255)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/ui)
|
||||
(i32.const 255)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/ui
|
||||
(i32.const 255)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/ui)
|
||||
(i32.const 255)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/ui
|
||||
(i32.const 254)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/ui)
|
||||
(i32.const 254)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/ui
|
||||
(i32.const 1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/ui)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/ui
|
||||
(i32.const 1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/ui)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/ui
|
||||
(i32.const 1)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $retain-i32/ui)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $retain-i32/ui
|
||||
(i32.const 0)
|
||||
)
|
||||
(if
|
||||
(get_global $retain-i32/ui)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
131
tests/compiler/retain-i32.ts
Normal file
131
tests/compiler/retain-i32.ts
Normal file
@ -0,0 +1,131 @@
|
||||
function test(a: i32, b: i32): void {
|
||||
|
||||
// signed
|
||||
assert(<i8>(a + b) == <i8>(<i8>a + <i8>b));
|
||||
assert(<i8>(a - b) == <i8>(<i8>a - <i8>b));
|
||||
assert(<i8>(a * b) == <i8>(<i8>a * <i8>b));
|
||||
assert(<i8>(a & b) == <i8>(<i8>a & <i8>b));
|
||||
assert(<i8>(a | b) == <i8>(<i8>a | <i8>b));
|
||||
assert(<i8>(a ^ b) == <i8>(<i8>a ^ <i8>b));
|
||||
assert(<i8>(a << b) == <i8>(<i8>a << <i8>b));
|
||||
|
||||
// unsigned
|
||||
assert(<u8>(a + b) == <u8>(<u8>a + <u8>b));
|
||||
assert(<u8>(a - b) == <u8>(<u8>a - <u8>b));
|
||||
assert(<u8>(a * b) == <u8>(<u8>a * <u8>b));
|
||||
assert(<u8>(a & b) == <u8>(<u8>a & <u8>b));
|
||||
assert(<u8>(a | b) == <u8>(<u8>a | <u8>b));
|
||||
assert(<u8>(a ^ b) == <u8>(<u8>a ^ <u8>b));
|
||||
assert(<u8>(a << b) == <u8>(<u8>a << <u8>b));
|
||||
}
|
||||
|
||||
// signed
|
||||
test(0, i8.MAX_VALUE);
|
||||
test(i8.MAX_VALUE, 0);
|
||||
|
||||
test(1, i8.MAX_VALUE);
|
||||
test(i8.MAX_VALUE, 1);
|
||||
|
||||
test(-1, i8.MAX_VALUE);
|
||||
test(i8.MAX_VALUE, -1);
|
||||
|
||||
test(0, i8.MIN_VALUE);
|
||||
test(i8.MIN_VALUE, 0);
|
||||
|
||||
test(1, i8.MIN_VALUE);
|
||||
test(i8.MIN_VALUE, 1);
|
||||
|
||||
test(-1, i8.MIN_VALUE);
|
||||
test(i8.MIN_VALUE, -1);
|
||||
|
||||
test(i8.MAX_VALUE, i8.MAX_VALUE);
|
||||
test(i8.MIN_VALUE, i8.MIN_VALUE);
|
||||
test(i8.MAX_VALUE, i8.MIN_VALUE);
|
||||
test(i8.MIN_VALUE, i8.MAX_VALUE);
|
||||
|
||||
// unsigned
|
||||
test(0, u8.MAX_VALUE);
|
||||
test(u8.MAX_VALUE, 0);
|
||||
|
||||
test(1, u8.MAX_VALUE);
|
||||
test(u8.MAX_VALUE, 1);
|
||||
|
||||
test(-1, u8.MAX_VALUE);
|
||||
test(u8.MAX_VALUE, -1);
|
||||
|
||||
test(u8.MAX_VALUE, u8.MAX_VALUE);
|
||||
|
||||
// various
|
||||
for (var i: i32 = i8.MIN_VALUE; i <= u8.MAX_VALUE; ++i) {
|
||||
test(0, i);
|
||||
test(1, i);
|
||||
test(-1, i);
|
||||
test(i8.MIN_VALUE, i);
|
||||
test(i8.MAX_VALUE, i);
|
||||
test(u8.MAX_VALUE, i);
|
||||
test(i16.MIN_VALUE, i);
|
||||
test(i16.MAX_VALUE, i);
|
||||
test(u16.MAX_VALUE, i);
|
||||
test(i32.MAX_VALUE, i);
|
||||
test(i32.MIN_VALUE, i);
|
||||
test(u32.MAX_VALUE, i);
|
||||
}
|
||||
|
||||
// visually
|
||||
var si: i8;
|
||||
|
||||
si = 127 + 127 + 1; // sign-extends exactly once
|
||||
assert(si == -1);
|
||||
|
||||
si = 127 - 1 - 127; // sign-extends exactly once
|
||||
assert(si == -1);
|
||||
|
||||
si = 127 * 2; // sign-extends exactly once
|
||||
assert(si == -2);
|
||||
|
||||
si = -(-128); // -MIN_VALUE == MIN_VALUE
|
||||
assert(si == -128);
|
||||
|
||||
si = -128 * -1; // -MIN_VALUE == MIN_VALUE
|
||||
assert(si == -128);
|
||||
|
||||
si = 127 / -1;
|
||||
assert(si == -127);
|
||||
|
||||
si = -128 / -1; // -MIN_VALUE == MIN_VALUE
|
||||
assert(si == -128);
|
||||
|
||||
si = 127 % 2;
|
||||
assert(si == 1);
|
||||
|
||||
si = 1 % 127;
|
||||
assert(si == 1);
|
||||
|
||||
si = -128 % 2;
|
||||
assert(si == 0);
|
||||
|
||||
si = 1 % -128;
|
||||
assert(si == 1);
|
||||
|
||||
var ui: u8;
|
||||
|
||||
ui = 255 + 255 + 1;
|
||||
assert(ui == 255);
|
||||
|
||||
ui = 255 - 1 - 255;
|
||||
assert(ui == 255);
|
||||
|
||||
ui = 255 * 2;
|
||||
assert(ui == 254);
|
||||
|
||||
ui = 255 * 255;
|
||||
assert(ui == 1);
|
||||
|
||||
ui = 255 / 255;
|
||||
assert(ui == 1);
|
||||
|
||||
ui = 255 % 2;
|
||||
assert(ui == 1);
|
||||
|
||||
ui = 255 % 255;
|
||||
assert(ui == 0);
|
1185
tests/compiler/retain-i32.wast
Normal file
1185
tests/compiler/retain-i32.wast
Normal file
File diff suppressed because it is too large
Load Diff
@ -1806,14 +1806,14 @@
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -1863,14 +1863,14 @@
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $5)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2004,14 +2004,14 @@
|
||||
)
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -3443,14 +3443,14 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const -42)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(tee_local $2
|
||||
(i32.const -42)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.lt_s
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3522,14 +3522,14 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(tee_local $3
|
||||
(i64.const -42)
|
||||
)
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $3
|
||||
(i64.const -42)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $3)
|
||||
(i64.lt_s
|
||||
(i64.gt_s
|
||||
(get_local $3)
|
||||
(i64.const 0)
|
||||
)
|
||||
|
@ -1827,14 +1827,14 @@
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -1884,14 +1884,14 @@
|
||||
)
|
||||
(i64.shl
|
||||
(get_local $5)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2025,14 +2025,14 @@
|
||||
)
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -3465,14 +3465,14 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const -42)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(tee_local $2
|
||||
(i32.const -42)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(get_local $2)
|
||||
(i32.lt_s
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3544,14 +3544,14 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(tee_local $3
|
||||
(i64.const -42)
|
||||
)
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $3
|
||||
(i64.const -42)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $3)
|
||||
(i64.lt_s
|
||||
(i64.gt_s
|
||||
(get_local $3)
|
||||
(i64.const 0)
|
||||
)
|
||||
|
@ -172,18 +172,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $7
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $7)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $7)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2114,14 +2106,14 @@
|
||||
(set_local $2
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2191,14 +2183,14 @@
|
||||
(set_local $3
|
||||
(i64.shl
|
||||
(get_local $3)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $5)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2274,18 +2266,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $8
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $8)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $8)
|
||||
(set_local $4
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|2)
|
||||
@ -2381,14 +2365,14 @@
|
||||
(set_local $2
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.add
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.extend_u/i32
|
||||
(i64.extend_u/i32
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2943,32 +2927,16 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
@ -3093,32 +3061,16 @@
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i64)
|
||||
(set_local $1
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i64)
|
||||
(set_local $1
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
@ -3132,8 +3084,8 @@
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.extend_s/i32
|
||||
(i32.eqz
|
||||
(i32.const 1)
|
||||
(i64.eqz
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -3241,32 +3193,16 @@
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(set_local $2
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_local $2)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(set_local $2
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_local $2)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
@ -3373,32 +3309,16 @@
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f64)
|
||||
(set_local $3
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_local $3)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f64)
|
||||
(set_local $3
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_local $3)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
@ -4528,17 +4448,17 @@
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(i32.lt_s
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -4601,17 +4521,17 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(i32.lt_s
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -4701,17 +4621,17 @@
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $1
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
(tee_local $1
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i64.lt_s
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i64.gt_s
|
||||
(get_local $1)
|
||||
(i64.const 0)
|
||||
)
|
||||
@ -4746,17 +4666,17 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(tee_local $1
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
(tee_local $1
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(i64.const 42)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i64.lt_s
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_local $1)
|
||||
)
|
||||
(i64.gt_s
|
||||
(get_local $1)
|
||||
(i64.const 0)
|
||||
)
|
||||
@ -6319,8 +6239,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -31,8 +31,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
@ -73,12 +71,16 @@
|
||||
FUNCTION_PROTOTYPE: std:heap/Heap.compare
|
||||
CLASS_PROTOTYPE: std:map/Map
|
||||
CLASS_PROTOTYPE: Map
|
||||
CLASS_PROTOTYPE: std:regexp/RegExp
|
||||
CLASS_PROTOTYPE: RegExp
|
||||
CLASS_PROTOTYPE: std:set/Set
|
||||
CLASS_PROTOTYPE: Set
|
||||
GLOBAL: std:string/EMPTY
|
||||
CLASS_PROTOTYPE: std:string/String
|
||||
CLASS_PROTOTYPE: String
|
||||
FUNCTION_PROTOTYPE: std:string/isWhiteSpaceOrLineTerminator
|
||||
FUNCTION_PROTOTYPE: std:string/parseInt
|
||||
FUNCTION_PROTOTYPE: std:string/parseFloat
|
||||
[program.exports]
|
||||
CLASS_PROTOTYPE: std:array/Array
|
||||
CLASS_PROTOTYPE: std:array/CArray
|
||||
@ -88,4 +90,6 @@
|
||||
CLASS_PROTOTYPE: std:map/Map
|
||||
CLASS_PROTOTYPE: std:set/Set
|
||||
CLASS_PROTOTYPE: std:string/String
|
||||
FUNCTION_PROTOTYPE: std:string/parseInt
|
||||
FUNCTION_PROTOTYPE: std:string/parseFloat
|
||||
;)
|
||||
|
@ -565,18 +565,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $6
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $6)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $6)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2330,7 +2322,6 @@
|
||||
)
|
||||
)
|
||||
(func $std:heap/Heap.compare (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
@ -2357,46 +2348,22 @@
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $3
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $3
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2580,8 +2547,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
@ -2622,12 +2587,16 @@
|
||||
FUNCTION_PROTOTYPE: std:heap/Heap.compare
|
||||
CLASS_PROTOTYPE: std:map/Map
|
||||
CLASS_PROTOTYPE: Map
|
||||
CLASS_PROTOTYPE: std:regexp/RegExp
|
||||
CLASS_PROTOTYPE: RegExp
|
||||
CLASS_PROTOTYPE: std:set/Set
|
||||
CLASS_PROTOTYPE: Set
|
||||
GLOBAL: std:string/EMPTY
|
||||
CLASS_PROTOTYPE: std:string/String
|
||||
CLASS_PROTOTYPE: String
|
||||
FUNCTION_PROTOTYPE: std:string/isWhiteSpaceOrLineTerminator
|
||||
FUNCTION_PROTOTYPE: std:string/parseInt
|
||||
FUNCTION_PROTOTYPE: std:string/parseFloat
|
||||
GLOBAL: std/heap/size
|
||||
GLOBAL: std/heap/ptr1
|
||||
GLOBAL: std/heap/ptr2
|
||||
@ -2641,4 +2610,6 @@
|
||||
CLASS_PROTOTYPE: std:map/Map
|
||||
CLASS_PROTOTYPE: std:set/Set
|
||||
CLASS_PROTOTYPE: std:string/String
|
||||
FUNCTION_PROTOTYPE: std:string/parseInt
|
||||
FUNCTION_PROTOTYPE: std:string/parseFloat
|
||||
;)
|
||||
|
@ -173,8 +173,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -86,8 +86,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -364,8 +364,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -43,8 +43,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -79,32 +79,16 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(get_global $unary/i)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
@ -229,32 +213,16 @@
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i64)
|
||||
(set_local $1
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(set_global $unary/I
|
||||
(i64.add
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i64)
|
||||
(set_local $1
|
||||
(get_global $unary/I)
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_local $1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(set_global $unary/I
|
||||
(i64.sub
|
||||
(get_global $unary/I)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
@ -268,8 +236,8 @@
|
||||
)
|
||||
(set_global $unary/I
|
||||
(i64.extend_s/i32
|
||||
(i32.eqz
|
||||
(i32.const 1)
|
||||
(i64.eqz
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -377,32 +345,16 @@
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(set_local $2
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_local $2)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(set_global $unary/f
|
||||
(f32.add
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(set_local $2
|
||||
(get_global $unary/f)
|
||||
)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_local $2)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(set_global $unary/f
|
||||
(f32.sub
|
||||
(get_global $unary/f)
|
||||
(f32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/f
|
||||
@ -509,32 +461,16 @@
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f64)
|
||||
(set_local $3
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_local $3)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f64)
|
||||
(set_local $3
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_local $3)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(get_global $unary/F)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
@ -649,8 +585,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -15,32 +15,16 @@
|
||||
(get_global $while/n)
|
||||
(block
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $while/n)
|
||||
)
|
||||
(set_global $while/n
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $while/n
|
||||
(i32.sub
|
||||
(get_global $while/n)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $while/m)
|
||||
)
|
||||
(set_global $while/m
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $while/m
|
||||
(i32.add
|
||||
(get_global $while/m)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -79,32 +63,16 @@
|
||||
(get_global $while/n)
|
||||
(block
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $while/n)
|
||||
)
|
||||
(set_global $while/n
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $while/n
|
||||
(i32.sub
|
||||
(get_global $while/n)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $while/m)
|
||||
)
|
||||
(set_global $while/m
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $while/m
|
||||
(i32.add
|
||||
(get_global $while/m)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block $break|2
|
||||
@ -113,32 +81,16 @@
|
||||
(get_global $while/n)
|
||||
(block
|
||||
(block
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $while/n)
|
||||
)
|
||||
(set_global $while/n
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $while/n
|
||||
(i32.sub
|
||||
(get_global $while/n)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(set_local $0
|
||||
(get_global $while/o)
|
||||
)
|
||||
(set_global $while/o
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(set_global $while/o
|
||||
(i32.add
|
||||
(get_global $while/o)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -291,8 +243,6 @@
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
|
@ -10,6 +10,7 @@ var Parser = require("../src/parser").Parser;
|
||||
|
||||
var isCreate = process.argv[2] === "--create";
|
||||
var filter = process.argv.length > 2 && !isCreate ? "*" + process.argv[2] + "*.ts" : "**.ts";
|
||||
var failures = 0;
|
||||
|
||||
glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => {
|
||||
if (filename.charAt(0) == "_" || filename.endsWith(".fixture.ts"))
|
||||
@ -17,6 +18,7 @@ glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => {
|
||||
|
||||
console.log(chalk.default.whiteBright("Testing parser/" + filename));
|
||||
|
||||
var failed = false;
|
||||
var parser = new Parser();
|
||||
parser.silentDiagnostics = true;
|
||||
var sourceText = fs.readFileSync(__dirname + "/parser/" + filename, { encoding: "utf8" }).replace(/\r?\n/g, "\n").replace(/^\/\/.*\r?\n/mg, "");
|
||||
@ -34,7 +36,7 @@ glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => {
|
||||
var expected = fs.readFileSync(__dirname + "/parser/" + fixture, { encoding: "utf8" });
|
||||
var diffs = diff("parser/" + fixture, expected, actual);
|
||||
if (diffs !== null) {
|
||||
process.exitCode = 1;
|
||||
failed = true;
|
||||
console.log(diffs);
|
||||
console.log(chalk.default.red("diff ERROR"));
|
||||
} else {
|
||||
@ -43,4 +45,12 @@ glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => {
|
||||
}
|
||||
|
||||
console.log();
|
||||
if (failed)
|
||||
++failures;
|
||||
});
|
||||
|
||||
if (failures) {
|
||||
process.exitCode = 1;
|
||||
console.log(chalk.red("ERROR: ") + failures + " parser tests failed");
|
||||
} else
|
||||
console.log(chalk.whiteBright("SUCCESS"));
|
||||
|
@ -2,7 +2,7 @@ var JsDiff = require("diff");
|
||||
var chalk = require("chalk");
|
||||
|
||||
module.exports = function diff(filename, expected, actual) {
|
||||
var diff = JsDiff.structuredPatch(filename, filename, expected, actual, "expected", "actual", { context: 2 });
|
||||
var diff = JsDiff.structuredPatch(filename, filename, expected, actual, "expected", "actual", { context: 5 });
|
||||
if (!diff.hunks.length)
|
||||
return null;
|
||||
|
||||
|
Reference in New Issue
Block a user