mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-05-02 10:22:15 +00:00
Control flow evaluator; Support for block-level let/const variables
This commit is contained in:
parent
1c4b0ddc57
commit
7be4f9fabb
@ -541,7 +541,7 @@ function fls<T>(word: T): i32 {
|
||||
return (<i32>sizeof<T>() << 3) - 1 - <i32>clz(word);
|
||||
}
|
||||
|
||||
var fl_out: i32, sl_out: i32;
|
||||
let fl_out: i32, sl_out: i32;
|
||||
|
||||
function mapping_insert(size: usize): void {
|
||||
var fl: i32, sl: i32;
|
||||
@ -585,7 +585,7 @@ function find_suitable_block(control: Control, fl: i32, sl: i32): BlockHeader {
|
||||
|
||||
// Exported interface
|
||||
|
||||
var TLSF: Control;
|
||||
let TLSF: Control;
|
||||
|
||||
/** Requests more memory from the host environment. */
|
||||
function request_memory(size: usize): void {
|
||||
@ -711,8 +711,8 @@ function check(): i32 {
|
||||
return status;
|
||||
}
|
||||
|
||||
var integrity_prev_status: i32;
|
||||
var integrity_status: i32;
|
||||
let integrity_prev_status: i32,
|
||||
integrity_status: i32;
|
||||
|
||||
function integrity_walker(ptr: usize, size: usize, used: bool): void {
|
||||
var block = BlockHeader.fromDataPtr(ptr);
|
||||
|
@ -980,6 +980,7 @@ export class UnaryPrefixExpression extends UnaryExpression {
|
||||
export enum ModifierKind {
|
||||
ASYNC,
|
||||
CONST,
|
||||
LET,
|
||||
DECLARE,
|
||||
EXPORT,
|
||||
IMPORT,
|
||||
|
@ -36,7 +36,8 @@ import {
|
||||
Program,
|
||||
Global,
|
||||
FunctionPrototype,
|
||||
Local
|
||||
Local,
|
||||
ElementFlags
|
||||
} from "./program";
|
||||
|
||||
/** Initializes the specified program with built-in constants and functions. */
|
||||
@ -152,8 +153,8 @@ export function initialize(program: Program): void {
|
||||
/** Adds a built-in constant to the specified program. */
|
||||
function addConstant(program: Program, name: string, type: Type): Global {
|
||||
var global = new Global(program, name, name, null, type);
|
||||
global.isBuiltIn = true;
|
||||
global.isConstant = true;
|
||||
global.set(ElementFlags.BUILTIN);
|
||||
global.set(ElementFlags.CONSTANT);
|
||||
program.elements.set(name, global);
|
||||
return global;
|
||||
}
|
||||
@ -161,9 +162,9 @@ function addConstant(program: Program, name: string, type: Type): Global {
|
||||
/** Adds a built-in function to the specified program. */
|
||||
function addFunction(program: Program, name: string, isGeneric: bool = false): FunctionPrototype {
|
||||
var prototype = new FunctionPrototype(program, name, name, null, null);
|
||||
prototype.isBuiltIn = true;
|
||||
prototype.set(ElementFlags.BUILTIN);
|
||||
if (isGeneric)
|
||||
prototype.isGeneric = true;
|
||||
prototype.set(ElementFlags.GENERIC);
|
||||
program.elements.set(name, prototype);
|
||||
return prototype;
|
||||
}
|
||||
|
326
src/compiler.ts
326
src/compiler.ts
@ -42,7 +42,10 @@ import {
|
||||
Parameter,
|
||||
EnumValue,
|
||||
Property,
|
||||
VariableLikeElement
|
||||
VariableLikeElement,
|
||||
Flow,
|
||||
FlowFlags,
|
||||
ElementFlags
|
||||
} from "./program";
|
||||
|
||||
import {
|
||||
@ -112,6 +115,7 @@ import {
|
||||
Type,
|
||||
TypeKind,
|
||||
TypeFlags,
|
||||
|
||||
typesToNativeTypes
|
||||
} from "./types";
|
||||
|
||||
@ -166,17 +170,13 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
/** Start function being compiled. */
|
||||
startFunction: Function;
|
||||
/** Start function expressions. */
|
||||
/** Start function statements. */
|
||||
startFunctionBody: ExpressionRef[] = new Array();
|
||||
|
||||
/** Current type in compilation. */
|
||||
currentType: Type = Type.void;
|
||||
/** Current function in compilation. */
|
||||
currentFunction: Function;
|
||||
/** Marker indicating whether continue statements are allowed in the current break context. */
|
||||
disallowContinue: bool = true;
|
||||
/** Marker indicating that a new variable, if present, is always a local. Used to distinguish locals from globals in the start function. */
|
||||
variableIsLocal: bool = false;
|
||||
/** Current type in compilation. */
|
||||
currentType: Type = Type.void;
|
||||
|
||||
/** Counting memory offset. */
|
||||
memoryOffset: U64 = new U64(8, 0); // leave space for (any size of) NULL
|
||||
@ -297,8 +297,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
this.compileNamespaceDeclaration(<NamespaceDeclaration>statement);
|
||||
break;
|
||||
|
||||
case NodeKind.VARIABLE: // global
|
||||
this.compileVariableStatement(<VariableStatement>statement); // always because initializers might have side effects
|
||||
case NodeKind.VARIABLE: // global, always compiled because initializers might have side effects
|
||||
var variableInit = this.compileVariableStatement(<VariableStatement>statement);
|
||||
if (variableInit)
|
||||
this.startFunctionBody.push(variableInit);
|
||||
break;
|
||||
|
||||
case NodeKind.EXPORT:
|
||||
@ -322,7 +324,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
// globals
|
||||
|
||||
compileGlobalDeclaration(declaration: VariableDeclaration, isConst: bool): Global | null {
|
||||
compileGlobalDeclaration(declaration: VariableDeclaration): Global | null {
|
||||
var element = this.program.elements.get(declaration.fileLevelInternalName);
|
||||
if (!element || element.kind != ElementKind.GLOBAL)
|
||||
throw new Error("global expected");
|
||||
@ -332,7 +334,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
compileGlobal(global: Global): bool {
|
||||
if (global.isCompiled || global.isBuiltIn)
|
||||
if (global.is(ElementFlags.COMPILED) || global.is(ElementFlags.BUILTIN))
|
||||
return true;
|
||||
|
||||
var declaration = global.declaration;
|
||||
@ -366,10 +368,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
var nativeType = global.type.toNativeType();
|
||||
|
||||
if (global.isDeclared) {
|
||||
if (global.isConstant) {
|
||||
if (global.is(ElementFlags.DECLARED)) {
|
||||
if (global.is(ElementFlags.CONSTANT)) {
|
||||
this.module.addGlobalImport(global.internalName, global.namespace ? global.namespace.simpleName : "env", global.simpleName, nativeType);
|
||||
global.isCompiled = true;
|
||||
global.set(ElementFlags.COMPILED);
|
||||
return true;
|
||||
} else if (declaration) {
|
||||
this.error(DiagnosticCode.Operation_not_supported, declaration.range);
|
||||
@ -379,14 +381,14 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
var initializeInStart = false;
|
||||
|
||||
if (global.hasConstantValue) {
|
||||
if (global.is(ElementFlags.INLINED)) {
|
||||
initExpr = makeInlineConstant(global, this.module);
|
||||
} else if (declaration) {
|
||||
if (declaration.initializer) {
|
||||
if (!initExpr)
|
||||
initExpr = this.compileExpression(declaration.initializer, global.type);
|
||||
if (_BinaryenExpressionGetId(initExpr) != ExpressionId.Const) {
|
||||
if (!global.isMutable) {
|
||||
if (global.is(ElementFlags.CONSTANT)) {
|
||||
initExpr = this.precomputeExpressionRef(initExpr);
|
||||
if (_BinaryenExpressionGetId(initExpr) != ExpressionId.Const) {
|
||||
this.warning(DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable, declaration.range);
|
||||
@ -406,7 +408,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
var setExpr = this.module.createSetGlobal(internalName, initExpr);
|
||||
this.startFunctionBody.push(setExpr);
|
||||
} else {
|
||||
if (!global.isMutable) {
|
||||
if (global.is(ElementFlags.CONSTANT)) {
|
||||
var exprType = _BinaryenExpressionGetType(initExpr);
|
||||
switch (exprType) {
|
||||
|
||||
@ -429,16 +431,16 @@ export class Compiler extends DiagnosticEmitter {
|
||||
default:
|
||||
throw new Error("concrete type expected");
|
||||
}
|
||||
global.hasConstantValue = true;
|
||||
global.set(ElementFlags.INLINED);
|
||||
if (!declaration || declaration.isTopLevel) { // might be re-exported
|
||||
this.module.addGlobal(internalName, nativeType, global.isMutable, initExpr);
|
||||
this.module.addGlobal(internalName, nativeType, !global.is(ElementFlags.CONSTANT), initExpr);
|
||||
}
|
||||
if (declaration && declaration.range.source.isEntry && declaration.isTopLevelExport)
|
||||
this.module.addGlobalExport(global.internalName, declaration.programLevelInternalName);
|
||||
} else
|
||||
this.module.addGlobal(internalName, nativeType, global.isMutable, initExpr);
|
||||
this.module.addGlobal(internalName, nativeType, !global.is(ElementFlags.CONSTANT), initExpr);
|
||||
}
|
||||
global.isCompiled = true;
|
||||
global.set(ElementFlags.COMPILED);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -452,10 +454,12 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
compileEnum(element: Enum): bool {
|
||||
if (element.isCompiled)
|
||||
if (element.is(ElementFlags.COMPILED))
|
||||
return true;
|
||||
|
||||
element.isCompiled = true; // members might reference each other, triggering another compile
|
||||
// members might reference each other, triggering another compile
|
||||
element.set(ElementFlags.COMPILED);
|
||||
|
||||
var previousValue: EnumValue | null = null;
|
||||
if (element.members)
|
||||
for (var member of element.members.values()) {
|
||||
@ -464,7 +468,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
var initInStart = false;
|
||||
var val = <EnumValue>member;
|
||||
var valueDeclaration = val.declaration;
|
||||
if (val.hasConstantValue) {
|
||||
if (val.is(ElementFlags.INLINED)) {
|
||||
if (!element.declaration || element.declaration.isTopLevelExport)
|
||||
this.module.addGlobal(val.internalName, NativeType.I32, false, this.module.createI32(val.constantValue));
|
||||
} else if (valueDeclaration) {
|
||||
@ -474,14 +478,14 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (_BinaryenExpressionGetId(initExpr) != ExpressionId.Const) {
|
||||
initExpr = this.precomputeExpressionRef(initExpr);
|
||||
if (_BinaryenExpressionGetId(initExpr) != ExpressionId.Const) {
|
||||
if (element.isConstant)
|
||||
if (element.is(ElementFlags.CONSTANT))
|
||||
this.warning(DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable, valueDeclaration.range);
|
||||
initInStart = true;
|
||||
}
|
||||
}
|
||||
} else if (previousValue == null) {
|
||||
initExpr = this.module.createI32(0);
|
||||
} else if (previousValue.hasConstantValue) {
|
||||
} else if (previousValue.is(ElementFlags.INLINED)) {
|
||||
initExpr = this.module.createI32(previousValue.constantValue + 1);
|
||||
} else {
|
||||
// in TypeScript this errors with TS1061, but actually we can do:
|
||||
@ -489,7 +493,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
this.module.createGetGlobal(previousValue.internalName, NativeType.I32),
|
||||
this.module.createI32(1)
|
||||
);
|
||||
if (element.isConstant)
|
||||
if (element.is(ElementFlags.CONSTANT))
|
||||
this.warning(DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable, valueDeclaration.range);
|
||||
initInStart = true;
|
||||
}
|
||||
@ -501,7 +505,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
this.module.addGlobal(val.internalName, NativeType.I32, false, initExpr);
|
||||
if (_BinaryenExpressionGetType(initExpr) == NativeType.I32) {
|
||||
val.constantValue = _BinaryenConstGetValueI32(initExpr);
|
||||
val.hasConstantValue = true;
|
||||
val.set(ElementFlags.INLINED);
|
||||
} else
|
||||
throw new Error("i32 expected");
|
||||
}
|
||||
@ -511,7 +515,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
// export values if the enum is exported
|
||||
if (element.declaration && element.declaration.range.source.isEntry && element.declaration.isTopLevelExport) {
|
||||
if (member.hasConstantValue)
|
||||
if (member.is(ElementFlags.INLINED))
|
||||
this.module.addGlobalExport(member.internalName, member.internalName);
|
||||
else if (valueDeclaration)
|
||||
this.warning(DiagnosticCode.Cannot_export_a_mutable_global, valueDeclaration.range);
|
||||
@ -537,14 +541,14 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
compileFunction(instance: Function): bool {
|
||||
if (instance.isCompiled)
|
||||
if (instance.is(ElementFlags.COMPILED))
|
||||
return true;
|
||||
|
||||
var declaration = instance.prototype.declaration;
|
||||
if (!declaration)
|
||||
throw new Error("declaration expected"); // built-ins are not compiled here
|
||||
|
||||
if (instance.isDeclared) {
|
||||
if (instance.is(ElementFlags.DECLARED)) {
|
||||
if (declaration.statements) {
|
||||
this.error(DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts, declaration.name.range);
|
||||
return false;
|
||||
@ -555,11 +559,13 @@ export class Compiler extends DiagnosticEmitter {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
instance.isCompiled = true;
|
||||
|
||||
// might trigger compilation of other functions referring to this one
|
||||
instance.set(ElementFlags.COMPILED);
|
||||
|
||||
// compile statements
|
||||
var stmts: ExpressionRef[] | null = null;
|
||||
if (!instance.isDeclared) {
|
||||
if (!instance.is(ElementFlags.DECLARED)) {
|
||||
var previousFunction = this.currentFunction;
|
||||
this.currentFunction = instance;
|
||||
stmts = this.compileStatements(<Statement[]>declaration.statements);
|
||||
@ -589,7 +595,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
typeRef = this.module.addFunctionType(signatureNameParts.join(""), nativeResultType, nativeParamTypes);
|
||||
|
||||
// create the function
|
||||
if (instance.isDeclared) {
|
||||
if (instance.is(ElementFlags.DECLARED)) {
|
||||
this.module.addFunctionImport(instance.internalName, instance.prototype.namespace ? instance.prototype.namespace.simpleName : "env", declaration.name.name, typeRef);
|
||||
} else {
|
||||
this.module.addFunction(instance.internalName, typeRef, typesToNativeTypes(instance.additionalLocals), this.module.createBlock(null, <ExpressionRef[]>stmts, NativeType.None));
|
||||
@ -636,8 +642,11 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
|
||||
case NodeKind.VARIABLE:
|
||||
if (noTreeShaking || hasModifier(ModifierKind.EXPORT, (<VariableStatement>member).modifiers))
|
||||
this.compileVariableStatement(<VariableStatement>member);
|
||||
if (noTreeShaking || hasModifier(ModifierKind.EXPORT, (<VariableStatement>member).modifiers)) {
|
||||
var variableInit = this.compileVariableStatement(<VariableStatement>member, true);
|
||||
if (variableInit)
|
||||
this.startFunctionBody.push(variableInit);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -655,7 +664,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
switch (element.kind) {
|
||||
|
||||
case ElementKind.CLASS_PROTOTYPE:
|
||||
if ((noTreeShaking || (<ClassPrototype>element).isExported) && !(<ClassPrototype>element).isGeneric)
|
||||
if ((noTreeShaking || (<ClassPrototype>element).is(ElementFlags.EXPORTED)) && !(<ClassPrototype>element).is(ElementFlags.GENERIC))
|
||||
this.compileClassUsingTypeArguments(<ClassPrototype>element, []);
|
||||
break;
|
||||
|
||||
@ -664,7 +673,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
|
||||
case ElementKind.FUNCTION_PROTOTYPE:
|
||||
if ((noTreeShaking || (<FunctionPrototype>element).isExported) && !(<FunctionPrototype>element).isGeneric)
|
||||
if ((noTreeShaking || (<FunctionPrototype>element).is(ElementFlags.EXPORTED)) && !(<FunctionPrototype>element).is(ElementFlags.GENERIC))
|
||||
this.compileFunctionUsingTypeArguments(<FunctionPrototype>element, []);
|
||||
break;
|
||||
|
||||
@ -692,7 +701,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
switch (element.kind) {
|
||||
|
||||
case ElementKind.CLASS_PROTOTYPE:
|
||||
if (!(<ClassPrototype>element).isGeneric)
|
||||
if (!(<ClassPrototype>element).is(ElementFlags.GENERIC))
|
||||
this.compileClassUsingTypeArguments(<ClassPrototype>element, []);
|
||||
break;
|
||||
|
||||
@ -701,7 +710,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
|
||||
case ElementKind.FUNCTION_PROTOTYPE:
|
||||
if (!(<FunctionPrototype>element).isGeneric && statement.range.source.isEntry) {
|
||||
if (!(<FunctionPrototype>element).is(ElementFlags.GENERIC) && statement.range.source.isEntry) {
|
||||
var functionInstance = this.compileFunctionUsingTypeArguments(<FunctionPrototype>element, []);
|
||||
if (functionInstance) {
|
||||
var functionDeclaration = functionInstance.prototype.declaration;
|
||||
@ -715,7 +724,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (this.compileGlobal(<Global>element) && statement.range.source.isEntry) {
|
||||
var globalDeclaration = (<Global>element).declaration;
|
||||
if (globalDeclaration && globalDeclaration.needsExplicitExport(member)) {
|
||||
if ((<Global>element).hasConstantValue)
|
||||
if ((<Global>element).is(ElementFlags.INLINED))
|
||||
this.module.addGlobalExport(element.internalName, member.externalIdentifier.name);
|
||||
else
|
||||
this.warning(DiagnosticCode.Cannot_export_a_mutable_global, member.range);
|
||||
@ -747,10 +756,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
compileClass(instance: Class): bool {
|
||||
if (instance.isCompiled)
|
||||
if (instance.is(ElementFlags.COMPILED))
|
||||
return true;
|
||||
instance.set(ElementFlags.COMPILED);
|
||||
return true;
|
||||
|
||||
return instance.isCompiled = true;
|
||||
}
|
||||
|
||||
compileInterfaceDeclaration(declaration: InterfaceDeclaration, typeArguments: TypeNode[], contextualTypeArguments: Map<string,Type> | null = null, alternativeReportNode: Node | null = null): void {
|
||||
@ -813,7 +822,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
return this.compileTryStatement(<TryStatement>statement);
|
||||
|
||||
case NodeKind.VARIABLE:
|
||||
return this.compileVariableStatement(<VariableStatement>statement);
|
||||
var variableInit = this.compileVariableStatement(<VariableStatement>statement);
|
||||
return variableInit ? variableInit : this.module.createNop();
|
||||
|
||||
case NodeKind.WHILE:
|
||||
return this.compileWhileStatement(<WhileStatement>statement);
|
||||
@ -838,11 +848,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
compileBlockStatement(statement: BlockStatement): ExpressionRef {
|
||||
var statements = statement.statements;
|
||||
if (statements.length == 0)
|
||||
return this.module.createNop();
|
||||
if (statements.length == 1)
|
||||
return this.compileStatement(statements[0]);
|
||||
return this.module.createBlock(null, this.compileStatements(statements), NativeType.None);
|
||||
|
||||
// NOTE that we could optimize this to a NOP if empty or unwrap a single
|
||||
// statement, but that's not what the source told us to do and left to the
|
||||
// optimizer.
|
||||
|
||||
// Not actually a branch, but can contain its own scoped variables.
|
||||
this.currentFunction.flow = this.currentFunction.flow.enterBranch();
|
||||
|
||||
var stmt = this.module.createBlock(null, this.compileStatements(statements), NativeType.None);
|
||||
|
||||
// Switch back to the parent flow
|
||||
this.currentFunction.flow = this.currentFunction.flow.leaveBranch();
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
compileBreakStatement(statement: BreakStatement): ExpressionRef {
|
||||
@ -850,34 +869,48 @@ export class Compiler extends DiagnosticEmitter {
|
||||
this.error(DiagnosticCode.Operation_not_supported, statement.label.range);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
var context = this.currentFunction.breakContext;
|
||||
if (context != null)
|
||||
return this.module.createBreak("break|" + context);
|
||||
|
||||
var breakLabel = this.currentFunction.flow.breakLabel;
|
||||
if (breakLabel == null) {
|
||||
this.error(DiagnosticCode.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement, statement.range);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
return this.module.createBreak(breakLabel);
|
||||
}
|
||||
|
||||
compileContinueStatement(statement: ContinueStatement): ExpressionRef {
|
||||
if (statement.label) {
|
||||
this.error(DiagnosticCode.Operation_not_supported, statement.label.range);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
var context = this.currentFunction.breakContext;
|
||||
if (context && !this.disallowContinue)
|
||||
return this.module.createBreak("continue|" + context);
|
||||
|
||||
// Check if 'continue' is allowed here
|
||||
var continueLabel = this.currentFunction.flow.continueLabel;
|
||||
if (continueLabel == null) {
|
||||
this.error(DiagnosticCode.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement, statement.range);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
return this.module.createBreak(continueLabel);
|
||||
}
|
||||
|
||||
compileDoStatement(statement: DoStatement): ExpressionRef {
|
||||
|
||||
// A do statement does not initiate a new branch because it is executed at
|
||||
// least once, but has its own break and continue labels.
|
||||
var label = this.currentFunction.enterBreakContext();
|
||||
var previousBreakLabel = this.currentFunction.flow.breakLabel;
|
||||
var previousContinueLabel = this.currentFunction.flow.continueLabel;
|
||||
var breakLabel = this.currentFunction.flow.breakLabel = "break|" + label;
|
||||
var continueLabel = this.currentFunction.flow.continueLabel = "continue|" + label;
|
||||
|
||||
var body = this.compileStatement(statement.statement);
|
||||
|
||||
// Reset to the previous break and continue labels, if any.
|
||||
this.currentFunction.flow.breakLabel = previousBreakLabel;
|
||||
this.currentFunction.flow.continueLabel = previousContinueLabel;
|
||||
|
||||
var condition = this.compileExpression(statement.condition, Type.i32);
|
||||
|
||||
this.currentFunction.leaveBreakContext();
|
||||
var breakLabel = "break|" + label;
|
||||
var continueLabel = "continue|" + label;
|
||||
|
||||
return this.module.createBlock(breakLabel, [
|
||||
this.module.createLoop(continueLabel,
|
||||
this.module.createBlock(null, [
|
||||
@ -901,18 +934,24 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
compileForStatement(statement: ForStatement): ExpressionRef {
|
||||
|
||||
// A for statement initiates a new branch with its own scoped variables
|
||||
// possibly declared in its initializer, and break context.
|
||||
var context = this.currentFunction.enterBreakContext();
|
||||
var variableWasLocal = this.variableIsLocal;
|
||||
if (this.currentFunction == this.startFunction)
|
||||
this.variableIsLocal = true;
|
||||
this.currentFunction.flow = this.currentFunction.flow.enterBranch();
|
||||
var breakLabel = this.currentFunction.flow.breakLabel = "break|" + context;
|
||||
var continueLabel = this.currentFunction.flow.continueLabel = "continue|" + context;
|
||||
|
||||
// Compile in correct order
|
||||
var initializer = statement.initializer ? this.compileStatement(<Statement>statement.initializer) : this.module.createNop();
|
||||
this.variableIsLocal = variableWasLocal;
|
||||
var condition = statement.condition ? this.compileExpression(<Expression>statement.condition, Type.i32) : this.module.createI32(1);
|
||||
var incrementor = statement.incrementor ? this.compileExpression(<Expression>statement.incrementor, Type.void) : this.module.createNop();
|
||||
var body = this.compileStatement(statement.statement);
|
||||
|
||||
// Switch back to the parent flow
|
||||
this.currentFunction.flow = this.currentFunction.flow.leaveBranch();
|
||||
this.currentFunction.leaveBreakContext();
|
||||
var continueLabel = "continue|" + context;
|
||||
var breakLabel = "break|" + context;
|
||||
|
||||
return this.module.createBlock(breakLabel, [
|
||||
initializer,
|
||||
this.module.createLoop(continueLabel, this.module.createBlock(null, [
|
||||
@ -926,30 +965,47 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
compileIfStatement(statement: IfStatement): ExpressionRef {
|
||||
|
||||
// The condition doesn't initiate a branch yet
|
||||
var condition = this.compileExpression(statement.condition, Type.i32);
|
||||
|
||||
// Each arm initiates a branch
|
||||
this.currentFunction.flow = this.currentFunction.flow.enterBranch();
|
||||
var ifTrue = this.compileStatement(statement.ifTrue);
|
||||
var ifFalse = statement.ifFalse ? this.compileStatement(<Statement>statement.ifFalse) : <ExpressionRef>0;
|
||||
this.currentFunction.flow = this.currentFunction.flow.leaveBranch();
|
||||
|
||||
var ifFalse: ExpressionRef = 0;
|
||||
if (statement.ifFalse) {
|
||||
this.currentFunction.flow = this.currentFunction.flow.enterBranch();
|
||||
ifFalse = this.compileStatement(statement.ifFalse);
|
||||
this.currentFunction.flow = this.currentFunction.flow.leaveBranch();
|
||||
}
|
||||
return this.module.createIf(condition, ifTrue, ifFalse);
|
||||
}
|
||||
|
||||
compileReturnStatement(statement: ReturnStatement): ExpressionRef {
|
||||
if (this.currentFunction) {
|
||||
var expression = statement.value ? this.compileExpression(<Expression>statement.value, this.currentFunction.returnType) : <ExpressionRef>0;
|
||||
assert(this.currentFunction);
|
||||
|
||||
var expression: ExpressionRef = 0;
|
||||
if (statement.value)
|
||||
expression = this.compileExpression(<Expression>statement.value, this.currentFunction.returnType);
|
||||
|
||||
// Remember that this flow returns
|
||||
this.currentFunction.flow.set(FlowFlags.RETURNS);
|
||||
|
||||
return this.module.createReturn(expression);
|
||||
}
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
|
||||
compileSwitchStatement(statement: SwitchStatement): ExpressionRef {
|
||||
|
||||
// Everything within a switch uses the same break context
|
||||
var context = this.currentFunction.enterBreakContext();
|
||||
var previousDisallowContinue = this.disallowContinue;
|
||||
this.disallowContinue = true;
|
||||
|
||||
// introduce a local for evaluating the condition (exactly once)
|
||||
var tempLocal = this.currentFunction.getTempLocal(Type.i32);
|
||||
var k = statement.cases.length;
|
||||
|
||||
// prepend initializer to inner block
|
||||
// Prepend initializer to inner block. Does not initiate a new branch, yet.
|
||||
var breaks = new Array<ExpressionRef>(1 + k);
|
||||
breaks[0] = this.module.createSetLocal(tempLocal.index, this.compileExpression(statement.condition, Type.i32)); // initializer
|
||||
|
||||
@ -981,22 +1037,34 @@ export class Compiler extends DiagnosticEmitter {
|
||||
var currentBlock = this.module.createBlock("case0|" + context, breaks, NativeType.None);
|
||||
for (i = 0; i < k; ++i) {
|
||||
case_ = statement.cases[i];
|
||||
var nextLabel = i == k - 1 ? "break|" + context : "case" + (i + 1).toString(10) + "|" + context;
|
||||
var l = case_.statements.length;
|
||||
var body = new Array<ExpressionRef>(1 + l);
|
||||
body[0] = currentBlock;
|
||||
|
||||
// Each switch case initiates a new branch
|
||||
this.currentFunction.flow = this.currentFunction.flow.enterBranch();
|
||||
var breakLabel = this.currentFunction.flow.breakLabel = "break|" + context;
|
||||
|
||||
var nextLabel = i == k - 1 ? breakLabel : "case" + (i + 1).toString(10) + "|" + context;
|
||||
for (var j = 0; j < l; ++j)
|
||||
body[j + 1] = this.compileStatement(case_.statements[j]);
|
||||
|
||||
// Switch back to the parent flow
|
||||
this.currentFunction.flow = this.currentFunction.flow.leaveBranch();
|
||||
|
||||
currentBlock = this.module.createBlock(nextLabel, body, NativeType.None);
|
||||
}
|
||||
this.currentFunction.leaveBreakContext();
|
||||
this.disallowContinue = previousDisallowContinue;
|
||||
|
||||
return currentBlock;
|
||||
}
|
||||
|
||||
compileThrowStatement(statement: ThrowStatement): ExpressionRef {
|
||||
return this.module.createUnreachable(); // TODO: waiting for exception-handling spec
|
||||
|
||||
// Remember that this branch possibly throws
|
||||
this.currentFunction.flow.set(FlowFlags.THROWS);
|
||||
|
||||
// TODO: requires exception-handling spec.
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
|
||||
compileTryStatement(statement: TryStatement): ExpressionRef {
|
||||
@ -1005,16 +1073,28 @@ export class Compiler extends DiagnosticEmitter {
|
||||
// worthwhile to investigate lowering returns to block results (here)?
|
||||
}
|
||||
|
||||
compileVariableStatement(statement: VariableStatement): ExpressionRef {
|
||||
/**
|
||||
* Compiles a variable statement. Returns `0` if an initializer is not
|
||||
* necessary.
|
||||
*/
|
||||
compileVariableStatement(statement: VariableStatement, isKnownGlobal: bool = false): ExpressionRef {
|
||||
var declarations = statement.declarations;
|
||||
|
||||
// top-level variables become globals
|
||||
if (this.currentFunction == this.startFunction && !this.variableIsLocal) {
|
||||
var isConst = hasModifier(ModifierKind.CONST, statement.modifiers);
|
||||
// top-level variables and constants become globals
|
||||
if (isKnownGlobal || (
|
||||
this.currentFunction == this.startFunction &&
|
||||
statement.parent && statement.parent.kind == NodeKind.SOURCE
|
||||
)) {
|
||||
// NOTE that the above condition also covers top-level variables declared with 'let', even
|
||||
// though such variables could also become start function locals if, and only if, not used
|
||||
// within any function declared in the same source, which is unknown at this point. the only
|
||||
// efficient way to deal with this would be to keep track of all occasions it is used and
|
||||
// replace these instructions afterwards, dynamically. (TOOD: what about a Binaryen pass?)
|
||||
for (var i = 0, k = declarations.length; i < k; ++i)
|
||||
this.compileGlobalDeclaration(declarations[i], isConst);
|
||||
return this.module.createNop();
|
||||
this.compileGlobalDeclaration(declarations[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// other variables become locals
|
||||
var initializers = new Array<ExpressionRef>();
|
||||
for (i = 0, k = declarations.length; i < k; ++i) {
|
||||
@ -1039,9 +1119,6 @@ export class Compiler extends DiagnosticEmitter {
|
||||
this.error(DiagnosticCode.Type_expected, declaration.name.range.atEnd);
|
||||
continue;
|
||||
}
|
||||
if (this.currentFunction.locals.has(name))
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.name.range, name); // recoverable
|
||||
else {
|
||||
if (hasModifier(ModifierKind.CONST, declaration.modifiers)) {
|
||||
if (init) {
|
||||
init = this.precomputeExpressionRef(init);
|
||||
@ -1063,29 +1140,52 @@ export class Compiler extends DiagnosticEmitter {
|
||||
default:
|
||||
throw new Error("concrete type expected");
|
||||
}
|
||||
this.currentFunction.locals.set(name, local);
|
||||
continue;
|
||||
// Create a virtual local that doesn't actually exist in WebAssembly
|
||||
var scopedLocals = this.currentFunction.flow.scopedLocals;
|
||||
if (!scopedLocals)
|
||||
scopedLocals = this.currentFunction.flow.scopedLocals = new Map();
|
||||
else if (scopedLocals.has(name)) {
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.name.range, name);
|
||||
return 0;
|
||||
}
|
||||
scopedLocals.set(name, local);
|
||||
return 0;
|
||||
} else
|
||||
this.warning(DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable, declaration.range);
|
||||
} else {
|
||||
} else
|
||||
this.error(DiagnosticCode._const_declarations_must_be_initialized, declaration.range);
|
||||
}
|
||||
}
|
||||
this.currentFunction.addLocal(type, name);
|
||||
if (hasModifier(ModifierKind.LET, declaration.modifiers)) // here: not top-level
|
||||
this.currentFunction.flow.addScopedLocal(name, type, declaration.name); // reports
|
||||
else
|
||||
this.currentFunction.addLocal(type, name); // reports
|
||||
if (init)
|
||||
initializers.push(this.compileAssignmentWithValue(declaration.name, init));
|
||||
}
|
||||
}
|
||||
return initializers.length ? this.module.createBlock(null, initializers, NativeType.None) : this.module.createNop();
|
||||
return initializers.length // we can unwrap these here because the
|
||||
? initializers.length == 1 // source didn't tell us exactly what to do
|
||||
? initializers[0]
|
||||
: this.module.createBlock(null, initializers, NativeType.None)
|
||||
: 0;
|
||||
}
|
||||
|
||||
compileWhileStatement(statement: WhileStatement): ExpressionRef {
|
||||
var label = this.currentFunction.enterBreakContext();
|
||||
|
||||
// The condition does not yet initialize a branch
|
||||
var condition = this.compileExpression(statement.condition, Type.i32);
|
||||
var breakLabel = "break|" + label;
|
||||
var continueLabel = "continue|" + label;
|
||||
|
||||
// Statements initiate a new branch with its own break context
|
||||
var label = this.currentFunction.enterBreakContext();
|
||||
this.currentFunction.flow = this.currentFunction.flow.enterBranch();
|
||||
var breakLabel = this.currentFunction.flow.breakLabel = "break|" + label;
|
||||
var continueLabel = this.currentFunction.flow.continueLabel = "continue|" + label;
|
||||
|
||||
var body = this.compileStatement(statement.statement);
|
||||
|
||||
// Switch back to the parent flow
|
||||
this.currentFunction.flow = this.currentFunction.flow.leaveBranch();
|
||||
this.currentFunction.leaveBreakContext();
|
||||
|
||||
return this.module.createBlock(breakLabel, [
|
||||
this.module.createLoop(continueLabel,
|
||||
this.module.createIf(condition, this.module.createBlock(null, [
|
||||
@ -2256,7 +2356,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
case ElementKind.LOCAL:
|
||||
this.currentType = tee ? (<Local>element).type : Type.void;
|
||||
if ((<Local>element).isConstant) {
|
||||
if ((<Local>element).is(ElementFlags.CONSTANT)) {
|
||||
this.error(DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, expression.range, (<Local>element).internalName);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
@ -2269,7 +2369,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
return this.module.createUnreachable();
|
||||
assert((<Global>element).type != Type.void);
|
||||
this.currentType = tee ? (<Global>element).type : Type.void;
|
||||
if ((<Local>element).isConstant) {
|
||||
if ((<Local>element).is(ElementFlags.CONSTANT)) {
|
||||
this.error(DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, expression.range, (<Local>element).internalName);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
@ -2307,7 +2407,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (setterInstance) {
|
||||
assert(setterInstance.parameters.length == 1);
|
||||
if (!tee) {
|
||||
if (setterInstance.isInstance) {
|
||||
if (setterInstance.is(ElementFlags.INSTANCE)) {
|
||||
assert(resolved.targetExpression != null);
|
||||
targetExpr = this.compileExpression(<Expression>resolved.targetExpression, this.options.target == Target.WASM64 ? Type.usize64 : Type.usize32, ConversionKind.NONE);
|
||||
assert(this.currentType.classType);
|
||||
@ -2323,7 +2423,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
var getterInstance = (<FunctionPrototype>getterPrototype).resolve(); // reports
|
||||
if (getterInstance) {
|
||||
assert(getterInstance.parameters.length == 0);
|
||||
if (setterInstance.isInstance) {
|
||||
if (setterInstance.is(ElementFlags.INSTANCE)) {
|
||||
assert(resolved.targetExpression != null);
|
||||
targetExpr = this.compileExpression(<Expression>resolved.targetExpression, this.options.target == Target.WASM64 ? Type.usize64 : Type.usize32, ConversionKind.NONE);
|
||||
assert(this.currentType.classType);
|
||||
@ -2388,7 +2488,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (element.kind == ElementKind.FUNCTION_PROTOTYPE) {
|
||||
var functionPrototype = <FunctionPrototype>element;
|
||||
var functionInstance: Function | null = null;
|
||||
if (functionPrototype.isBuiltIn) {
|
||||
if (functionPrototype.is(ElementFlags.BUILTIN)) {
|
||||
var resolvedTypeArguments: Type[] | null = null;
|
||||
if (expression.typeArguments) {
|
||||
var k = expression.typeArguments.length;
|
||||
@ -2489,11 +2589,11 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
private makeCall(functionInstance: Function, operands: ExpressionRef[] | null = null): ExpressionRef {
|
||||
if (!(functionInstance.isCompiled || this.compileFunction(functionInstance)))
|
||||
if (!(functionInstance.is(ElementFlags.COMPILED) || this.compileFunction(functionInstance)))
|
||||
return this.module.createUnreachable();
|
||||
|
||||
// imported function
|
||||
if (functionInstance.isDeclared)
|
||||
if (functionInstance.is(ElementFlags.DECLARED))
|
||||
return this.module.createCallImport(functionInstance.internalName, operands, functionInstance.returnType.toNativeType());
|
||||
|
||||
// internal function
|
||||
@ -2576,19 +2676,19 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
case ElementKind.LOCAL:
|
||||
this.currentType = (<Local>element).type;
|
||||
if ((<Local>element).hasConstantValue)
|
||||
if ((<Local>element).is(ElementFlags.INLINED))
|
||||
return makeInlineConstant(<Local>element, this.module);
|
||||
assert((<Local>element).index >= 0);
|
||||
return this.module.createGetLocal((<Local>element).index, this.currentType.toNativeType());
|
||||
|
||||
case ElementKind.GLOBAL:
|
||||
if (element.isBuiltIn)
|
||||
if (element.is(ElementFlags.BUILTIN))
|
||||
return compileBuiltinGetConstant(this, <Global>element, expression);
|
||||
if (!this.compileGlobal(<Global>element)) // reports; not yet compiled if a static field compiled as a global
|
||||
return this.module.createUnreachable();
|
||||
assert((<Global>element).type != Type.void);
|
||||
this.currentType = (<Global>element).type;
|
||||
if ((<Global>element).hasConstantValue)
|
||||
if ((<Global>element).is(ElementFlags.INLINED))
|
||||
return makeInlineConstant(<Global>element, this.module);
|
||||
return this.module.createGetGlobal((<Global>element).internalName, this.currentType.toNativeType());
|
||||
}
|
||||
@ -2660,13 +2760,13 @@ export class Compiler extends DiagnosticEmitter {
|
||||
switch (element.kind) {
|
||||
|
||||
case ElementKind.GLOBAL: // static property
|
||||
if (element.isBuiltIn)
|
||||
if (element.is(ElementFlags.BUILTIN))
|
||||
return compileBuiltinGetConstant(this, <Global>element, propertyAccess);
|
||||
if (!this.compileGlobal(<Global>element)) // reports; not yet compiled if a static field compiled as a global
|
||||
return this.module.createUnreachable();
|
||||
assert((<Global>element).type != Type.void);
|
||||
this.currentType = (<Global>element).type;
|
||||
if ((<Global>element).hasConstantValue)
|
||||
if ((<Global>element).is(ElementFlags.INLINED))
|
||||
return makeInlineConstant(<Global>element, this.module);
|
||||
return this.module.createGetGlobal((<Global>element).internalName, this.currentType.toNativeType());
|
||||
|
||||
@ -2674,7 +2774,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (!this.compileEnum((<EnumValue>element).enum))
|
||||
return this.module.createUnreachable();
|
||||
this.currentType = Type.i32;
|
||||
if ((<EnumValue>element).hasConstantValue)
|
||||
if ((<EnumValue>element).is(ElementFlags.INLINED))
|
||||
return this.module.createI32((<EnumValue>element).constantValue);
|
||||
return this.module.createGetGlobal((<EnumValue>element).internalName, NativeType.I32);
|
||||
|
||||
@ -2698,7 +2798,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
return this.module.createUnreachable();
|
||||
assert(getterInstance.parameters.length == 0);
|
||||
this.currentType = getterInstance.returnType;
|
||||
if (getterInstance.isInstance) {
|
||||
if (getterInstance.is(ElementFlags.INSTANCE)) {
|
||||
var targetExpr = this.compileExpression(<Expression>resolved.targetExpression, this.options.target == Target.WASM64 ? Type.usize64 : Type.usize32)
|
||||
this.currentType = getterInstance.returnType;
|
||||
return this.makeCall(getterInstance, [ targetExpr ]);
|
||||
@ -3062,7 +3162,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
/** Creates an inlined expression of a constant variable-like element. */
|
||||
function makeInlineConstant(element: VariableLikeElement, module: Module): ExpressionRef {
|
||||
assert(element.hasConstantValue);
|
||||
assert(element.is(ElementFlags.INLINED));
|
||||
assert(element.type != null);
|
||||
switch ((<Type>element.type).kind) {
|
||||
|
||||
|
@ -153,15 +153,17 @@ export class Parser extends DiagnosticEmitter {
|
||||
|
||||
case Token.CONST:
|
||||
modifiers = addModifier(Node.createModifier(ModifierKind.CONST, tn.range()), modifiers);
|
||||
|
||||
if (tn.skip(Token.ENUM)) {
|
||||
statement = this.parseEnum(tn, modifiers, decorators);
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
statement = this.parseVariable(tn, modifiers, decorators);
|
||||
decorators = null;
|
||||
break;
|
||||
|
||||
case Token.VAR:
|
||||
case Token.LET:
|
||||
modifiers = addModifier(Node.createModifier(ModifierKind.LET, tn.range()), modifiers);
|
||||
case Token.VAR:
|
||||
statement = this.parseVariable(tn, modifiers, decorators);
|
||||
decorators = null;
|
||||
break;
|
||||
@ -1032,6 +1034,8 @@ export class Parser extends DiagnosticEmitter {
|
||||
return this.parseIfStatement(tn);
|
||||
|
||||
case Token.LET:
|
||||
return this.parseVariable(tn, [ Node.createModifier(ModifierKind.LET, tn.range()) ], null);
|
||||
|
||||
case Token.VAR:
|
||||
return this.parseVariable(tn, null, null);
|
||||
|
||||
|
232
src/program.ts
232
src/program.ts
@ -272,7 +272,7 @@ export class Program extends DiagnosticEmitter {
|
||||
}
|
||||
|
||||
private checkGlobalAlias(element: Element, declaration: DeclarationStatement) {
|
||||
if (hasDecorator("global", declaration.decorators) || (declaration.range.source.isStdlib && assert(declaration.parent).kind == NodeKind.SOURCE && element.isExported)) {
|
||||
if (hasDecorator("global", declaration.decorators) || (declaration.range.source.isStdlib && assert(declaration.parent).kind == NodeKind.SOURCE && element.is(ElementFlags.EXPORTED))) {
|
||||
if (this.elements.has(declaration.name.name))
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.name.range, element.internalName);
|
||||
else {
|
||||
@ -317,7 +317,7 @@ export class Program extends DiagnosticEmitter {
|
||||
namespace.members.set(declaration.name.name, prototype);
|
||||
|
||||
// otherwise add to file-level exports if exported
|
||||
} else if (prototype.isExported) {
|
||||
} else if (prototype.is(ElementFlags.EXPORTED)) {
|
||||
if (this.exports.has(internalName)) {
|
||||
this.error(DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, declaration.name.range, internalName);
|
||||
return;
|
||||
@ -541,7 +541,7 @@ export class Program extends DiagnosticEmitter {
|
||||
} else
|
||||
namespace.members = new Map();
|
||||
namespace.members.set(declaration.name.name, enm);
|
||||
} else if (enm.isExported) {
|
||||
} else if (enm.is(ElementFlags.EXPORTED)) {
|
||||
if (this.exports.has(internalName)) {
|
||||
this.error(DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, declaration.name.range, internalName);
|
||||
return;
|
||||
@ -669,7 +669,7 @@ export class Program extends DiagnosticEmitter {
|
||||
} else
|
||||
namespace.members = new Map();
|
||||
namespace.members.set(declaration.name.name, prototype);
|
||||
} else if (prototype.isExported) {
|
||||
} else if (prototype.is(ElementFlags.EXPORTED)) {
|
||||
if (this.exports.has(internalName)) {
|
||||
this.error(DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, declaration.name.range, internalName);
|
||||
return;
|
||||
@ -759,7 +759,7 @@ export class Program extends DiagnosticEmitter {
|
||||
} else
|
||||
namespace.members = new Map();
|
||||
namespace.members.set(prototype.internalName, prototype);
|
||||
} else if (prototype.isExported) {
|
||||
} else if (prototype.is(ElementFlags.EXPORTED)) {
|
||||
if (this.exports.has(internalName)) {
|
||||
this.error(DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, declaration.name.range, internalName);
|
||||
return;
|
||||
@ -810,7 +810,7 @@ export class Program extends DiagnosticEmitter {
|
||||
} else
|
||||
parentNamespace.members = new Map();
|
||||
parentNamespace.members.set(declaration.name.name, namespace);
|
||||
} else if (namespace.isExported) {
|
||||
} else if (namespace.is(ElementFlags.EXPORTED)) {
|
||||
if (this.exports.has(internalName)) {
|
||||
this.error(DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, declaration.name.range, internalName);
|
||||
return;
|
||||
@ -884,7 +884,7 @@ export class Program extends DiagnosticEmitter {
|
||||
this.elements.set(internalName, global);
|
||||
|
||||
// differs a bit from this.checkGlobalAlias in that it checks the statement's parent
|
||||
if (hasDecorator("global", declaration.decorators) || (declaration.range.source.isStdlib && assert(statement.parent).kind == NodeKind.SOURCE && global.isExported)) {
|
||||
if (hasDecorator("global", declaration.decorators) || (declaration.range.source.isStdlib && assert(statement.parent).kind == NodeKind.SOURCE && global.is(ElementFlags.EXPORTED))) {
|
||||
if (this.elements.has(declaration.name.name))
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.name.range, internalName);
|
||||
else
|
||||
@ -900,7 +900,7 @@ export class Program extends DiagnosticEmitter {
|
||||
} else
|
||||
namespace.members = new Map();
|
||||
namespace.members.set(declaration.name.name, global);
|
||||
} else if (global.isExported) {
|
||||
} else if (global.is(ElementFlags.EXPORTED)) {
|
||||
if (this.exports.has(internalName))
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.name.range, internalName);
|
||||
else
|
||||
@ -994,8 +994,9 @@ export class Program extends DiagnosticEmitter {
|
||||
var namespace: Element | null;
|
||||
|
||||
if (contextualFunction) {
|
||||
|
||||
// check locals
|
||||
var local = contextualFunction.locals.get(name);
|
||||
var local = contextualFunction.flow.getScopedLocal(name);
|
||||
if (local)
|
||||
return (resolvedElement || (resolvedElement = new ResolvedElement())).set(local);
|
||||
|
||||
@ -1228,8 +1229,8 @@ export enum ElementFlags {
|
||||
GENERIC = 1 << 5,
|
||||
/** Is constant. */
|
||||
CONSTANT = 1 << 6,
|
||||
/** Has constant value. */
|
||||
CONSTANT_VALUE = 1 << 7,
|
||||
/** Has a constant value and is therefore inlined. */
|
||||
INLINED = 1 << 7,
|
||||
/** Is instance member. */
|
||||
INSTANCE = 1 << 8,
|
||||
/** Is getter. */
|
||||
@ -1251,7 +1252,9 @@ export enum ElementFlags {
|
||||
/** Is an explicitly layed out and allocated class with limited capabilites. */
|
||||
EXPLICIT = 1 << 17,
|
||||
/** Has already inherited base class static members. */
|
||||
HAS_STATIC_BASE_MEMBERS = 1 << 18
|
||||
HAS_STATIC_BASE_MEMBERS = 1 << 18,
|
||||
/** Is scoped. */
|
||||
SCOPED = 1 << 19
|
||||
}
|
||||
|
||||
/** Base class of all program elements. */
|
||||
@ -1279,49 +1282,11 @@ export abstract class Element {
|
||||
this.internalName = internalName;
|
||||
}
|
||||
|
||||
/** Whether compiled or not. */
|
||||
get isCompiled(): bool { return (this.flags & ElementFlags.COMPILED) != 0; }
|
||||
set isCompiled(is: bool) { if (is) this.flags |= ElementFlags.COMPILED; else this.flags &= ~ElementFlags.COMPILED; }
|
||||
/** Tests if this element has a specific flag or flags. */
|
||||
is(flag: ElementFlags): bool { return (this.flags & flag) == flag; }
|
||||
|
||||
/** Whether imported or not. */
|
||||
get isImported(): bool { return (this.flags & ElementFlags.IMPORTED) != 0; }
|
||||
set isImported(is: bool) { if (is) this.flags |= ElementFlags.IMPORTED; else this.flags &= ~ElementFlags.IMPORTED; }
|
||||
|
||||
/** Whether exported or not. */
|
||||
get isExported(): bool { return (this.flags & ElementFlags.EXPORTED) != 0; }
|
||||
set isExported(is: bool) { if (is) this.flags |= ElementFlags.EXPORTED; else this.flags &= ~ElementFlags.EXPORTED; }
|
||||
|
||||
/** Whether built-in or not. */
|
||||
get isBuiltIn(): bool { return (this.flags & ElementFlags.BUILTIN) != 0; }
|
||||
set isBuiltIn(is: bool) { if (is) this.flags |= ElementFlags.BUILTIN; else this.flags &= ~ElementFlags.BUILTIN; }
|
||||
|
||||
/** Whether declared or not. */
|
||||
get isDeclared(): bool { return (this.flags & ElementFlags.DECLARED) != 0; }
|
||||
set isDeclared(is: bool) { if (is) this.flags |= ElementFlags.DECLARED; else this.flags &= ~ElementFlags.DECLARED; }
|
||||
|
||||
/** Whether generic or not. */
|
||||
get isGeneric(): bool { return (this.flags & ElementFlags.GENERIC) != 0; }
|
||||
set isGeneric(is: bool) { if (is) this.flags |= ElementFlags.GENERIC; else this.flags &= ~ElementFlags.GENERIC; }
|
||||
|
||||
/** Whether constant or not. */
|
||||
get isConstant(): bool { return (this.flags & ElementFlags.CONSTANT) != 0; }
|
||||
set isConstant(is: bool) { if (is) this.flags |= ElementFlags.CONSTANT; else this.flags &= ~ElementFlags.CONSTANT; }
|
||||
|
||||
/** Whether mutable or not. */
|
||||
get isMutable(): bool { return !(this.flags & ElementFlags.CONSTANT); } // reuses constant flag
|
||||
set isMutable(is: bool) { if (is) this.flags &= ~ElementFlags.CONSTANT; else this.flags |= ElementFlags.CONSTANT; }
|
||||
|
||||
/** Whether this element has a constant value or not. */
|
||||
get hasConstantValue(): bool { return (this.flags & ElementFlags.CONSTANT_VALUE) != 0; }
|
||||
set hasConstantValue(is: bool) { if (is) this.flags |= ElementFlags.CONSTANT_VALUE; else this.flags &= ~ElementFlags.CONSTANT_VALUE; }
|
||||
|
||||
/** Whether an instance member or not. */
|
||||
get isInstance(): bool { return (this.flags & ElementFlags.INSTANCE) != 0; }
|
||||
set isInstance(is: bool) { if (is) this.flags |= ElementFlags.INSTANCE; else this.flags &= ~ElementFlags.INSTANCE; }
|
||||
|
||||
/** Whether a member of the global namespace or not. */
|
||||
get isGlobal(): bool { return (this.flags & ElementFlags.GLOBAL) != 0; }
|
||||
set isGlobal(is: bool) { if (is) this.flags |= ElementFlags.GLOBAL; else this.flags &= ~ElementFlags.GLOBAL; }
|
||||
/** Sets a specific flag or flags. */
|
||||
set(flag: ElementFlags): void { this.flags |= flag; }
|
||||
}
|
||||
|
||||
/** A namespace. */
|
||||
@ -1339,9 +1304,9 @@ export class Namespace extends Element {
|
||||
if ((this.declaration = declaration) && this.declaration.modifiers) {
|
||||
for (var i = 0, k = this.declaration.modifiers.length; i < k; ++i) {
|
||||
switch (this.declaration.modifiers[i].modifierKind) {
|
||||
case ModifierKind.IMPORT: this.isImported = true; break;
|
||||
case ModifierKind.EXPORT: this.isExported = true; break;
|
||||
case ModifierKind.DECLARE: this.isDeclared = true; break;
|
||||
case ModifierKind.IMPORT: this.set(ElementFlags.IMPORTED); break;
|
||||
case ModifierKind.EXPORT: this.set(ElementFlags.EXPORTED); break;
|
||||
case ModifierKind.DECLARE: this.set(ElementFlags.DECLARED); break;
|
||||
default: throw new Error("unexpected modifier");
|
||||
}
|
||||
}
|
||||
@ -1363,10 +1328,10 @@ export class Enum extends Element {
|
||||
if ((this.declaration = declaration) && this.declaration.modifiers) {
|
||||
for (var i = 0, k = this.declaration.modifiers.length; i < k; ++i) {
|
||||
switch (this.declaration.modifiers[i].modifierKind) {
|
||||
case ModifierKind.EXPORT: this.isExported = true; break;
|
||||
case ModifierKind.IMPORT: this.isImported = true; break;
|
||||
case ModifierKind.DECLARE: this.isDeclared = true; break;
|
||||
case ModifierKind.CONST: this.isConstant = true; break;
|
||||
case ModifierKind.EXPORT: this.set(ElementFlags.EXPORTED); break;
|
||||
case ModifierKind.IMPORT: this.set(ElementFlags.IMPORTED); break;
|
||||
case ModifierKind.DECLARE: this.set(ElementFlags.DECLARED); break;
|
||||
case ModifierKind.CONST: this.set(ElementFlags.CONSTANT); break;
|
||||
default: throw new Error("unexpected modifier");
|
||||
}
|
||||
}
|
||||
@ -1408,15 +1373,13 @@ export class VariableLikeElement extends Element {
|
||||
|
||||
withConstantIntegerValue(lo: i32, hi: i32): this {
|
||||
this.constantIntegerValue = new I64(lo, hi);
|
||||
this.hasConstantValue = true;
|
||||
this.isMutable = false;
|
||||
this.set(ElementFlags.CONSTANT | ElementFlags.INLINED);
|
||||
return this;
|
||||
}
|
||||
|
||||
withConstantFloatValue(value: f64): this {
|
||||
this.constantFloatValue = value;
|
||||
this.hasConstantValue = true;
|
||||
this.isMutable = false;
|
||||
this.set(ElementFlags.CONSTANT | ElementFlags.INLINED);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1432,18 +1395,19 @@ export class Global extends VariableLikeElement {
|
||||
if (this.declaration.modifiers) {
|
||||
for (var i = 0, k = this.declaration.modifiers.length; i < k; ++i) {
|
||||
switch (this.declaration.modifiers[i].modifierKind) {
|
||||
case ModifierKind.IMPORT: this.isImported = true; break;
|
||||
case ModifierKind.EXPORT: this.isExported = true; break;
|
||||
case ModifierKind.CONST: this.isConstant = true; break;
|
||||
case ModifierKind.DECLARE: this.isDeclared = true; break;
|
||||
case ModifierKind.READONLY: this.isConstant = true; break;
|
||||
case ModifierKind.IMPORT: this.set(ElementFlags.IMPORTED); break;
|
||||
case ModifierKind.EXPORT: this.set(ElementFlags.EXPORTED); break;
|
||||
case ModifierKind.CONST: this.set(ElementFlags.CONSTANT); break;
|
||||
case ModifierKind.LET: this.set(ElementFlags.SCOPED); break;
|
||||
case ModifierKind.DECLARE: this.set(ElementFlags.DECLARED); break;
|
||||
case ModifierKind.READONLY: this.set(this.declaration.initializer ? ElementFlags.CONSTANT | ElementFlags.READONLY : ElementFlags.READONLY); break;
|
||||
case ModifierKind.STATIC: break; // static fields become globals
|
||||
default: throw new Error("unexpected modifier");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.hasConstantValue = true; // built-ins have constant values
|
||||
this.set(ElementFlags.CONSTANT | ElementFlags.INLINED); // built-ins have constant values
|
||||
}
|
||||
this.type = type; // resolved later if `void`
|
||||
}
|
||||
@ -1505,11 +1469,11 @@ export class FunctionPrototype extends Element {
|
||||
if (this.declaration.modifiers)
|
||||
for (var i = 0, k = this.declaration.modifiers.length; i < k; ++i) {
|
||||
switch (this.declaration.modifiers[i].modifierKind) {
|
||||
case ModifierKind.IMPORT: this.isImported = true; break;
|
||||
case ModifierKind.EXPORT: this.isExported = true; break;
|
||||
case ModifierKind.DECLARE: this.isDeclared = true; break;
|
||||
case ModifierKind.GET: this.isGetter = true; break;
|
||||
case ModifierKind.SET: this.isSetter = true; break;
|
||||
case ModifierKind.IMPORT: this.set(ElementFlags.IMPORTED); break;
|
||||
case ModifierKind.EXPORT: this.set(ElementFlags.EXPORTED); break;
|
||||
case ModifierKind.DECLARE: this.set(ElementFlags.DECLARED); break;
|
||||
case ModifierKind.GET: this.set(ElementFlags.GETTER); break;
|
||||
case ModifierKind.SET: this.set(ElementFlags.SETTER); break;
|
||||
case ModifierKind.STATIC:
|
||||
case ModifierKind.ABSTRACT:
|
||||
case ModifierKind.PRIVATE:
|
||||
@ -1519,10 +1483,10 @@ export class FunctionPrototype extends Element {
|
||||
}
|
||||
}
|
||||
if (this.declaration.typeParameters.length)
|
||||
this.isGeneric = true;
|
||||
this.set(ElementFlags.GENERIC);
|
||||
}
|
||||
if (this.classPrototype = classPrototype)
|
||||
this.isInstance = true;
|
||||
this.set(ElementFlags.INSTANCE);
|
||||
}
|
||||
|
||||
/** Whether a getter function or not. */
|
||||
@ -1629,7 +1593,7 @@ export class FunctionPrototype extends Element {
|
||||
|
||||
resolveInclTypeArguments(typeArgumentNodes: TypeNode[] | null, contextualTypeArguments: Map<string,Type> | null, alternativeReportNode: Node | null): Function | null {
|
||||
var resolvedTypeArguments: Type[] | null = null;
|
||||
if (this.isGeneric) {
|
||||
if (this.is(ElementFlags.GENERIC)) {
|
||||
assert(typeArgumentNodes != null && typeArgumentNodes.length != 0);
|
||||
if (!this.declaration)
|
||||
throw new Error("cannot resolve built-ins");
|
||||
@ -1678,6 +1642,8 @@ export class Function extends Element {
|
||||
breakContext: string | null = null;
|
||||
/** Contextual type arguments. */
|
||||
contextualTypeArguments: Map<string,Type> | null;
|
||||
/** Current control flow. */
|
||||
flow: Flow;
|
||||
|
||||
private nextBreakId: i32 = 0;
|
||||
private breakStack: i32[] | null = null;
|
||||
@ -1693,7 +1659,7 @@ export class Function extends Element {
|
||||
this.flags = prototype.flags;
|
||||
var localIndex = 0;
|
||||
if (instanceMethodOf) {
|
||||
assert(this.isInstance); // internal error
|
||||
assert(this.is(ElementFlags.INSTANCE)); // internal error
|
||||
this.locals.set("this", new Local(prototype.program, "this", localIndex++, instanceMethodOf.type));
|
||||
if (instanceMethodOf.contextualTypeArguments) {
|
||||
if (!this.contextualTypeArguments)
|
||||
@ -1702,18 +1668,19 @@ export class Function extends Element {
|
||||
this.contextualTypeArguments.set(inheritedName, inheritedType);
|
||||
}
|
||||
} else
|
||||
assert(!this.isInstance); // internal error
|
||||
assert(!this.is(ElementFlags.INSTANCE)); // internal error
|
||||
for (var i = 0, k = parameters.length; i < k; ++i) {
|
||||
var parameter = parameters[i];
|
||||
this.locals.set(parameter.name, new Local(prototype.program, parameter.name, localIndex++, parameter.type));
|
||||
}
|
||||
this.flow = Flow.create(this);
|
||||
}
|
||||
|
||||
/** Adds a local of the specified type, with an optional name. */
|
||||
addLocal(type: Type, name: string | null = null): Local {
|
||||
// if it has a name, check previously as this method will throw otherwise
|
||||
var localIndex = this.parameters.length + this.additionalLocals.length;
|
||||
if (this.isInstance) localIndex++; // plus 'this'
|
||||
if (this.is(ElementFlags.INSTANCE)) localIndex++; // plus 'this'
|
||||
var local = new Local(this.prototype.program, name ? name : "anonymous$" + localIndex.toString(10), localIndex, type);
|
||||
if (name) {
|
||||
if (this.locals.has(name))
|
||||
@ -1831,8 +1798,8 @@ export class FieldPrototype extends Element {
|
||||
if ((this.declaration = declaration) && this.declaration.modifiers) {
|
||||
for (var i = 0, k = this.declaration.modifiers.length; i < k; ++i) {
|
||||
switch (this.declaration.modifiers[i].modifierKind) {
|
||||
case ModifierKind.EXPORT: this.isExported = true; break;
|
||||
case ModifierKind.READONLY: this.isReadonly = true; break;
|
||||
case ModifierKind.EXPORT: this.set(ElementFlags.EXPORTED); break;
|
||||
case ModifierKind.READONLY: this.set(ElementFlags.READONLY); break;
|
||||
case ModifierKind.PRIVATE:
|
||||
case ModifierKind.PROTECTED:
|
||||
case ModifierKind.PUBLIC:
|
||||
@ -1915,15 +1882,15 @@ export class ClassPrototype extends Element {
|
||||
if (this.declaration.modifiers) {
|
||||
for (var i = 0, k = this.declaration.modifiers.length; i < k; ++i) {
|
||||
switch (this.declaration.modifiers[i].modifierKind) {
|
||||
case ModifierKind.IMPORT: this.isImported = true; break;
|
||||
case ModifierKind.EXPORT: this.isExported = true; break;
|
||||
case ModifierKind.DECLARE: this.isDeclared = true; break;
|
||||
case ModifierKind.IMPORT: this.set(ElementFlags.IMPORTED); break;
|
||||
case ModifierKind.EXPORT: this.set(ElementFlags.EXPORTED); break;
|
||||
case ModifierKind.DECLARE: this.set(ElementFlags.DECLARED); break;
|
||||
default: throw new Error("unexpected modifier");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.declaration.typeParameters.length)
|
||||
this.isGeneric = true;
|
||||
this.set(ElementFlags.GENERIC);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2050,7 +2017,7 @@ export class ClassPrototype extends Element {
|
||||
|
||||
resolveInclTypeArguments(typeArgumentNodes: TypeNode[] | null, contextualTypeArguments: Map<string,Type> | null, alternativeReportNode: Node | null): Class | null {
|
||||
var resolvedTypeArguments: Type[] | null = null;
|
||||
if (this.isGeneric) {
|
||||
if (this.is(ElementFlags.GENERIC)) {
|
||||
assert(typeArgumentNodes != null && typeArgumentNodes.length != 0);
|
||||
if (!this.declaration)
|
||||
throw new Error("cannot resolve built-ins");
|
||||
@ -2153,3 +2120,90 @@ export class Interface extends Class {
|
||||
super(prototype, internalName, typeArguments, base);
|
||||
}
|
||||
}
|
||||
|
||||
/** Control flow flags indicating specific conditions. */
|
||||
export const enum FlowFlags {
|
||||
NONE = 0,
|
||||
RETURNS = 1 << 0,
|
||||
THROWS = 1 << 1
|
||||
}
|
||||
|
||||
/** A control flow evaluator. */
|
||||
export class Flow {
|
||||
|
||||
/** Parent flow. */
|
||||
parent: Flow | null;
|
||||
/** Flow flags indicating specific conditions. */
|
||||
flags: FlowFlags;
|
||||
/** Function this flow belongs to. */
|
||||
currentFunction: Function;
|
||||
/** The label we break to when encountering a continue statement. */
|
||||
continueLabel: string | null;
|
||||
/** The label we break to when encountering a break statement. */
|
||||
breakLabel: string | null;
|
||||
/** Scoped local variables. */
|
||||
scopedLocals: Map<string,Local> | null = null;
|
||||
|
||||
/** Creates the parent flow of the specified function. */
|
||||
static create(currentFunction: Function): Flow {
|
||||
var parentFlow = new Flow();
|
||||
parentFlow.flags = FlowFlags.NONE;
|
||||
parentFlow.currentFunction = currentFunction;
|
||||
parentFlow.continueLabel = null;
|
||||
parentFlow.breakLabel = null;
|
||||
return parentFlow;
|
||||
}
|
||||
|
||||
private constructor() { }
|
||||
|
||||
/** Tests if this flow has the specified flag or flags. */
|
||||
is(flag: FlowFlags): bool { return (this.flags & flag) == flag; }
|
||||
|
||||
/** Sets the specified flag or flags. */
|
||||
set(flag: FlowFlags): void { this.flags |= flag; }
|
||||
|
||||
/** Enters a new branch and returns the new flow. */
|
||||
enterBranch(): Flow {
|
||||
var branchFlow = new Flow();
|
||||
branchFlow.parent = this;
|
||||
branchFlow.flags = this.flags;
|
||||
branchFlow.currentFunction = this.currentFunction;
|
||||
branchFlow.continueLabel = this.continueLabel;
|
||||
branchFlow.breakLabel = this.breakLabel;
|
||||
return branchFlow;
|
||||
}
|
||||
|
||||
/** Leaves the current branch and returns the parent flow. */
|
||||
leaveBranch(): Flow {
|
||||
if (this.scopedLocals) {
|
||||
for (var scopedLocal of this.scopedLocals.values())
|
||||
this.currentFunction.freeTempLocal(scopedLocal);
|
||||
this.scopedLocals = null;
|
||||
}
|
||||
return assert(this.parent);
|
||||
}
|
||||
|
||||
/** Adds a new scoped local of the specified name. */
|
||||
addScopedLocal(name: string, type: Type, reportNode: Node): void {
|
||||
var scopedLocal = this.currentFunction.getTempLocal(type);
|
||||
if (!this.scopedLocals)
|
||||
this.scopedLocals = new Map();
|
||||
else if (this.scopedLocals.has(name)) {
|
||||
this.currentFunction.program.error(DiagnosticCode.Duplicate_identifier_0, reportNode.range);
|
||||
return;
|
||||
}
|
||||
this.scopedLocals.set(name, scopedLocal);
|
||||
}
|
||||
|
||||
/** Gets the local of the specified name in the current scope. */
|
||||
getScopedLocal(name: string): Local | null {
|
||||
// console.log("checking: " + name);
|
||||
var local: Local | null;
|
||||
var current: Flow | null = this;
|
||||
do {
|
||||
if (current.scopedLocals && (local = current.scopedLocals.get(name)))
|
||||
return local;
|
||||
} while (current = current.parent);
|
||||
return this.currentFunction.locals.get(name);
|
||||
}
|
||||
}
|
||||
|
@ -51,13 +51,20 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
var program = parser.finish();
|
||||
var parseTime = process.hrtime(startTime);
|
||||
startTime = process.hrtime();
|
||||
var module = Compiler.compile(program);
|
||||
var module;
|
||||
try {
|
||||
module = Compiler.compile(program);
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
module = Module.create();
|
||||
console.log(chalk.red("compile ERROR: ") + e.stack);
|
||||
}
|
||||
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;
|
||||
// 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");
|
||||
|
||||
@ -87,16 +94,14 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
console.log(chalk.green("instantiate OK"));
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
console.log(chalk.red("instantiate ERROR: ") + e);
|
||||
console.log(chalk.red("instantiate ERROR: ") + e.stack);
|
||||
}
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
console.log(chalk.red("interpret ERROR:") + e);
|
||||
console.log(chalk.red("interpret ERROR:") + e.stack);
|
||||
}
|
||||
module.optimize();
|
||||
actualOptimized = module.toText();
|
||||
module.runPasses([ "inlining" ]);
|
||||
actualInlined = module.toText();
|
||||
if (isCreate)
|
||||
fs.writeFileSync(__dirname + "/compiler/" + fixture + ".optimized.wasm", module.toBinary());
|
||||
} else {
|
||||
@ -111,17 +116,6 @@ glob.sync(filter, { cwd: __dirname + "/compiler" }).forEach(filename => {
|
||||
fs.writeFileSync(__dirname + "/compiler/" + fixture + ".optimized.wast", actualOptimized, { encoding: "utf8" });
|
||||
console.log("Created optimized");
|
||||
}
|
||||
if (actualInlined != null) {
|
||||
if (actualInlined != actualOptimized) {
|
||||
fs.writeFileSync(__dirname + "/compiler/" + fixture + ".optimized-inlined.wast", actualInlined, { encoding: "utf8" });
|
||||
console.log("Created optimized & inlined");
|
||||
} else {
|
||||
try {
|
||||
fs.unlinkSync(__dirname + "/compiler/" + fixture + ".optimized-inlined.wast");
|
||||
console.log("Deleted optimized & inlined");
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var expected;
|
||||
try {
|
||||
|
@ -34,20 +34,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $3
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.const 31)
|
||||
)
|
||||
@ -90,9 +76,7 @@
|
||||
(tee_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $3
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
@ -108,12 +92,8 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $3
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
@ -187,12 +167,8 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(tee_local $4
|
||||
(i64.const 1)
|
||||
)
|
||||
(tee_local $5
|
||||
(i64.const 2)
|
||||
)
|
||||
(i64.lt_s
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
@ -251,10 +227,8 @@
|
||||
(select
|
||||
(f32.ne
|
||||
(f32.abs
|
||||
(tee_local $0
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(f32.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
@ -309,10 +283,8 @@
|
||||
(select
|
||||
(f64.ne
|
||||
(f64.abs
|
||||
(tee_local $1
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(f64.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
|
@ -1,141 +0,0 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $ifff (func (param i32 f32 f32) (result f32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $class/Animal.ONE (mut i32) (i32.const 1))
|
||||
(memory $0 1)
|
||||
(export "test" (func $class/test))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $class/test (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 f32)
|
||||
(local $6 f32)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$class/Animal#instanceAdd (result i32)
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(block $__inlined_func$class/Animal#instanceSub<f32> (result f32)
|
||||
(set_local $4
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $5
|
||||
(f32.const 1)
|
||||
)
|
||||
(set_local $6
|
||||
(f32.const 2)
|
||||
)
|
||||
(f32.add
|
||||
(f32.sub
|
||||
(get_local $5)
|
||||
(get_local $6)
|
||||
)
|
||||
(f32.convert_s/i32
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_s offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load8_s offset=6
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.store16 offset=4
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.store8 offset=6
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 f32)
|
||||
(local $3 f32)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$class/Animal.add (result i32)
|
||||
(set_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(block $__inlined_func$class/Animal.sub<f32> (result f32)
|
||||
(set_local $2
|
||||
(f32.const 1)
|
||||
)
|
||||
(set_local $3
|
||||
(f32.const 2)
|
||||
)
|
||||
(f32.add
|
||||
(f32.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(f32.convert_s/i32
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,70 +1,11 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $ifff (func (param i32 f32 f32) (result f32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $class/Animal.ONE (mut i32) (i32.const 1))
|
||||
(memory $0 1)
|
||||
(export "test" (func $class/test))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $class/Animal.add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
(func $class/Animal.sub<f32> (; 1 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
(f32.add
|
||||
(f32.sub
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(f32.convert_s/i32
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $class/Animal#instanceAdd (; 2 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
)
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
(func $class/Animal#instanceSub<f32> (; 3 ;) (type $ifff) (param $0 i32) (param $1 f32) (param $2 f32) (result f32)
|
||||
(f32.add
|
||||
(f32.sub
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
)
|
||||
(f32.convert_s/i32
|
||||
(get_global $class/Animal.ONE)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $class/test (; 4 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(drop
|
||||
(call $class/Animal#instanceAdd
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $class/Animal#instanceSub<f32>
|
||||
(get_local $0)
|
||||
(f32.const 1)
|
||||
(f32.const 2)
|
||||
)
|
||||
)
|
||||
(func $class/test (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
@ -94,18 +35,7 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $start (; 5 ;) (type $v)
|
||||
(drop
|
||||
(call $class/Animal.add
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $class/Animal.sub<f32>
|
||||
(f32.const 1)
|
||||
(f32.const 2)
|
||||
)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
|
@ -127,16 +127,12 @@
|
||||
(i32.const 24)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $2)
|
||||
)
|
||||
|
@ -147,11 +147,9 @@
|
||||
(unreachable)
|
||||
)
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
|
@ -1,48 +0,0 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $enum/Implicit.ZERO i32 (i32.const 0))
|
||||
(global $enum/Implicit.ONE i32 (i32.const 1))
|
||||
(global $enum/Implicit.TWO i32 (i32.const 2))
|
||||
(global $enum/Implicit.THREE i32 (i32.const 3))
|
||||
(global $enum/Explicit.ZERO i32 (i32.const 0))
|
||||
(global $enum/Explicit.ONE i32 (i32.const 1))
|
||||
(global $enum/Explicit.TWO i32 (i32.const 2))
|
||||
(global $enum/Explicit.THREE i32 (i32.const 3))
|
||||
(global $enum/Mixed.ZERO i32 (i32.const 0))
|
||||
(global $enum/Mixed.ONE i32 (i32.const 1))
|
||||
(global $enum/Mixed.THREE i32 (i32.const 3))
|
||||
(global $enum/Mixed.FOUR i32 (i32.const 4))
|
||||
(global $enum/NonConstant.ZERO (mut i32) (i32.const 0))
|
||||
(global $enum/NonConstant.ONE (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(export "enum/Implicit.ZERO" (global $enum/Implicit.ZERO))
|
||||
(export "enum/Implicit.ONE" (global $enum/Implicit.ONE))
|
||||
(export "enum/Implicit.TWO" (global $enum/Implicit.TWO))
|
||||
(export "enum/Implicit.THREE" (global $enum/Implicit.THREE))
|
||||
(export "enum/Explicit.ZERO" (global $enum/Explicit.ZERO))
|
||||
(export "enum/Explicit.ONE" (global $enum/Explicit.ONE))
|
||||
(export "enum/Explicit.TWO" (global $enum/Explicit.TWO))
|
||||
(export "enum/Explicit.THREE" (global $enum/Explicit.THREE))
|
||||
(export "enum/Mixed.ZERO" (global $enum/Mixed.ZERO))
|
||||
(export "enum/Mixed.ONE" (global $enum/Mixed.ONE))
|
||||
(export "enum/Mixed.THREE" (global $enum/Mixed.THREE))
|
||||
(export "enum/Mixed.FOUR" (global $enum/Mixed.FOUR))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(set_global $enum/NonConstant.ZERO
|
||||
(block (result i32)
|
||||
(block $__inlined_func$enum/getZero (result i32)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $enum/NonConstant.ONE
|
||||
(i32.add
|
||||
(get_global $enum/NonConstant.ZERO)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,5 +1,4 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $enum/Implicit.ZERO i32 (i32.const 0))
|
||||
(global $enum/Implicit.ONE i32 (i32.const 1))
|
||||
@ -30,12 +29,9 @@
|
||||
(export "enum/Mixed.FOUR" (global $enum/Mixed.FOUR))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $enum/getZero (; 0 ;) (type $i) (result i32)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(set_global $enum/NonConstant.ZERO
|
||||
(call $enum/getZero)
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_global $enum/NonConstant.ONE
|
||||
(i32.add
|
||||
|
@ -14,8 +14,8 @@
|
||||
(local $5 i64)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(local $9 f64)
|
||||
(local $8 f64)
|
||||
(block $folding-inner0
|
||||
(set_local $3
|
||||
(i32.wrap/i64
|
||||
(i64.and
|
||||
@ -46,14 +46,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.wrap/i64
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -71,10 +63,10 @@
|
||||
)
|
||||
(get_local $7)
|
||||
(f64.ne
|
||||
(tee_local $9
|
||||
(tee_local $8
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $9)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -113,7 +105,7 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i64.eq
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
@ -124,18 +116,20 @@
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.wrap/i64
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(if (result i64)
|
||||
(get_local $3)
|
||||
@ -270,16 +264,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i64.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
(return
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $4)
|
||||
@ -315,16 +303,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i64.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
(return
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $4)
|
||||
@ -356,14 +338,11 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.reinterpret/i64
|
||||
(i64.or
|
||||
(tee_local $2
|
||||
(if (result i64)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
)
|
||||
(select
|
||||
(i64.or
|
||||
(i64.sub
|
||||
(get_local $2)
|
||||
@ -388,25 +367,36 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i64.shl
|
||||
(i64.extend_u/i32
|
||||
(get_local $8)
|
||||
(get_local $7)
|
||||
)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $fmod/fmodf (; 1 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 f32)
|
||||
(local $7 f32)
|
||||
(local $8 i32)
|
||||
(block $folding-inner0
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
@ -433,12 +423,6 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -455,10 +439,10 @@
|
||||
)
|
||||
(get_local $3)
|
||||
(f32.ne
|
||||
(tee_local $8
|
||||
(tee_local $7
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $8)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -497,7 +481,7 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.eq
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
@ -508,18 +492,18 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(if (result i32)
|
||||
(get_local $4)
|
||||
@ -650,16 +634,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $3)
|
||||
@ -695,16 +673,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $3)
|
||||
@ -736,14 +708,11 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.reinterpret/i32
|
||||
(i32.or
|
||||
(tee_local $2
|
||||
(if (result i32)
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(i32.const 0)
|
||||
)
|
||||
(select
|
||||
(i32.or
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
@ -764,10 +733,20 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
|
@ -19,21 +19,16 @@
|
||||
(local $7 f64)
|
||||
(local $8 i32)
|
||||
(local $9 i64)
|
||||
(block
|
||||
(set_local $2
|
||||
(i64.reinterpret/f64
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i64.reinterpret/f64
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.wrap/i64
|
||||
(i64.and
|
||||
@ -45,8 +40,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.wrap/i64
|
||||
(i64.and
|
||||
@ -58,8 +51,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.wrap/i64
|
||||
(i64.shr_u
|
||||
@ -68,7 +59,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -163,14 +153,12 @@
|
||||
)
|
||||
(block
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $9
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
(i64.const 12)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i64.eqz
|
||||
@ -497,21 +485,16 @@
|
||||
(local $7 f32)
|
||||
(local $8 i32)
|
||||
(local $9 i32)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.reinterpret/f32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i32.reinterpret/f32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
@ -521,8 +504,6 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
@ -532,15 +513,12 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -635,14 +613,12 @@
|
||||
)
|
||||
(block
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $9
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.eqz
|
||||
|
@ -33,9 +33,6 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_s
|
||||
|
@ -17,8 +17,10 @@
|
||||
(get_global $for/i)
|
||||
(i32.const 10)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(nop)
|
||||
)
|
||||
(set_global $for/i
|
||||
(i32.add
|
||||
(get_global $for/i)
|
||||
@ -40,19 +42,19 @@
|
||||
(unreachable)
|
||||
)
|
||||
(block $break|1
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $0)
|
||||
(i32.const 10)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(nop)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
|
@ -1,195 +0,0 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(type $i (func (result i32)))
|
||||
(type $I (func (result i64)))
|
||||
(type $f (func (result f32)))
|
||||
(type $F (func (result f64)))
|
||||
(type $iv (func (param i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $II (func (param i64) (result i64)))
|
||||
(type $ff (func (param f32) (result f32)))
|
||||
(type $FF (func (param f64) (result f64)))
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $IiI (func (param i64 i32) (result i64)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i64)
|
||||
(local $3 f32)
|
||||
(local $4 f64)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(local $9 i64)
|
||||
(local $10 i32)
|
||||
(local $11 f32)
|
||||
(local $12 f32)
|
||||
(local $13 f64)
|
||||
(local $14 f64)
|
||||
(block
|
||||
(block $__inlined_func$function/v
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$function/i (result i32)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i64)
|
||||
(block $__inlined_func$function/I (result i64)
|
||||
(i64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(block $__inlined_func$function/f (result f32)
|
||||
(f32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f64)
|
||||
(block $__inlined_func$function/F (result f64)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(block $__inlined_func$function/iv
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$function/ii (result i32)
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i64)
|
||||
(block $__inlined_func$function/II (result i64)
|
||||
(set_local $2
|
||||
(i64.const 0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(block $__inlined_func$function/ff (result f32)
|
||||
(set_local $3
|
||||
(f32.const 0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f64)
|
||||
(block $__inlined_func$function/FF (result f64)
|
||||
(set_local $4
|
||||
(f64.const 0)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(block $__inlined_func$function/iiv
|
||||
(set_local $5
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $6
|
||||
(i32.const 2)
|
||||
)
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$function/iii (result i32)
|
||||
(set_local $7
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i64)
|
||||
(block $__inlined_func$function/III (result i64)
|
||||
(set_local $9
|
||||
(i64.const 1)
|
||||
)
|
||||
(set_local $10
|
||||
(i32.const 2)
|
||||
)
|
||||
(i64.add
|
||||
(get_local $9)
|
||||
(i64.extend_s/i32
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f32)
|
||||
(block $__inlined_func$function/fff (result f32)
|
||||
(set_local $11
|
||||
(f32.const 1)
|
||||
)
|
||||
(set_local $12
|
||||
(f32.const 2)
|
||||
)
|
||||
(f32.add
|
||||
(get_local $11)
|
||||
(get_local $12)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result f64)
|
||||
(block $__inlined_func$function/FFF (result f64)
|
||||
(set_local $13
|
||||
(f64.const 1)
|
||||
)
|
||||
(set_local $14
|
||||
(f64.const 2)
|
||||
)
|
||||
(f64.add
|
||||
(get_local $13)
|
||||
(get_local $14)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,145 +1,9 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(type $i (func (result i32)))
|
||||
(type $I (func (result i64)))
|
||||
(type $f (func (result f32)))
|
||||
(type $F (func (result f64)))
|
||||
(type $iv (func (param i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $II (func (param i64) (result i64)))
|
||||
(type $ff (func (param f32) (result f32)))
|
||||
(type $FF (func (param f64) (result f64)))
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $IiI (func (param i64 i32) (result i64)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $function/v (; 0 ;) (type $v)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
(func $function/i (; 1 ;) (type $i) (result i32)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $function/I (; 2 ;) (type $I) (result i64)
|
||||
(i64.const 0)
|
||||
)
|
||||
(func $function/f (; 3 ;) (type $f) (result f32)
|
||||
(f32.const 0)
|
||||
)
|
||||
(func $function/F (; 4 ;) (type $F) (result f64)
|
||||
(f64.const 0)
|
||||
)
|
||||
(func $function/iv (; 5 ;) (type $iv) (param $0 i32)
|
||||
(nop)
|
||||
)
|
||||
(func $function/ii (; 6 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $function/II (; 7 ;) (type $II) (param $0 i64) (result i64)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $function/ff (; 8 ;) (type $ff) (param $0 f32) (result f32)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $function/FF (; 9 ;) (type $FF) (param $0 f64) (result f64)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $function/iiv (; 10 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(nop)
|
||||
)
|
||||
(func $function/iii (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $function/III (; 12 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64)
|
||||
(i64.add
|
||||
(get_local $0)
|
||||
(i64.extend_s/i32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $function/fff (; 13 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
(f32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $function/FFF (; 14 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
(f64.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $start (; 15 ;) (type $v)
|
||||
(call $function/v)
|
||||
(drop
|
||||
(call $function/i)
|
||||
)
|
||||
(drop
|
||||
(call $function/I)
|
||||
)
|
||||
(drop
|
||||
(call $function/f)
|
||||
)
|
||||
(drop
|
||||
(call $function/F)
|
||||
)
|
||||
(call $function/iv
|
||||
(i32.const 0)
|
||||
)
|
||||
(drop
|
||||
(call $function/ii
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $function/II
|
||||
(i64.const 0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $function/ff
|
||||
(f32.const 0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $function/FF
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(call $function/iiv
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(drop
|
||||
(call $function/iii
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $function/III
|
||||
(i64.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $function/fff
|
||||
(f32.const 1)
|
||||
(f32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $function/FFF
|
||||
(f64.const 1)
|
||||
(f64.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -43,9 +43,6 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
@ -210,11 +207,7 @@
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
(select
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
@ -223,6 +216,10 @@
|
||||
(get_local $2)
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
|
@ -48,11 +48,9 @@
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
@ -90,11 +88,9 @@
|
||||
)
|
||||
)
|
||||
(block $break|1
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_u
|
||||
@ -131,7 +127,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $8
|
||||
(i32.and
|
||||
(i32.add
|
||||
@ -223,7 +218,6 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load8_u
|
||||
(i32.add
|
||||
|
@ -50,7 +50,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/clz_ (; 2 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i64)
|
||||
(block
|
||||
(set_local $2
|
||||
(i64.clz
|
||||
(i64.or
|
||||
@ -66,7 +65,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $2)
|
||||
@ -78,7 +76,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/ctz_ (; 3 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i64)
|
||||
(block
|
||||
(set_local $2
|
||||
(i64.ctz
|
||||
(i64.or
|
||||
@ -94,7 +91,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $2)
|
||||
@ -106,7 +102,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/popcnt_ (; 4 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i64)
|
||||
(block
|
||||
(set_local $2
|
||||
(i64.popcnt
|
||||
(i64.or
|
||||
@ -122,7 +117,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $2)
|
||||
@ -134,7 +128,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/eqz (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(block
|
||||
(set_local $2
|
||||
(i64.eqz
|
||||
(i64.or
|
||||
@ -150,7 +143,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $2)
|
||||
)
|
||||
@ -160,7 +152,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/add (; 6 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.add
|
||||
(i64.or
|
||||
@ -187,7 +178,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -204,7 +194,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/sub (; 7 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.sub
|
||||
(i64.or
|
||||
@ -231,7 +220,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -248,7 +236,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/mul (; 8 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.mul
|
||||
(i64.or
|
||||
@ -275,7 +262,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -292,7 +278,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/div_s (; 9 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.div_s
|
||||
(i64.or
|
||||
@ -319,7 +304,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -336,7 +320,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/div_u (; 10 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.div_u
|
||||
(i64.or
|
||||
@ -363,7 +346,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -380,7 +362,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/rem_s (; 11 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.rem_s
|
||||
(i64.or
|
||||
@ -407,7 +388,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -424,7 +404,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/rem_u (; 12 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.rem_u
|
||||
(i64.or
|
||||
@ -451,7 +430,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -468,7 +446,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/and (; 13 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.and
|
||||
(i64.or
|
||||
@ -495,7 +472,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -512,7 +488,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/or (; 14 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.or
|
||||
(i64.or
|
||||
@ -539,7 +514,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -556,7 +530,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/xor (; 15 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.xor
|
||||
(i64.or
|
||||
@ -583,7 +556,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -600,7 +572,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/shl (; 16 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.shl
|
||||
(i64.or
|
||||
@ -627,7 +598,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -644,7 +614,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/shr_s (; 17 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.shr_s
|
||||
(i64.or
|
||||
@ -671,7 +640,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -688,7 +656,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/shr_u (; 18 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.shr_u
|
||||
(i64.or
|
||||
@ -715,7 +682,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -732,7 +698,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/rotl_ (; 19 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.rotl
|
||||
(i64.or
|
||||
@ -759,7 +724,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -776,7 +740,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/rotr_ (; 20 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i64)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.rotr
|
||||
(i64.or
|
||||
@ -803,7 +766,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(i32.wrap/i64
|
||||
(get_local $4)
|
||||
@ -820,7 +782,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/eq (; 21 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.eq
|
||||
(i64.or
|
||||
@ -847,7 +808,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -857,7 +817,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/ne (; 22 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.ne
|
||||
(i64.or
|
||||
@ -884,7 +843,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -894,7 +852,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/lt_s (; 23 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.lt_s
|
||||
(i64.or
|
||||
@ -921,7 +878,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -931,7 +887,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/lt_u (; 24 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.lt_u
|
||||
(i64.or
|
||||
@ -958,7 +913,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -968,7 +922,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/le_s (; 25 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.le_s
|
||||
(i64.or
|
||||
@ -995,7 +948,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -1005,7 +957,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/le_u (; 26 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.le_u
|
||||
(i64.or
|
||||
@ -1032,7 +983,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -1042,7 +992,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/gt_s (; 27 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.gt_s
|
||||
(i64.or
|
||||
@ -1069,7 +1018,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -1079,7 +1027,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/gt_u (; 28 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.gt_u
|
||||
(i64.or
|
||||
@ -1106,7 +1053,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -1116,7 +1062,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/ge_s (; 29 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.ge_s
|
||||
(i64.or
|
||||
@ -1143,7 +1088,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
@ -1153,7 +1097,6 @@
|
||||
)
|
||||
(func $../../examples/i64-polyfill/assembly/i64/ge_u (; 30 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.ge_u
|
||||
(i64.or
|
||||
@ -1180,7 +1123,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $../../examples/i64-polyfill/assembly/i64/lo
|
||||
(get_local $4)
|
||||
)
|
||||
|
@ -8,10 +8,10 @@
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $if/ifThenElse (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(select
|
||||
(i32.const 1)
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $if/ifThen (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
|
@ -1,68 +0,0 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.add
|
||||
(block (result i32)
|
||||
(block $__inlined_func$export/add (result i32)
|
||||
(set_local $0
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block (result i32)
|
||||
(block $__inlined_func$export/sub (result i32)
|
||||
(set_local $2
|
||||
(i32.const 2)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block (result i32)
|
||||
(block $__inlined_func$export/mul (result i32)
|
||||
(set_local $4
|
||||
(i32.const 3)
|
||||
)
|
||||
(set_local $5
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(block $__inlined_func$export/ns.two
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,49 +1,9 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $export/add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $export/sub (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $export/mul (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $export/ns.two (; 3 ;) (type $v)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
(func $start (; 4 ;) (type $v)
|
||||
(drop
|
||||
(i32.add
|
||||
(i32.add
|
||||
(call $export/add
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(call $export/sub
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(call $export/mul
|
||||
(i32.const 3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $export/ns.two)
|
||||
)
|
||||
)
|
||||
|
@ -1,74 +0,0 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(type $i (func (result i32)))
|
||||
(type $I (func (result i64)))
|
||||
(type $f (func (result f32)))
|
||||
(type $F (func (result f64)))
|
||||
(global $infer-type/ri (mut i32) (i32.const 0))
|
||||
(global $infer-type/rI (mut i64) (i64.const 0))
|
||||
(global $infer-type/rf (mut f32) (f32.const 0))
|
||||
(global $infer-type/rF (mut f64) (f64.const 0))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(block
|
||||
(block $__inlined_func$infer-type/locals
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
(set_global $infer-type/ri
|
||||
(block (result i32)
|
||||
(block $__inlined_func$infer-type/reti (result i32)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $infer-type/rI
|
||||
(block (result i64)
|
||||
(block $__inlined_func$infer-type/retI (result i64)
|
||||
(i64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $infer-type/rf
|
||||
(block (result f32)
|
||||
(block $__inlined_func$infer-type/retf (result f32)
|
||||
(f32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $infer-type/rF
|
||||
(block (result f64)
|
||||
(block $__inlined_func$infer-type/refF (result f64)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 10)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,9 +1,5 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(type $i (func (result i32)))
|
||||
(type $I (func (result i64)))
|
||||
(type $f (func (result f32)))
|
||||
(type $F (func (result f64)))
|
||||
(global $infer-type/ri (mut i32) (i32.const 0))
|
||||
(global $infer-type/rI (mut i64) (i64.const 0))
|
||||
(global $infer-type/rf (mut f32) (f32.const 0))
|
||||
@ -11,48 +7,25 @@
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $infer-type/locals (; 0 ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
(func $infer-type/reti (; 1 ;) (type $i) (result i32)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $infer-type/retI (; 2 ;) (type $I) (result i64)
|
||||
(i64.const 0)
|
||||
)
|
||||
(func $infer-type/retf (; 3 ;) (type $f) (result f32)
|
||||
(f32.const 0)
|
||||
)
|
||||
(func $infer-type/refF (; 4 ;) (type $F) (result f64)
|
||||
(f64.const 0)
|
||||
)
|
||||
(func $start (; 5 ;) (type $v)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(call $infer-type/locals)
|
||||
(set_global $infer-type/ri
|
||||
(call $infer-type/reti)
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_global $infer-type/rI
|
||||
(call $infer-type/retI)
|
||||
(i64.const 0)
|
||||
)
|
||||
(set_global $infer-type/rf
|
||||
(call $infer-type/retf)
|
||||
(f32.const 0)
|
||||
)
|
||||
(set_global $infer-type/rF
|
||||
(call $infer-type/refF)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 10)
|
||||
(f64.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(i32.const 10)
|
||||
)
|
||||
(block
|
||||
(set_local $0
|
||||
|
@ -22,37 +22,25 @@
|
||||
(local $3 i32)
|
||||
(local $4 i64)
|
||||
(local $5 f64)
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i64.const 4294967296)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(f64.const 1.5)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i64.const 4294967296)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(f64.const 1.5)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $infer-type/reti (; 1 ;) (type $i) (result i32)
|
||||
(return
|
||||
(i32.const 0)
|
||||
@ -125,8 +113,10 @@
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(nop)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,11 +13,9 @@
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(block
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(nop)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
|
@ -10,11 +10,9 @@
|
||||
(func $memmove/memmove (; 0 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(block
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
@ -282,6 +280,7 @@
|
||||
(loop $continue|5
|
||||
(if
|
||||
(get_local $2)
|
||||
(block
|
||||
(block
|
||||
(i32.store8
|
||||
(i32.add
|
||||
@ -300,6 +299,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|5)
|
||||
)
|
||||
)
|
||||
|
@ -10,16 +10,14 @@
|
||||
(local $3 i32)
|
||||
(local $4 i64)
|
||||
(local $5 i32)
|
||||
(block $folding-inner0
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
(return
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $0)
|
||||
@ -35,14 +33,11 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
(return
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
@ -78,14 +73,11 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 6)
|
||||
)
|
||||
(return
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
@ -104,14 +96,11 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 8)
|
||||
)
|
||||
(return
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $0
|
||||
@ -153,14 +142,11 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 8)
|
||||
)
|
||||
(return
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
@ -196,14 +182,11 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.le_u
|
||||
(get_local $2)
|
||||
(i32.const 24)
|
||||
)
|
||||
(return
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
@ -354,6 +337,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
|
@ -11,11 +11,9 @@
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i64)
|
||||
(block
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
@ -116,7 +114,6 @@
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.sub
|
||||
@ -126,7 +123,6 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
@ -148,7 +144,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.mul
|
||||
(i32.div_u
|
||||
@ -161,7 +156,6 @@
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $5)
|
||||
@ -317,7 +311,6 @@
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i64.or
|
||||
(i64.extend_u/i32
|
||||
@ -331,7 +324,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
(if
|
||||
|
@ -1,24 +0,0 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $namespace/Outer.Inner.aVar (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$namespace/Outer.Inner.aFunc (result i32)
|
||||
(get_global $namespace/Outer.Inner.aVar)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(block (result i32)
|
||||
(block $__inlined_func$namespace/Joined.anotherFunc (result i32)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,22 +1,9 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $namespace/Outer.Inner.aVar (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $namespace/Outer.Inner.aFunc (; 0 ;) (type $i) (result i32)
|
||||
(get_global $namespace/Outer.Inner.aVar)
|
||||
)
|
||||
(func $namespace/Joined.anotherFunc (; 1 ;) (type $i) (result i32)
|
||||
(i32.const 3)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
(drop
|
||||
(call $namespace/Outer.Inner.aFunc)
|
||||
)
|
||||
(drop
|
||||
(call $namespace/Joined.anotherFunc)
|
||||
)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
)
|
||||
|
@ -593,11 +593,9 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.const -128)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.le_s
|
||||
|
46
tests/compiler/scoped.optimized.wast
Normal file
46
tests/compiler/scoped.optimized.wast
Normal file
@ -0,0 +1,46 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
14
tests/compiler/scoped.ts
Normal file
14
tests/compiler/scoped.ts
Normal file
@ -0,0 +1,14 @@
|
||||
var aGlobal: i32 = 1;
|
||||
const aConstant: i32 = 3;
|
||||
|
||||
let aStartFunctionLocal: i32 = 2;
|
||||
for (var anotherStartFunctionLocal: i32 = 0; anotherStartFunctionLocal < 1; ++anotherStartFunctionLocal);
|
||||
for (let aGlobal /* that shadows */: i32 = 0; aGlobal < 1; ++aGlobal)
|
||||
aGlobal;
|
||||
|
||||
{
|
||||
let /* actually not */ aConstant: i64 = 5;
|
||||
{
|
||||
let /* still not */ aConstant: f32 = 10;
|
||||
}
|
||||
}
|
124
tests/compiler/scoped.wast
Normal file
124
tests/compiler/scoped.wast
Normal file
@ -0,0 +1,124 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(global $scoped/aGlobal (mut i32) (i32.const 1))
|
||||
(global $scoped/aConstant i32 (i32.const 3))
|
||||
(global $scoped/aStartFunctionLocal (mut i32) (i32.const 2))
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i64)
|
||||
(local $3 f32)
|
||||
(block $break|0
|
||||
(set_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(nop)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|1
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(drop
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(i64.const 5)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(f32.const 10)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
GLOBAL: NaN
|
||||
GLOBAL: Infinity
|
||||
FUNCTION_PROTOTYPE: isNaN
|
||||
FUNCTION_PROTOTYPE: isFinite
|
||||
FUNCTION_PROTOTYPE: clz
|
||||
FUNCTION_PROTOTYPE: ctz
|
||||
FUNCTION_PROTOTYPE: popcnt
|
||||
FUNCTION_PROTOTYPE: rotl
|
||||
FUNCTION_PROTOTYPE: rotr
|
||||
FUNCTION_PROTOTYPE: abs
|
||||
FUNCTION_PROTOTYPE: max
|
||||
FUNCTION_PROTOTYPE: min
|
||||
FUNCTION_PROTOTYPE: ceil
|
||||
FUNCTION_PROTOTYPE: floor
|
||||
FUNCTION_PROTOTYPE: copysign
|
||||
FUNCTION_PROTOTYPE: nearest
|
||||
FUNCTION_PROTOTYPE: reinterpret
|
||||
FUNCTION_PROTOTYPE: sqrt
|
||||
FUNCTION_PROTOTYPE: trunc
|
||||
FUNCTION_PROTOTYPE: load
|
||||
FUNCTION_PROTOTYPE: store
|
||||
FUNCTION_PROTOTYPE: sizeof
|
||||
FUNCTION_PROTOTYPE: select
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
FUNCTION_PROTOTYPE: i16
|
||||
FUNCTION_PROTOTYPE: i32
|
||||
FUNCTION_PROTOTYPE: i64
|
||||
FUNCTION_PROTOTYPE: u8
|
||||
FUNCTION_PROTOTYPE: u16
|
||||
FUNCTION_PROTOTYPE: u32
|
||||
FUNCTION_PROTOTYPE: u64
|
||||
FUNCTION_PROTOTYPE: bool
|
||||
FUNCTION_PROTOTYPE: f32
|
||||
FUNCTION_PROTOTYPE: f64
|
||||
FUNCTION_PROTOTYPE: isize
|
||||
FUNCTION_PROTOTYPE: usize
|
||||
GLOBAL: HEAP_BASE
|
||||
GLOBAL: scoped/aGlobal
|
||||
GLOBAL: scoped/aConstant
|
||||
GLOBAL: scoped/aStartFunctionLocal
|
||||
[program.exports]
|
||||
|
||||
;)
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,8 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $fff (func (param f32 f32) (result f32)))
|
||||
(type $FFF (func (param f64 f64) (result f64)))
|
||||
(type $v (func))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $ifv (func (param i32 f32)))
|
||||
(type $if (func (param i32) (result f32)))
|
||||
(global $showcase/aConstantGlobal i32 (i32.const 42))
|
||||
(global $showcase/anExportedConstantGlobal f32 (f32.const 42))
|
||||
(global $showcase/aMutableGlobal (mut i32) (i32.const 42))
|
||||
@ -50,31 +46,10 @@
|
||||
(export "anExportedFunction" (func $showcase/anExportedFunction))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $showcase/ANamespace.aNamespacedFunction (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $showcase/addGeneric<i32> (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $showcase/addGeneric<f32> (; 2 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
(f32.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $showcase/addGeneric<f64> (; 3 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
(f64.add
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $showcase/anExportedFunction (; 4 ;) (type $v)
|
||||
(func $showcase/anExportedFunction (; 0 ;) (type $v)
|
||||
(nop)
|
||||
)
|
||||
(func $memcpy/memcpy (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $memcpy/memcpy (; 1 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
@ -1657,15 +1632,15 @@
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
(func $fmod/fmod (; 6 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
(func $fmod/fmod (; 2 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
|
||||
(local $2 i64)
|
||||
(local $3 i32)
|
||||
(local $4 i64)
|
||||
(local $5 i64)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(local $9 f64)
|
||||
(local $8 f64)
|
||||
(block $folding-inner0
|
||||
(set_local $3
|
||||
(i32.wrap/i64
|
||||
(i64.and
|
||||
@ -1696,14 +1671,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.wrap/i64
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -1721,10 +1688,10 @@
|
||||
)
|
||||
(get_local $7)
|
||||
(f64.ne
|
||||
(tee_local $9
|
||||
(tee_local $8
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $9)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -1763,7 +1730,7 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i64.eq
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
@ -1774,18 +1741,20 @@
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.wrap/i64
|
||||
(i64.shr_u
|
||||
(get_local $2)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(if (result i64)
|
||||
(get_local $3)
|
||||
@ -1920,16 +1889,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i64.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
(return
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $4)
|
||||
@ -1965,16 +1928,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i64.eqz
|
||||
(get_local $4)
|
||||
)
|
||||
(return
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $4)
|
||||
@ -2006,14 +1963,11 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.reinterpret/i64
|
||||
(i64.or
|
||||
(tee_local $2
|
||||
(if (result i64)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
)
|
||||
(select
|
||||
(i64.or
|
||||
(i64.sub
|
||||
(get_local $2)
|
||||
@ -2038,25 +1992,36 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i64.shl
|
||||
(i64.extend_u/i32
|
||||
(get_local $8)
|
||||
(get_local $7)
|
||||
)
|
||||
(i64.const 63)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $fmod/fmodf (; 7 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
)
|
||||
(f64.mul
|
||||
(f64.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $fmod/fmodf (; 3 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 f32)
|
||||
(local $7 f32)
|
||||
(local $8 i32)
|
||||
(block $folding-inner0
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
@ -2083,12 +2048,6 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -2105,10 +2064,10 @@
|
||||
)
|
||||
(get_local $3)
|
||||
(f32.ne
|
||||
(tee_local $8
|
||||
(tee_local $7
|
||||
(get_local $1)
|
||||
)
|
||||
(get_local $8)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -2147,7 +2106,7 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.eq
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
@ -2158,18 +2117,18 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(if (result i32)
|
||||
(get_local $4)
|
||||
@ -2300,16 +2259,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $3)
|
||||
@ -2345,16 +2298,10 @@
|
||||
)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(br_if $folding-inner0
|
||||
(i32.eqz
|
||||
(get_local $3)
|
||||
)
|
||||
(return
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(get_local $3)
|
||||
@ -2386,14 +2333,11 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f32.reinterpret/i32
|
||||
(i32.or
|
||||
(tee_local $2
|
||||
(if (result i32)
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(i32.const 0)
|
||||
)
|
||||
(select
|
||||
(i32.or
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
@ -2414,30 +2358,27 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $7)
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $showcase/ADerivedClass#set:aWildAccessorAppears (; 8 ;) (type $ifv) (param $0 i32) (param $1 f32)
|
||||
(f32.store offset=4
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
(func $showcase/ADerivedClass#get:aWildAccessorAppears (; 9 ;) (type $if) (param $0 i32) (result f32)
|
||||
(f32.load offset=4
|
||||
)
|
||||
)
|
||||
(f32.mul
|
||||
(f32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $start (; 10 ;) (type $v)
|
||||
(local $0 f64)
|
||||
(func $start (; 4 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 f32)
|
||||
(local $2 i32)
|
||||
(local $2 f64)
|
||||
(local $3 i64)
|
||||
(local $4 i32)
|
||||
(local $5 i64)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(get_global $unary/i)
|
||||
@ -2517,26 +2458,26 @@
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.add
|
||||
(tee_local $2
|
||||
(tee_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/i
|
||||
(block (result i32)
|
||||
(set_global $unary/i
|
||||
(i32.sub
|
||||
(tee_local $2
|
||||
(tee_local $0
|
||||
(get_global $unary/i)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_global $unary/I
|
||||
@ -2806,26 +2747,26 @@
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.add
|
||||
(tee_local $0
|
||||
(tee_local $2
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_global $unary/F
|
||||
(block (result f64)
|
||||
(set_global $unary/F
|
||||
(f64.sub
|
||||
(tee_local $0
|
||||
(tee_local $2
|
||||
(get_global $unary/F)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
@ -3334,17 +3275,13 @@
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $2
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.eq
|
||||
(tee_local $0
|
||||
(f64.const 2)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3429,34 +3366,6 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $4
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $4
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.const 31)
|
||||
)
|
||||
@ -3474,17 +3383,9 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const -42)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 42)
|
||||
(i32.const 0)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -3496,16 +3397,9 @@
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $4
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -3516,19 +3410,8 @@
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $4
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $builtins/i)
|
||||
@ -3553,17 +3436,9 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(tee_local $3
|
||||
(i64.const -42)
|
||||
)
|
||||
(i64.sub
|
||||
(i64.const 0)
|
||||
(get_local $3)
|
||||
)
|
||||
(i64.gt_s
|
||||
(get_local $3)
|
||||
(i64.const 0)
|
||||
)
|
||||
(i64.const 42)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -3575,16 +3450,9 @@
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(tee_local $3
|
||||
(i64.const 1)
|
||||
)
|
||||
(tee_local $5
|
||||
(i64.const 2)
|
||||
)
|
||||
(i64.gt_s
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -3595,19 +3463,8 @@
|
||||
(unreachable)
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(select
|
||||
(tee_local $3
|
||||
(i64.const 1)
|
||||
)
|
||||
(tee_local $5
|
||||
(i64.const 2)
|
||||
)
|
||||
(i64.lt_s
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $builtins/i)
|
||||
@ -3650,28 +3507,12 @@
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(f32.ne
|
||||
(tee_local $1
|
||||
(f32.const 1.25)
|
||||
)
|
||||
(get_local $1)
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(select
|
||||
(f32.ne
|
||||
(f32.abs
|
||||
(tee_local $1
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(f32.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f32.eq
|
||||
(get_local $1)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.const nan:0x8000000000000)
|
||||
@ -3708,28 +3549,12 @@
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(f64.ne
|
||||
(tee_local $0
|
||||
(f64.const 1.25)
|
||||
)
|
||||
(get_local $0)
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(select
|
||||
(f64.ne
|
||||
(f64.abs
|
||||
(tee_local $0
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(f64.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f64.eq
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.load
|
||||
@ -3833,19 +3658,15 @@
|
||||
)
|
||||
(if
|
||||
(f32.eq
|
||||
(tee_local $1
|
||||
(f32.const nan:0x400000)
|
||||
)
|
||||
(get_local $1)
|
||||
(f32.const nan:0x400000)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.eq
|
||||
(tee_local $0
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
(get_local $0)
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -3853,17 +3674,12 @@
|
||||
(select
|
||||
(f32.ne
|
||||
(f32.abs
|
||||
(tee_local $1
|
||||
(f32.const nan:0x400000)
|
||||
)
|
||||
)
|
||||
(f32.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f32.eq
|
||||
(get_local $1)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -3871,17 +3687,12 @@
|
||||
(select
|
||||
(f32.ne
|
||||
(f32.abs
|
||||
(tee_local $1
|
||||
(f32.const inf)
|
||||
)
|
||||
)
|
||||
(f32.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f32.eq
|
||||
(get_local $1)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -3889,17 +3700,12 @@
|
||||
(select
|
||||
(f64.ne
|
||||
(f64.abs
|
||||
(tee_local $0
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(f64.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f64.eq
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -3907,17 +3713,12 @@
|
||||
(select
|
||||
(f64.ne
|
||||
(f64.abs
|
||||
(tee_local $0
|
||||
(f64.const inf)
|
||||
)
|
||||
)
|
||||
(f64.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f64.eq
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -3926,17 +3727,12 @@
|
||||
(select
|
||||
(f32.ne
|
||||
(f32.abs
|
||||
(tee_local $1
|
||||
(f32.const 0)
|
||||
)
|
||||
)
|
||||
(f32.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f32.eq
|
||||
(get_local $1)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3946,24 +3742,19 @@
|
||||
(select
|
||||
(f64.ne
|
||||
(f64.abs
|
||||
(tee_local $0
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(f64.const inf)
|
||||
)
|
||||
(i32.const 0)
|
||||
(f64.eq
|
||||
(get_local $0)
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $showcase/ANamespace.aNamespacedFunction
|
||||
(tee_local $0
|
||||
(get_global $showcase/ANamespace.aNamespacedGlobal)
|
||||
)
|
||||
(i32.const 42)
|
||||
@ -3993,24 +3784,6 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(drop
|
||||
(call $showcase/addGeneric<i32>
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $showcase/addGeneric<f32>
|
||||
(f32.const 1)
|
||||
(f32.const 2)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $showcase/addGeneric<f64>
|
||||
(f64.const 1)
|
||||
(f64.const 2)
|
||||
)
|
||||
)
|
||||
(i64.store
|
||||
(i32.const 8)
|
||||
(i64.const 1229782938247303441)
|
||||
@ -4161,13 +3934,13 @@
|
||||
)
|
||||
(if
|
||||
(f64.eq
|
||||
(tee_local $0
|
||||
(tee_local $2
|
||||
(call $fmod/fmod
|
||||
(f64.const 1)
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
(get_local $2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
@ -4289,15 +4062,19 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(call $showcase/ADerivedClass#set:aWildAccessorAppears
|
||||
(f32.store offset=4
|
||||
(tee_local $0
|
||||
(get_global $showcase/aClassInstance)
|
||||
)
|
||||
(f32.const 123)
|
||||
)
|
||||
(if
|
||||
(f32.ne
|
||||
(call $showcase/ADerivedClass#get:aWildAccessorAppears
|
||||
(f32.load offset=4
|
||||
(tee_local $0
|
||||
(get_global $showcase/aClassInstance)
|
||||
)
|
||||
)
|
||||
(f32.const 123)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -121,11 +121,9 @@
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(block
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(nop)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
@ -1936,21 +1934,16 @@
|
||||
(local $7 f64)
|
||||
(local $8 i32)
|
||||
(local $9 i64)
|
||||
(block
|
||||
(set_local $2
|
||||
(i64.reinterpret/f64
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i64.reinterpret/f64
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.wrap/i64
|
||||
(i64.and
|
||||
@ -1962,8 +1955,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.wrap/i64
|
||||
(i64.and
|
||||
@ -1975,8 +1966,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.wrap/i64
|
||||
(i64.shr_u
|
||||
@ -1985,7 +1974,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -2080,14 +2068,12 @@
|
||||
)
|
||||
(block
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $9
|
||||
(i64.shl
|
||||
(get_local $2)
|
||||
(i64.const 12)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i64.eqz
|
||||
@ -2414,21 +2400,16 @@
|
||||
(local $7 f32)
|
||||
(local $8 i32)
|
||||
(local $9 i32)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.reinterpret/f32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i32.reinterpret/f32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
@ -2438,8 +2419,6 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
@ -2449,15 +2428,12 @@
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.and
|
||||
(get_local $2)
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
@ -2552,14 +2528,12 @@
|
||||
)
|
||||
(block
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $9
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.eqz
|
||||
|
@ -2159,13 +2159,13 @@
|
||||
(if
|
||||
(i32.le_s
|
||||
(tee_local $3
|
||||
(if (result i32)
|
||||
(get_local $2)
|
||||
(select
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(i32.load offset=4
|
||||
@ -2655,9 +2655,6 @@
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
|
@ -30,11 +30,9 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(current_memory)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(i32.add
|
||||
@ -82,11 +80,9 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(get_global $std:heap/HEAP_OFFSET)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(block (result i32)
|
||||
@ -2219,6 +2215,7 @@
|
||||
(loop $continue|5
|
||||
(if
|
||||
(get_local $2)
|
||||
(block
|
||||
(block
|
||||
(i32.store8
|
||||
(i32.add
|
||||
@ -2237,6 +2234,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|5)
|
||||
)
|
||||
)
|
||||
@ -2260,7 +2258,6 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(call $std:heap/allocate_memory
|
||||
(i32.mul
|
||||
@ -2269,7 +2266,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
@ -2430,13 +2426,11 @@
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.load offset=8
|
||||
@ -2444,7 +2438,6 @@
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(set_local $3
|
||||
(if (result i32)
|
||||
@ -2456,7 +2449,6 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.gt_s
|
||||
@ -2468,7 +2460,6 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(call $std:heap/allocate_memory
|
||||
(i32.mul
|
||||
@ -2477,7 +2468,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
@ -2648,7 +2638,6 @@
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i32.and
|
||||
(i32.sub
|
||||
@ -2658,7 +2647,6 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
@ -2680,7 +2668,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.mul
|
||||
(i32.div_u
|
||||
@ -2693,7 +2680,6 @@
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $4)
|
||||
@ -2845,7 +2831,6 @@
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i64.or
|
||||
(i64.extend_u/i32
|
||||
@ -2859,7 +2844,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
(if
|
||||
@ -2924,7 +2908,6 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.load
|
||||
(i32.load
|
||||
@ -2932,7 +2915,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $std:heap/move_memory
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
@ -3008,7 +2990,6 @@
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(block
|
||||
(set_local $3
|
||||
@ -3024,7 +3005,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(i32.load
|
||||
|
@ -30,11 +30,9 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(current_memory)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(i32.add
|
||||
@ -82,11 +80,9 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(get_global $std:heap/HEAP_OFFSET)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(block (result i32)
|
||||
@ -210,7 +206,6 @@
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(i32.and
|
||||
(i32.sub
|
||||
@ -220,7 +215,6 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
@ -242,7 +236,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.mul
|
||||
(i32.div_u
|
||||
@ -255,7 +248,6 @@
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(get_local $4)
|
||||
@ -407,7 +399,6 @@
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i64.or
|
||||
(i64.extend_u/i32
|
||||
@ -421,7 +412,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
(if
|
||||
@ -2573,6 +2563,7 @@
|
||||
(loop $continue|5
|
||||
(if
|
||||
(get_local $2)
|
||||
(block
|
||||
(block
|
||||
(i32.store8
|
||||
(i32.add
|
||||
@ -2591,6 +2582,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|5)
|
||||
)
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,6 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iv (func (param i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(global $std:heap/HEAP_OFFSET (mut i32) (i32.const 0))
|
||||
@ -1970,10 +1969,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std:heap/free_memory (; 4 ;) (type $iv) (param $0 i32)
|
||||
(nop)
|
||||
)
|
||||
(func $std:set/Set#add (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $std:set/Set#add (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
@ -1999,12 +1995,10 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $3
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.gt_u
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -2029,7 +2023,7 @@
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(call $std:heap/free_memory
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
@ -2071,12 +2065,9 @@
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $std:set/Set#has (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $std:set/Set#has (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
@ -2120,12 +2111,9 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $std:set/Set#delete (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(func $std:set/Set#delete (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
@ -2223,13 +2211,7 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $std:set/Set#clear (; 8 ;) (type $iv) (param $0 i32)
|
||||
(i32.store offset=8
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(func $start (; 9 ;) (type $v)
|
||||
(func $start (; 7 ;) (type $v)
|
||||
(set_global $std:heap/HEAP_OFFSET
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
@ -2345,8 +2327,9 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(call $std:set/Set#clear
|
||||
(i32.store offset=8
|
||||
(get_global $std/set/set)
|
||||
(i32.const 0)
|
||||
)
|
||||
(if
|
||||
(call $std:set/Set#get:size
|
||||
|
@ -27,11 +27,9 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(current_memory)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(i32.add
|
||||
@ -79,11 +77,9 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(get_global $std:heap/HEAP_OFFSET)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(block (result i32)
|
||||
@ -2216,6 +2212,7 @@
|
||||
(loop $continue|5
|
||||
(if
|
||||
(get_local $2)
|
||||
(block
|
||||
(block
|
||||
(i32.store8
|
||||
(i32.add
|
||||
@ -2234,6 +2231,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|5)
|
||||
)
|
||||
)
|
||||
@ -2258,7 +2256,6 @@
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(set_local $4
|
||||
(select
|
||||
@ -2279,8 +2276,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(call $std:heap/allocate_memory
|
||||
(i32.mul
|
||||
@ -2289,7 +2284,6 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
|
@ -6,16 +6,37 @@
|
||||
(export "doSwitchDefaultOmitted" (func $switch/doSwitchDefaultOmitted))
|
||||
(export "memory" (memory $0))
|
||||
(func $switch/doSwitch (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $case4|0
|
||||
(block $case2|0
|
||||
(block $case0|0
|
||||
(block $tablify|0
|
||||
(br_table $case2|0 $case0|0 $case4|0 $case4|0 $tablify|0
|
||||
(if
|
||||
(i32.ne
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(br_if $case2|0
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(br_if $case4|0
|
||||
(i32.or
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $case2|0)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -27,20 +48,33 @@
|
||||
(i32.const 23)
|
||||
)
|
||||
(func $switch/doSwitchDefaultFirst (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $case3|0
|
||||
(block $case1|0
|
||||
(block $tablify|0
|
||||
(br_table $case1|0 $case3|0 $case3|0 $tablify|0
|
||||
(i32.sub
|
||||
(if
|
||||
(i32.ne
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(br_if $case3|0
|
||||
(i32.or
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -48,19 +82,32 @@
|
||||
(i32.const 23)
|
||||
)
|
||||
(func $switch/doSwitchDefaultOmitted (; 2 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(block $break|0
|
||||
(block $case2|0
|
||||
(block $case0|0
|
||||
(block $tablify|0
|
||||
(br_table $case0|0 $case2|0 $case2|0 $tablify|0
|
||||
(i32.sub
|
||||
(if
|
||||
(i32.ne
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(br_if $case2|0
|
||||
(i32.or
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $break|0)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(i32.const 1)
|
||||
)
|
||||
|
@ -1,277 +0,0 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iv (func (param i32)))
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(export "control$construct" (func $tlsf/control$construct))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $tlsf/fls (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.const 31)
|
||||
(i32.clz
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(func $tlsf/ffs (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(i32.ctz
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(func $tlsf/control$set_block (; 2 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.const 23)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $2)
|
||||
(i32.const 32)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 112)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 32)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(func $tlsf/control$construct (; 3 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(local $9 i32)
|
||||
(local $10 i32)
|
||||
(local $11 i32)
|
||||
(block
|
||||
(block $__inlined_func$tlsf/block$set_next_free
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $4
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(block $__inlined_func$tlsf/block$set_prev_free
|
||||
(set_local $5
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $6
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(i32.const 12)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(block $__inlined_func$tlsf/control$set_fl_bitmap
|
||||
(set_local $7
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
(i32.const 23)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(block $__inlined_func$tlsf/control$set_sl_bitmap
|
||||
(set_local $9
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $10
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $11
|
||||
(i32.const 0)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $10)
|
||||
(i32.const 23)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $9)
|
||||
(i32.const 20)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $10)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(i32.const 32)
|
||||
)
|
||||
(block
|
||||
(call $tlsf/control$set_block
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 4 ;) (type $v)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $tlsf/fls
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(call $tlsf/fls
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $tlsf/fls
|
||||
(i32.const -2147483640)
|
||||
)
|
||||
(i32.const 31)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $tlsf/fls
|
||||
(i32.const 2147483647)
|
||||
)
|
||||
(i32.const 30)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $tlsf/ffs
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(call $tlsf/ffs
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $tlsf/ffs
|
||||
(i32.const -2147483648)
|
||||
)
|
||||
(i32.const 31)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(call $tlsf/control$construct
|
||||
(i32.load
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,7 +1,5 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iv (func (param i32)))
|
||||
(type $v (func))
|
||||
@ -10,8 +8,7 @@
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $tlsf/fls (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(select
|
||||
(i32.sub
|
||||
(i32.const 31)
|
||||
(i32.clz
|
||||
@ -19,67 +16,19 @@
|
||||
)
|
||||
)
|
||||
(i32.const -1)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $tlsf/ffs (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
(select
|
||||
(i32.ctz
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(func $tlsf/block$set_next_free (; 2 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $tlsf/block$set_prev_free (; 3 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 12)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $tlsf/control$set_fl_bitmap (; 4 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $tlsf/control$set_sl_bitmap (; 5 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.const 23)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 20)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $tlsf/control$set_block (; 6 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(func $tlsf/control$set_block (; 2 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
@ -114,55 +63,92 @@
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(func $tlsf/control$construct (; 7 ;) (type $iv) (param $0 i32)
|
||||
(func $tlsf/control$construct (; 3 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(call $tlsf/block$set_next_free
|
||||
(get_local $0)
|
||||
(local $3 i32)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(tee_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(call $tlsf/block$set_prev_free
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(call $tlsf/control$set_fl_bitmap
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.store
|
||||
(i32.add
|
||||
(tee_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 12)
|
||||
)
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
(i32.const 23)
|
||||
)
|
||||
(block
|
||||
(call $tlsf/control$set_sl_bitmap
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(tee_local $1
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 23)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.store
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 20)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
(i32.const 32)
|
||||
)
|
||||
(block
|
||||
(call $tlsf/control$set_block
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $2
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -170,9 +156,9 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -181,7 +167,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 8 ;) (type $v)
|
||||
(func $start (; 4 ;) (type $v)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $tlsf/fls
|
||||
|
@ -175,11 +175,9 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
@ -194,11 +192,9 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(block $break|1
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_u
|
||||
|
@ -132,10 +132,8 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(tee_local $0
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_global $while/m
|
||||
(i32.add
|
||||
|
Loading…
x
Reference in New Issue
Block a user