Builtins rewrite with type parameter inference; Small integer math optimizations; Switchify

This commit is contained in:
dcodeIO 2018-01-10 13:09:05 +01:00
parent 0de05b543b
commit fc777b3a89
64 changed files with 4894 additions and 1620 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -11,6 +11,7 @@ export enum DiagnosticCode {
Structs_cannot_extend_classes_and_vice_versa = 107, Structs_cannot_extend_classes_and_vice_versa = 107,
Structs_cannot_implement_interfaces = 108, Structs_cannot_implement_interfaces = 108,
Invalid_regular_expression_flags = 109, Invalid_regular_expression_flags = 109,
Type_0_cannot_be_reinterpreted_as_type_1 = 110,
Unterminated_string_literal = 1002, Unterminated_string_literal = 1002,
Identifier_expected = 1003, Identifier_expected = 1003,
_0_expected = 1005, _0_expected = 1005,
@ -97,6 +98,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
case 107: return "Structs cannot extend classes and vice-versa."; case 107: return "Structs cannot extend classes and vice-versa.";
case 108: return "Structs cannot implement interfaces."; case 108: return "Structs cannot implement interfaces.";
case 109: return "Invalid regular expression flags."; case 109: return "Invalid regular expression flags.";
case 110: return "Type '{0}' cannot be reinterpreted as type '{1}'.";
case 1002: return "Unterminated string literal."; case 1002: return "Unterminated string literal.";
case 1003: return "Identifier expected."; case 1003: return "Identifier expected.";
case 1005: return "'{0}' expected."; case 1005: return "'{0}' expected.";

@ -9,6 +9,7 @@
"Structs cannot extend classes and vice-versa.": 107, "Structs cannot extend classes and vice-versa.": 107,
"Structs cannot implement interfaces.": 108, "Structs cannot implement interfaces.": 108,
"Invalid regular expression flags.": 109, "Invalid regular expression flags.": 109,
"Type '{0}' cannot be reinterpreted as type '{1}'.": 110,
"Unterminated string literal.": 1002, "Unterminated string literal.": 1002,
"Identifier expected.": 1003, "Identifier expected.": 1003,

@ -351,6 +351,8 @@ export class Range {
} }
} }
declare function parseFloat(str: string): f64;
export class Tokenizer extends DiagnosticEmitter { export class Tokenizer extends DiagnosticEmitter {
source: Source; source: Source;

@ -58,8 +58,10 @@ export class Type {
functionType: Function | null; functionType: Function | null;
/** Whether nullable or not. */ /** Whether nullable or not. */
isNullable: bool = false; isNullable: bool = false;
/** Respective nullable type, if nullable. */ /** Respective nullable type, if non-nullable. */
nullableType: Type | null = null; nullableType: Type | null = null;
/** Respective non-nullable type, if nullable. */
nonNullableType: Type;
/** Constructs a new resolved type. */ /** Constructs a new resolved type. */
constructor(kind: TypeKind, size: i32) { constructor(kind: TypeKind, size: i32) {
@ -67,6 +69,7 @@ export class Type {
this.size = size; this.size = size;
this.byteSize = <i32>ceil<f64>(<f64>size / 8); this.byteSize = <i32>ceil<f64>(<f64>size / 8);
this.classType = null; this.classType = null;
this.nonNullableType = this;
} }
/** Sign-extending 32-bit shift, if a small signed integer. */ /** Sign-extending 32-bit shift, if a small signed integer. */
@ -75,23 +78,157 @@ export class Type {
get smallIntegerMask(): i32 { return -1 >>> (32 - this.size); } get smallIntegerMask(): i32 { return -1 >>> (32 - this.size); }
/** Tests if this type is of any integer kind. */ /** Tests if this type is of any integer kind. */
get isAnyInteger(): bool { return this.kind >= TypeKind.I8 && this.kind <= TypeKind.BOOL; } get isAnyInteger(): bool {
/** Tests if this type is of any small integer kind. */ switch (this.kind) {
get isSmallInteger(): bool { return this.size != 0 && this.size < 32; } case TypeKind.I8:
/** Tests if this type is of any long integer kind. */ case TypeKind.I16:
get isLongInteger(): bool { return this.size == 64 && this.kind != TypeKind.F64; } case TypeKind.I32:
case TypeKind.I64:
case TypeKind.ISIZE:
case TypeKind.U8:
case TypeKind.U16:
case TypeKind.U32:
case TypeKind.U64:
case TypeKind.USIZE:
case TypeKind.BOOL:
return true;
default:
return false;
}
}
/** Tests if this type is of any unsigned integer kind. */ /** Tests if this type is of any unsigned integer kind. */
get isUnsignedInteger(): bool { return this.kind >= TypeKind.U8 && this.kind <= TypeKind.BOOL; } get isAnyUnsignedInteger(): bool {
switch (this.kind) {
case TypeKind.U8:
case TypeKind.U16:
case TypeKind.U32:
case TypeKind.U64:
case TypeKind.USIZE:
case TypeKind.BOOL:
return true;
default:
return false;
}
}
/** Tests if this type is of any signed integer kind. */ /** Tests if this type is of any signed integer kind. */
get isSignedInteger(): bool { return this.kind >= TypeKind.I8 && this.kind <= TypeKind.ISIZE; } get isAnySignedInteger(): bool {
/** Tests if this type is of any size kind, i.e., `isize` or `usize`. */ switch (this.kind) {
get isAnySize(): bool { return this.kind == TypeKind.ISIZE || this.kind == TypeKind.USIZE; } case TypeKind.I8:
case TypeKind.I16:
case TypeKind.I32:
case TypeKind.I64:
case TypeKind.ISIZE:
return true;
default:
return false;
}
}
/** Tests if this type is of any small integer kind. */
get isSmallInteger(): bool {
switch (this.kind) {
case TypeKind.I8:
case TypeKind.I16:
case TypeKind.U8:
case TypeKind.U16:
case TypeKind.BOOL:
return true;
default:
return false;
}
}
/** Tests if this type is of any small signed integer kind. */
get isSmallSignedInteger(): bool {
switch (this.kind) {
case TypeKind.I8:
case TypeKind.I16:
return true;
default:
return false;
}
}
/** Tests if this type is of any small unsigned integer kind. */
get isSmallUnsignedInteger(): bool {
switch (this.kind) {
case TypeKind.U8:
case TypeKind.U16:
case TypeKind.BOOL:
return true;
default:
return false;
}
}
/** Tests if this type is of any long integer kind. */
get isLongInteger(): bool {
switch (this.kind) {
case TypeKind.I64:
case TypeKind.U64:
return true;
case TypeKind.ISIZE:
case TypeKind.USIZE:
return this.size == 64;
default:
return false;
}
}
/** Tests if this type is of any long signed integer kind. */
get isLongSignedInteger(): bool {
switch (this.kind) {
case TypeKind.I64:
return true;
case TypeKind.ISIZE:
return this.size == 64;
default:
return false;
}
}
/** Tests if this type is of any long unsigned integer kind. */
get isLongUnsignedInteger(): bool {
switch (this.kind) {
case TypeKind.U64:
return true;
case TypeKind.USIZE:
return this.size == 64;
default:
return false;
}
}
/** Tests if this type is of any size kind, that is `isize` or `usize`. */
get isAnySize(): bool {
switch (this.kind) {
case TypeKind.ISIZE:
case TypeKind.USIZE:
return true;
default:
return false;
}
}
/** Tests if this type is of any float kind, i.e., `f32` or `f64`. */ /** Tests if this type is of any float kind, i.e., `f32` or `f64`. */
get isAnyFloat(): bool { return this.kind == TypeKind.F32 || this.kind == TypeKind.F64; } get isAnyFloat(): bool {
switch (this.kind) {
case TypeKind.F32:
case TypeKind.F64:
return true;
default:
return false;
}
}
/** Tests if this type is a class type. */ /** Tests if this type is a class type. */
get isClass(): bool { return this.classType != null; } get isClass(): bool { return this.classType != null; }
/** Tests if this type is a function type. */ /** Tests if this type is a function type. */
get isFunction(): bool { return this.functionType != null; } get isFunction(): bool { return this.functionType != null; }
/** Tests if this type is a reference type. */
get isReference(): bool { return this.classType != null || this.functionType != null; }
/** Composes a class type from this type and a class. */ /** Composes a class type from this type and a class. */
asClass(classType: Class): Type { asClass(classType: Class): Type {
@ -103,7 +240,7 @@ export class Type {
/** Composes a function type from this type and a function. */ /** Composes a function type from this type and a function. */
asFunction(functionType: Function): Type { asFunction(functionType: Function): Type {
assert(this.kind == TypeKind.USIZE); assert(this.kind == TypeKind.USIZE && !this.isReference);
var ret = new Type(this.kind, this.size); var ret = new Type(this.kind, this.size);
ret.functionType = functionType; ret.functionType = functionType;
return ret; return ret;
@ -111,9 +248,12 @@ export class Type {
/** Composes the respective nullable type of this type. */ /** Composes the respective nullable type of this type. */
asNullable(): Type | null { asNullable(): Type | null {
assert(this.kind == TypeKind.USIZE); assert(this.kind == TypeKind.USIZE && !this.isReference);
if (this.isNullable && !this.nullableType) if (this.isNullable && !this.nullableType) {
(this.nullableType = new Type(this.kind, this.size)).isNullable = true; (this.nullableType = new Type(this.kind, this.size)).isNullable = true;
this.nullableType.classType = this.classType;
this.nullableType.functionType = this.functionType;
}
return this.nullableType; return this.nullableType;
} }
@ -226,6 +366,34 @@ export class Type {
} }
} }
/** Converts this type to its native `-1` value. */
toNativeNegOne(module: Module): ExpressionRef {
switch (this.kind) {
case TypeKind.VOID:
assert(false);
default:
return module.createI32(-1);
case TypeKind.ISIZE:
case TypeKind.USIZE:
if (this.size != 64)
return module.createI32(-1);
// fall-through
case TypeKind.I64:
case TypeKind.U64:
return module.createI64(-1, -1);
case TypeKind.F32:
return module.createF32(-1);
case TypeKind.F64:
return module.createF64(-1);
}
}
/** Converts this type to its signature string. */ /** Converts this type to its signature string. */
toSignatureString(): string { toSignatureString(): string {
switch (this.kind) { switch (this.kind) {

6
std/assembly.d.ts vendored

@ -173,14 +173,14 @@ declare const Infinity: f32 | f64;
declare const HEAP_BASE: usize; declare const HEAP_BASE: usize;
/** Determines the byte size of the specified core or class type. Compiles to a constant. */ /** Determines the byte size of the specified core or class type. Compiles to a constant. */
declare function sizeof<T>(): usize; declare function sizeof<T>(): usize;
/** Changes the type of a value to another one. Useful for casting class instances to their pointer values and vice-versa. */ /** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/
declare function changetype<T>(value: any): T; declare function changetype<T>(value: any): T;
/** Tests if a 32-bit or 64-bit float is `NaN`. */ /** Tests if a 32-bit or 64-bit float is `NaN`. */
declare function isNaN<T = f32 | f64>(value: T): bool; declare function isNaN<T = f32 | f64>(value: T): bool;
/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */ /** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */
declare function isFinite<T = f32 | f64>(value: T): bool; declare function isFinite<T = f32 | f64>(value: T): bool;
/** Traps if the specified value evaluates to `false`. */ /** Traps if the specified value is not true-ish, otherwise returns the value. */
declare function assert(isTrue: bool, message?: string): void; declare function assert<T>(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?
/** Parses an integer string to a 64-bit float. */ /** Parses an integer string to a 64-bit float. */
declare function parseInt(str: string, radix?: i32): f64; declare function parseInt(str: string, radix?: i32): f64;
/** Parses a string to a 64-bit float. */ /** Parses a string to a 64-bit float. */

13
std/assembly/regexp.ts Normal file

@ -0,0 +1,13 @@
@global
class RegExp {
// @binding(CALL_NEW, [ STRING, STRING], OBJECT_HANDLE)
constructor(pattern: string, flags: string = "") { throw new Error("unreachable"); }
// @binding(CALL_THIS, [ STRING ], PASS_THRU)
test(search: string): bool { throw new Error("unreachable"); }
// @binding(CALL_THIS, [], STRING)
toString(): string { throw new Error("unreachable"); }
}

@ -196,3 +196,15 @@ function isWhiteSpaceOrLineTerminator(c: u16): bool {
return false; return false;
} }
} }
// @global
// @binding(CALL, [ STRING, PASS_THRU ], PASS_THRU)
export function parseInt(str: string, radix: i32 = 10): f64 {
throw new Error("not implemented");
}
// @global
// @binding(CALL, [ STRING ], PASS_THRU)
export function parseFloat(str: string): f64 {
throw new Error("not implemented");
}

6
std/portable.d.ts vendored

@ -123,10 +123,10 @@ declare function store<T = u8>(offset: usize, value: T): void;
/** Emits an unreachable operation that results in a runtime error when executed. */ /** Emits an unreachable operation that results in a runtime error when executed. */
declare function unreachable(): any; // sic declare function unreachable(): any; // sic
/** Changes the type of a value to another one. Useful for casting class instances to their pointer values and vice-versa. */ /** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/
declare function changetype<T>(value: any): T; declare function changetype<T>(value: any): T;
/** Traps if the specified value evaluates to `false`. */ /** Traps if the specified value is not true-ish, otherwise returns the value. */
declare function assert(isTrue: bool, message?: string): void; declare function assert<T>(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?
/** Parses an integer string to a 64-bit float. */ /** Parses an integer string to a 64-bit float. */
declare function parseInt(str: string, radix?: i32): f64; declare function parseInt(str: string, radix?: i32): f64;
/** Parses a floating point string to a 64-bit float. */ /** Parses a floating point string to a 64-bit float. */

@ -93,7 +93,7 @@ function AssertionError(message) {
AssertionError.prototype = Object.create(Error.prototype); AssertionError.prototype = Object.create(Error.prototype);
AssertionError.prototype.name = "AssertionError"; AssertionError.prototype.name = "AssertionError";
globalScope["assert"] = function assert(isTrue, message) { if (!isTrue) throw new AssertionError(message); }; globalScope["assert"] = function assert(isTrueish, message) { if (isTrueish) return isTrueish; throw new AssertionError(message); };
globalScope["changetype"] = function changetype(value) { return value; } globalScope["changetype"] = function changetype(value) { return value; }
String["fromCharCodes"] = function fromCharCodes(arr) { return String.fromCharCode.apply(String, arr); } String["fromCharCodes"] = function fromCharCodes(arr) { return String.fromCharCode.apply(String, arr); }

@ -17,13 +17,17 @@ var filter = process.argv.length > 2 && !isCreate ? "**/" + process.argv[2] + ".
var stdFiles = glob.sync("*.ts", { cwd: __dirname + "/../std/assembly" }); var stdFiles = glob.sync("*.ts", { cwd: __dirname + "/../std/assembly" });
var success = 0;
var failures = 0;
glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => { glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
if (filename.charAt(0) == "_") if (filename.charAt(0) == "_")
return; return;
console.log(chalk.default.whiteBright("Testing compiler/" + filename)); console.log(chalk.whiteBright("Testing compiler/" + filename));
var fixture = path.basename(filename, ".ts"); var fixture = path.basename(filename, ".ts");
var startTime = process.hrtime();
var parser = new Parser(); var parser = new Parser();
if (filename.startsWith("std/")) { if (filename.startsWith("std/")) {
stdFiles.forEach(file => { stdFiles.forEach(file => {
@ -45,18 +49,24 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
parser.parseFile(nextSourceText, nextFile, false); parser.parseFile(nextSourceText, nextFile, false);
} }
var program = parser.finish(); var program = parser.finish();
var parseTime = process.hrtime(startTime);
startTime = process.hrtime();
var module = Compiler.compile(program); var module = Compiler.compile(program);
var compileTime = process.hrtime(startTime);
var actual = module.toText() + "(;\n[program.elements]\n " + elements(program.elements) var actual = module.toText() + "(;\n[program.elements]\n " + elements(program.elements)
+ "\n[program.exports]\n " + elements(program.exports) + "\n[program.exports]\n " + elements(program.exports)
+ "\n;)\n"; + "\n;)\n";
var actualOptimized = null; var actualOptimized = null;
var actualInlined = 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()) { if (module.validate()) {
console.log(chalk.default.green("validate OK")); console.log(chalk.green("validate OK"));
try { try {
module.interpret(); module.interpret();
console.log(chalk.default.green("interpret OK")); console.log(chalk.green("interpret OK"));
try { try {
var binary = module.toBinary(); var binary = module.toBinary();
var wasmModule = new WebAssembly.Module(binary); var wasmModule = new WebAssembly.Module(binary);
@ -70,22 +80,22 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
externalConst: 2 externalConst: 2
} }
}); });
console.log(chalk.default.green("instantiate OK")); console.log(chalk.green("instantiate OK"));
} catch (e) { } catch (e) {
process.exitCode = 1; failed = true;
console.log(chalk.default.red("instantiate ERROR: ") + e); console.log(chalk.red("instantiate ERROR: ") + e);
} }
} catch (e) { } catch (e) {
process.exitCode = 1; failed = true;
console.log(chalk.default.red("interpret ERROR:") + e); console.log(chalk.red("interpret ERROR:") + e);
} }
module.optimize(); module.optimize();
actualOptimized = module.toText(); actualOptimized = module.toText();
module.runPasses([ "inlining" ]); module.runPasses([ "inlining" ]);
actualInlined = module.toText(); actualInlined = module.toText();
} else { } else {
process.exitCode = 1; failed = true;
console.log(chalk.default.red("validate ERROR")); console.log(chalk.red("validate ERROR"));
} }
if (isCreate) { if (isCreate) {
@ -107,25 +117,25 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
} }
} }
} else { } else {
var expected;
try { try {
var expected = fs.readFileSync(__dirname + "/compiler/" + fixture + ".wast", { encoding: "utf8" }); expected = fs.readFileSync(__dirname + "/compiler/" + fixture + ".wast", { encoding: "utf8" });
} catch (e) {
expected = e.message + "\n";
}
var diffs = diff(filename + ".wast", expected, actual); var diffs = diff(filename + ".wast", expected, actual);
if (diffs !== null) { if (diffs !== null) {
process.exitCode = 1;
console.log(diffs); console.log(diffs);
console.log(chalk.default.red("diff ERROR")); console.log(chalk.red("diff ERROR"));
} else { failed = true;
console.log(chalk.default.green("diff OK")); } else
} console.log(chalk.green("diff OK"));
} catch (e) {
process.exitCode = 1;
console.log(e.message);
console.log(chalk.default.red("diff ERROR"));
}
} }
module.dispose(); module.dispose();
console.log(); console.log();
if (failed)
++failures;
}); });
function elements(map) { function elements(map) {
@ -135,3 +145,9 @@ function elements(map) {
}); });
return arr.join("\n "); 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)) (export "memory" (memory $0))
(start $start) (start $start)
(func $start (; 0 ;) (type $v) (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(true);
assert(1 == 1); assert(1);
assert(1 > 0);
assert(0.5);
assert(0.5 > 0.4); 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)) (export "memory" (memory $0))
(start $start) (start $start)
(func $start (; 0 ;) (type $v) (func $start (; 0 ;) (type $v)
(local $0 i32)
(if (if
(i32.eqz (i32.eqz
(i32.const 1) (i32.const 1)
@ -13,10 +14,23 @@
) )
(if (if
(i32.eqz (i32.eqz
(i32.eq
(i32.const 1)
(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) (unreachable)
) )
@ -29,6 +43,35 @@
) )
(unreachable) (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: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -844,8 +844,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -65,14 +65,14 @@
) )
(set_global $builtins/i (set_global $builtins/i
(select (select
(i32.sub
(i32.const 0)
(tee_local $2 (tee_local $2
(i32.const -42) (i32.const -42)
) )
) (i32.sub
(i32.const 0)
(get_local $2) (get_local $2)
(i32.lt_s )
(i32.gt_s
(get_local $2) (get_local $2)
(i32.const 0) (i32.const 0)
) )
@ -144,14 +144,14 @@
) )
(set_global $builtins/I (set_global $builtins/I
(select (select
(i64.sub
(i64.const 0)
(tee_local $4 (tee_local $4
(i64.const -42) (i64.const -42)
) )
) (i64.sub
(i64.const 0)
(get_local $4) (get_local $4)
(i64.lt_s )
(i64.gt_s
(get_local $4) (get_local $4)
(i64.const 0) (i64.const 0)
) )

@ -77,17 +77,17 @@
) )
(drop (drop
(select (select
(i32.sub
(i32.const 0)
(tee_local $0 (tee_local $0
(i32.sub (i32.sub
(i32.const 0) (i32.const 0)
(i32.const 42) (i32.const 42)
) )
) )
) (i32.sub
(i32.const 0)
(get_local $0) (get_local $0)
(i32.lt_s )
(i32.gt_s
(get_local $0) (get_local $0)
(i32.const 0) (i32.const 0)
) )
@ -150,17 +150,17 @@
) )
(set_global $builtins/i (set_global $builtins/i
(select (select
(i32.sub
(i32.const 0)
(tee_local $0 (tee_local $0
(i32.sub (i32.sub
(i32.const 0) (i32.const 0)
(i32.const 42) (i32.const 42)
) )
) )
) (i32.sub
(i32.const 0)
(get_local $0) (get_local $0)
(i32.lt_s )
(i32.gt_s
(get_local $0) (get_local $0)
(i32.const 0) (i32.const 0)
) )
@ -250,17 +250,17 @@
) )
(drop (drop
(select (select
(i64.sub
(i64.const 0)
(tee_local $2 (tee_local $2
(i64.sub (i64.sub
(i64.const 0) (i64.const 0)
(i64.const 42) (i64.const 42)
) )
) )
) (i64.sub
(i64.const 0)
(get_local $2) (get_local $2)
(i64.lt_s )
(i64.gt_s
(get_local $2) (get_local $2)
(i64.const 0) (i64.const 0)
) )
@ -295,17 +295,17 @@
) )
(set_global $builtins/I (set_global $builtins/I
(select (select
(i64.sub
(i64.const 0)
(tee_local $2 (tee_local $2
(i64.sub (i64.sub
(i64.const 0) (i64.const 0)
(i64.const 42) (i64.const 42)
) )
) )
) (i64.sub
(i64.const 0)
(get_local $2) (get_local $2)
(i64.lt_s )
(i64.gt_s
(get_local $2) (get_local $2)
(i64.const 0) (i64.const 0)
) )
@ -1370,8 +1370,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -53,8 +53,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -25,8 +25,8 @@ export function test(animal: Animal<f64>): Animal<f64> {
animal.three; animal.three;
animal.one = 0 + 1; animal.one = 0 + 1;
animal.two = 1 + 1; animal.two = 1 + 1; // checks overflow
animal.three = 1 + 1 + 1; animal.three = 1 + 1 + 1; // checks overflow (once)
var ptr = changetype<usize>(animal); var ptr = changetype<usize>(animal);
var cls = changetype<Animal<f64>>(ptr); var cls = changetype<Animal<f64>>(ptr);

@ -100,13 +100,21 @@
) )
(i32.store16 offset=4 (i32.store16 offset=4
(get_local $0) (get_local $0)
(i32.shr_s
(i32.shl
(i32.add (i32.add
(i32.const 1) (i32.const 1)
(i32.const 1) (i32.const 1)
) )
(i32.const 16)
)
(i32.const 16)
)
) )
(i32.store8 offset=6 (i32.store8 offset=6
(get_local $0) (get_local $0)
(i32.shr_s
(i32.shl
(i32.add (i32.add
(i32.add (i32.add
(i32.const 1) (i32.const 1)
@ -114,6 +122,10 @@
) )
(i32.const 1) (i32.const 1)
) )
(i32.const 24)
)
(i32.const 24)
)
) )
(block (block
(set_local $1 (set_local $1
@ -184,8 +196,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -47,20 +47,12 @@
(unreachable) (unreachable)
) )
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $comma/a)
)
(set_global $comma/a (set_global $comma/a
(i32.add (i32.add
(get_local $0) (get_global $comma/a)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(set_global $comma/b (set_global $comma/b
(get_global $comma/a) (get_global $comma/a)
) )
@ -93,20 +85,12 @@
) )
(set_global $comma/b (set_global $comma/b
(block (result i32) (block (result i32)
(drop
(block (result i32)
(set_local $0
(get_global $comma/a)
)
(set_global $comma/a (set_global $comma/a
(i32.add (i32.add
(get_local $0) (get_global $comma/a)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(get_global $comma/a) (get_global $comma/a)
) )
) )
@ -130,20 +114,12 @@
) )
(set_global $comma/a (set_global $comma/a
(block (result i32) (block (result i32)
(drop
(block (result i32)
(set_local $0
(get_global $comma/a)
)
(set_global $comma/a (set_global $comma/a
(i32.add (i32.add
(get_local $0) (get_global $comma/a)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(block (result i32) (block (result i32)
(set_global $comma/b (set_global $comma/b
(get_global $comma/a) (get_global $comma/a)
@ -185,34 +161,18 @@
(block (block
(nop) (nop)
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $comma/a)
)
(set_global $comma/a (set_global $comma/a
(i32.sub (i32.sub
(get_local $0) (get_global $comma/a)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_local $1)
)
(set_local $1 (set_local $1
(i32.add (i32.add
(get_local $0) (get_local $1)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
) )
(br $continue|0) (br $continue|0)
) )
@ -269,8 +229,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -47,8 +47,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -12,34 +12,18 @@
(block $break|0 (block $break|0
(loop $continue|0 (loop $continue|0
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $do/n)
)
(set_global $do/n (set_global $do/n
(i32.sub (i32.sub
(get_local $0) (get_global $do/n)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $do/m)
)
(set_global $do/m (set_global $do/m
(i32.add (i32.add
(get_local $0) (get_global $do/m)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
) )
(br_if $continue|0 (br_if $continue|0
(get_global $do/n) (get_global $do/n)
@ -107,65 +91,33 @@
(block $break|2 (block $break|2
(loop $continue|2 (loop $continue|2
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $do/n)
)
(set_global $do/n (set_global $do/n
(i32.sub (i32.sub
(get_local $0) (get_global $do/n)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $do/m)
)
(set_global $do/m (set_global $do/m
(i32.add (i32.add
(get_local $0) (get_global $do/m)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(block $break|3 (block $break|3
(loop $continue|3 (loop $continue|3
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $do/n)
)
(set_global $do/n (set_global $do/n
(i32.sub (i32.sub
(get_local $0) (get_global $do/n)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $do/o)
)
(set_global $do/o (set_global $do/o
(i32.add (i32.add
(get_local $0) (get_global $do/o)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
) )
(br_if $continue|3 (br_if $continue|3
(get_global $do/n) (get_global $do/n)
@ -253,8 +205,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -31,8 +31,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -76,8 +76,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -64,8 +64,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -174,14 +174,14 @@
) )
(i64.shl (i64.shl
(get_local $2) (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) (get_local $3)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -231,14 +231,14 @@
) )
(i64.shl (i64.shl
(get_local $5) (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) (get_local $6)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -372,14 +372,14 @@
) )
(i64.shr_u (i64.shr_u
(get_local $2) (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) (get_local $3)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )

@ -188,14 +188,14 @@
(set_local $2 (set_local $2
(i64.shl (i64.shl
(get_local $2) (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) (get_local $4)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -265,14 +265,14 @@
(set_local $3 (set_local $3
(i64.shl (i64.shl
(get_local $3) (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) (get_local $5)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -348,20 +348,12 @@
) )
) )
) )
(drop
(block (result i32)
(set_local $8
(get_local $4)
)
(set_local $4 (set_local $4
(i32.sub (i32.sub
(get_local $8) (get_local $4)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $8)
)
)
(br $continue|2) (br $continue|2)
) )
) )
@ -455,14 +447,14 @@
(set_local $2 (set_local $2
(i64.shr_u (i64.shr_u
(get_local $2) (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) (get_local $4)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -1076,8 +1068,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -175,8 +175,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -193,8 +193,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -87,6 +87,7 @@
) )
(block (block
(set_local $2 (set_local $2
(i32.and
(i32.add (i32.add
(i32.add (i32.add
(i32.add (i32.add
@ -194,6 +195,8 @@
) )
) )
) )
(i32.const 255)
)
) )
(if (if
(i32.load8_u (i32.load8_u

@ -133,6 +133,7 @@
) )
(block (block
(set_local $8 (set_local $8
(i32.and
(i32.add (i32.add
(i32.add (i32.add
(i32.add (i32.add
@ -219,6 +220,8 @@
) )
) )
) )
(i32.const 255)
)
) )
) )
(if (if
@ -334,8 +337,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -83,8 +83,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -1217,8 +1217,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -74,8 +74,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -72,8 +72,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -1,10 +1,10 @@
const i = 10; const i = 10; // infers i32 because
i; i;
const I = 0x100000000; const I = 0x100000000; // infers i64 because the value doesn't fit into 32 bits
I; I;
const F = 1.5; const F = 1.5; // infers f64 because of float notation
F; F;
function locals(): void { function locals(): void {

@ -168,8 +168,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -56,8 +56,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -135,8 +135,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -167,8 +167,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -253,8 +253,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -64,20 +64,12 @@
) )
) )
) )
(drop
(block (result i32)
(set_local $7
(get_local $2)
)
(set_local $2 (set_local $2
(i32.sub (i32.sub
(get_local $7) (get_local $2)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $7)
)
)
) )
(br $continue|0) (br $continue|0)
) )
@ -2079,8 +2071,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -62,8 +62,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -357,8 +357,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -60,8 +60,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -77,8 +77,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -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)
)
)
)

@ -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);

File diff suppressed because it is too large Load Diff

@ -1806,14 +1806,14 @@
) )
(i64.shl (i64.shl
(get_local $2) (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) (get_local $3)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -1863,14 +1863,14 @@
) )
(i64.shl (i64.shl
(get_local $5) (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) (get_local $6)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -2004,14 +2004,14 @@
) )
(i64.shr_u (i64.shr_u
(get_local $2) (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) (get_local $3)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -3443,14 +3443,14 @@
) )
(set_global $builtins/i (set_global $builtins/i
(select (select
(i32.sub
(i32.const 0)
(tee_local $2 (tee_local $2
(i32.const -42) (i32.const -42)
) )
) (i32.sub
(i32.const 0)
(get_local $2) (get_local $2)
(i32.lt_s )
(i32.gt_s
(get_local $2) (get_local $2)
(i32.const 0) (i32.const 0)
) )
@ -3522,14 +3522,14 @@
) )
(set_global $builtins/I (set_global $builtins/I
(select (select
(i64.sub
(i64.const 0)
(tee_local $3 (tee_local $3
(i64.const -42) (i64.const -42)
) )
) (i64.sub
(i64.const 0)
(get_local $3) (get_local $3)
(i64.lt_s )
(i64.gt_s
(get_local $3) (get_local $3)
(i64.const 0) (i64.const 0)
) )

@ -1827,14 +1827,14 @@
) )
(i64.shl (i64.shl
(get_local $2) (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) (get_local $3)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -1884,14 +1884,14 @@
) )
(i64.shl (i64.shl
(get_local $5) (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) (get_local $6)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -2025,14 +2025,14 @@
) )
(i64.shr_u (i64.shr_u
(get_local $2) (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) (get_local $3)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -3465,14 +3465,14 @@
) )
(set_global $builtins/i (set_global $builtins/i
(select (select
(i32.sub
(i32.const 0)
(tee_local $2 (tee_local $2
(i32.const -42) (i32.const -42)
) )
) (i32.sub
(i32.const 0)
(get_local $2) (get_local $2)
(i32.lt_s )
(i32.gt_s
(get_local $2) (get_local $2)
(i32.const 0) (i32.const 0)
) )
@ -3544,14 +3544,14 @@
) )
(set_global $builtins/I (set_global $builtins/I
(select (select
(i64.sub
(i64.const 0)
(tee_local $3 (tee_local $3
(i64.const -42) (i64.const -42)
) )
) (i64.sub
(i64.const 0)
(get_local $3) (get_local $3)
(i64.lt_s )
(i64.gt_s
(get_local $3) (get_local $3)
(i64.const 0) (i64.const 0)
) )

@ -172,20 +172,12 @@
) )
) )
) )
(drop
(block (result i32)
(set_local $7
(get_local $2)
)
(set_local $2 (set_local $2
(i32.sub (i32.sub
(get_local $7) (get_local $2)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $7)
)
)
) )
(br $continue|0) (br $continue|0)
) )
@ -2114,14 +2106,14 @@
(set_local $2 (set_local $2
(i64.shl (i64.shl
(get_local $2) (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) (get_local $4)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -2191,14 +2183,14 @@
(set_local $3 (set_local $3
(i64.shl (i64.shl
(get_local $3) (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) (get_local $5)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -2274,20 +2266,12 @@
) )
) )
) )
(drop
(block (result i32)
(set_local $8
(get_local $4)
)
(set_local $4 (set_local $4
(i32.sub (i32.sub
(get_local $8) (get_local $4)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $8)
)
)
(br $continue|2) (br $continue|2)
) )
) )
@ -2381,14 +2365,14 @@
(set_local $2 (set_local $2
(i64.shr_u (i64.shr_u
(get_local $2) (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) (get_local $4)
) )
(i32.const 1)
) )
(i64.const 1)
) )
) )
) )
@ -2943,34 +2927,18 @@
(i32.const 1) (i32.const 1)
) )
) )
(drop
(block (result i32)
(set_local $0
(get_global $unary/i)
)
(set_global $unary/i (set_global $unary/i
(i32.add (i32.add
(get_local $0) (get_global $unary/i)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $unary/i)
)
(set_global $unary/i (set_global $unary/i
(i32.sub (i32.sub
(get_local $0) (get_global $unary/i)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(set_global $unary/i (set_global $unary/i
(i32.const 1) (i32.const 1)
) )
@ -3093,34 +3061,18 @@
(i64.const 1) (i64.const 1)
) )
) )
(drop
(block (result i64)
(set_local $1
(get_global $unary/I)
)
(set_global $unary/I (set_global $unary/I
(i64.add (i64.add
(get_local $1) (get_global $unary/I)
(i64.const 1) (i64.const 1)
) )
) )
(get_local $1)
)
)
(drop
(block (result i64)
(set_local $1
(get_global $unary/I)
)
(set_global $unary/I (set_global $unary/I
(i64.sub (i64.sub
(get_local $1) (get_global $unary/I)
(i64.const 1) (i64.const 1)
) )
) )
(get_local $1)
)
)
(set_global $unary/I (set_global $unary/I
(i64.const 1) (i64.const 1)
) )
@ -3132,8 +3084,8 @@
) )
(set_global $unary/I (set_global $unary/I
(i64.extend_s/i32 (i64.extend_s/i32
(i32.eqz (i64.eqz
(i32.const 1) (i64.const 1)
) )
) )
) )
@ -3241,34 +3193,18 @@
(f32.const 1) (f32.const 1)
) )
) )
(drop
(block (result f32)
(set_local $2
(get_global $unary/f)
)
(set_global $unary/f (set_global $unary/f
(f32.add (f32.add
(get_local $2) (get_global $unary/f)
(f32.const 1) (f32.const 1)
) )
) )
(get_local $2)
)
)
(drop
(block (result f32)
(set_local $2
(get_global $unary/f)
)
(set_global $unary/f (set_global $unary/f
(f32.sub (f32.sub
(get_local $2) (get_global $unary/f)
(f32.const 1) (f32.const 1)
) )
) )
(get_local $2)
)
)
(set_global $unary/f (set_global $unary/f
(f32.const 1.25) (f32.const 1.25)
) )
@ -3373,34 +3309,18 @@
(f64.const 1) (f64.const 1)
) )
) )
(drop
(block (result f64)
(set_local $3
(get_global $unary/F)
)
(set_global $unary/F (set_global $unary/F
(f64.add (f64.add
(get_local $3) (get_global $unary/F)
(f64.const 1) (f64.const 1)
) )
) )
(get_local $3)
)
)
(drop
(block (result f64)
(set_local $3
(get_global $unary/F)
)
(set_global $unary/F (set_global $unary/F
(f64.sub (f64.sub
(get_local $3) (get_global $unary/F)
(f64.const 1) (f64.const 1)
) )
) )
(get_local $3)
)
)
(set_global $unary/F (set_global $unary/F
(f64.const 1.25) (f64.const 1.25)
) )
@ -4528,17 +4448,17 @@
) )
(drop (drop
(select (select
(i32.sub
(i32.const 0)
(tee_local $0 (tee_local $0
(i32.sub (i32.sub
(i32.const 0) (i32.const 0)
(i32.const 42) (i32.const 42)
) )
) )
) (i32.sub
(i32.const 0)
(get_local $0) (get_local $0)
(i32.lt_s )
(i32.gt_s
(get_local $0) (get_local $0)
(i32.const 0) (i32.const 0)
) )
@ -4601,17 +4521,17 @@
) )
(set_global $builtins/i (set_global $builtins/i
(select (select
(i32.sub
(i32.const 0)
(tee_local $0 (tee_local $0
(i32.sub (i32.sub
(i32.const 0) (i32.const 0)
(i32.const 42) (i32.const 42)
) )
) )
) (i32.sub
(i32.const 0)
(get_local $0) (get_local $0)
(i32.lt_s )
(i32.gt_s
(get_local $0) (get_local $0)
(i32.const 0) (i32.const 0)
) )
@ -4701,17 +4621,17 @@
) )
(drop (drop
(select (select
(i64.sub
(i64.const 0)
(tee_local $1 (tee_local $1
(i64.sub (i64.sub
(i64.const 0) (i64.const 0)
(i64.const 42) (i64.const 42)
) )
) )
) (i64.sub
(i64.const 0)
(get_local $1) (get_local $1)
(i64.lt_s )
(i64.gt_s
(get_local $1) (get_local $1)
(i64.const 0) (i64.const 0)
) )
@ -4746,17 +4666,17 @@
) )
(set_global $builtins/I (set_global $builtins/I
(select (select
(i64.sub
(i64.const 0)
(tee_local $1 (tee_local $1
(i64.sub (i64.sub
(i64.const 0) (i64.const 0)
(i64.const 42) (i64.const 42)
) )
) )
) (i64.sub
(i64.const 0)
(get_local $1) (get_local $1)
(i64.lt_s )
(i64.gt_s
(get_local $1) (get_local $1)
(i64.const 0) (i64.const 0)
) )
@ -6319,8 +6239,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -31,8 +31,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8
@ -73,12 +71,16 @@
FUNCTION_PROTOTYPE: std:heap/Heap.compare FUNCTION_PROTOTYPE: std:heap/Heap.compare
CLASS_PROTOTYPE: std:map/Map CLASS_PROTOTYPE: std:map/Map
CLASS_PROTOTYPE: Map CLASS_PROTOTYPE: Map
CLASS_PROTOTYPE: std:regexp/RegExp
CLASS_PROTOTYPE: RegExp
CLASS_PROTOTYPE: std:set/Set CLASS_PROTOTYPE: std:set/Set
CLASS_PROTOTYPE: Set CLASS_PROTOTYPE: Set
GLOBAL: std:string/EMPTY GLOBAL: std:string/EMPTY
CLASS_PROTOTYPE: std:string/String CLASS_PROTOTYPE: std:string/String
CLASS_PROTOTYPE: String CLASS_PROTOTYPE: String
FUNCTION_PROTOTYPE: std:string/isWhiteSpaceOrLineTerminator FUNCTION_PROTOTYPE: std:string/isWhiteSpaceOrLineTerminator
FUNCTION_PROTOTYPE: std:string/parseInt
FUNCTION_PROTOTYPE: std:string/parseFloat
[program.exports] [program.exports]
CLASS_PROTOTYPE: std:array/Array CLASS_PROTOTYPE: std:array/Array
CLASS_PROTOTYPE: std:array/CArray CLASS_PROTOTYPE: std:array/CArray
@ -88,4 +90,6 @@
CLASS_PROTOTYPE: std:map/Map CLASS_PROTOTYPE: std:map/Map
CLASS_PROTOTYPE: std:set/Set CLASS_PROTOTYPE: std:set/Set
CLASS_PROTOTYPE: std:string/String CLASS_PROTOTYPE: std:string/String
FUNCTION_PROTOTYPE: std:string/parseInt
FUNCTION_PROTOTYPE: std:string/parseFloat
;) ;)

@ -565,20 +565,12 @@
) )
) )
) )
(drop
(block (result i32)
(set_local $6
(get_local $2)
)
(set_local $2 (set_local $2
(i32.sub (i32.sub
(get_local $6) (get_local $2)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $6)
)
)
) )
(br $continue|0) (br $continue|0)
) )
@ -2330,7 +2322,6 @@
) )
) )
(func $std:heap/Heap.compare (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func $std:heap/Heap.compare (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(if (if
(i32.eq (i32.eq
(get_local $0) (get_local $0)
@ -2357,48 +2348,24 @@
) )
(block (block
(block (block
(drop
(block (result i32)
(set_local $3
(get_local $2)
)
(set_local $2 (set_local $2
(i32.sub (i32.sub
(get_local $3) (get_local $2)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $3)
)
)
(drop
(block (result i32)
(set_local $3
(get_local $0)
)
(set_local $0 (set_local $0
(i32.add (i32.add
(get_local $3) (get_local $0)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $3)
)
)
(drop
(block (result i32)
(set_local $3
(get_local $1)
)
(set_local $1 (set_local $1
(i32.add (i32.add
(get_local $3) (get_local $1)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $3)
)
)
) )
(br $continue|0) (br $continue|0)
) )
@ -2580,8 +2547,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8
@ -2622,12 +2587,16 @@
FUNCTION_PROTOTYPE: std:heap/Heap.compare FUNCTION_PROTOTYPE: std:heap/Heap.compare
CLASS_PROTOTYPE: std:map/Map CLASS_PROTOTYPE: std:map/Map
CLASS_PROTOTYPE: Map CLASS_PROTOTYPE: Map
CLASS_PROTOTYPE: std:regexp/RegExp
CLASS_PROTOTYPE: RegExp
CLASS_PROTOTYPE: std:set/Set CLASS_PROTOTYPE: std:set/Set
CLASS_PROTOTYPE: Set CLASS_PROTOTYPE: Set
GLOBAL: std:string/EMPTY GLOBAL: std:string/EMPTY
CLASS_PROTOTYPE: std:string/String CLASS_PROTOTYPE: std:string/String
CLASS_PROTOTYPE: String CLASS_PROTOTYPE: String
FUNCTION_PROTOTYPE: std:string/isWhiteSpaceOrLineTerminator FUNCTION_PROTOTYPE: std:string/isWhiteSpaceOrLineTerminator
FUNCTION_PROTOTYPE: std:string/parseInt
FUNCTION_PROTOTYPE: std:string/parseFloat
GLOBAL: std/heap/size GLOBAL: std/heap/size
GLOBAL: std/heap/ptr1 GLOBAL: std/heap/ptr1
GLOBAL: std/heap/ptr2 GLOBAL: std/heap/ptr2
@ -2641,4 +2610,6 @@
CLASS_PROTOTYPE: std:map/Map CLASS_PROTOTYPE: std:map/Map
CLASS_PROTOTYPE: std:set/Set CLASS_PROTOTYPE: std:set/Set
CLASS_PROTOTYPE: std:string/String CLASS_PROTOTYPE: std:string/String
FUNCTION_PROTOTYPE: std:string/parseInt
FUNCTION_PROTOTYPE: std:string/parseFloat
;) ;)

@ -173,8 +173,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -86,8 +86,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -364,8 +364,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -43,8 +43,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -79,34 +79,18 @@
(i32.const 1) (i32.const 1)
) )
) )
(drop
(block (result i32)
(set_local $0
(get_global $unary/i)
)
(set_global $unary/i (set_global $unary/i
(i32.add (i32.add
(get_local $0) (get_global $unary/i)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $unary/i)
)
(set_global $unary/i (set_global $unary/i
(i32.sub (i32.sub
(get_local $0) (get_global $unary/i)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(set_global $unary/i (set_global $unary/i
(i32.const 1) (i32.const 1)
) )
@ -229,34 +213,18 @@
(i64.const 1) (i64.const 1)
) )
) )
(drop
(block (result i64)
(set_local $1
(get_global $unary/I)
)
(set_global $unary/I (set_global $unary/I
(i64.add (i64.add
(get_local $1) (get_global $unary/I)
(i64.const 1) (i64.const 1)
) )
) )
(get_local $1)
)
)
(drop
(block (result i64)
(set_local $1
(get_global $unary/I)
)
(set_global $unary/I (set_global $unary/I
(i64.sub (i64.sub
(get_local $1) (get_global $unary/I)
(i64.const 1) (i64.const 1)
) )
) )
(get_local $1)
)
)
(set_global $unary/I (set_global $unary/I
(i64.const 1) (i64.const 1)
) )
@ -268,8 +236,8 @@
) )
(set_global $unary/I (set_global $unary/I
(i64.extend_s/i32 (i64.extend_s/i32
(i32.eqz (i64.eqz
(i32.const 1) (i64.const 1)
) )
) )
) )
@ -377,34 +345,18 @@
(f32.const 1) (f32.const 1)
) )
) )
(drop
(block (result f32)
(set_local $2
(get_global $unary/f)
)
(set_global $unary/f (set_global $unary/f
(f32.add (f32.add
(get_local $2) (get_global $unary/f)
(f32.const 1) (f32.const 1)
) )
) )
(get_local $2)
)
)
(drop
(block (result f32)
(set_local $2
(get_global $unary/f)
)
(set_global $unary/f (set_global $unary/f
(f32.sub (f32.sub
(get_local $2) (get_global $unary/f)
(f32.const 1) (f32.const 1)
) )
) )
(get_local $2)
)
)
(set_global $unary/f (set_global $unary/f
(f32.const 1.25) (f32.const 1.25)
) )
@ -509,34 +461,18 @@
(f64.const 1) (f64.const 1)
) )
) )
(drop
(block (result f64)
(set_local $3
(get_global $unary/F)
)
(set_global $unary/F (set_global $unary/F
(f64.add (f64.add
(get_local $3) (get_global $unary/F)
(f64.const 1) (f64.const 1)
) )
) )
(get_local $3)
)
)
(drop
(block (result f64)
(set_local $3
(get_global $unary/F)
)
(set_global $unary/F (set_global $unary/F
(f64.sub (f64.sub
(get_local $3) (get_global $unary/F)
(f64.const 1) (f64.const 1)
) )
) )
(get_local $3)
)
)
(set_global $unary/F (set_global $unary/F
(f64.const 1.25) (f64.const 1.25)
) )
@ -649,8 +585,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -15,34 +15,18 @@
(get_global $while/n) (get_global $while/n)
(block (block
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $while/n)
)
(set_global $while/n (set_global $while/n
(i32.sub (i32.sub
(get_local $0) (get_global $while/n)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $while/m)
)
(set_global $while/m (set_global $while/m
(i32.add (i32.add
(get_local $0) (get_global $while/m)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
) )
(br $continue|0) (br $continue|0)
) )
@ -79,68 +63,36 @@
(get_global $while/n) (get_global $while/n)
(block (block
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $while/n)
)
(set_global $while/n (set_global $while/n
(i32.sub (i32.sub
(get_local $0) (get_global $while/n)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $while/m)
)
(set_global $while/m (set_global $while/m
(i32.add (i32.add
(get_local $0) (get_global $while/m)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(block $break|2 (block $break|2
(loop $continue|2 (loop $continue|2
(if (if
(get_global $while/n) (get_global $while/n)
(block (block
(block (block
(drop
(block (result i32)
(set_local $0
(get_global $while/n)
)
(set_global $while/n (set_global $while/n
(i32.sub (i32.sub
(get_local $0) (get_global $while/n)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
(drop
(block (result i32)
(set_local $0
(get_global $while/o)
)
(set_global $while/o (set_global $while/o
(i32.add (i32.add
(get_local $0) (get_global $while/o)
(i32.const 1) (i32.const 1)
) )
) )
(get_local $0)
)
)
) )
(br $continue|2) (br $continue|2)
) )
@ -291,8 +243,6 @@
FUNCTION_PROTOTYPE: unreachable FUNCTION_PROTOTYPE: unreachable
FUNCTION_PROTOTYPE: current_memory FUNCTION_PROTOTYPE: current_memory
FUNCTION_PROTOTYPE: grow_memory FUNCTION_PROTOTYPE: grow_memory
FUNCTION_PROTOTYPE: parseInt
FUNCTION_PROTOTYPE: parseFloat
FUNCTION_PROTOTYPE: changetype FUNCTION_PROTOTYPE: changetype
FUNCTION_PROTOTYPE: assert FUNCTION_PROTOTYPE: assert
FUNCTION_PROTOTYPE: i8 FUNCTION_PROTOTYPE: i8

@ -10,6 +10,7 @@ var Parser = require("../src/parser").Parser;
var isCreate = process.argv[2] === "--create"; var isCreate = process.argv[2] === "--create";
var filter = process.argv.length > 2 && !isCreate ? "*" + process.argv[2] + "*.ts" : "**.ts"; var filter = process.argv.length > 2 && !isCreate ? "*" + process.argv[2] + "*.ts" : "**.ts";
var failures = 0;
glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => { glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => {
if (filename.charAt(0) == "_" || filename.endsWith(".fixture.ts")) 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)); console.log(chalk.default.whiteBright("Testing parser/" + filename));
var failed = false;
var parser = new Parser(); var parser = new Parser();
parser.silentDiagnostics = true; parser.silentDiagnostics = true;
var sourceText = fs.readFileSync(__dirname + "/parser/" + filename, { encoding: "utf8" }).replace(/\r?\n/g, "\n").replace(/^\/\/.*\r?\n/mg, ""); 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 expected = fs.readFileSync(__dirname + "/parser/" + fixture, { encoding: "utf8" });
var diffs = diff("parser/" + fixture, expected, actual); var diffs = diff("parser/" + fixture, expected, actual);
if (diffs !== null) { if (diffs !== null) {
process.exitCode = 1; failed = true;
console.log(diffs); console.log(diffs);
console.log(chalk.default.red("diff ERROR")); console.log(chalk.default.red("diff ERROR"));
} else { } else {
@ -43,4 +45,12 @@ glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => {
} }
console.log(); 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"); var chalk = require("chalk");
module.exports = function diff(filename, expected, actual) { 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) if (!diff.hunks.length)
return null; return null;