1
0
mirror of https://github.com/fluencelabs/assemblyscript synced 2025-06-22 19:21:47 +00:00

Implement function types / indirect calls / trampolines ()

This commit is contained in:
Daniel Wirtz
2018-03-12 14:06:39 +01:00
committed by GitHub
parent 5d5f458ab1
commit 423533c6b0
67 changed files with 7499 additions and 5763 deletions

@ -1,4 +1,4 @@
![](https://s.gravatar.com/avatar/f105de3decfafc734b8eabe9a960b25d?size=64) AssemblyScript ![](https://avatars1.githubusercontent.com/u/28916798?s=64) AssemblyScript
================= =================
[![npm](https://img.shields.io/npm/v/assemblyscript.svg)](https://www.npmjs.com/package/assemblyscript) [![npm](https://img.shields.io/npm/v/assemblyscript.svg)](https://www.npmjs.com/package/assemblyscript)

2
dist/asc.js vendored

File diff suppressed because one or more lines are too long

2
dist/asc.js.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -21,7 +21,7 @@ class ObjectHeader {
///////////////////////////////// Fields //////////////////////////////////// ///////////////////////////////// Fields ////////////////////////////////////
// the next and prev pointer with tags in the least significant two bits that // the next and prev pointer with tags in the least significant two bits that
// would otherwise be zero (blocks are guaranteed to be aligned to 4/8 bytes) // would otherwise be zero (blocks are guaranteed to be aligned to 8 bytes)
tagged_next: usize; tagged_next: usize;
tagged_prev: usize; tagged_prev: usize;

@ -35,16 +35,19 @@ export class Formatter extends AbstractFormatter {
} else { } else {
var message = this.lastSeverity ? "\n" : ""; var message = this.lastSeverity ? "\n" : "";
switch (this.lastSeverity = failure.getRuleSeverity()) { switch (this.lastSeverity = failure.getRuleSeverity()) {
case "warning": case "warning": {
message += colorYellow + "WARNING:" + colorReset; message += colorYellow + "WARNING:" + colorReset;
break; break;
case "error": }
case "error": {
message += colorRed + "ERROR:" + colorReset; message += colorRed + "ERROR:" + colorReset;
break; break;
default: }
default: {
message += failure.getRuleSeverity(); message += failure.getRuleSeverity();
break; break;
} }
}
this.lastFailure = failureString; this.lastFailure = failureString;
return message + " " + failureString + " [" + ruleName + "]\n in " + fileName + positionTuple; return message + " " + failureString + " [" + ruleName + "]\n in " + fileName + positionTuple;
} }

@ -12,6 +12,7 @@ export class Rule extends Lint.Rules.AbstractRule {
} }
class DiagnosticsWalker extends Lint.RuleWalker { class DiagnosticsWalker extends Lint.RuleWalker {
visitVariableDeclaration(node: ts.VariableDeclaration) { visitVariableDeclaration(node: ts.VariableDeclaration) {
if ( if (
!node.type && !node.initializer && !node.type && !node.initializer &&
@ -20,16 +21,19 @@ class DiagnosticsWalker extends Lint.RuleWalker {
this.addFailureAtNode(node, Rule.MISSING_TYPE_OR_INITIALIZER); this.addFailureAtNode(node, Rule.MISSING_TYPE_OR_INITIALIZER);
} }
} }
visitPropertyDeclaration(node: ts.PropertyDeclaration) { visitPropertyDeclaration(node: ts.PropertyDeclaration) {
if (!node.type && !node.initializer) { if (!node.type && !node.initializer) {
this.addFailureAtNode(node, Rule.MISSING_TYPE_OR_INITIALIZER); this.addFailureAtNode(node, Rule.MISSING_TYPE_OR_INITIALIZER);
} }
} }
visitParameterDeclaration(node: ts.ParameterDeclaration) { visitParameterDeclaration(node: ts.ParameterDeclaration) {
if (!node.type && !node.initializer) { if (!node.type && !node.initializer) {
this.addFailureAtNode(node, Rule.MISSING_TYPE_OR_INITIALIZER); this.addFailureAtNode(node, Rule.MISSING_TYPE_OR_INITIALIZER);
} }
} }
visitFunctionDeclaration(node: ts.FunctionDeclaration) { visitFunctionDeclaration(node: ts.FunctionDeclaration) {
if (!node.type) { if (!node.type) {
this.addFailureAtNode(node, Rule.MISSING_RETURN_TYPE); this.addFailureAtNode(node, Rule.MISSING_RETURN_TYPE);

@ -0,0 +1,56 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
var ts = require("typescript");
var Lint = require("tslint");
var tsutils_1 = require("tsutils");
var Rule = /** @class */ (function (_super) {
__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithWalker(new DiagnosticsWalker(sourceFile, this.getOptions()));
};
Rule.NOT_BRACED = "Multi-line case clauses should be braced.";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var DiagnosticsWalker = /** @class */ (function (_super) {
__extends(DiagnosticsWalker, _super);
function DiagnosticsWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
DiagnosticsWalker.prototype.visitDefaultClause = function (node) {
this.checkDefaultOrCaseClause(node);
_super.prototype.visitDefaultClause.call(this, node);
};
DiagnosticsWalker.prototype.visitCaseClause = function (node) {
this.checkDefaultOrCaseClause(node);
_super.prototype.visitCaseClause.call(this, node);
};
DiagnosticsWalker.prototype.checkDefaultOrCaseClause = function (node) {
var count = node.statements.length;
if (count > 1) {
this.addFailureAtNode(node, Rule.NOT_BRACED);
}
else if (count == 1) {
var stmt = node.statements[0];
if (stmt.kind != ts.SyntaxKind.Block) {
if (!tsutils_1.isSameLine(node.getSourceFile(), node.getStart(), stmt.getStart())) {
this.addFailureAtNode(node, Rule.NOT_BRACED);
}
}
}
};
return DiagnosticsWalker;
}(Lint.RuleWalker));

@ -0,0 +1,39 @@
import * as ts from "typescript";
import * as Lint from "tslint";
import { isSameLine } from "tsutils";
export class Rule extends Lint.Rules.AbstractRule {
static NOT_BRACED = "Multi-line case clauses should be braced.";
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new DiagnosticsWalker(sourceFile, this.getOptions()));
}
}
class DiagnosticsWalker extends Lint.RuleWalker {
visitDefaultClause(node: ts.DefaultClause) {
this.checkDefaultOrCaseClause(node);
super.visitDefaultClause(node);
}
visitCaseClause(node: ts.CaseClause) {
this.checkDefaultOrCaseClause(node);
super.visitCaseClause(node);
}
private checkDefaultOrCaseClause(node: ts.DefaultClause | ts.CaseClause) {
var count = node.statements.length;
if (count > 1) {
this.addFailureAtNode(node, Rule.NOT_BRACED);
} else if (count == 1) {
let stmt = node.statements[0];
if (stmt.kind != ts.SyntaxKind.Block) {
if (!isSameLine(node.getSourceFile(), node.getStart(), stmt.getStart())) {
this.addFailureAtNode(node, Rule.NOT_BRACED);
}
}
}
}
}

@ -12,6 +12,7 @@ export class Rule extends Lint.Rules.AbstractRule {
} }
class DiagnosticsWalker extends Lint.RuleWalker { class DiagnosticsWalker extends Lint.RuleWalker {
visitPropertyAccessExpression(node: ts.PropertyAccessExpression) { visitPropertyAccessExpression(node: ts.PropertyAccessExpression) {
if (node.expression.kind === ts.SyntaxKind.Identifier) { if (node.expression.kind === ts.SyntaxKind.Identifier) {
if ( if (

@ -1,4 +1,4 @@
![](https://s.gravatar.com/avatar/f105de3decfafc734b8eabe9a960b25d?size=48) utils ![AS](https://avatars1.githubusercontent.com/u/28916798?s=48) utils
================= =================
Utilities for working with [AssemblyScript](http://assemblyscript.org) modules. Utilities for working with [AssemblyScript](http://assemblyscript.org) modules.

@ -1,4 +1,4 @@
![](https://s.gravatar.com/avatar/f105de3decfafc734b8eabe9a960b25d?size=48) webpack ![AS](https://avatars1.githubusercontent.com/u/28916798?s=48) webpack
================= =================
[webpack](https://webpack.js.org/) loader for [AssemblyScript](http://assemblyscript.org) modules. [webpack](https://webpack.js.org/) loader for [AssemblyScript](http://assemblyscript.org) modules.

@ -25,6 +25,8 @@ export enum NodeKind {
// types // types
TYPE, TYPE,
TYPEPARAMETER, TYPEPARAMETER,
PARAMETER,
SIGNATURE,
// expressions // expressions
IDENTIFIER, IDENTIFIER,
@ -82,11 +84,10 @@ export enum NodeKind {
TYPEDECLARATION, TYPEDECLARATION,
VARIABLEDECLARATION, VARIABLEDECLARATION,
// other // special
DECORATOR, DECORATOR,
EXPORTMEMBER,
MODIFIER, MODIFIER,
PARAMETER, EXPORTMEMBER,
SWITCHCASE SWITCHCASE
} }
@ -103,19 +104,121 @@ export abstract class Node {
// types // types
static createType( static createType(
identifier: IdentifierExpression, name: IdentifierExpression,
typeArguments: TypeNode[], typeArguments: CommonTypeNode[] | null,
isNullable: bool, isNullable: bool,
range: Range range: Range
): TypeNode { ): TypeNode {
var type = new TypeNode(); var type = new TypeNode();
type.range = range; type.range = range;
type.name = identifier; type.name = name; name.parent = type;
type.typeArguments = typeArguments; type.typeArguments = typeArguments; if (typeArguments) setParent(typeArguments, type);
type.isNullable = isNullable; type.isNullable = isNullable;
return type; return type;
} }
static createOmittedType(
range: Range
) {
return Node.createType(
Node.createIdentifierExpression("", range),
null,
false,
range
);
}
static createTypeParameter(
name: IdentifierExpression,
extendsType: TypeNode | null,
range: Range
): TypeParameterNode {
var elem = new TypeParameterNode();
elem.range = range;
elem.name = name; name.parent = elem;
elem.extendsType = extendsType; if (extendsType) extendsType.parent = elem;
return elem;
}
static createParameter(
name: IdentifierExpression,
type: CommonTypeNode | null,
initializer: Expression | null,
kind: ParameterKind,
range: Range
): ParameterNode {
var elem = new ParameterNode();
elem.range = range;
elem.name = name; name.parent = elem;
elem.type = type; if (type) type.parent = elem;
elem.initializer = initializer; if (initializer) initializer.parent = elem;
elem.parameterKind = kind;
return elem;
}
static createSignature(
parameters: ParameterNode[],
returnType: CommonTypeNode,
explicitThisType: TypeNode | null,
isNullable: bool,
range: Range
): SignatureNode {
var sig = new SignatureNode();
sig.range = range;
sig.parameterTypes = parameters; setParent(parameters, sig);
sig.returnType = returnType; returnType.parent = sig;
sig.explicitThisType = explicitThisType; if (explicitThisType) explicitThisType.parent = sig;
sig.isNullable = isNullable;
return sig;
}
// special
static createDecorator(
expression: Expression,
args: Expression[] | null,
range: Range
): DecoratorNode {
var stmt = new DecoratorNode();
stmt.range = range;
stmt.name = expression; expression.parent = stmt;
stmt.arguments = args; if (args) setParent(args, stmt);
if (expression.kind == NodeKind.IDENTIFIER) {
switch ((<IdentifierExpression>expression).text) {
case "global": {
stmt.decoratorKind = DecoratorKind.GLOBAL;
break;
}
case "operator": {
stmt.decoratorKind = DecoratorKind.OPERATOR;
break;
}
case "unmanaged": {
stmt.decoratorKind = DecoratorKind.UNMANAGED;
break;
}
case "offset": {
stmt.decoratorKind = DecoratorKind.OFFSET;
break;
}
default: {
stmt.decoratorKind = DecoratorKind.CUSTOM;
break;
}
}
} else {
stmt.decoratorKind = DecoratorKind.CUSTOM;
}
return stmt;
}
static createModifier(kind: ModifierKind, range: Range): ModifierNode {
var elem = new ModifierNode();
elem.range = range;
elem.modifierKind = kind;
return elem;
}
// expressions // expressions
static createIdentifierExpression( static createIdentifierExpression(
@ -128,20 +231,29 @@ export abstract class Node {
return expr; return expr;
} }
static createEmptyIdentifierExpression(
range: Range
): IdentifierExpression {
var expr = new IdentifierExpression();
expr.range = range;
expr.text = "";
return expr;
}
static createArrayLiteralExpression( static createArrayLiteralExpression(
elements: (Expression | null)[], elements: (Expression | null)[],
range: Range range: Range
): ArrayLiteralExpression { ): ArrayLiteralExpression {
var expr = new ArrayLiteralExpression(); var expr = new ArrayLiteralExpression();
expr.range = range; expr.range = range;
expr.elementExpressions = elements; setParentOpt(elements, expr); expr.elementExpressions = elements; setParentIfNotNull(elements, expr);
return expr; return expr;
} }
static createAssertionExpression( static createAssertionExpression(
assertionKind: AssertionKind, assertionKind: AssertionKind,
expression: Expression, expression: Expression,
toType: TypeNode, toType: CommonTypeNode,
range: Range range: Range
): AssertionExpression { ): AssertionExpression {
var expr = new AssertionExpression(); var expr = new AssertionExpression();
@ -168,7 +280,7 @@ export abstract class Node {
static createCallExpression( static createCallExpression(
expression: Expression, expression: Expression,
typeArgs: TypeNode[] | null, typeArgs: CommonTypeNode[] | null,
args: Expression[], args: Expression[],
range: Range range: Range
): CallExpression { ): CallExpression {
@ -252,7 +364,7 @@ export abstract class Node {
static createNewExpression( static createNewExpression(
expression: Expression, expression: Expression,
typeArgs: TypeNode[] | null, typeArgs: CommonTypeNode[] | null,
args: Expression[], args: Expression[],
range: Range range: Range
): NewExpression { ): NewExpression {
@ -402,12 +514,12 @@ export abstract class Node {
static createClassDeclaration( static createClassDeclaration(
identifier: IdentifierExpression, identifier: IdentifierExpression,
typeParameters: TypeParameter[], typeParameters: TypeParameterNode[],
extendsType: TypeNode | null, extendsType: TypeNode | null, // can't be a function
implementsTypes: TypeNode[], implementsTypes: TypeNode[], // can't be a function
members: DeclarationStatement[], members: DeclarationStatement[],
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): ClassDeclaration { ): ClassDeclaration {
var stmt = new ClassDeclaration(); var stmt = new ClassDeclaration();
@ -432,29 +544,6 @@ export abstract class Node {
return stmt; return stmt;
} }
static createDecorator(
expression: Expression,
args: Expression[] | null,
range: Range
): Decorator {
var stmt = new Decorator();
stmt.range = range;
stmt.name = expression; expression.parent = stmt;
stmt.arguments = args; if (args) setParent(args, stmt);
if (expression.kind == NodeKind.IDENTIFIER) {
switch ((<IdentifierExpression>expression).text) {
case "global": stmt.decoratorKind = DecoratorKind.GLOBAL; break;
case "operator": stmt.decoratorKind = DecoratorKind.OPERATOR; break;
case "unmanaged": stmt.decoratorKind = DecoratorKind.UNMANAGED; break;
case "offset": stmt.decoratorKind = DecoratorKind.OFFSET; break;
default: stmt.decoratorKind = DecoratorKind.CUSTOM; break;
}
} else {
stmt.decoratorKind = DecoratorKind.CUSTOM;
}
return stmt;
}
static createDoStatement( static createDoStatement(
statement: Statement, statement: Statement,
condition: Expression, condition: Expression,
@ -478,8 +567,8 @@ export abstract class Node {
static createEnumDeclaration( static createEnumDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
members: EnumValueDeclaration[], members: EnumValueDeclaration[],
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): EnumDeclaration { ): EnumDeclaration {
var stmt = new EnumDeclaration(); var stmt = new EnumDeclaration();
@ -506,7 +595,7 @@ export abstract class Node {
static createExportStatement( static createExportStatement(
members: ExportMember[], members: ExportMember[],
path: StringLiteralExpression | null, path: StringLiteralExpression | null,
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
range: Range range: Range
): ExportStatement { ): ExportStatement {
var stmt = new ExportStatement(); var stmt = new ExportStatement();
@ -644,9 +733,9 @@ export abstract class Node {
static createInterfaceDeclaration( static createInterfaceDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
extendsType: TypeNode | null, extendsType: TypeNode | null, // can't be a function
members: DeclarationStatement[], members: DeclarationStatement[],
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
range: Range range: Range
): InterfaceDeclaration { ): InterfaceDeclaration {
var stmt = new InterfaceDeclaration(); var stmt = new InterfaceDeclaration();
@ -660,10 +749,10 @@ export abstract class Node {
static createFieldDeclaration( static createFieldDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
type: TypeNode | null, type: CommonTypeNode | null,
initializer: Expression | null, initializer: Expression | null,
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): FieldDeclaration { ): FieldDeclaration {
var stmt = new FieldDeclaration(); var stmt = new FieldDeclaration();
@ -692,50 +781,20 @@ export abstract class Node {
return stmt; return stmt;
} }
static createTypeParameter(
name: IdentifierExpression,
extendsType: TypeNode | null,
range: Range
): TypeParameter {
var elem = new TypeParameter();
elem.range = range;
elem.name = name; name.parent = elem;
elem.extendsType = extendsType; if (extendsType) extendsType.parent = elem;
return elem;
}
static createParameter(
name: IdentifierExpression,
type: TypeNode | null,
initializer: Expression | null,
kind: ParameterKind,
range: Range
): Parameter {
var elem = new Parameter();
elem.range = range;
elem.name = name; name.parent = elem;
elem.type = type; if (type) type.parent = elem;
elem.initializer = initializer; if (initializer) initializer.parent = elem;
elem.parameterKind = kind;
return elem;
}
static createFunctionDeclaration( static createFunctionDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
typeParameters: TypeParameter[] | null, typeParameters: TypeParameterNode[] | null,
parameters: Parameter[], signature: SignatureNode,
returnType: TypeNode | null,
body: Statement | null, body: Statement | null,
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): FunctionDeclaration { ): FunctionDeclaration {
var stmt = new FunctionDeclaration(); var stmt = new FunctionDeclaration();
stmt.range = range; stmt.range = range;
stmt.name = name; name.parent = stmt; stmt.name = name; name.parent = stmt;
stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt); stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt);
stmt.parameters = parameters; setParent(parameters, stmt); stmt.signature = signature; signature.parent = stmt;
stmt.returnType = returnType; if (returnType) returnType.parent = stmt;
stmt.body = body; if (body) body.parent = stmt; stmt.body = body; if (body) body.parent = stmt;
stmt.modifiers = modifiers; if (modifiers) setParent(modifiers, stmt); stmt.modifiers = modifiers; if (modifiers) setParent(modifiers, stmt);
stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); stmt.decorators = decorators; if (decorators) setParent(decorators, stmt);
@ -744,38 +803,29 @@ export abstract class Node {
static createMethodDeclaration( static createMethodDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
typeParameters: TypeParameter[] | null, typeParameters: TypeParameterNode[] | null,
parameters: Parameter[], signature: SignatureNode,
returnType: TypeNode | null,
body: Statement | null, body: Statement | null,
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): MethodDeclaration { ): MethodDeclaration {
var stmt = new MethodDeclaration(); var stmt = new MethodDeclaration();
stmt.range = range; stmt.range = range;
stmt.name = name; name.parent = stmt; stmt.name = name; name.parent = stmt;
stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt); stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt);
stmt.parameters = parameters; setParent(parameters, stmt); stmt.signature = signature; signature.parent = stmt;
stmt.returnType = returnType; if (returnType) returnType.parent = stmt;
stmt.body = body; if (body) body.parent = stmt; stmt.body = body; if (body) body.parent = stmt;
stmt.modifiers = modifiers; if (modifiers) setParent(modifiers, stmt); stmt.modifiers = modifiers; if (modifiers) setParent(modifiers, stmt);
stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); stmt.decorators = decorators; if (decorators) setParent(decorators, stmt);
return stmt; return stmt;
} }
static createModifier(kind: ModifierKind, range: Range): Modifier {
var elem = new Modifier();
elem.range = range;
elem.modifierKind = kind;
return elem;
}
static createNamespaceDeclaration( static createNamespaceDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
members: Statement[], members: Statement[],
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): NamespaceDeclaration { ): NamespaceDeclaration {
var stmt = new NamespaceDeclaration(); var stmt = new NamespaceDeclaration();
@ -852,9 +902,9 @@ export abstract class Node {
static createTypeDeclaration( static createTypeDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
alias: TypeNode, alias: CommonTypeNode,
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): TypeDeclaration { ): TypeDeclaration {
var stmt = new TypeDeclaration(); var stmt = new TypeDeclaration();
@ -868,8 +918,8 @@ export abstract class Node {
static createVariableStatement( static createVariableStatement(
declarations: VariableDeclaration[], declarations: VariableDeclaration[],
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): VariableStatement { ): VariableStatement {
var stmt = new VariableStatement(); var stmt = new VariableStatement();
@ -882,10 +932,10 @@ export abstract class Node {
static createVariableDeclaration( static createVariableDeclaration(
name: IdentifierExpression, name: IdentifierExpression,
type: TypeNode | null, type: CommonTypeNode | null,
initializer: Expression | null, initializer: Expression | null,
modifiers: Modifier[] | null, modifiers: ModifierNode[] | null,
decorators: Decorator[] | null, decorators: DecoratorNode[] | null,
range: Range range: Range
): VariableDeclaration { ): VariableDeclaration {
var elem = new VariableDeclaration(); var elem = new VariableDeclaration();
@ -923,26 +973,116 @@ export abstract class Node {
// types // types
export abstract class CommonTypeNode extends Node {
// kind varies
/** Whether nullable or not. */
isNullable: bool;
}
/** Represents a type annotation. */ /** Represents a type annotation. */
export class TypeNode extends Node { export class TypeNode extends CommonTypeNode {
kind = NodeKind.TYPE; kind = NodeKind.TYPE;
/** Identifier reference. */ /** Identifier reference. */
name: IdentifierExpression; name: IdentifierExpression;
/** Type argument references. */ /** Type argument references. */
typeArguments: TypeNode[]; typeArguments: CommonTypeNode[] | null;
/** Whether nullable or not. */
isNullable: bool;
} }
/** Represents a type parameter. */ /** Represents a type parameter. */
export class TypeParameter extends Node { export class TypeParameterNode extends Node {
kind = NodeKind.TYPEPARAMETER; kind = NodeKind.TYPEPARAMETER;
/** Identifier reference. */ /** Identifier reference. */
name: IdentifierExpression; name: IdentifierExpression;
/** Extended type reference, if any. */ /** Extended type reference, if any. */
extendsType: TypeNode | null; extendsType: TypeNode | null; // can't be a function
}
/** Represents the kind of a parameter. */
export enum ParameterKind {
/** No specific flags. */
DEFAULT,
/** Is an optional parameter. */
OPTIONAL,
/** Is a rest parameter. */
REST
}
/** Represents a function parameter. */
export class ParameterNode extends Node {
kind = NodeKind.PARAMETER;
/** Parameter kind. */
parameterKind: ParameterKind;
/** Parameter name. */
name: IdentifierExpression;
/** Parameter type. */
type: CommonTypeNode | null;
/** Initializer expression, if present. */
initializer: Expression | null;
}
/** Represents a function signature. */
export class SignatureNode extends CommonTypeNode {
kind = NodeKind.SIGNATURE;
/** Accepted parameters. */
parameterTypes: ParameterNode[];
/** Return type. */
returnType: CommonTypeNode | null;
/** Explicitly provided this type, if any. */
explicitThisType: TypeNode | null; // can't be a function
}
// special
/** Built-in decorator kinds. */
export const enum DecoratorKind {
CUSTOM,
GLOBAL,
OPERATOR,
UNMANAGED,
OFFSET
}
/** Depresents a decorator. */
export class DecoratorNode extends Node {
kind = NodeKind.DECORATOR;
/** Built-in kind, if applicable. */
decoratorKind: DecoratorKind;
/** Name expression. */
name: Expression;
/** Argument expressions. */
arguments: Expression[] | null;
}
/** Indicates the specific kind of a modifier. */
export enum ModifierKind {
ASYNC,
CONST,
LET,
DECLARE,
EXPORT,
IMPORT,
STATIC,
ABSTRACT,
PUBLIC,
PRIVATE,
PROTECTED,
READONLY,
GET,
SET,
}
/** Represents a single modifier. */
export class ModifierNode extends Node {
kind = NodeKind.MODIFIER;
/** Specific modifier kind. */
modifierKind: ModifierKind;
} }
// expressions // expressions
@ -999,7 +1139,7 @@ export class AssertionExpression extends Expression {
/** Expression being asserted. */ /** Expression being asserted. */
expression: Expression; expression: Expression;
/** Target type. */ /** Target type. */
toType: TypeNode; toType: CommonTypeNode;
} }
/** Represents a binary expression. */ /** Represents a binary expression. */
@ -1021,7 +1161,7 @@ export class CallExpression extends Expression {
/** Called expression. Usually an identifier or property access expression. */ /** Called expression. Usually an identifier or property access expression. */
expression: Expression; expression: Expression;
/** Provided type arguments. */ /** Provided type arguments. */
typeArguments: TypeNode[] | null; typeArguments: CommonTypeNode[] | null;
/** Provided arguments. */ /** Provided arguments. */
arguments: Expression[]; arguments: Expression[];
} }
@ -1183,24 +1323,6 @@ export class UnaryPrefixExpression extends UnaryExpression {
// statements // statements
/** Indicates the specific kind of a modifier. */
export enum ModifierKind {
ASYNC,
CONST,
LET,
DECLARE,
EXPORT,
IMPORT,
STATIC,
ABSTRACT,
PUBLIC,
PRIVATE,
PROTECTED,
READONLY,
GET,
SET,
}
/** Base class of all statement nodes. */ /** Base class of all statement nodes. */
export abstract class Statement extends Node { } export abstract class Statement extends Node { }
@ -1257,9 +1379,9 @@ export abstract class DeclarationStatement extends Statement {
/** Simple name being declared. */ /** Simple name being declared. */
name: IdentifierExpression; name: IdentifierExpression;
/** Array of modifiers. */ /** Array of modifiers. */
modifiers: Modifier[] | null; modifiers: ModifierNode[] | null;
/** Array of decorators. */ /** Array of decorators. */
decorators: Decorator[] | null = null; decorators: DecoratorNode[] | null = null;
protected cachedProgramLevelInternalName: string | null = null; protected cachedProgramLevelInternalName: string | null = null;
protected cachedFileLevelInternalName: string | null = null; protected cachedFileLevelInternalName: string | null = null;
@ -1333,7 +1455,7 @@ export abstract class DeclarationStatement extends Statement {
export abstract class VariableLikeDeclarationStatement extends DeclarationStatement { export abstract class VariableLikeDeclarationStatement extends DeclarationStatement {
/** Variable type. */ /** Variable type. */
type: TypeNode | null; type: CommonTypeNode | null;
/** Variable initializer. */ /** Variable initializer. */
initializer: Expression | null; initializer: Expression | null;
} }
@ -1359,13 +1481,18 @@ export class ClassDeclaration extends DeclarationStatement {
kind = NodeKind.CLASSDECLARATION; kind = NodeKind.CLASSDECLARATION;
/** Accepted type parameters. */ /** Accepted type parameters. */
typeParameters: TypeParameter[]; typeParameters: TypeParameterNode[];
/** Base class type being extended. */ /** Base class type being extended. */
extendsType: TypeNode | null; extendsType: TypeNode | null; // can't be a function
/** Interface types being implemented. */ /** Interface types being implemented. */
implementsTypes: TypeNode[]; implementsTypes: TypeNode[]; // can't be a function
/** Class member declarations. */ /** Class member declarations. */
members: DeclarationStatement[]; members: DeclarationStatement[];
get isGeneric(): bool {
var typeParameters = this.typeParameters;
return typeParameters != null && typeParameters.length > 0;
}
} }
/** Represents a `continue` statement. */ /** Represents a `continue` statement. */
@ -1376,27 +1503,6 @@ export class ContinueStatement extends Statement {
label: IdentifierExpression | null; label: IdentifierExpression | null;
} }
/** Built-in decorator kinds. */
export const enum DecoratorKind {
CUSTOM,
GLOBAL,
OPERATOR,
UNMANAGED,
OFFSET
}
/** Depresents a decorator. */
export class Decorator extends Statement {
kind = NodeKind.DECORATOR;
/** Name expression. */
name: Expression;
/** Argument expressions. */
arguments: Expression[] | null;
/** Built-in kind, if applicable. */
decoratorKind: DecoratorKind;
}
/** Represents a `do` statement. */ /** Represents a `do` statement. */
export class DoStatement extends Statement { export class DoStatement extends Statement {
kind = NodeKind.DO; kind = NodeKind.DO;
@ -1455,7 +1561,7 @@ export class ExportStatement extends Statement {
kind = NodeKind.EXPORT; kind = NodeKind.EXPORT;
/** Array of modifiers. */ /** Array of modifiers. */
modifiers: Modifier[] | null; modifiers: ModifierNode[] | null;
/** Array of members. */ /** Array of members. */
members: ExportMember[]; members: ExportMember[];
/** Path being exported from, if applicable. */ /** Path being exported from, if applicable. */
@ -1500,17 +1606,16 @@ export class ForStatement extends Statement {
export class FunctionDeclaration extends DeclarationStatement { export class FunctionDeclaration extends DeclarationStatement {
kind = NodeKind.FUNCTIONDECLARATION; kind = NodeKind.FUNCTIONDECLARATION;
/** Accepted type parameters. */ /** Type parameters, if any. */
typeParameters: TypeParameter[] | null; typeParameters: TypeParameterNode[] | null;
/** Accepted parameters. */ /** Function signature. */
parameters: Parameter[]; signature: SignatureNode;
/** Return type. */
returnType: TypeNode | null;
/** Body statement. Usually a block. */ /** Body statement. Usually a block. */
body: Statement | null; body: Statement | null;
get isGeneric(): bool { get isGeneric(): bool {
return this.typeParameters != null && this.typeParameters.length > 0; var typeParameters = this.typeParameters;
return typeParameters != null && typeParameters.length > 0;
} }
} }
@ -1569,38 +1674,6 @@ export class NamespaceDeclaration extends DeclarationStatement {
members: Statement[]; members: Statement[];
} }
/** Represents the kind of a parameter. */
export enum ParameterKind {
/** No specific flags. */
DEFAULT,
/** Is an optional parameter. */
OPTIONAL,
/** Is a rest parameter. */
REST
}
/** Represents a function parameter. */
export class Parameter extends Node {
kind = NodeKind.PARAMETER;
/** Parameter name. */
name: IdentifierExpression;
/** Parameter type. */
type: TypeNode | null;
/** Parameter kind. */
parameterKind: ParameterKind;
/** Initializer expression, if present. */
initializer: Expression | null;
}
/** Represents a single modifier. */
export class Modifier extends Node {
kind = NodeKind.MODIFIER;
/** Specific modifier kind. */
modifierKind: ModifierKind;
}
/** Represents a `return` statement. */ /** Represents a `return` statement. */
export class ReturnStatement extends Statement { export class ReturnStatement extends Statement {
kind = NodeKind.RETURN; kind = NodeKind.RETURN;
@ -1656,7 +1729,7 @@ export class TypeDeclaration extends DeclarationStatement {
kind = NodeKind.TYPEDECLARATION; kind = NodeKind.TYPEDECLARATION;
/** Type being aliased. */ /** Type being aliased. */
alias: TypeNode; alias: CommonTypeNode;
} }
/** Represents a variable declaration part of a {@link VariableStatement}. */ /** Represents a variable declaration part of a {@link VariableStatement}. */
@ -1664,7 +1737,7 @@ export class VariableDeclaration extends VariableLikeDeclarationStatement {
kind = NodeKind.VARIABLEDECLARATION; kind = NodeKind.VARIABLEDECLARATION;
/** Array of modifiers. */ /** Array of modifiers. */
modifiers: Modifier[] | null; modifiers: ModifierNode[] | null;
} }
/** Represents a variable statement wrapping {@link VariableDeclaration}s. */ /** Represents a variable statement wrapping {@link VariableDeclaration}s. */
@ -1672,9 +1745,9 @@ export class VariableStatement extends Statement {
kind = NodeKind.VARIABLE; kind = NodeKind.VARIABLE;
/** Array of modifiers. */ /** Array of modifiers. */
modifiers: Modifier[] | null; modifiers: ModifierNode[] | null;
/** Array of decorators. */ /** Array of decorators. */
decorators: Decorator[] | null; decorators: DecoratorNode[] | null;
/** Array of member declarations. */ /** Array of member declarations. */
declarations: VariableDeclaration[]; declarations: VariableDeclaration[];
} }
@ -1698,15 +1771,15 @@ export class WhileStatement extends Statement {
} }
/** Cached unused modifiers for reuse. */ /** Cached unused modifiers for reuse. */
var reusableModifiers: Modifier[] | null = null; var reusableModifiers: ModifierNode[] | null = null;
export function setReusableModifiers(modifiers: Modifier[]): void { export function setReusableModifiers(modifiers: ModifierNode[]): void {
reusableModifiers = modifiers; reusableModifiers = modifiers;
} }
/** Creates a new modifiers array. */ /** Creates a new modifiers array. */
export function createModifiers(): Modifier[] { export function createModifiers(): ModifierNode[] {
var ret: Modifier[]; var ret: ModifierNode[];
if (reusableModifiers != null) { if (reusableModifiers != null) {
ret = reusableModifiers; ret = reusableModifiers;
reusableModifiers = null; reusableModifiers = null;
@ -1720,14 +1793,14 @@ export function createModifiers(): Modifier[] {
// Utility // Utility
/** Adds a modifier to a set of modifiers. Creates a new set if `null`. */ /** Adds a modifier to a set of modifiers. Creates a new set if `null`. */
export function addModifier(modifier: Modifier, modifiers: Modifier[] | null): Modifier[] { export function addModifier(modifier: ModifierNode, modifiers: ModifierNode[] | null): ModifierNode[] {
if (modifiers == null) modifiers = createModifiers(); if (modifiers == null) modifiers = createModifiers();
modifiers.push(modifier); modifiers.push(modifier);
return modifiers; return modifiers;
} }
/** Gets a specific modifier from the specified set of modifiers. */ /** Gets a specific modifier from the specified set of modifiers. */
export function getModifier(kind: ModifierKind, modifiers: Modifier[] | null): Modifier | null { export function getModifier(kind: ModifierKind, modifiers: ModifierNode[] | null): ModifierNode | null {
if (modifiers) { if (modifiers) {
for (var i = 0, k = modifiers.length; i < k; ++i) { for (var i = 0, k = modifiers.length; i < k; ++i) {
if (modifiers[i].modifierKind == kind) { if (modifiers[i].modifierKind == kind) {
@ -1739,12 +1812,12 @@ export function getModifier(kind: ModifierKind, modifiers: Modifier[] | null): M
} }
/** Tests whether a modifier exists in the specified set of modifiers. */ /** Tests whether a modifier exists in the specified set of modifiers. */
export function hasModifier(kind: ModifierKind, modifiers: Modifier[] | null): bool { export function hasModifier(kind: ModifierKind, modifiers: ModifierNode[] | null): bool {
return getModifier(kind, modifiers) != null; return getModifier(kind, modifiers) != null;
} }
/** Gets the first decorator by name within at set of decorators, if present. */ /** Gets the first decorator by name within at set of decorators, if present. */
export function getFirstDecorator(name: string, decorators: Decorator[] | null): Decorator | null { export function getFirstDecorator(name: string, decorators: DecoratorNode[] | null): DecoratorNode | null {
if (decorators) { if (decorators) {
for (var i = 0, k = decorators.length; i < k; ++i) { for (var i = 0, k = decorators.length; i < k; ++i) {
var decorator = decorators[i]; var decorator = decorators[i];
@ -1758,7 +1831,7 @@ export function getFirstDecorator(name: string, decorators: Decorator[] | null):
} }
/** Tests if a specific decorator is present within the specified decorators. */ /** Tests if a specific decorator is present within the specified decorators. */
export function hasDecorator(name: string, decorators: Decorator[] | null): bool { export function hasDecorator(name: string, decorators: DecoratorNode[] | null): bool {
return getFirstDecorator(name, decorators) != null; return getFirstDecorator(name, decorators) != null;
} }
@ -1800,13 +1873,15 @@ export function mangleInternalPath(path: string): string {
// Helpers // Helpers
/** Sets the parent node on an array of nodes. */
function setParent(nodes: Node[], parent: Node): void { function setParent(nodes: Node[], parent: Node): void {
for (var i = 0, k = nodes.length; i < k; ++i) { for (var i = 0, k = nodes.length; i < k; ++i) {
nodes[i].parent = parent; nodes[i].parent = parent;
} }
} }
function setParentOpt(nodes: (Node | null)[], parent: Node): void { /** Sets the parent node on an array of nullable nodes. */
function setParentIfNotNull(nodes: (Node | null)[], parent: Node): void {
for (var i = 0, k = nodes.length; i < k; ++i) { for (var i = 0, k = nodes.length; i < k; ++i) {
var node = nodes[i]; var node = nodes[i];
if (node) node.parent = parent; if (node) node.parent = parent;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -66,8 +66,7 @@ export class Decompiler {
var i: Index, k: Index; var i: Index, k: Index;
switch (id) { switch (id) {
case ExpressionId.Block: { // TODO: magic
case ExpressionId.Block: // TODO: magic
if ((string = readString(_BinaryenBlockGetName(expr))) != null) { if ((string = readString(_BinaryenBlockGetName(expr))) != null) {
this.push(string); this.push(string);
this.push(": "); this.push(": ");
@ -79,8 +78,8 @@ export class Decompiler {
} }
this.push("}\n"); this.push("}\n");
return; return;
}
case ExpressionId.If: case ExpressionId.If: {
if (type == NativeType.None) { if (type == NativeType.None) {
this.push("if ("); this.push("if (");
this.decompileExpression(_BinaryenIfGetCondition(expr)); this.decompileExpression(_BinaryenIfGetCondition(expr));
@ -98,8 +97,8 @@ export class Decompiler {
this.decompileExpression(_BinaryenIfGetIfFalse(expr)); this.decompileExpression(_BinaryenIfGetIfFalse(expr));
} }
return; return;
}
case ExpressionId.Loop: case ExpressionId.Loop: {
if ((string = readString(_BinaryenLoopGetName(expr))) != null) { if ((string = readString(_BinaryenLoopGetName(expr))) != null) {
this.push(string); this.push(string);
this.push(": "); this.push(": ");
@ -107,8 +106,8 @@ export class Decompiler {
this.push("do "); this.push("do ");
this.decompileExpression(_BinaryenLoopGetBody(expr)); this.decompileExpression(_BinaryenLoopGetBody(expr));
this.push("while (0);\n"); this.push("while (0);\n");
}
case ExpressionId.Break: case ExpressionId.Break: {
if (nested = _BinaryenBreakGetCondition(expr)) { if (nested = _BinaryenBreakGetCondition(expr)) {
this.push("if ("); this.push("if (");
this.decompileExpression(nested); this.decompileExpression(nested);
@ -122,32 +121,30 @@ export class Decompiler {
this.push("break;\n"); this.push("break;\n");
} }
return; return;
}
case ExpressionId.Switch: case ExpressionId.Switch:
case ExpressionId.Call: case ExpressionId.Call:
case ExpressionId.CallImport: case ExpressionId.CallImport:
case ExpressionId.CallIndirect: {
case ExpressionId.CallIndirect: throw new Error("not implemented");
}
case ExpressionId.GetLocal: case ExpressionId.GetLocal: {
this.push("$"); this.push("$");
this.push(_BinaryenGetLocalGetIndex(expr).toString(10)); this.push(_BinaryenGetLocalGetIndex(expr).toString(10));
return; return;
}
case ExpressionId.SetLocal: case ExpressionId.SetLocal: {
this.push("$"); this.push("$");
this.push(_BinaryenSetLocalGetIndex(expr).toString(10)); this.push(_BinaryenSetLocalGetIndex(expr).toString(10));
this.push(" = "); this.push(" = ");
this.decompileExpression(_BinaryenSetLocalGetValue(expr)); this.decompileExpression(_BinaryenSetLocalGetValue(expr));
return; return;
}
case ExpressionId.GetGlobal: case ExpressionId.GetGlobal:
case ExpressionId.SetGlobal: {
case ExpressionId.SetGlobal: throw new Error("not implemented");
}
case ExpressionId.Load: case ExpressionId.Load: {
this.push("load<"); this.push("load<");
this.push(nativeTypeToType(type)); this.push(nativeTypeToType(type));
this.push(">("); this.push(">(");
@ -156,8 +153,8 @@ export class Decompiler {
this.decompileExpression(_BinaryenLoadGetPtr(expr)); this.decompileExpression(_BinaryenLoadGetPtr(expr));
this.push(")"); this.push(")");
return; return;
}
case ExpressionId.Store: case ExpressionId.Store: {
this.push("store<"); this.push("store<");
this.push(nativeTypeToType(type)); this.push(nativeTypeToType(type));
this.push(">("); this.push(">(");
@ -168,15 +165,14 @@ export class Decompiler {
this.decompileExpression(_BinaryenStoreGetValue(expr)); this.decompileExpression(_BinaryenStoreGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case ExpressionId.Const: case ExpressionId.Const: {
switch (type) { switch (type) {
case NativeType.I32: {
case NativeType.I32:
this.push(_BinaryenConstGetValueI32(expr).toString(10)); this.push(_BinaryenConstGetValueI32(expr).toString(10));
return; return;
}
case NativeType.I64: case NativeType.I64: {
this.push( this.push(
i64_to_string( i64_to_string(
i64_new( i64_new(
@ -186,572 +182,572 @@ export class Decompiler {
) )
); );
return; return;
}
case NativeType.F32: case NativeType.F32: {
this.push(_BinaryenConstGetValueF32(expr).toString(10)); this.push(_BinaryenConstGetValueF32(expr).toString(10));
return; return;
}
case NativeType.F64: case NativeType.F64: {
this.push(_BinaryenConstGetValueF64(expr).toString(10)); this.push(_BinaryenConstGetValueF64(expr).toString(10));
return; return;
} }
}
break; break;
}
case ExpressionId.Unary: case ExpressionId.Unary: {
switch (_BinaryenUnaryGetOp(expr)) { switch (_BinaryenUnaryGetOp(expr)) {
case UnaryOp.ClzI32: {
case UnaryOp.ClzI32:
this.push("clz<i32>("); this.push("clz<i32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.CtzI32: case UnaryOp.CtzI32: {
this.push("ctz<i32>("); this.push("ctz<i32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.PopcntI32: case UnaryOp.PopcntI32: {
this.push("popcnt<i32>("); this.push("popcnt<i32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.NegF32: case UnaryOp.NegF32:
case UnaryOp.NegF64: case UnaryOp.NegF64: {
this.push("-"); this.push("-");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.AbsF32: case UnaryOp.AbsF32: {
this.push("abs<f32>("); this.push("abs<f32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.CeilF32: case UnaryOp.CeilF32: {
this.push("ceil<f32>("); this.push("ceil<f32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.FloorF32: case UnaryOp.FloorF32: {
this.push("floor<f32>("); this.push("floor<f32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.TruncF32: case UnaryOp.TruncF32: {
this.push("trunc<f32>("); this.push("trunc<f32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.NearestF32: case UnaryOp.NearestF32: {
this.push("nearest<i32>("); this.push("nearest<i32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.SqrtF32: case UnaryOp.SqrtF32: {
this.push("sqrt<f32>("); this.push("sqrt<f32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.EqzI32: case UnaryOp.EqzI32:
case UnaryOp.EqzI64: case UnaryOp.EqzI64: {
this.push("!"); this.push("!");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ClzI64: case UnaryOp.ClzI64: {
this.push("clz<i64>("); this.push("clz<i64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.CtzI64: case UnaryOp.CtzI64: {
this.push("ctz<i64>("); this.push("ctz<i64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.PopcntI64: case UnaryOp.PopcntI64: {
this.push("popcnt<i64>("); this.push("popcnt<i64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.AbsF64: case UnaryOp.AbsF64: {
this.push("abs<f64>("); this.push("abs<f64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.CeilF64: case UnaryOp.CeilF64: {
this.push("ceil<f64>("); this.push("ceil<f64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.FloorF64: case UnaryOp.FloorF64: {
this.push("floor<f64>("); this.push("floor<f64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.TruncF64: case UnaryOp.TruncF64: {
this.push("trunc<f64>("); this.push("trunc<f64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.NearestF64: case UnaryOp.NearestF64: {
this.push("nearest<f64>("); this.push("nearest<f64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.SqrtF64: case UnaryOp.SqrtF64: {
this.push("sqrt<f64>("); this.push("sqrt<f64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.ExtendI32: case UnaryOp.ExtendI32: {
this.push("<i64>"); this.push("<i64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ExtendU32: case UnaryOp.ExtendU32: {
this.push("<i64><u64>"); this.push("<i64><u64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.WrapI64: case UnaryOp.WrapI64: {
this.push("<i32>"); this.push("<i32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF32ToI32: case UnaryOp.TruncF32ToI32: {
this.push("<i32>"); this.push("<i32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF32ToI64: case UnaryOp.TruncF32ToI64: {
this.push("<i64>"); this.push("<i64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF32ToU32: case UnaryOp.TruncF32ToU32: {
this.push("<i32><u32>"); this.push("<i32><u32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF32ToU64: case UnaryOp.TruncF32ToU64: {
this.push("<i64><u64>"); this.push("<i64><u64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF64ToI32: case UnaryOp.TruncF64ToI32: {
this.push("<i32>"); this.push("<i32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF64ToI64: case UnaryOp.TruncF64ToI64: {
this.push("<i64>"); this.push("<i64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF64ToU32: case UnaryOp.TruncF64ToU32: {
this.push("<i32><u32>"); this.push("<i32><u32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.TruncF64ToU64: case UnaryOp.TruncF64ToU64: {
this.push("<i64><u64>"); this.push("<i64><u64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ReinterpretF32: case UnaryOp.ReinterpretF32: {
this.push("reinterpret<f32,i32>("); this.push("reinterpret<f32,i32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.ReinterpretF64: case UnaryOp.ReinterpretF64: {
this.push("reinterpret<f64,i64>("); this.push("reinterpret<f64,i64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.ConvertI32ToF32: case UnaryOp.ConvertI32ToF32: {
this.push("<f32>"); this.push("<f32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ConvertI32ToF64: case UnaryOp.ConvertI32ToF64: {
this.push("<f64>"); this.push("<f64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ConvertU32ToF32: case UnaryOp.ConvertU32ToF32: {
this.push("<f32><u32>"); this.push("<f32><u32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ConvertU32ToF64: case UnaryOp.ConvertU32ToF64: {
this.push("<f64><u32>"); this.push("<f64><u32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ConvertI64ToF32: case UnaryOp.ConvertI64ToF32: {
this.push("<f32>"); this.push("<f32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ConvertI64ToF64: case UnaryOp.ConvertI64ToF64: {
this.push("<f64>"); this.push("<f64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ConvertU64ToF32: case UnaryOp.ConvertU64ToF32: {
this.push("<f32><u64>"); this.push("<f32><u64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ConvertU64ToF64: case UnaryOp.ConvertU64ToF64: {
this.push("<f64><u64>"); this.push("<f64><u64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.PromoteF32: case UnaryOp.PromoteF32: {
this.push("<f64>"); this.push("<f64>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.DemoteF64: case UnaryOp.DemoteF64: {
this.push("<f32>"); this.push("<f32>");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
return; return;
}
case UnaryOp.ReinterpretI32: case UnaryOp.ReinterpretI32: {
this.push("reinterpret<i32,f32>("); this.push("reinterpret<i32,f32>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
}
case UnaryOp.ReinterpretI64: case UnaryOp.ReinterpretI64: {
this.push("reinterpret<i64,f64>("); this.push("reinterpret<i64,f64>(");
this.decompileExpression(_BinaryenUnaryGetValue(expr)); this.decompileExpression(_BinaryenUnaryGetValue(expr));
this.push(")"); this.push(")");
return; return;
} }
}
break; break;
}
case ExpressionId.Binary: // TODO: precedence case ExpressionId.Binary: { // TODO: precedence
switch (_BinaryenBinaryGetOp(expr)) { switch (_BinaryenBinaryGetOp(expr)) {
case BinaryOp.AddI32: case BinaryOp.AddI32:
case BinaryOp.AddI64: case BinaryOp.AddI64:
case BinaryOp.AddF32: case BinaryOp.AddF32:
case BinaryOp.AddF64: case BinaryOp.AddF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" + "); this.push(" + ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.SubI32: case BinaryOp.SubI32:
case BinaryOp.SubI64: case BinaryOp.SubI64:
case BinaryOp.SubF32: case BinaryOp.SubF32:
case BinaryOp.SubF64: case BinaryOp.SubF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" - "); this.push(" - ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.MulI32: case BinaryOp.MulI32:
case BinaryOp.MulI64: case BinaryOp.MulI64:
case BinaryOp.MulF32: case BinaryOp.MulF32:
case BinaryOp.MulF64: case BinaryOp.MulF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" * "); this.push(" * ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.DivI32: case BinaryOp.DivI32:
case BinaryOp.DivI64: case BinaryOp.DivI64:
case BinaryOp.DivF32: case BinaryOp.DivF32:
case BinaryOp.DivF64: case BinaryOp.DivF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" / "); this.push(" / ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.DivU32: case BinaryOp.DivU32: {
this.push("<i32>(<u32>"); this.push("<i32>(<u32>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" / <u32>"); this.push(" / <u32>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.RemI32: case BinaryOp.RemI32:
case BinaryOp.RemI64: case BinaryOp.RemI64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" % "); this.push(" % ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.RemU32: case BinaryOp.RemU32: {
this.push("<i32>(<u32>"); this.push("<i32>(<u32>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" / <u32>"); this.push(" / <u32>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.AndI32: case BinaryOp.AndI32:
case BinaryOp.AndI64: case BinaryOp.AndI64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" & "); this.push(" & ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.OrI32: case BinaryOp.OrI32:
case BinaryOp.OrI64: case BinaryOp.OrI64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" | "); this.push(" | ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.XorI32: case BinaryOp.XorI32:
case BinaryOp.XorI64: case BinaryOp.XorI64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" ^ "); this.push(" ^ ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.ShlI32: case BinaryOp.ShlI32:
case BinaryOp.ShlI64: case BinaryOp.ShlI64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" << "); this.push(" << ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.ShrU32: case BinaryOp.ShrU32:
case BinaryOp.ShrU64: case BinaryOp.ShrU64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" >>> "); this.push(" >>> ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.ShrI32: case BinaryOp.ShrI32:
case BinaryOp.ShrI64: case BinaryOp.ShrI64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" >> "); this.push(" >> ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.RotlI32: case BinaryOp.RotlI32: {
this.push("rotl<i32>("); this.push("rotl<i32>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.RotrI32: case BinaryOp.RotrI32: {
this.push("rotr<i32>("); this.push("rotr<i32>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.EqI32: case BinaryOp.EqI32:
case BinaryOp.EqI64: case BinaryOp.EqI64:
case BinaryOp.EqF32: case BinaryOp.EqF32:
case BinaryOp.EqF64: case BinaryOp.EqF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" == "); this.push(" == ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.NeI32: case BinaryOp.NeI32:
case BinaryOp.NeI64: case BinaryOp.NeI64:
case BinaryOp.NeF32: case BinaryOp.NeF32:
case BinaryOp.NeF64: case BinaryOp.NeF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" != "); this.push(" != ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.LtI32: case BinaryOp.LtI32:
case BinaryOp.LtI64: case BinaryOp.LtI64:
case BinaryOp.LtF32: case BinaryOp.LtF32:
case BinaryOp.LtF64: case BinaryOp.LtF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" < "); this.push(" < ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.LtU32: case BinaryOp.LtU32: {
this.push("<u32>"); this.push("<u32>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" < <u32>"); this.push(" < <u32>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.LeI32: case BinaryOp.LeI32:
case BinaryOp.LeI64: case BinaryOp.LeI64:
case BinaryOp.LeF32: case BinaryOp.LeF32:
case BinaryOp.LeF64: case BinaryOp.LeF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" <= "); this.push(" <= ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.LeU32: case BinaryOp.LeU32: {
this.push("<u32>"); this.push("<u32>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" <= <u32>"); this.push(" <= <u32>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.GtI32: case BinaryOp.GtI32:
case BinaryOp.GtI64: case BinaryOp.GtI64:
case BinaryOp.GtF32: case BinaryOp.GtF32:
case BinaryOp.GtF64: case BinaryOp.GtF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" > "); this.push(" > ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.GtU32: case BinaryOp.GtU32: {
this.push("<u32>"); this.push("<u32>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" > <u32>"); this.push(" > <u32>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.GeI32: case BinaryOp.GeI32:
case BinaryOp.GeI64: case BinaryOp.GeI64:
case BinaryOp.GeF32: case BinaryOp.GeF32:
case BinaryOp.GeF64: case BinaryOp.GeF64: {
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" >= "); this.push(" >= ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.GeU32: case BinaryOp.GeU32: {
this.push("<u32>"); this.push("<u32>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" >= <u32>"); this.push(" >= <u32>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.DivU64: case BinaryOp.DivU64: {
this.push("<u64>"); this.push("<u64>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" / <u64>"); this.push(" / <u64>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.RemU64: case BinaryOp.RemU64: {
this.push("<u64>"); this.push("<u64>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" % <u64>"); this.push(" % <u64>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.RotlI64: case BinaryOp.RotlI64: {
this.push("rotl<i64>("); this.push("rotl<i64>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.RotrI64: case BinaryOp.RotrI64: {
this.push("rotr<i64>("); this.push("rotr<i64>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.LtU64: case BinaryOp.LtU64: {
this.push("<u64>"); this.push("<u64>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" < <u64>"); this.push(" < <u64>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.LeU64: case BinaryOp.LeU64: {
this.push("<u64>"); this.push("<u64>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" <= <u64>"); this.push(" <= <u64>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.GtU64: case BinaryOp.GtU64: {
this.push("<u64>"); this.push("<u64>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" > <u64>"); this.push(" > <u64>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.GeU64: case BinaryOp.GeU64: {
this.push("<u64>"); this.push("<u64>");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(" >= <u64>"); this.push(" >= <u64>");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
return; return;
}
case BinaryOp.CopysignF32: case BinaryOp.CopysignF32: {
this.push("copysign<f32>("); this.push("copysign<f32>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.MinF32: case BinaryOp.MinF32: {
this.push("min<f32>("); this.push("min<f32>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.MaxF32: case BinaryOp.MaxF32: {
this.push("max<f32>("); this.push("max<f32>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.CopysignF64: case BinaryOp.CopysignF64: {
this.push("copysign<f64>("); this.push("copysign<f64>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.MinF64: case BinaryOp.MinF64: {
this.push("min<f64>("); this.push("min<f64>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
this.decompileExpression(_BinaryenBinaryGetRight(expr)); this.decompileExpression(_BinaryenBinaryGetRight(expr));
this.push(")"); this.push(")");
return; return;
}
case BinaryOp.MaxF64: case BinaryOp.MaxF64: {
this.push("max<f64>("); this.push("max<f64>(");
this.decompileExpression(_BinaryenBinaryGetLeft(expr)); this.decompileExpression(_BinaryenBinaryGetLeft(expr));
this.push(", "); this.push(", ");
@ -759,9 +755,10 @@ export class Decompiler {
this.push(")"); this.push(")");
return; return;
} }
}
return; return;
}
case ExpressionId.Select: case ExpressionId.Select: {
this.push("select<"); this.push("select<");
this.push(nativeTypeToType(type)); this.push(nativeTypeToType(type));
this.push(">("); this.push(">(");
@ -772,13 +769,13 @@ export class Decompiler {
this.decompileExpression(_BinaryenSelectGetCondition(expr)); this.decompileExpression(_BinaryenSelectGetCondition(expr));
this.push(")"); this.push(")");
return; return;
}
case ExpressionId.Drop: case ExpressionId.Drop: {
this.decompileExpression(_BinaryenDropGetValue(expr)); this.decompileExpression(_BinaryenDropGetValue(expr));
this.push(";\n"); this.push(";\n");
return; return;
}
case ExpressionId.Return: case ExpressionId.Return: {
if (nested = _BinaryenReturnGetValue(expr)) { if (nested = _BinaryenReturnGetValue(expr)) {
this.push("return "); this.push("return ");
this.decompileExpression(nested); this.decompileExpression(nested);
@ -787,34 +784,33 @@ export class Decompiler {
this.push("return;\n"); this.push("return;\n");
} }
return; return;
}
case ExpressionId.Host: case ExpressionId.Host: {
switch (_BinaryenHostGetOp(expr)) { switch (_BinaryenHostGetOp(expr)) {
case HostOp.CurrentMemory: case HostOp.CurrentMemory: {
this.push("current_memory()"); this.push("current_memory()");
return; return;
case HostOp.GrowMemory: }
case HostOp.GrowMemory: {
this.push("grow_memory("); this.push("grow_memory(");
this.decompileExpression(_BinaryenHostGetOperand(expr, 0)); this.decompileExpression(_BinaryenHostGetOperand(expr, 0));
this.push(")"); this.push(")");
return; return;
} }
}
break; break;
}
case ExpressionId.Nop: case ExpressionId.Nop: {
this.push(";\n"); this.push(";\n");
return; return;
}
case ExpressionId.Unreachable: case ExpressionId.Unreachable: {
this.push("unreachable()"); this.push("unreachable()");
return; return;
}
case ExpressionId.AtomicCmpxchg: case ExpressionId.AtomicCmpxchg:
case ExpressionId.AtomicRMW: case ExpressionId.AtomicRMW:
case ExpressionId.AtomicWait: case ExpressionId.AtomicWait:
case ExpressionId.AtomicWake: case ExpressionId.AtomicWake:
} }
throw new Error("not implemented"); throw new Error("not implemented");

@ -7,8 +7,10 @@ import {
NodeKind, NodeKind,
Source, Source,
CommonTypeNode,
TypeNode, TypeNode,
TypeParameter, TypeParameterNode,
SignatureNode,
Expression, Expression,
IdentifierExpression, IdentifierExpression,
@ -65,10 +67,10 @@ import {
TypeDeclaration, TypeDeclaration,
VariableDeclaration, VariableDeclaration,
Decorator, DecoratorNode,
Modifier, ModifierNode,
ModifierKind, ModifierKind,
Parameter, ParameterNode,
ParameterKind, ParameterKind,
ExportMember, ExportMember,
SwitchCase, SwitchCase,
@ -79,6 +81,7 @@ import {
import { import {
CharCode CharCode
} from "../util/charcode"; } from "../util/charcode";
import { Signature } from "../types";
export function serializeNode(node: Node, sb: string[]): void { export function serializeNode(node: Node, sb: string[]): void {
switch (node.kind) { switch (node.kind) {
@ -94,7 +97,7 @@ export function serializeNode(node: Node, sb: string[]): void {
break; break;
case NodeKind.TYPEPARAMETER: case NodeKind.TYPEPARAMETER:
serializeTypeParameter(<TypeParameter>node, sb); serializeTypeParameter(<TypeParameterNode>node, sb);
break; break;
// expressions // expressions
@ -277,7 +280,7 @@ export function serializeNode(node: Node, sb: string[]): void {
// other // other
case NodeKind.DECORATOR: case NodeKind.DECORATOR:
serializeDecorator(<Decorator>node, sb); serializeDecorator(<DecoratorNode>node, sb);
break; break;
case NodeKind.EXPORTMEMBER: case NodeKind.EXPORTMEMBER:
@ -285,11 +288,11 @@ export function serializeNode(node: Node, sb: string[]): void {
break; break;
case NodeKind.MODIFIER: case NodeKind.MODIFIER:
serializeModifier(<Modifier>node, sb); serializeModifier(<ModifierNode>node, sb);
break; break;
case NodeKind.PARAMETER: case NodeKind.PARAMETER:
serializeParameter(<Parameter>node, sb); serializeParameter(<ParameterNode>node, sb);
break; break;
case NodeKind.SWITCHCASE: case NodeKind.SWITCHCASE:
@ -310,29 +313,64 @@ export function serializeSource(source: Source, sb: string[]): void {
// types // types
export function serializeTypeNode(node: TypeNode, sb: string[]): void { export function serializeTypeNode(node: CommonTypeNode, sb: string[]): void {
serializeIdentifierExpression(<IdentifierExpression>node.name, sb); if (node.kind == NodeKind.SIGNATURE) {
var k = node.typeArguments.length; return serializeSignatureNode(<SignatureNode>node, sb);
}
var typeNode = <TypeNode>node;
serializeIdentifierExpression(<IdentifierExpression>typeNode.name, sb);
if (typeNode.typeArguments) {
var k = typeNode.typeArguments.length;
if (k) { if (k) {
sb.push("<"); sb.push("<");
serializeTypeNode(node.typeArguments[0], sb); serializeTypeNode(typeNode.typeArguments[0], sb);
for (var i = 1; i < k; ++i) { for (var i = 1; i < k; ++i) {
sb.push(", "); sb.push(", ");
serializeTypeNode(node.typeArguments[i], sb); serializeTypeNode(typeNode.typeArguments[i], sb);
} }
sb.push(">"); sb.push(">");
} }
if (node.isNullable) sb.push(" | null"); if (node.isNullable) sb.push(" | null");
}
} }
export function serializeTypeParameter(node: TypeParameter, sb: string[]): void { export function serializeTypeParameter(node: TypeParameterNode, sb: string[]): void {
serializeIdentifierExpression(node.name, sb); serializeIdentifierExpression(node.name, sb);
if (node.extendsType) { var extendsType = node.extendsType;
if (extendsType) {
sb.push(" extends "); sb.push(" extends ");
serializeTypeNode(node.extendsType, sb); serializeTypeNode(extendsType, sb);
} }
} }
export function serializeSignatureNode(node: SignatureNode, sb: string[]): void {
var isNullable = node.isNullable;
sb.push(isNullable ? "((" : "(");
var explicitThisType = node.explicitThisType;
if (explicitThisType) {
sb.push("this: ");
serializeTypeNode(explicitThisType, sb);
}
var parameters = node.parameterTypes;
var numParameters = parameters.length;
if (numParameters) {
if (explicitThisType) sb.push(", ");
serializeParameter(parameters[0], sb);
for (let i = 1; i < numParameters; ++i) {
sb.push(", ");
serializeParameter(parameters[i], sb);
}
}
var returnType = node.returnType;
if (returnType) {
sb.push(") => ");
serializeTypeNode(returnType, sb);
} else {
sb.push(") => void");
}
if (isNullable) sb.push(") | null");
}
// expressions // expressions
export function serializeExpression(node: Expression, sb: string[]): void { export function serializeExpression(node: Expression, sb: string[]): void {
@ -876,6 +914,7 @@ export function serializeFunctionDeclaration(node: FunctionDeclaration, sb: stri
function serializeFunctionCommon(node: FunctionDeclaration, sb: string[], isArrow: bool = false): void { function serializeFunctionCommon(node: FunctionDeclaration, sb: string[], isArrow: bool = false): void {
var i: i32, k: i32; var i: i32, k: i32;
serializeIdentifierExpression(node.name, sb); serializeIdentifierExpression(node.name, sb);
var signature = node.signature;
if (node.typeParameters) { if (node.typeParameters) {
if (k = node.typeParameters.length) { if (k = node.typeParameters.length) {
sb.push("<"); sb.push("<");
@ -888,34 +927,35 @@ function serializeFunctionCommon(node: FunctionDeclaration, sb: string[], isArro
} }
} }
sb.push("("); sb.push("(");
if (k = node.parameters.length) { if (k = signature.parameterTypes.length) {
serializeParameter(node.parameters[0], sb); serializeParameter(signature.parameterTypes[0], sb);
for (i = 1; i < k; ++i) { for (i = 1; i < k; ++i) {
sb.push(", "); sb.push(", ");
serializeParameter(node.parameters[i], sb); serializeParameter(signature.parameterTypes[i], sb);
} }
} }
if (isArrow) { if (isArrow) {
if (node.body) { if (node.body) {
if (node.returnType) { if (signature.returnType) {
sb.push("): "); sb.push("): ");
serializeTypeNode(node.returnType, sb); serializeTypeNode(signature.returnType, sb);
} }
sb.push(" => "); sb.push(" => ");
serializeStatement(<Statement>node.body, sb); serializeStatement(node.body, sb);
} else { } else {
if (node.returnType) { if (signature.returnType) {
sb.push(" => "); sb.push(" => ");
serializeTypeNode(node.returnType, sb); serializeTypeNode(signature.returnType, sb);
} else { } else {
sb.push(" => void"); sb.push(" => void");
} }
} }
} else { } else {
if (node.returnType && !hasModifier(ModifierKind.SET, node.modifiers)) { if (signature.returnType && !hasModifier(ModifierKind.SET, node.modifiers)) {
sb.push("): "); sb.push("): ");
serializeTypeNode(node.returnType, sb); serializeTypeNode(signature.returnType, sb);
} else { } else {
// TODO: constructor?
sb.push(")"); sb.push(")");
} }
if (node.body) { if (node.body) {
@ -1203,7 +1243,7 @@ export function serializeWhileStatement(node: WhileStatement, sb: string[]): voi
// other // other
export function serializeDecorator(node: Decorator, sb: string[]): void { export function serializeDecorator(node: DecoratorNode, sb: string[]): void {
sb.push("@"); sb.push("@");
serializeExpression(node.name, sb); serializeExpression(node.name, sb);
if (node.arguments) { if (node.arguments) {
@ -1220,11 +1260,11 @@ export function serializeDecorator(node: Decorator, sb: string[]): void {
} }
} }
export function serializeModifier(node: Modifier, sb: string[]): void { export function serializeModifier(node: ModifierNode, sb: string[]): void {
sb.push(modifierToString(node)); sb.push(modifierToString(node));
} }
export function serializeParameter(node: Parameter, sb: string[]): void { export function serializeParameter(node: ParameterNode, sb: string[]): void {
if (node.parameterKind == ParameterKind.REST) { if (node.parameterKind == ParameterKind.REST) {
sb.push("..."); sb.push("...");
} }
@ -1245,7 +1285,7 @@ export function serializeParameter(node: Parameter, sb: string[]): void {
// helpers // helpers
export function modifierToString(node: Modifier): string { export function modifierToString(node: ModifierNode): string {
switch (node.modifierKind) { switch (node.modifierKind) {
case ModifierKind.ASYNC: return "async"; case ModifierKind.ASYNC: return "async";
case ModifierKind.CONST: return "const"; case ModifierKind.CONST: return "const";

@ -265,12 +265,12 @@ export class Module {
addFunctionType( addFunctionType(
name: string, name: string,
result: NativeType, result: NativeType,
paramTypes: NativeType[] paramTypes: NativeType[] | null
): FunctionRef { ): FunctionRef {
var cStr = allocString(name); var cStr = allocString(name);
var cArr = allocI32Array(paramTypes); var cArr = allocI32Array(paramTypes);
try { try {
return _BinaryenAddFunctionType(this.ref, cStr, result, cArr, paramTypes.length); return _BinaryenAddFunctionType(this.ref, cStr, result, cArr, paramTypes ? paramTypes.length : 0);
} finally { } finally {
free_memory(cArr); free_memory(cArr);
free_memory(cStr); free_memory(cStr);
@ -279,11 +279,11 @@ export class Module {
getFunctionTypeBySignature( getFunctionTypeBySignature(
result: NativeType, result: NativeType,
paramTypes: NativeType[] paramTypes: NativeType[] | null
): FunctionTypeRef { ): FunctionTypeRef {
var cArr = allocI32Array(paramTypes); var cArr = allocI32Array(paramTypes);
try { try {
return _BinaryenGetFunctionTypeBySignature(this.ref, result, cArr, paramTypes.length); return _BinaryenGetFunctionTypeBySignature(this.ref, result, cArr, paramTypes ? paramTypes.length : 0);
} finally { } finally {
free_memory(cArr); free_memory(cArr);
} }
@ -594,6 +594,21 @@ export class Module {
} }
} }
createCallIndirect(
index: ExpressionRef,
operands: ExpressionRef[] | null,
typeName: string
): ExpressionRef {
var cArr = allocI32Array(operands);
var cStr = allocString(typeName);
try {
return _BinaryenCallIndirect(this.ref, index, cArr, operands && operands.length || 0, cStr);
} finally {
free_memory(cStr);
free_memory(cArr);
}
}
createUnreachable(): ExpressionRef { createUnreachable(): ExpressionRef {
return _BinaryenUnreachable(this.ref); return _BinaryenUnreachable(this.ref);
} }
@ -617,13 +632,13 @@ export class Module {
addFunction( addFunction(
name: string, name: string,
type: FunctionTypeRef, type: FunctionTypeRef,
varTypes: NativeType[], varTypes: NativeType[] | null,
body: ExpressionRef body: ExpressionRef
): FunctionRef { ): FunctionRef {
var cStr = allocString(name); var cStr = allocString(name);
var cArr = allocI32Array(varTypes); var cArr = allocI32Array(varTypes);
try { try {
return _BinaryenAddFunction(this.ref, cStr, type, cArr, varTypes.length, body); return _BinaryenAddFunction(this.ref, cStr, type, cArr, varTypes ? varTypes.length : 0, body);
} finally { } finally {
free_memory(cArr); free_memory(cArr);
free_memory(cStr); free_memory(cStr);
@ -928,36 +943,40 @@ export class Module {
nested2: ExpressionRef; nested2: ExpressionRef;
switch (_BinaryenExpressionGetId(expr)) { switch (_BinaryenExpressionGetId(expr)) {
case ExpressionId.Const: {
case ExpressionId.Const:
switch (_BinaryenExpressionGetType(expr)) { switch (_BinaryenExpressionGetType(expr)) {
case NativeType.I32: case NativeType.I32: {
return this.createI32(_BinaryenConstGetValueI32(expr)); return this.createI32(_BinaryenConstGetValueI32(expr));
case NativeType.I64: }
case NativeType.I64: {
return this.createI64( return this.createI64(
_BinaryenConstGetValueI64Low(expr), _BinaryenConstGetValueI64Low(expr),
_BinaryenConstGetValueI64High(expr) _BinaryenConstGetValueI64High(expr)
); );
case NativeType.F32: }
case NativeType.F32: {
return this.createF32(_BinaryenConstGetValueF32(expr)); return this.createF32(_BinaryenConstGetValueF32(expr));
case NativeType.F64: }
case NativeType.F64: {
return this.createF64(_BinaryenConstGetValueF64(expr)); return this.createF64(_BinaryenConstGetValueF64(expr));
default: }
default: {
throw new Error("concrete type expected"); throw new Error("concrete type expected");
} }
}
case ExpressionId.GetLocal: }
case ExpressionId.GetLocal: {
return _BinaryenGetLocal(this.ref, return _BinaryenGetLocal(this.ref,
_BinaryenGetLocalGetIndex(expr), _BinaryenGetLocalGetIndex(expr),
_BinaryenExpressionGetType(expr) _BinaryenExpressionGetType(expr)
); );
}
case ExpressionId.GetGlobal: case ExpressionId.GetGlobal: {
var globalName = _BinaryenGetGlobalGetName(expr); var globalName = _BinaryenGetGlobalGetName(expr);
if (!globalName) break; if (!globalName) break;
return _BinaryenGetGlobal(this.ref, globalName, _BinaryenExpressionGetType(expr)); return _BinaryenGetGlobal(this.ref, globalName, _BinaryenExpressionGetType(expr));
}
case ExpressionId.Load: case ExpressionId.Load: {
if (!(nested1 = this.cloneExpression(_BinaryenLoadGetPtr(expr), noSideEffects, maxDepth))) { if (!(nested1 = this.cloneExpression(_BinaryenLoadGetPtr(expr), noSideEffects, maxDepth))) {
break; break;
} }
@ -976,14 +995,14 @@ export class Module {
_BinaryenExpressionGetType(expr), _BinaryenExpressionGetType(expr),
nested1 nested1
); );
}
case ExpressionId.Unary: case ExpressionId.Unary: {
if (!(nested1 = this.cloneExpression(_BinaryenUnaryGetValue(expr), noSideEffects, maxDepth))) { if (!(nested1 = this.cloneExpression(_BinaryenUnaryGetValue(expr), noSideEffects, maxDepth))) {
break; break;
} }
return _BinaryenUnary(this.ref, _BinaryenUnaryGetOp(expr), nested1); return _BinaryenUnary(this.ref, _BinaryenUnaryGetOp(expr), nested1);
}
case ExpressionId.Binary: case ExpressionId.Binary: {
if (!(nested1 = this.cloneExpression(_BinaryenBinaryGetLeft(expr), noSideEffects, maxDepth))) { if (!(nested1 = this.cloneExpression(_BinaryenBinaryGetLeft(expr), noSideEffects, maxDepth))) {
break; break;
} }
@ -992,6 +1011,7 @@ export class Module {
} }
return _BinaryenBinary(this.ref, _BinaryenBinaryGetOp(expr), nested1, nested2); return _BinaryenBinary(this.ref, _BinaryenBinaryGetOp(expr), nested1, nested2);
} }
}
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -260,10 +260,8 @@ export namespace Token {
case Token.NAMESPACE: case Token.NAMESPACE:
case Token.READONLY: case Token.READONLY:
case Token.SET: case Token.SET:
case Token.TYPE: case Token.TYPE: return true;
return true; default: return false;
default:
return false;
} }
} }
@ -317,7 +315,10 @@ export namespace Token {
case Token.AMPERSAND_EQUALS: return "&="; case Token.AMPERSAND_EQUALS: return "&=";
case Token.BAR_EQUALS: return "|="; case Token.BAR_EQUALS: return "|=";
case Token.CARET_EQUALS: return "^="; case Token.CARET_EQUALS: return "^=";
default: assert(false); return ""; default: {
assert(false);
return "";
}
} }
} }
} }
@ -394,10 +395,6 @@ export class Tokenizer extends DiagnosticEmitter {
token: Token = -1; token: Token = -1;
tokenPos: i32 = 0; tokenPos: i32 = 0;
markedPos: i32 = 0;
markedToken: Token = -1;
markedTokenPos: i32 = 0;
nextToken: Token = -1; nextToken: Token = -1;
nextTokenOnNewLine: bool = false; nextTokenOnNewLine: bool = false;
@ -446,8 +443,7 @@ export class Tokenizer extends DiagnosticEmitter {
this.tokenPos = this.pos; this.tokenPos = this.pos;
var c = text.charCodeAt(this.pos); var c = text.charCodeAt(this.pos);
switch (c) { switch (c) {
case CharCode.CARRIAGERETURN: {
case CharCode.CARRIAGERETURN:
if ( if (
++this.pos < this.end && ++this.pos < this.end &&
text.charCodeAt(this.pos) == CharCode.LINEFEED text.charCodeAt(this.pos) == CharCode.LINEFEED
@ -455,16 +451,16 @@ export class Tokenizer extends DiagnosticEmitter {
++this.pos; ++this.pos;
} }
break; break;
}
case CharCode.LINEFEED: case CharCode.LINEFEED:
case CharCode.TAB: case CharCode.TAB:
case CharCode.VERTICALTAB: case CharCode.VERTICALTAB:
case CharCode.FORMFEED: case CharCode.FORMFEED:
case CharCode.SPACE: case CharCode.SPACE: {
++this.pos; ++this.pos;
break; break;
}
case CharCode.EXCLAMATION: case CharCode.EXCLAMATION: {
++this.pos; ++this.pos;
if ( if (
maxTokenLength > 1 && this.pos < this.end && maxTokenLength > 1 && this.pos < this.end &&
@ -481,13 +477,13 @@ export class Tokenizer extends DiagnosticEmitter {
return Token.EXCLAMATION_EQUALS; return Token.EXCLAMATION_EQUALS;
} }
return Token.EXCLAMATION; return Token.EXCLAMATION;
}
case CharCode.DOUBLEQUOTE: case CharCode.DOUBLEQUOTE:
case CharCode.SINGLEQUOTE: case CharCode.SINGLEQUOTE:
case CharCode.BACKTICK: // TODO case CharCode.BACKTICK: { // TODO
return Token.STRINGLITERAL; // expects a call to readString return Token.STRINGLITERAL; // expects a call to readString
}
case CharCode.PERCENT: case CharCode.PERCENT: {
++this.pos; ++this.pos;
if ( if (
maxTokenLength > 1 && this.pos < this.end && maxTokenLength > 1 && this.pos < this.end &&
@ -497,8 +493,8 @@ export class Tokenizer extends DiagnosticEmitter {
return Token.PERCENT_EQUALS; return Token.PERCENT_EQUALS;
} }
return Token.PERCENT; return Token.PERCENT;
}
case CharCode.AMPERSAND: case CharCode.AMPERSAND: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.AMPERSAND) { if (text.charCodeAt(this.pos) == CharCode.AMPERSAND) {
@ -511,16 +507,16 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.AMPERSAND; return Token.AMPERSAND;
}
case CharCode.OPENPAREN: case CharCode.OPENPAREN: {
++this.pos; ++this.pos;
return Token.OPENPAREN; return Token.OPENPAREN;
}
case CharCode.CLOSEPAREN: case CharCode.CLOSEPAREN: {
++this.pos; ++this.pos;
return Token.CLOSEPAREN; return Token.CLOSEPAREN;
}
case CharCode.ASTERISK: case CharCode.ASTERISK: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.EQUALS) { if (text.charCodeAt(this.pos) == CharCode.EQUALS) {
@ -540,8 +536,8 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.ASTERISK; return Token.ASTERISK;
}
case CharCode.PLUS: case CharCode.PLUS: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.PLUS) { if (text.charCodeAt(this.pos) == CharCode.PLUS) {
@ -554,12 +550,12 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.PLUS; return Token.PLUS;
}
case CharCode.COMMA: case CharCode.COMMA: {
++this.pos; ++this.pos;
return Token.COMMA; return Token.COMMA;
}
case CharCode.MINUS: case CharCode.MINUS: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.MINUS) { if (text.charCodeAt(this.pos) == CharCode.MINUS) {
@ -572,8 +568,8 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.MINUS; return Token.MINUS;
}
case CharCode.DOT: case CharCode.DOT: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (isDecimalDigit(text.charCodeAt(this.pos))) { if (isDecimalDigit(text.charCodeAt(this.pos))) {
@ -590,8 +586,8 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.DOT; return Token.DOT;
}
case CharCode.SLASH: case CharCode.SLASH: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.SLASH) { // single-line if (text.charCodeAt(this.pos) == CharCode.SLASH) { // single-line
@ -634,7 +630,7 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.SLASH; return Token.SLASH;
}
case CharCode._0: case CharCode._0:
case CharCode._1: case CharCode._1:
case CharCode._2: case CharCode._2:
@ -644,20 +640,20 @@ export class Tokenizer extends DiagnosticEmitter {
case CharCode._6: case CharCode._6:
case CharCode._7: case CharCode._7:
case CharCode._8: case CharCode._8:
case CharCode._9: case CharCode._9: {
return this.testInteger() return this.testInteger()
? Token.INTEGERLITERAL // expects a call to readInteger ? Token.INTEGERLITERAL // expects a call to readInteger
: Token.FLOATLITERAL; // expects a call to readFloat : Token.FLOATLITERAL; // expects a call to readFloat
}
case CharCode.COLON: case CharCode.COLON: {
++this.pos; ++this.pos;
return Token.COLON; return Token.COLON;
}
case CharCode.SEMICOLON: case CharCode.SEMICOLON: {
++this.pos; ++this.pos;
return Token.SEMICOLON; return Token.SEMICOLON;
}
case CharCode.LESSTHAN: case CharCode.LESSTHAN: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.LESSTHAN) { if (text.charCodeAt(this.pos) == CharCode.LESSTHAN) {
@ -678,8 +674,8 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.LESSTHAN; return Token.LESSTHAN;
}
case CharCode.EQUALS: case CharCode.EQUALS: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.EQUALS) { if (text.charCodeAt(this.pos) == CharCode.EQUALS) {
@ -700,8 +696,8 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.EQUALS; return Token.EQUALS;
}
case CharCode.GREATERTHAN: case CharCode.GREATERTHAN: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.GREATERTHAN) { if (text.charCodeAt(this.pos) == CharCode.GREATERTHAN) {
@ -731,20 +727,20 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.GREATERTHAN; return Token.GREATERTHAN;
}
case CharCode.QUESTION: case CharCode.QUESTION: {
++this.pos; ++this.pos;
return Token.QUESTION; return Token.QUESTION;
}
case CharCode.OPENBRACKET: case CharCode.OPENBRACKET: {
++this.pos; ++this.pos;
return Token.OPENBRACKET; return Token.OPENBRACKET;
}
case CharCode.CLOSEBRACKET: case CharCode.CLOSEBRACKET: {
++this.pos; ++this.pos;
return Token.CLOSEBRACKET; return Token.CLOSEBRACKET;
}
case CharCode.CARET: case CharCode.CARET: {
++this.pos; ++this.pos;
if ( if (
maxTokenLength > 1 && this.pos < this.end && maxTokenLength > 1 && this.pos < this.end &&
@ -754,12 +750,12 @@ export class Tokenizer extends DiagnosticEmitter {
return Token.CARET_EQUALS; return Token.CARET_EQUALS;
} }
return Token.CARET; return Token.CARET;
}
case CharCode.OPENBRACE: case CharCode.OPENBRACE: {
++this.pos; ++this.pos;
return Token.OPENBRACE; return Token.OPENBRACE;
}
case CharCode.BAR: case CharCode.BAR: {
++this.pos; ++this.pos;
if (maxTokenLength > 1 && this.pos < this.end) { if (maxTokenLength > 1 && this.pos < this.end) {
if (text.charCodeAt(this.pos) == CharCode.BAR) { if (text.charCodeAt(this.pos) == CharCode.BAR) {
@ -772,20 +768,20 @@ export class Tokenizer extends DiagnosticEmitter {
} }
} }
return Token.BAR; return Token.BAR;
}
case CharCode.CLOSEBRACE: case CharCode.CLOSEBRACE: {
++this.pos; ++this.pos;
return Token.CLOSEBRACE; return Token.CLOSEBRACE;
}
case CharCode.TILDE: case CharCode.TILDE: {
++this.pos; ++this.pos;
return Token.TILDE; return Token.TILDE;
}
case CharCode.AT: case CharCode.AT: {
++this.pos; ++this.pos;
return Token.AT; return Token.AT;
}
default: default: {
if (isIdentifierStart(c)) { if (isIdentifierStart(c)) {
if (isKeywordCharacter(c)) { if (isKeywordCharacter(c)) {
var posBefore = this.pos; var posBefore = this.pos;
@ -821,6 +817,7 @@ export class Tokenizer extends DiagnosticEmitter {
return Token.INVALID; return Token.INVALID;
} }
} }
}
return Token.ENDOFFILE; return Token.ENDOFFILE;
} }
@ -857,10 +854,11 @@ export class Tokenizer extends DiagnosticEmitter {
var tokenPosBefore = this.tokenPos; var tokenPosBefore = this.tokenPos;
var maxCompoundLength = i32.MAX_VALUE; var maxCompoundLength = i32.MAX_VALUE;
switch (token) { switch (token) {
case Token.GREATERTHAN: // where parsing type arguments case Token.GREATERTHAN: { // where parsing type arguments
maxCompoundLength = 1; maxCompoundLength = 1;
break; break;
} }
}
this.token = this.unsafeNext(token == Token.IDENTIFIER, maxCompoundLength); this.token = this.unsafeNext(token == Token.IDENTIFIER, maxCompoundLength);
if (this.token == token) { if (this.token == token) {
this.nextToken = -1; this.nextToken = -1;
@ -884,17 +882,30 @@ export class Tokenizer extends DiagnosticEmitter {
// } while (true); // } while (true);
// } // }
mark(): void { mark(): State {
this.markedPos = this.pos; var state: State;
this.markedToken = this.token; if (reusableState) {
this.markedTokenPos = this.tokenPos; state = reusableState;
reusableState = null;
} else {
state = new State();
}
state.pos = this.pos;
state.token = this.token;
state.tokenPos = this.tokenPos;
return state;
} }
reset(): void { discard(state: State): void {
this.pos = this.markedPos; reusableState = state;
this.token = this.markedToken; }
this.tokenPos = this.markedTokenPos;
reset(state: State): void {
this.pos = state.pos;
this.token = state.token;
this.tokenPos = state.tokenPos;
this.nextToken = -1; this.nextToken = -1;
reusableState = state;
} }
range(start: i32 = -1, end: i32 = -1): Range { range(start: i32 = -1, end: i32 = -1): Range {
@ -967,34 +978,15 @@ export class Tokenizer extends DiagnosticEmitter {
var text = this.source.text; var text = this.source.text;
var c = text.charCodeAt(this.pos++); var c = text.charCodeAt(this.pos++);
switch (c) { switch (c) {
case CharCode._0: return "\0";
case CharCode._0: case CharCode.b: return "\b";
return "\0"; case CharCode.t: return "\t";
case CharCode.n: return "\n";
case CharCode.b: case CharCode.v: return "\v";
return "\b"; case CharCode.f: return "\f";
case CharCode.r: return "\r";
case CharCode.t: case CharCode.SINGLEQUOTE: return "'";
return "\t"; case CharCode.DOUBLEQUOTE: return "\"";
case CharCode.n:
return "\n";
case CharCode.v:
return "\v";
case CharCode.f:
return "\f";
case CharCode.r:
return "\r";
case CharCode.SINGLEQUOTE:
return "'";
case CharCode.DOUBLEQUOTE:
return "\"";
case CharCode.u: { case CharCode.u: {
if ( if (
this.pos < this.end && this.pos < this.end &&
@ -1005,8 +997,7 @@ export class Tokenizer extends DiagnosticEmitter {
} }
return this.readUnicodeEscape(); // \uDDDD return this.readUnicodeEscape(); // \uDDDD
} }
case CharCode.CARRIAGERETURN: {
case CharCode.CARRIAGERETURN:
if ( if (
this.pos < this.end && this.pos < this.end &&
text.charCodeAt(this.pos) == CharCode.LINEFEED text.charCodeAt(this.pos) == CharCode.LINEFEED
@ -1014,13 +1005,11 @@ export class Tokenizer extends DiagnosticEmitter {
++this.pos; ++this.pos;
} }
// fall through // fall through
}
case CharCode.LINEFEED: case CharCode.LINEFEED:
case CharCode.LINESEPARATOR: case CharCode.LINESEPARATOR:
case CharCode.PARAGRAPHSEPARATOR: case CharCode.PARAGRAPHSEPARATOR: return "";
return ""; default: return String.fromCharCode(c);
default:
return String.fromCharCode(c);
} }
} }
@ -1067,24 +1056,24 @@ export class Tokenizer extends DiagnosticEmitter {
// make sure each supported flag is unique // make sure each supported flag is unique
switch (c) { switch (c) {
case CharCode.g: {
case CharCode.g:
flags |= flags & 1 ? -1 : 1; flags |= flags & 1 ? -1 : 1;
break; break;
}
case CharCode.i: case CharCode.i: {
flags |= flags & 2 ? -1 : 2; flags |= flags & 2 ? -1 : 2;
break; break;
}
case CharCode.m: case CharCode.m: {
flags |= flags & 4 ? -1 : 4; flags |= flags & 4 ? -1 : 4;
break; break;
}
default: default: {
flags = -1; flags = -1;
break; break;
} }
} }
}
if (flags == -1) { if (flags == -1) {
this.error( this.error(
DiagnosticCode.Invalid_regular_expression_flags, DiagnosticCode.Invalid_regular_expression_flags,
@ -1103,8 +1092,7 @@ export class Tokenizer extends DiagnosticEmitter {
case CharCode.B: case CharCode.B:
case CharCode.b: case CharCode.b:
case CharCode.O: case CharCode.O:
case CharCode.o: case CharCode.o: return true;
return true;
} }
} }
var pos = this.pos; var pos = this.pos;
@ -1123,22 +1111,22 @@ export class Tokenizer extends DiagnosticEmitter {
var text = this.source.text; var text = this.source.text;
if (text.charCodeAt(this.pos) == CharCode._0 && this.pos + 2 < this.end) { if (text.charCodeAt(this.pos) == CharCode._0 && this.pos + 2 < this.end) {
switch (text.charCodeAt(this.pos + 1)) { switch (text.charCodeAt(this.pos + 1)) {
case CharCode.X: case CharCode.X:
case CharCode.x: case CharCode.x: {
this.pos += 2; this.pos += 2;
return this.readHexInteger(); return this.readHexInteger();
}
case CharCode.B: case CharCode.B:
case CharCode.b: case CharCode.b: {
this.pos += 2; this.pos += 2;
return this.readBinaryInteger(); return this.readBinaryInteger();
}
case CharCode.O: case CharCode.O:
case CharCode.o: case CharCode.o: {
this.pos += 2; this.pos += 2;
return this.readOctalInteger(); return this.readOctalInteger();
} }
}
if (isOctalDigit(text.charCodeAt(this.pos + 1))) { if (isOctalDigit(text.charCodeAt(this.pos + 1))) {
var start = this.pos; var start = this.pos;
++this.pos; ++this.pos;
@ -1387,3 +1375,16 @@ export class Tokenizer extends DiagnosticEmitter {
finish(): void { finish(): void {
} }
} }
/** Tokenizer state as returned by {@link Tokenizer#mark} and consumed by {@link Tokenizer#reset}. */
export class State {
/** Current position. */
pos: i32;
/** Current token. */
token: Token;
/** Current token's position. */
tokenPos: i32;
}
// Reusable state object to reduce allocations
var reusableState: State | null = null;

@ -1,6 +1,5 @@
import { import {
Class, Class
Function
} from "./program"; } from "./program";
import { import {
@ -74,7 +73,7 @@ export class Type {
/** Underlying class type, if a class type. */ /** Underlying class type, if a class type. */
classType: Class | null; classType: Class | null;
/** Underlying function type, if a function type. */ /** Underlying function type, if a function type. */
functionType: Function | null; functionType: Signature | null;
/** Respective nullable type, if non-nullable. */ /** Respective nullable type, if non-nullable. */
nullableType: Type | null = null; nullableType: Type | null = null;
/** Respective non-nullable type, if nullable. */ /** Respective non-nullable type, if nullable. */
@ -97,7 +96,7 @@ export class Type {
/** Computes the truncating mask in the target type. */ /** Computes the truncating mask in the target type. */
computeSmallIntegerMask(targetType: Type): u32 { computeSmallIntegerMask(targetType: Type): u32 {
return -1 >>> (targetType.size - this.size); return ~0 >>> (targetType.size - this.size);
} }
/** Tests if this type has the specified capabilities. */ /** Tests if this type has the specified capabilities. */
@ -121,7 +120,7 @@ export class Type {
} }
/** Composes a function type from this type and a function. */ /** Composes a function type from this type and a function. */
asFunction(functionType: Function): Type { asFunction(functionType: Signature): Type {
assert(this.kind == TypeKind.U32 && !this.functionType); assert(this.kind == TypeKind.U32 && !this.functionType);
var ret = new Type(this.kind, this.flags & ~TypeFlags.VALUE | TypeFlags.REFERENCE, this.size); var ret = new Type(this.kind, this.flags & ~TypeFlags.VALUE | TypeFlags.REFERENCE, this.size);
ret.functionType = functionType; ret.functionType = functionType;
@ -144,8 +143,8 @@ export class Type {
isAssignableTo(target: Type, signednessIsImportant: bool = false): bool { isAssignableTo(target: Type, signednessIsImportant: bool = false): bool {
var currentClass: Class | null; var currentClass: Class | null;
var targetClass: Class | null; var targetClass: Class | null;
var currentFunction: Function | null; var currentFunction: Signature | null;
var targetFunction: Function | null; var targetFunction: Signature | null;
if (this.isReference) { if (this.isReference) {
if (target.isReference) { if (target.isReference) {
if (currentClass = this.classType) { if (currentClass = this.classType) {
@ -198,20 +197,25 @@ export class Type {
case TypeKind.ISIZE: return "isize"; case TypeKind.ISIZE: return "isize";
case TypeKind.U8: return "u8"; case TypeKind.U8: return "u8";
case TypeKind.U16: return "u16"; case TypeKind.U16: return "u16";
case TypeKind.U32: return "u32"; case TypeKind.U32: {
return kindOnly || !this.functionType
? "u32"
: this.functionType.toString(true);
}
case TypeKind.U64: return "u64"; case TypeKind.U64: return "u64";
case TypeKind.USIZE: case TypeKind.USIZE: {
if (kindOnly) return "usize"; return kindOnly || !this.classType
return this.classType ? "usize"
? this.classType.toString() : this.classType.toString();
: this.functionType }
? this.functionType.toTypeString()
: "usize";
case TypeKind.BOOL: return "bool"; case TypeKind.BOOL: return "bool";
case TypeKind.F32: return "f32"; case TypeKind.F32: return "f32";
case TypeKind.F64: return "f64"; case TypeKind.F64: return "f64";
case TypeKind.VOID: return "void"; case TypeKind.VOID: return "void";
default: assert(false); return ""; default: {
assert(false);
return "";
}
} }
} }
@ -220,133 +224,70 @@ export class Type {
/** Converts this type to its respective native type. */ /** Converts this type to its respective native type. */
toNativeType(): NativeType { toNativeType(): NativeType {
switch (this.kind) { switch (this.kind) {
default: return NativeType.I32;
default:
return NativeType.I32;
case TypeKind.I64: case TypeKind.I64:
case TypeKind.U64: case TypeKind.U64: return NativeType.I64;
return NativeType.I64;
case TypeKind.ISIZE: case TypeKind.ISIZE:
case TypeKind.USIZE: case TypeKind.USIZE: return this.size == 64 ? NativeType.I64 : NativeType.I32;
return this.size == 64 ? NativeType.I64 : NativeType.I32; case TypeKind.F32: return NativeType.F32;
case TypeKind.F64: return NativeType.F64;
case TypeKind.F32: case TypeKind.VOID: return NativeType.None;
return NativeType.F32;
case TypeKind.F64:
return NativeType.F64;
case TypeKind.VOID:
return NativeType.None;
} }
} }
/** Converts this type to its native `0` value. */ /** Converts this type to its native `0` value. */
toNativeZero(module: Module): ExpressionRef { toNativeZero(module: Module): ExpressionRef {
switch (this.kind) { switch (this.kind) {
case TypeKind.VOID: assert(false);
case TypeKind.VOID: default: return module.createI32(0);
assert(false);
default:
return module.createI32(0);
case TypeKind.ISIZE: case TypeKind.ISIZE:
case TypeKind.USIZE: case TypeKind.USIZE: if (this.size != 64) return module.createI32(0);
if (this.size != 64) return module.createI32(0);
// fall-through
case TypeKind.I64: case TypeKind.I64:
case TypeKind.U64: case TypeKind.U64: return module.createI64(0);
return module.createI64(0); case TypeKind.F32: return module.createF32(0);
case TypeKind.F64: return module.createF64(0);
case TypeKind.F32:
return module.createF32(0);
case TypeKind.F64:
return module.createF64(0);
} }
} }
/** Converts this type to its native `1` value. */ /** Converts this type to its native `1` value. */
toNativeOne(module: Module): ExpressionRef { toNativeOne(module: Module): ExpressionRef {
switch (this.kind) { switch (this.kind) {
case TypeKind.VOID: assert(false);
case TypeKind.VOID: default: return module.createI32(1);
assert(false);
default:
return module.createI32(1);
case TypeKind.ISIZE: case TypeKind.ISIZE:
case TypeKind.USIZE: case TypeKind.USIZE: if (this.size != 64) return module.createI32(1);
if (this.size != 64) return module.createI32(1);
// fall-through
case TypeKind.I64: case TypeKind.I64:
case TypeKind.U64: case TypeKind.U64: return module.createI64(1);
return module.createI64(1); case TypeKind.F32: return module.createF32(1);
case TypeKind.F64: return module.createF64(1);
case TypeKind.F32:
return module.createF32(1);
case TypeKind.F64:
return module.createF64(1);
} }
} }
/** Converts this type to its native `-1` value. */ /** Converts this type to its native `-1` value. */
toNativeNegOne(module: Module): ExpressionRef { toNativeNegOne(module: Module): ExpressionRef {
switch (this.kind) { switch (this.kind) {
case TypeKind.VOID: assert(false);
case TypeKind.VOID: default: return module.createI32(-1);
assert(false);
default:
return module.createI32(-1);
case TypeKind.ISIZE: case TypeKind.ISIZE:
case TypeKind.USIZE: case TypeKind.USIZE: if (this.size != 64) return module.createI32(-1);
if (this.size != 64) return module.createI32(-1);
// fall-through
case TypeKind.I64: case TypeKind.I64:
case TypeKind.U64: case TypeKind.U64: return module.createI64(-1, -1);
return module.createI64(-1, -1); case TypeKind.F32: return module.createF32(-1);
case TypeKind.F64: return module.createF64(-1);
case TypeKind.F32:
return module.createF32(-1);
case TypeKind.F64:
return module.createF64(-1);
} }
} }
/** Converts this type to its signature string. */ /** Converts this type to its signature string. */
toSignatureString(): string { toSignatureString(): string {
switch (this.kind) { switch (this.kind) {
default: return "i";
default:
return "i";
case TypeKind.I64: case TypeKind.I64:
case TypeKind.U64: case TypeKind.U64: return "I";
return "I";
case TypeKind.ISIZE: case TypeKind.ISIZE:
case TypeKind.USIZE: case TypeKind.USIZE: return this.size == 64 ? "I" : "i";
return this.size == 64 ? "I" : "i"; case TypeKind.F32: return "f";
case TypeKind.F64: return "F";
case TypeKind.F32: case TypeKind.VOID: return "v";
return "f";
case TypeKind.F64:
return "F";
case TypeKind.VOID:
return "v";
} }
} }
@ -495,3 +436,149 @@ export function typesToString(types: Type[]): string {
} }
return sb.join(", "); return sb.join(", ");
} }
/** Represents a fully resolved function signature. */
export class Signature {
/** Parameter types, if any, excluding `this`. */
parameterTypes: Type[];
/** Parameter names, if known, excluding `this`. */
parameterNames: string[] | null;
/** Number of required parameters. Other parameters are considered optional. */
requiredParameters: i32;
/** Return type. */
returnType: Type;
/** This type, if an instance signature. */
thisType: Type | null;
/** Whether the last parameter is a rest parameter. */
hasRest: bool;
constructor(
parameterTypes: Type[] | null = null,
returnType: Type | null = null,
thisType: Type | null = null
) {
this.parameterTypes = parameterTypes ? parameterTypes : [];
this.parameterNames = null;
this.requiredParameters = 0;
this.returnType = returnType ? returnType : Type.void;
this.thisType = thisType;
this.hasRest = false;
}
/** Gets the known or, alternatively, generic parameter name at the specified index. */
getParameterName(index: i32): string {
return this.parameterNames && this.parameterNames.length > index
? this.parameterNames[index]
: getGenericParameterName(index);
}
/** Tests if a value of this function type is assignable to a target of the specified function type. */
isAssignableTo(target: Signature): bool {
// TODO: maybe cache results?
// check `this` type
var thisThisType = this.thisType;
var targetThisType = target.thisType;
if (thisThisType) {
if (!(targetThisType && thisThisType.isAssignableTo(targetThisType))) {
return false;
}
} else if (targetThisType) {
return false;
}
// check rest parameter
if (this.hasRest != target.hasRest) {
return false; // TODO
}
// check parameter types
var thisParameterTypes = this.parameterTypes;
var targetParameterTypes = target.parameterTypes;
var numParameters = thisParameterTypes.length;
if (numParameters != targetParameterTypes.length) {
return false;
}
for (let i = 0; i < numParameters; ++i) {
let thisParameterType = thisParameterTypes[i];
let targetParameterType = targetParameterTypes[i];
if (!thisParameterType.isAssignableTo(targetParameterType)) {
return false;
}
}
// check return type
return this.returnType.isAssignableTo(target.returnType);
}
/** Converts this signature to a function type string. */
toSignatureString(): string {
var sb = [];
var thisType = this.thisType;
if (thisType) {
sb.push(thisType.toSignatureString());
}
var parameterTypes = this.parameterTypes;
for (let i = 0, k = parameterTypes.length; i < k; ++i) {
sb.push(parameterTypes[i].toSignatureString());
}
sb.push(this.returnType.toSignatureString());
return sb.join("");
}
/** Converts this signature to a string. */
toString(includeThis: bool = false): string {
var sb = new Array<string>();
sb.push("(");
var index = 0;
var thisType = this.thisType;
if (thisType) {
if (includeThis) {
sb.push("this: ");
sb.push(thisType.toString());
index = 1;
}
}
var parameters = this.parameterTypes;
var numParameters = parameters.length;
if (numParameters) {
let names = this.parameterNames;
let numNames = names ? names.length : 0;
let optionalStart = this.requiredParameters;
let restIndex = this.hasRest ? numParameters - 1 : -1;
for (let i = 0; i < numParameters; ++i, ++index) {
if (index) sb.push(", ");
if (i == restIndex) sb.push("...");
if (i < numNames) {
sb.push((<string[]>names)[i]);
} else {
sb.push(getGenericParameterName(i));
}
if (i >= optionalStart && i != restIndex) {
sb.push("?: ");
} else {
sb.push(": ");
}
sb.push(parameters[i].toString());
}
}
sb.push(") => ");
sb.push(this.returnType.toString());
return sb.join("");
}
}
// helpers
// Cached generic parameter names used where names are unknown.
var cachedGenericParameterNames: string[] | null = null;
/** Gets the cached generic parameter name for the specified index. */
export function getGenericParameterName(index: i32): string {
if (!cachedGenericParameterNames) cachedGenericParameterNames = [];
for (var i = cachedGenericParameterNames.length; i < index; ++i) {
cachedGenericParameterNames.push("arg$" + i.toString(10));
}
return cachedGenericParameterNames[index];
}

@ -139,11 +139,13 @@ export function isLineBreak(c: CharCode): bool {
case CharCode.LINEFEED: case CharCode.LINEFEED:
case CharCode.CARRIAGERETURN: case CharCode.CARRIAGERETURN:
case CharCode.LINESEPARATOR: case CharCode.LINESEPARATOR:
case CharCode.PARAGRAPHSEPARATOR: case CharCode.PARAGRAPHSEPARATOR: {
return true; return true;
default: }
default: {
return false; return false;
} }
}
} }
/** Tests if the specified character code is some sort of white space. */ /** Tests if the specified character code is some sort of white space. */
@ -159,11 +161,13 @@ export function isWhiteSpace(c: i32): bool {
case CharCode.NARROWNOBREAKSPACE: case CharCode.NARROWNOBREAKSPACE:
case CharCode.MATHEMATICALSPACE: case CharCode.MATHEMATICALSPACE:
case CharCode.IDEOGRAPHICSPACE: case CharCode.IDEOGRAPHICSPACE:
case CharCode.BYTEORDERMARK: case CharCode.BYTEORDERMARK: {
return true; return true;
default: }
default: {
return c >= CharCode.ENQUAD && c <= CharCode.ZEROWIDTHSPACE; return c >= CharCode.ENQUAD && c <= CharCode.ZEROWIDTHSPACE;
} }
}
} }
/** Tests if the specified character code is a decimal digit. */ /** Tests if the specified character code is a decimal digit. */

@ -5,16 +5,14 @@
* sure that there are no more references to cleared memory afterwards. Always aligns to 8 bytes. * sure that there are no more references to cleared memory afterwards. Always aligns to 8 bytes.
*/ */
const AL_BITS: usize = 3; import { MASK as AL_MASK } from "./common/alignment";
const AL_SIZE: usize = 1 << AL_BITS;
const AL_MASK: usize = AL_SIZE - 1;
var OFFSET: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK; var offset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;
@global @global
export function allocate_memory(size: usize): usize { export function allocate_memory(size: usize): usize {
if (!size) return 0; if (!size) return 0;
var ptr = OFFSET; var ptr = offset;
var newPtr = (ptr + size + AL_MASK) & ~AL_MASK; var newPtr = (ptr + size + AL_MASK) & ~AL_MASK;
var pagesBefore = current_memory(); var pagesBefore = current_memory();
if (newPtr > <usize>pagesBefore << 16) { if (newPtr > <usize>pagesBefore << 16) {
@ -26,7 +24,7 @@ export function allocate_memory(size: usize): usize {
} }
} }
} }
OFFSET = newPtr; offset = newPtr;
return ptr; return ptr;
} }
@ -37,5 +35,5 @@ export function free_memory(ptr: usize): void {
@global @global
export function reset_memory(): void { export function reset_memory(): void {
OFFSET = (HEAP_BASE + AL_MASK) & ~AL_MASK; offset = (HEAP_BASE + AL_MASK) & ~AL_MASK;
} }

@ -61,7 +61,7 @@ const MIN_ALLOC: usize = 1 << MIN_ALLOC_LOG2;
* heaps will have multiple allocations, so the real maximum allocation limit * heaps will have multiple allocations, so the real maximum allocation limit
* is at most 1gb. * is at most 1gb.
*/ */
const MAX_ALLOC_LOG2: usize = 31; const MAX_ALLOC_LOG2: usize = 30; // 31;
const MAX_ALLOC: usize = 1 << MAX_ALLOC_LOG2; const MAX_ALLOC: usize = 1 << MAX_ALLOC_LOG2;
/* /*
@ -338,7 +338,7 @@ function lower_bucket_limit(bucket: usize): u32 {
} }
@global @global
function allocate_memory(request: usize): usize { export function allocate_memory(request: usize): usize {
var original_bucket: usize, bucket: usize; var original_bucket: usize, bucket: usize;
/* /*
@ -475,7 +475,7 @@ function allocate_memory(request: usize): usize {
} }
@global @global
function free_memory(ptr: usize): void { export function free_memory(ptr: usize): void {
var bucket: usize, i: usize; var bucket: usize, i: usize;
/* /*
@ -539,3 +539,8 @@ function free_memory(ptr: usize): void {
*/ */
list_push(buckets$get(bucket), changetype<List>(ptr_for_node(i, bucket))); list_push(buckets$get(bucket), changetype<List>(ptr_for_node(i, bucket)));
} }
@global
export function reset_memory(): void {
unreachable();
}

@ -0,0 +1,8 @@
/** Number of alignment bits. */
export const BITS: u32 = 3;
/** Number of possible alignment values. */
export const SIZE: usize = 1 << <usize>BITS;
/** Mask to obtain just the alignment bits. */
export const MASK: usize = SIZE - 1;

@ -20,4 +20,6 @@ export function free_memory(ptr: usize): void {
} }
@global @global
export { reset_memory } from "./none"; export function reset_memory(): void {
unreachable();
}

@ -1,15 +0,0 @@
/**
* @file Memory Allocator Stub
*/
export function allocate_memory(size: usize): usize {
throw new Error("not supported");
}
export function free_memory(ptr: usize): void {
throw new Error("not supported");
}
export function reset_memory(): void {
throw new Error("not supported");
}

@ -19,4 +19,6 @@ export function free_memory(ptr: usize): void {
} }
@global @global
export { reset_memory } from "./none"; export function reset_memory(): void {
unreachable();
}

@ -13,9 +13,11 @@
// └───────────────────────────────────────────────┴─────────╨─────┘ // └───────────────────────────────────────────────┴─────────╨─────┘
// FL: first level, SL: second level, AL: alignment, SB: small block // FL: first level, SL: second level, AL: alignment, SB: small block
const AL_BITS: u32 = 3; // always align to 8 bytes import {
const AL_SIZE: usize = 1 << <usize>AL_BITS; BITS as AL_BITS,
const AL_MASK: usize = AL_SIZE - 1; SIZE as AL_SIZE,
MASK as AL_MASK
} from "./common/alignment";
const SL_BITS: u32 = 5; const SL_BITS: u32 = 5;
const SL_SIZE: usize = 1 << <usize>SL_BITS; const SL_SIZE: usize = 1 << <usize>SL_BITS;
@ -32,7 +34,7 @@ const FL_BITS: u32 = (sizeof<usize>() == sizeof<u32>()
// 3 2 1 // 3 2 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits
// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┤ // ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┤
// │ size │L│F│ ◄─┐ // │ size │L│F│ ◄─┐ info
// ╞═══════════════════════════════════════════════════════════╧═╧═╡ │ ┐ // ╞═══════════════════════════════════════════════════════════╧═╧═╡ │ ┐
// │ if free: ◄ prev │ ◄─┤ usize // │ if free: ◄ prev │ ◄─┤ usize
// ├───────────────────────────────────────────────────────────────┤ │ // ├───────────────────────────────────────────────────────────────┤ │
@ -495,4 +497,7 @@ export function free_memory(data: usize): void {
} }
} }
export { reset_memory } from "./none"; @global
export function reset_memory(): void {
unreachable();
}

@ -43,7 +43,7 @@ function copy_memory(dest: usize, src: usize, n: usize): void {
if (n >= 32) { if (n >= 32) {
switch (dest & 3) { switch (dest & 3) {
// known to be != 0 // known to be != 0
case 1: case 1: {
w = load<u32>(src); w = load<u32>(src);
store<u8>(dest++, load<u8>(src++)); store<u8>(dest++, load<u8>(src++));
store<u8>(dest++, load<u8>(src++)); store<u8>(dest++, load<u8>(src++));
@ -61,7 +61,8 @@ function copy_memory(dest: usize, src: usize, n: usize): void {
src += 16; dest += 16; n -= 16; src += 16; dest += 16; n -= 16;
} }
break; break;
case 2: }
case 2: {
w = load<u32>(src); w = load<u32>(src);
store<u8>(dest++, load<u8>(src++)); store<u8>(dest++, load<u8>(src++));
store<u8>(dest++, load<u8>(src++)); store<u8>(dest++, load<u8>(src++));
@ -78,7 +79,8 @@ function copy_memory(dest: usize, src: usize, n: usize): void {
src += 16; dest += 16; n -= 16; src += 16; dest += 16; n -= 16;
} }
break; break;
case 3: }
case 3: {
w = load<u32>(src); w = load<u32>(src);
store<u8>(dest++, load<u8>(src++)); store<u8>(dest++, load<u8>(src++));
n -= 1; n -= 1;
@ -96,6 +98,7 @@ function copy_memory(dest: usize, src: usize, n: usize): void {
break; break;
} }
} }
}
// copy remaining bytes one by one // copy remaining bytes one by one
if (n & 16) { if (n & 16) {

@ -328,10 +328,10 @@ function isWhiteSpaceOrLineTerminator(c: u16): bool {
case 12: // <FF> case 12: // <FF>
case 32: // <SP> case 32: // <SP>
case 160: // <NBSP> case 160: // <NBSP>
case 65279: // <ZWNBSP> case 65279: { // <ZWNBSP>
return true; return true;
default: }
return false; default: return false;
} }
} }
@ -405,28 +405,28 @@ function parse<T>(str: String, radix: i32 = 0): T {
if (!radix) { if (!radix) {
if (code == CharCode._0 && len > 2) { if (code == CharCode._0 && len > 2) {
switch (<i32>load<u16>(ptr + 2, HEAD)) { switch (<i32>load<u16>(ptr + 2, HEAD)) {
case CharCode.B: case CharCode.B:
case CharCode.b: case CharCode.b: {
ptr += 4; len -= 2; ptr += 4; len -= 2;
radix = 2; radix = 2;
break; break;
}
case CharCode.O: case CharCode.O:
case CharCode.o: case CharCode.o: {
ptr += 4; len -= 2; ptr += 4; len -= 2;
radix = 8; radix = 8;
break; break;
}
case CharCode.X: case CharCode.X:
case CharCode.x: case CharCode.x: {
ptr += 4; len -= 2; ptr += 4; len -= 2;
radix = 16; radix = 16;
break; break;
}
default: default: {
radix = 10; radix = 10;
} }
}
} else radix = 10; } else radix = 10;
} else if (radix < 2 || radix > 36) { } else if (radix < 2 || radix > 36) {
return <T>NaN; return <T>NaN;

@ -2,7 +2,7 @@
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $v (func)) (type $v (func))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4)) (global $HEAP_BASE i32 (i32.const 4))
(memory $0 1) (memory $0 1)
(export "allocate_memory" (func "$(lib)/allocator/arena/allocate_memory")) (export "allocate_memory" (func "$(lib)/allocator/arena/allocate_memory"))
@ -15,83 +15,83 @@
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
;;@ (lib)/allocator/arena.ts:16:2 ;;@ (lib)/allocator/arena.ts:14:2
(if (if
;;@ (lib)/allocator/arena.ts:16:6 ;;@ (lib)/allocator/arena.ts:14:6
(i32.eqz (i32.eqz
;;@ (lib)/allocator/arena.ts:16:7 ;;@ (lib)/allocator/arena.ts:14:7
(get_local $0) (get_local $0)
) )
;;@ (lib)/allocator/arena.ts:16:20 ;;@ (lib)/allocator/arena.ts:14:20
(return (return
(i32.const 0) (i32.const 0)
) )
) )
;;@ (lib)/allocator/arena.ts:20:2
(if
;;@ (lib)/allocator/arena.ts:20:6
(i32.gt_u
;;@ (lib)/allocator/arena.ts:18:2 ;;@ (lib)/allocator/arena.ts:18:2
(if
;;@ (lib)/allocator/arena.ts:18:6
(i32.gt_u
;;@ (lib)/allocator/arena.ts:16:2
(tee_local $2 (tee_local $2
;;@ (lib)/allocator/arena.ts:18:15 ;;@ (lib)/allocator/arena.ts:16:15
(i32.and (i32.and
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:18:16 ;;@ (lib)/allocator/arena.ts:16:16
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:17:2 ;;@ (lib)/allocator/arena.ts:15:2
(tee_local $1 (tee_local $1
;;@ (lib)/allocator/arena.ts:17:12 ;;@ (lib)/allocator/arena.ts:15:12
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
;;@ (lib)/allocator/arena.ts:18:22 ;;@ (lib)/allocator/arena.ts:16:22
(get_local $0) (get_local $0)
) )
;;@ (lib)/allocator/arena.ts:18:29 ;;@ (lib)/allocator/arena.ts:16:29
(i32.const 7) (i32.const 7)
) )
(i32.const -8) (i32.const -8)
) )
) )
;;@ (lib)/allocator/arena.ts:20:15 ;;@ (lib)/allocator/arena.ts:18:15
(i32.shl (i32.shl
;;@ (lib)/allocator/arena.ts:19:2 ;;@ (lib)/allocator/arena.ts:17:2
(tee_local $0 (tee_local $0
;;@ (lib)/allocator/arena.ts:19:20 ;;@ (lib)/allocator/arena.ts:17:20
(current_memory) (current_memory)
) )
;;@ (lib)/allocator/arena.ts:20:37 ;;@ (lib)/allocator/arena.ts:18:37
(i32.const 16) (i32.const 16)
) )
) )
;;@ (lib)/allocator/arena.ts:23:4 ;;@ (lib)/allocator/arena.ts:21:4
(if (if
;;@ (lib)/allocator/arena.ts:23:8 ;;@ (lib)/allocator/arena.ts:21:8
(i32.lt_s (i32.lt_s
(grow_memory (grow_memory
;;@ (lib)/allocator/arena.ts:22:22 ;;@ (lib)/allocator/arena.ts:20:22
(select (select
;;@ (lib)/allocator/arena.ts:22:26 ;;@ (lib)/allocator/arena.ts:20:26
(get_local $0) (get_local $0)
(tee_local $4 (tee_local $4
;;@ (lib)/allocator/arena.ts:21:4 ;;@ (lib)/allocator/arena.ts:19:4
(tee_local $3 (tee_local $3
;;@ (lib)/allocator/arena.ts:21:22 ;;@ (lib)/allocator/arena.ts:19:22
(i32.shr_u (i32.shr_u
(i32.and (i32.and
;;@ (lib)/allocator/arena.ts:21:23 ;;@ (lib)/allocator/arena.ts:19:23
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:21:24 ;;@ (lib)/allocator/arena.ts:19:24
(i32.sub (i32.sub
(get_local $2) (get_local $2)
;;@ (lib)/allocator/arena.ts:21:33 ;;@ (lib)/allocator/arena.ts:19:33
(get_local $1) (get_local $1)
) )
;;@ (lib)/allocator/arena.ts:21:39 ;;@ (lib)/allocator/arena.ts:19:39
(i32.const 65535) (i32.const 65535)
) )
(i32.const -65536) (i32.const -65536)
) )
;;@ (lib)/allocator/arena.ts:21:62 ;;@ (lib)/allocator/arena.ts:19:62
(i32.const 16) (i32.const 16)
) )
) )
@ -102,46 +102,46 @@
) )
) )
) )
;;@ (lib)/allocator/arena.ts:23:35 ;;@ (lib)/allocator/arena.ts:21:35
(i32.const 0) (i32.const 0)
) )
;;@ (lib)/allocator/arena.ts:24:6 ;;@ (lib)/allocator/arena.ts:22:6
(if (if
;;@ (lib)/allocator/arena.ts:24:10 ;;@ (lib)/allocator/arena.ts:22:10
(i32.lt_s (i32.lt_s
(grow_memory (grow_memory
;;@ (lib)/allocator/arena.ts:24:22 ;;@ (lib)/allocator/arena.ts:22:22
(get_local $3) (get_local $3)
) )
;;@ (lib)/allocator/arena.ts:24:37 ;;@ (lib)/allocator/arena.ts:22:37
(i32.const 0) (i32.const 0)
) )
;;@ (lib)/allocator/arena.ts:25:8 ;;@ (lib)/allocator/arena.ts:23:8
(unreachable) (unreachable)
) )
) )
) )
;;@ (lib)/allocator/arena.ts:29:2 ;;@ (lib)/allocator/arena.ts:27:2
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
;;@ (lib)/allocator/arena.ts:29:11 ;;@ (lib)/allocator/arena.ts:27:11
(get_local $2) (get_local $2)
) )
;;@ (lib)/allocator/arena.ts:30:9 ;;@ (lib)/allocator/arena.ts:28:9
(get_local $1) (get_local $1)
) )
(func "$(lib)/allocator/arena/free_memory" (; 1 ;) (type $iv) (param $0 i32) (func "$(lib)/allocator/arena/free_memory" (; 1 ;) (type $iv) (param $0 i32)
;;@ (lib)/allocator/arena.ts:34:46 ;;@ (lib)/allocator/arena.ts:32:46
(nop) (nop)
) )
(func "$(lib)/allocator/arena/reset_memory" (; 2 ;) (type $v) (func "$(lib)/allocator/arena/reset_memory" (; 2 ;) (type $v)
;;@ (lib)/allocator/arena.ts:40:2 ;;@ (lib)/allocator/arena.ts:38:2
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
;;@ (lib)/allocator/arena.ts:40:11 ;;@ (lib)/allocator/arena.ts:38:11
(i32.and (i32.and
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:40:12 ;;@ (lib)/allocator/arena.ts:38:12
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
;;@ (lib)/allocator/arena.ts:40:24 ;;@ (lib)/allocator/arena.ts:38:24
(i32.const 7) (i32.const 7)
) )
(i32.const -8) (i32.const -8)

@ -3,10 +3,10 @@
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $v (func)) (type $v (func))
(global "$(lib)/allocator/arena/AL_BITS" i32 (i32.const 3)) (global "$(lib)/allocator/common/alignment/BITS" i32 (i32.const 3))
(global "$(lib)/allocator/arena/AL_SIZE" i32 (i32.const 8)) (global "$(lib)/allocator/common/alignment/SIZE" i32 (i32.const 8))
(global "$(lib)/allocator/arena/AL_MASK" i32 (i32.const 7)) (global "$(lib)/allocator/common/alignment/MASK" i32 (i32.const 7))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4)) (global $HEAP_BASE i32 (i32.const 4))
(memory $0 1) (memory $0 1)
(export "allocate_memory" (func "$(lib)/allocator/arena/allocate_memory")) (export "allocate_memory" (func "$(lib)/allocator/arena/allocate_memory"))
@ -22,101 +22,101 @@
(local $5 i32) (local $5 i32)
(local $6 i32) (local $6 i32)
(local $7 i32) (local $7 i32)
;;@ (lib)/allocator/arena.ts:16:2 ;;@ (lib)/allocator/arena.ts:14:2
(if (if
;;@ (lib)/allocator/arena.ts:16:6 ;;@ (lib)/allocator/arena.ts:14:6
(i32.eqz (i32.eqz
;;@ (lib)/allocator/arena.ts:16:7 ;;@ (lib)/allocator/arena.ts:14:7
(get_local $0) (get_local $0)
) )
;;@ (lib)/allocator/arena.ts:16:20 ;;@ (lib)/allocator/arena.ts:14:20
(return (return
(i32.const 0) (i32.const 0)
) )
) )
;;@ (lib)/allocator/arena.ts:17:2 ;;@ (lib)/allocator/arena.ts:15:2
(set_local $1 (set_local $1
;;@ (lib)/allocator/arena.ts:17:12 ;;@ (lib)/allocator/arena.ts:15:12
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
;;@ (lib)/allocator/arena.ts:18:2 ;;@ (lib)/allocator/arena.ts:16:2
(set_local $2 (set_local $2
;;@ (lib)/allocator/arena.ts:18:15 ;;@ (lib)/allocator/arena.ts:16:15
(i32.and (i32.and
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:18:16 ;;@ (lib)/allocator/arena.ts:16:16
(i32.add (i32.add
(get_local $1) (get_local $1)
;;@ (lib)/allocator/arena.ts:18:22 ;;@ (lib)/allocator/arena.ts:16:22
(get_local $0) (get_local $0)
) )
;;@ (lib)/allocator/arena.ts:18:29 ;;@ (lib)/allocator/arena.ts:16:29
(i32.const 7) (i32.const 7)
) )
;;@ (lib)/allocator/arena.ts:18:40 ;;@ (lib)/allocator/arena.ts:16:40
(i32.xor (i32.xor
;;@ (lib)/allocator/arena.ts:18:41 ;;@ (lib)/allocator/arena.ts:16:41
(i32.const 7) (i32.const 7)
(i32.const -1) (i32.const -1)
) )
) )
) )
;;@ (lib)/allocator/arena.ts:19:2 ;;@ (lib)/allocator/arena.ts:17:2
(set_local $3 (set_local $3
;;@ (lib)/allocator/arena.ts:19:20 ;;@ (lib)/allocator/arena.ts:17:20
(current_memory) (current_memory)
) )
;;@ (lib)/allocator/arena.ts:20:2 ;;@ (lib)/allocator/arena.ts:18:2
(if (if
;;@ (lib)/allocator/arena.ts:20:6 ;;@ (lib)/allocator/arena.ts:18:6
(i32.gt_u (i32.gt_u
(get_local $2) (get_local $2)
;;@ (lib)/allocator/arena.ts:20:15 ;;@ (lib)/allocator/arena.ts:18:15
(i32.shl (i32.shl
(get_local $3) (get_local $3)
;;@ (lib)/allocator/arena.ts:20:37 ;;@ (lib)/allocator/arena.ts:18:37
(i32.const 16) (i32.const 16)
) )
) )
;;@ (lib)/allocator/arena.ts:20:41 ;;@ (lib)/allocator/arena.ts:18:41
(block (block
;;@ (lib)/allocator/arena.ts:21:4 ;;@ (lib)/allocator/arena.ts:19:4
(set_local $4 (set_local $4
;;@ (lib)/allocator/arena.ts:21:22 ;;@ (lib)/allocator/arena.ts:19:22
(i32.shr_u (i32.shr_u
(i32.and (i32.and
;;@ (lib)/allocator/arena.ts:21:23 ;;@ (lib)/allocator/arena.ts:19:23
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:21:24 ;;@ (lib)/allocator/arena.ts:19:24
(i32.sub (i32.sub
(get_local $2) (get_local $2)
;;@ (lib)/allocator/arena.ts:21:33 ;;@ (lib)/allocator/arena.ts:19:33
(get_local $1) (get_local $1)
) )
;;@ (lib)/allocator/arena.ts:21:39 ;;@ (lib)/allocator/arena.ts:19:39
(i32.const 65535) (i32.const 65535)
) )
;;@ (lib)/allocator/arena.ts:21:49 ;;@ (lib)/allocator/arena.ts:19:49
(i32.xor (i32.xor
;;@ (lib)/allocator/arena.ts:21:50 ;;@ (lib)/allocator/arena.ts:19:50
(i32.const 65535) (i32.const 65535)
(i32.const -1) (i32.const -1)
) )
) )
;;@ (lib)/allocator/arena.ts:21:62 ;;@ (lib)/allocator/arena.ts:19:62
(i32.const 16) (i32.const 16)
) )
) )
;;@ (lib)/allocator/arena.ts:22:4 ;;@ (lib)/allocator/arena.ts:20:4
(set_local $7 (set_local $7
;;@ (lib)/allocator/arena.ts:22:22 ;;@ (lib)/allocator/arena.ts:20:22
(select (select
(tee_local $5 (tee_local $5
;;@ (lib)/allocator/arena.ts:22:26 ;;@ (lib)/allocator/arena.ts:20:26
(get_local $3) (get_local $3)
) )
(tee_local $6 (tee_local $6
;;@ (lib)/allocator/arena.ts:22:39 ;;@ (lib)/allocator/arena.ts:20:39
(get_local $4) (get_local $4)
) )
(i32.gt_s (i32.gt_s
@ -125,40 +125,40 @@
) )
) )
) )
;;@ (lib)/allocator/arena.ts:23:4 ;;@ (lib)/allocator/arena.ts:21:4
(if (if
;;@ (lib)/allocator/arena.ts:23:8 ;;@ (lib)/allocator/arena.ts:21:8
(i32.lt_s (i32.lt_s
(grow_memory (grow_memory
;;@ (lib)/allocator/arena.ts:23:20 ;;@ (lib)/allocator/arena.ts:21:20
(get_local $7) (get_local $7)
) )
;;@ (lib)/allocator/arena.ts:23:35 ;;@ (lib)/allocator/arena.ts:21:35
(i32.const 0) (i32.const 0)
) )
;;@ (lib)/allocator/arena.ts:24:6 ;;@ (lib)/allocator/arena.ts:22:6
(if (if
;;@ (lib)/allocator/arena.ts:24:10 ;;@ (lib)/allocator/arena.ts:22:10
(i32.lt_s (i32.lt_s
(grow_memory (grow_memory
;;@ (lib)/allocator/arena.ts:24:22 ;;@ (lib)/allocator/arena.ts:22:22
(get_local $4) (get_local $4)
) )
;;@ (lib)/allocator/arena.ts:24:37 ;;@ (lib)/allocator/arena.ts:22:37
(i32.const 0) (i32.const 0)
) )
;;@ (lib)/allocator/arena.ts:25:8 ;;@ (lib)/allocator/arena.ts:23:8
(unreachable) (unreachable)
) )
) )
) )
) )
;;@ (lib)/allocator/arena.ts:29:2 ;;@ (lib)/allocator/arena.ts:27:2
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
;;@ (lib)/allocator/arena.ts:29:11 ;;@ (lib)/allocator/arena.ts:27:11
(get_local $2) (get_local $2)
) )
;;@ (lib)/allocator/arena.ts:30:9 ;;@ (lib)/allocator/arena.ts:28:9
(return (return
(get_local $1) (get_local $1)
) )
@ -166,19 +166,19 @@
(func "$(lib)/allocator/arena/free_memory" (; 1 ;) (type $iv) (param $0 i32) (func "$(lib)/allocator/arena/free_memory" (; 1 ;) (type $iv) (param $0 i32)
) )
(func "$(lib)/allocator/arena/reset_memory" (; 2 ;) (type $v) (func "$(lib)/allocator/arena/reset_memory" (; 2 ;) (type $v)
;;@ (lib)/allocator/arena.ts:40:2 ;;@ (lib)/allocator/arena.ts:38:2
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
;;@ (lib)/allocator/arena.ts:40:11 ;;@ (lib)/allocator/arena.ts:38:11
(i32.and (i32.and
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:40:12 ;;@ (lib)/allocator/arena.ts:38:12
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
;;@ (lib)/allocator/arena.ts:40:24 ;;@ (lib)/allocator/arena.ts:38:24
(i32.const 7) (i32.const 7)
) )
;;@ (lib)/allocator/arena.ts:40:35 ;;@ (lib)/allocator/arena.ts:38:35
(i32.xor (i32.xor
;;@ (lib)/allocator/arena.ts:40:36 ;;@ (lib)/allocator/arena.ts:38:36
(i32.const 7) (i32.const 7)
(i32.const -1) (i32.const -1)
) )
@ -186,18 +186,18 @@
) )
) )
(func $start (; 3 ;) (type $v) (func $start (; 3 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
;;@ (lib)/allocator/arena.ts:12:20 ;;@ (lib)/allocator/arena.ts:10:20
(i32.and (i32.and
(i32.add (i32.add
;;@ (lib)/allocator/arena.ts:12:21 ;;@ (lib)/allocator/arena.ts:10:21
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
;;@ (lib)/allocator/arena.ts:12:33 ;;@ (lib)/allocator/arena.ts:10:33
(i32.const 7) (i32.const 7)
) )
;;@ (lib)/allocator/arena.ts:12:44 ;;@ (lib)/allocator/arena.ts:10:44
(i32.xor (i32.xor
;;@ (lib)/allocator/arena.ts:12:45 ;;@ (lib)/allocator/arena.ts:10:45
(i32.const 7) (i32.const 7)
(i32.const -1) (i32.const -1)
) )

@ -146,7 +146,7 @@
;;@ (lib)/allocator/buddy.ts:278:2 ;;@ (lib)/allocator/buddy.ts:278:2
(set_local $1 (set_local $1
;;@ (lib)/allocator/buddy.ts:278:15 ;;@ (lib)/allocator/buddy.ts:278:15
(i32.const 27) (i32.const 26)
) )
;;@ (lib)/allocator/buddy.ts:279:2 ;;@ (lib)/allocator/buddy.ts:279:2
(set_local $2 (set_local $2
@ -199,7 +199,7 @@
;;@ (lib)/allocator/buddy.ts:251:30 ;;@ (lib)/allocator/buddy.ts:251:30
(i32.sub (i32.sub
;;@ (lib)/allocator/buddy.ts:251:31 ;;@ (lib)/allocator/buddy.ts:251:31
(i32.const 31) (i32.const 30)
;;@ (lib)/allocator/buddy.ts:251:48 ;;@ (lib)/allocator/buddy.ts:251:48
(get_local $1) (get_local $1)
) )
@ -316,7 +316,7 @@
;;@ (lib)/allocator/buddy.ts:242:52 ;;@ (lib)/allocator/buddy.ts:242:52
(i32.sub (i32.sub
;;@ (lib)/allocator/buddy.ts:242:53 ;;@ (lib)/allocator/buddy.ts:242:53
(i32.const 31) (i32.const 30)
;;@ (lib)/allocator/buddy.ts:242:70 ;;@ (lib)/allocator/buddy.ts:242:70
(get_local $1) (get_local $1)
) )
@ -579,7 +579,7 @@
(i32.const 8) (i32.const 8)
) )
;;@ (lib)/allocator/buddy.ts:349:30 ;;@ (lib)/allocator/buddy.ts:349:30
(i32.const -2147483648) (i32.const 1073741824)
) )
;;@ (lib)/allocator/buddy.ts:350:11 ;;@ (lib)/allocator/buddy.ts:350:11
(return (return
@ -619,7 +619,7 @@
;;@ (lib)/allocator/buddy.ts:362:4 ;;@ (lib)/allocator/buddy.ts:362:4
(set_global "$(lib)/allocator/buddy/bucket_limit" (set_global "$(lib)/allocator/buddy/bucket_limit"
;;@ (lib)/allocator/buddy.ts:362:19 ;;@ (lib)/allocator/buddy.ts:362:19
(i32.const 27) (i32.const 26)
) )
;;@ (lib)/allocator/buddy.ts:363:4 ;;@ (lib)/allocator/buddy.ts:363:4
(if (if
@ -645,7 +645,7 @@
;;@ (lib)/allocator/buddy.ts:366:14 ;;@ (lib)/allocator/buddy.ts:366:14
(call "$(lib)/allocator/buddy/buckets$get" (call "$(lib)/allocator/buddy/buckets$get"
;;@ (lib)/allocator/buddy.ts:366:26 ;;@ (lib)/allocator/buddy.ts:366:26
(i32.const 27) (i32.const 26)
) )
) )
;;@ (lib)/allocator/buddy.ts:367:4 ;;@ (lib)/allocator/buddy.ts:367:4
@ -653,7 +653,7 @@
;;@ (lib)/allocator/buddy.ts:367:14 ;;@ (lib)/allocator/buddy.ts:367:14
(call "$(lib)/allocator/buddy/buckets$get" (call "$(lib)/allocator/buddy/buckets$get"
;;@ (lib)/allocator/buddy.ts:367:26 ;;@ (lib)/allocator/buddy.ts:367:26
(i32.const 27) (i32.const 26)
) )
;;@ (lib)/allocator/buddy.ts:367:45 ;;@ (lib)/allocator/buddy.ts:367:45
(get_global "$(lib)/allocator/buddy/base_ptr") (get_global "$(lib)/allocator/buddy/base_ptr")
@ -791,7 +791,7 @@
;;@ (lib)/allocator/buddy.ts:426:16 ;;@ (lib)/allocator/buddy.ts:426:16
(i32.sub (i32.sub
;;@ (lib)/allocator/buddy.ts:426:17 ;;@ (lib)/allocator/buddy.ts:426:17
(i32.const 31) (i32.const 30)
;;@ (lib)/allocator/buddy.ts:426:34 ;;@ (lib)/allocator/buddy.ts:426:34
(get_local $1) (get_local $1)
) )
@ -1091,7 +1091,7 @@
;;@ (lib)/allocator/buddy.ts:97:25 ;;@ (lib)/allocator/buddy.ts:97:25
(i32.add (i32.add
(get_global "$(lib)/allocator/buddy/BUCKETS_START") (get_global "$(lib)/allocator/buddy/BUCKETS_START")
(i32.const 224) (i32.const 216)
) )
) )
(set_global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START" (set_global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START"
@ -1103,7 +1103,7 @@
(i32.add (i32.add
(get_global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START") (get_global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START")
;;@ (lib)/allocator/buddy.ts:143:53 ;;@ (lib)/allocator/buddy.ts:143:53
(i32.const 16777216) (i32.const 8388608)
) )
) )
) )

@ -10,13 +10,13 @@
(global "$(lib)/allocator/buddy/HEADER_SIZE" i32 (i32.const 8)) (global "$(lib)/allocator/buddy/HEADER_SIZE" i32 (i32.const 8))
(global "$(lib)/allocator/buddy/MIN_ALLOC_LOG2" i32 (i32.const 4)) (global "$(lib)/allocator/buddy/MIN_ALLOC_LOG2" i32 (i32.const 4))
(global "$(lib)/allocator/buddy/MIN_ALLOC" i32 (i32.const 16)) (global "$(lib)/allocator/buddy/MIN_ALLOC" i32 (i32.const 16))
(global "$(lib)/allocator/buddy/MAX_ALLOC_LOG2" i32 (i32.const 31)) (global "$(lib)/allocator/buddy/MAX_ALLOC_LOG2" i32 (i32.const 30))
(global "$(lib)/allocator/buddy/MAX_ALLOC" i32 (i32.const -2147483648)) (global "$(lib)/allocator/buddy/MAX_ALLOC" i32 (i32.const 1073741824))
(global "$(lib)/allocator/buddy/BUCKET_COUNT" i32 (i32.const 28)) (global "$(lib)/allocator/buddy/BUCKET_COUNT" i32 (i32.const 27))
(global "$(lib)/allocator/buddy/BUCKETS_START" (mut i32) (i32.const 0)) (global "$(lib)/allocator/buddy/BUCKETS_START" (mut i32) (i32.const 0))
(global "$(lib)/allocator/buddy/BUCKETS_END" (mut i32) (i32.const 0)) (global "$(lib)/allocator/buddy/BUCKETS_END" (mut i32) (i32.const 0))
(global "$(lib)/allocator/buddy/bucket_limit" (mut i32) (i32.const 0)) (global "$(lib)/allocator/buddy/bucket_limit" (mut i32) (i32.const 0))
(global "$(lib)/allocator/buddy/SPLIT_COUNT" i32 (i32.const 16777216)) (global "$(lib)/allocator/buddy/SPLIT_COUNT" i32 (i32.const 8388608))
(global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START" (mut i32) (i32.const 0)) (global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START" (mut i32) (i32.const 0))
(global "$(lib)/allocator/buddy/NODE_IS_SPLIT_END" (mut i32) (i32.const 0)) (global "$(lib)/allocator/buddy/NODE_IS_SPLIT_END" (mut i32) (i32.const 0))
(global "$(lib)/allocator/buddy/base_ptr" (mut i32) (i32.const 0)) (global "$(lib)/allocator/buddy/base_ptr" (mut i32) (i32.const 0))
@ -134,7 +134,7 @@
(i32.lt_u (i32.lt_u
(get_local $0) (get_local $0)
;;@ (lib)/allocator/buddy.ts:100:17 ;;@ (lib)/allocator/buddy.ts:100:17
(i32.const 28) (i32.const 27)
) )
) )
(block (block
@ -217,7 +217,7 @@
(set_local $1 (set_local $1
;;@ (lib)/allocator/buddy.ts:278:15 ;;@ (lib)/allocator/buddy.ts:278:15
(i32.sub (i32.sub
(i32.const 28) (i32.const 27)
;;@ (lib)/allocator/buddy.ts:278:30 ;;@ (lib)/allocator/buddy.ts:278:30
(i32.const 1) (i32.const 1)
) )
@ -282,7 +282,7 @@
;;@ (lib)/allocator/buddy.ts:251:30 ;;@ (lib)/allocator/buddy.ts:251:30
(i32.sub (i32.sub
;;@ (lib)/allocator/buddy.ts:251:31 ;;@ (lib)/allocator/buddy.ts:251:31
(i32.const 31) (i32.const 30)
;;@ (lib)/allocator/buddy.ts:251:48 ;;@ (lib)/allocator/buddy.ts:251:48
(get_local $1) (get_local $1)
) )
@ -308,7 +308,7 @@
(i32.lt_u (i32.lt_u
(get_local $0) (get_local $0)
;;@ (lib)/allocator/buddy.ts:146:17 ;;@ (lib)/allocator/buddy.ts:146:17
(i32.const 16777216) (i32.const 8388608)
) )
) )
(block (block
@ -433,7 +433,7 @@
;;@ (lib)/allocator/buddy.ts:242:52 ;;@ (lib)/allocator/buddy.ts:242:52
(i32.sub (i32.sub
;;@ (lib)/allocator/buddy.ts:242:53 ;;@ (lib)/allocator/buddy.ts:242:53
(i32.const 31) (i32.const 30)
;;@ (lib)/allocator/buddy.ts:242:70 ;;@ (lib)/allocator/buddy.ts:242:70
(get_local $1) (get_local $1)
) )
@ -449,7 +449,7 @@
(i32.lt_u (i32.lt_u
(get_local $0) (get_local $0)
;;@ (lib)/allocator/buddy.ts:151:17 ;;@ (lib)/allocator/buddy.ts:151:17
(i32.const 16777216) (i32.const 8388608)
) )
) )
(block (block
@ -750,7 +750,7 @@
(i32.const 8) (i32.const 8)
) )
;;@ (lib)/allocator/buddy.ts:349:30 ;;@ (lib)/allocator/buddy.ts:349:30
(i32.const -2147483648) (i32.const 1073741824)
) )
;;@ (lib)/allocator/buddy.ts:350:11 ;;@ (lib)/allocator/buddy.ts:350:11
(return (return
@ -798,7 +798,7 @@
(set_global "$(lib)/allocator/buddy/bucket_limit" (set_global "$(lib)/allocator/buddy/bucket_limit"
;;@ (lib)/allocator/buddy.ts:362:19 ;;@ (lib)/allocator/buddy.ts:362:19
(i32.sub (i32.sub
(i32.const 28) (i32.const 27)
;;@ (lib)/allocator/buddy.ts:362:34 ;;@ (lib)/allocator/buddy.ts:362:34
(i32.const 1) (i32.const 1)
) )
@ -828,7 +828,7 @@
(call "$(lib)/allocator/buddy/buckets$get" (call "$(lib)/allocator/buddy/buckets$get"
;;@ (lib)/allocator/buddy.ts:366:26 ;;@ (lib)/allocator/buddy.ts:366:26
(i32.sub (i32.sub
(i32.const 28) (i32.const 27)
;;@ (lib)/allocator/buddy.ts:366:41 ;;@ (lib)/allocator/buddy.ts:366:41
(i32.const 1) (i32.const 1)
) )
@ -840,7 +840,7 @@
(call "$(lib)/allocator/buddy/buckets$get" (call "$(lib)/allocator/buddy/buckets$get"
;;@ (lib)/allocator/buddy.ts:367:26 ;;@ (lib)/allocator/buddy.ts:367:26
(i32.sub (i32.sub
(i32.const 28) (i32.const 27)
;;@ (lib)/allocator/buddy.ts:367:41 ;;@ (lib)/allocator/buddy.ts:367:41
(i32.const 1) (i32.const 1)
) )
@ -997,7 +997,7 @@
;;@ (lib)/allocator/buddy.ts:426:16 ;;@ (lib)/allocator/buddy.ts:426:16
(i32.sub (i32.sub
;;@ (lib)/allocator/buddy.ts:426:17 ;;@ (lib)/allocator/buddy.ts:426:17
(i32.const 31) (i32.const 30)
;;@ (lib)/allocator/buddy.ts:426:34 ;;@ (lib)/allocator/buddy.ts:426:34
(get_local $2) (get_local $2)
) )
@ -1337,7 +1337,7 @@
(get_global "$(lib)/allocator/buddy/BUCKETS_START") (get_global "$(lib)/allocator/buddy/BUCKETS_START")
;;@ (lib)/allocator/buddy.ts:97:41 ;;@ (lib)/allocator/buddy.ts:97:41
(i32.mul (i32.mul
(i32.const 28) (i32.const 27)
;;@ (lib)/allocator/buddy.ts:97:56 ;;@ (lib)/allocator/buddy.ts:97:56
(i32.const 8) (i32.const 8)
) )
@ -1353,7 +1353,7 @@
(get_global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START") (get_global "$(lib)/allocator/buddy/NODE_IS_SPLIT_START")
;;@ (lib)/allocator/buddy.ts:143:53 ;;@ (lib)/allocator/buddy.ts:143:53
(i32.mul (i32.mul
(i32.const 16777216) (i32.const 8388608)
;;@ (lib)/allocator/buddy.ts:143:67 ;;@ (lib)/allocator/buddy.ts:143:67
(i32.const 1) (i32.const 1)
) )

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,103 @@
(module
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 4) "\10\00\00\00c\00a\00l\00l\00-\00o\00p\00t\00i\00o\00n\00a\00l\00.\00t\00s")
(export "memory" (memory $0))
(start $start)
(func $call-optional/opt (; 1 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(i32.add
(i32.add
(get_local $0)
(get_local $1)
)
(get_local $2)
)
)
(func $call-optional/opt|trampoline (; 2 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=2
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=2 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $1
(i32.const -1)
)
)
(set_local $2
(i32.const -2)
)
)
(call $call-optional/opt
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func $start (; 3 ;) (type $v)
(if
(call $call-optional/opt|trampoline
(i32.const 3)
(i32.const 0)
(i32.const 0)
(i32.const 0)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 4)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $call-optional/opt|trampoline
(i32.const 3)
(i32.const 4)
(i32.const 0)
(i32.const 1)
)
(i32.const 5)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 5)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $call-optional/opt
(i32.const 3)
(i32.const 4)
(i32.const 5)
)
(i32.const 12)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 6)
(i32.const 0)
)
(unreachable)
)
)
)
)

@ -0,0 +1,6 @@
function opt(a: i32, b: i32 = -1, c: i32 = -2): i32 {
return a + b + c;
}
assert(opt(3) == 0); // calls the trampoline with N=0
assert(opt(3, 4) == 5); // calls the trampoline with N=1
assert(opt(3, 4, 5) == 12); // calls the function directly

@ -0,0 +1,115 @@
(module
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $HEAP_BASE i32 (i32.const 40))
(memory $0 1)
(data (i32.const 4) "\10\00\00\00c\00a\00l\00l\00-\00o\00p\00t\00i\00o\00n\00a\00l\00.\00t\00s\00")
(export "memory" (memory $0))
(start $start)
(func $call-optional/opt (; 1 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(return
(i32.add
(i32.add
(get_local $0)
(get_local $1)
)
(get_local $2)
)
)
)
(func $call-optional/opt|trampoline (; 2 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=2
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=2 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $1
(i32.const -1)
)
)
(set_local $2
(i32.const -2)
)
)
(call $call-optional/opt
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func $start (; 3 ;) (type $v)
(if
(i32.eqz
(i32.eq
(call $call-optional/opt|trampoline
(i32.const 3)
(i32.const 0)
(i32.const 0)
(i32.const 0)
)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 4)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $call-optional/opt|trampoline
(i32.const 3)
(i32.const 4)
(i32.const 0)
(i32.const 1)
)
(i32.const 5)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 5)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call $call-optional/opt
(i32.const 3)
(i32.const 4)
(i32.const 5)
)
(i32.const 12)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 6)
(i32.const 0)
)
(unreachable)
)
)
)
)

@ -1,9 +1,9 @@
(module (module
(type $iii (func (param i32 i32) (result i32))) (type $iii (func (param i32 i32) (result i32)))
(type $fff (func (param f32 f32) (result f32))) (type $fff (func (param f32 f32) (result f32)))
(type $ii (func (param i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $ifff (func (param i32 f32 f32) (result f32))) (type $ifff (func (param i32 f32 f32) (result f32)))
(type $ii (func (param i32) (result i32)))
(type $v (func)) (type $v (func))
(global $class/Animal.ONE (mut i32) (i32.const 1)) (global $class/Animal.ONE (mut i32) (i32.const 1))
(memory $0 1) (memory $0 1)

@ -2,9 +2,9 @@
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $iii (func (param i32 i32) (result i32))) (type $iii (func (param i32 i32) (result i32)))
(type $fff (func (param f32 f32) (result f32))) (type $fff (func (param f32 f32) (result f32)))
(type $ii (func (param i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $ifff (func (param i32 f32 f32) (result f32))) (type $ifff (func (param i32 f32 f32) (result f32)))
(type $ii (func (param i32) (result i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $class/Animal.ONE (mut i32) (i32.const 1)) (global $class/Animal.ONE (mut i32) (i32.const 1))

@ -1,28 +1,188 @@
(module (module
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(table 3 3 anyfunc) (type $i (func (result i32)))
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|0 $start~someName|2) (type $iii (func (param i32 i32) (result i32)))
(type $fff (func (param f32 f32) (result f32)))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $function-expression/f1 (mut i32) (i32.const 0))
(global $function-expression/f2 (mut i32) (i32.const 1))
(global $function-expression/f3 (mut i32) (i32.const 2))
(global $function-expression/i32Adder (mut i32) (i32.const 0))
(global $function-expression/f32Adder (mut i32) (i32.const 0))
(global $function-expression/i8Adder (mut i32) (i32.const 0))
(table 6 6 anyfunc)
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|0 $start~someName|2 $function-expression/makeAdder<i32>~theAdder|3 $function-expression/makeAdder<f32>~theAdder|4 $function-expression/makeAdderArrow<i8>~anonymous|5)
(memory $0 1) (memory $0 1)
(data (i32.const 4) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s")
(export "memory" (memory $0)) (export "memory" (memory $0))
(start $start) (start $start)
(func $start~anonymous|0 (; 0 ;) (type $ii) (param $0 i32) (result i32) (func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
(get_local $0) (get_local $0)
) )
(func $start~someName|2 (; 1 ;) (type $v) (func $start~someName|2 (; 2 ;) (type $v)
(nop) (nop)
) )
(func $start (; 2 ;) (type $v) (func $function-expression/makeAdder<i32>~theAdder|3 (; 3 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(drop (i32.add
(call $start~anonymous|0 (get_local $0)
(get_local $1)
)
)
(func $function-expression/makeAdder<i32> (; 4 ;) (type $i) (result i32)
(i32.const 3)
)
(func $function-expression/makeAdder<f32>~theAdder|4 (; 5 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(f32.add
(get_local $0)
(get_local $1)
)
)
(func $function-expression/makeAdder<f32> (; 6 ;) (type $i) (result i32)
(i32.const 4)
)
(func $function-expression/makeAdderArrow<i8>~anonymous|5 (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(i32.shr_s
(i32.shl
(i32.add
(get_local $0)
(get_local $1)
)
(i32.const 24)
)
(i32.const 24)
)
)
(func $function-expression/makeAdderArrow<i8> (; 8 ;) (type $i) (result i32)
(i32.const 5)
)
(func $start (; 9 ;) (type $v)
(if
(i32.ne
(call_indirect (type $ii)
(i32.const 1)
(get_global $function-expression/f1)
)
(i32.const 1) (i32.const 1)
) )
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 4)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call_indirect (type $ii)
(i32.const 2)
(get_global $function-expression/f2)
) )
(drop
(call $start~anonymous|0
(i32.const 2) (i32.const 2)
) )
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 9)
(i32.const 0)
)
(unreachable)
)
)
(call_indirect (type $v)
(get_global $function-expression/f3)
)
(set_global $function-expression/i32Adder
(call $function-expression/makeAdder<i32>)
)
(if
(i32.ne
(call_indirect (type $iii)
(i32.const 4)
(i32.const 2)
(get_global $function-expression/i32Adder)
)
(i32.const 6)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 22)
(i32.const 0)
)
(unreachable)
)
)
(set_global $function-expression/f32Adder
(call $function-expression/makeAdder<f32>)
)
(if
(f32.ne
(call_indirect (type $fff)
(f32.const 1.5)
(f32.const 2.5)
(get_global $function-expression/f32Adder)
)
(f32.const 4)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 25)
(i32.const 0)
)
(unreachable)
)
)
(set_global $function-expression/i8Adder
(call $function-expression/makeAdderArrow<i8>)
)
(if
(i32.ne
(call_indirect (type $iii)
(i32.const 127)
(i32.const 127)
(get_global $function-expression/i8Adder)
)
(i32.const -2)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 34)
(i32.const 0)
)
(unreachable)
)
)
(set_global $function-expression/f1
(get_global $function-expression/f2)
)
(if
(i32.ne
(call_indirect (type $ii)
(i32.const 4)
(get_global $function-expression/f1)
)
(i32.const 4)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 37)
(i32.const 0)
)
(unreachable)
)
) )
(call $start~someName|2)
) )
) )

@ -1,11 +1,37 @@
var f1 = function(a: i32): i32 { var f1 = function(a: i32): i32 {
return a; return a;
}; };
f1(1); assert(f1(1) == 1);
var f2 = (a: i32): i32 => { var f2 = (a: i32): i32 => {
return a; return a;
}; };
f2(2); assert(f2(2) == 2);
var f3 = function someName(): void { var f3 = function someName(): void {
}; };
f3(); f3();
function makeAdder<T>(): (a: T, b: T) => T {
return function theAdder(a: T, b: T): T {
return a + b;
};
}
var i32Adder = makeAdder<i32>();
assert(i32Adder(4, 2) == 6);
var f32Adder = makeAdder<f32>();
assert(f32Adder(1.5, 2.5) == 4.0);
function makeAdderArrow<T>(): (a: T, b: T) => T {
return (a: T, b: T): T => {
return a + b;
};
}
var i8Adder = makeAdderArrow<i8>();
assert(i8Adder(127, 127) == -2);
f1 = f2;
assert(f1(4) == 4);

@ -1,38 +1,219 @@
(module (module
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(type $i (func (result i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $fff (func (param f32 f32) (result f32)))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $function-expression/f1 (mut i32) (i32.const 0)) (global $function-expression/f1 (mut i32) (i32.const 0))
(global $function-expression/f2 (mut i32) (i32.const 1)) (global $function-expression/f2 (mut i32) (i32.const 1))
(global $function-expression/f3 (mut i32) (i32.const 2)) (global $function-expression/f3 (mut i32) (i32.const 2))
(global $HEAP_BASE i32 (i32.const 4)) (global $function-expression/i32Adder (mut i32) (i32.const 0))
(table 3 3 anyfunc) (global $function-expression/f32Adder (mut i32) (i32.const 0))
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|1 $start~someName|2) (global $function-expression/i8Adder (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 52))
(table 6 6 anyfunc)
(elem (i32.const 0) $start~anonymous|0 $start~anonymous|1 $start~someName|2 $function-expression/makeAdder<i32>~theAdder|3 $function-expression/makeAdder<f32>~theAdder|4 $function-expression/makeAdderArrow<i8>~anonymous|5)
(memory $0 1) (memory $0 1)
(data (i32.const 4) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s\00")
(export "memory" (memory $0)) (export "memory" (memory $0))
(start $start) (start $start)
(func $start~anonymous|0 (; 0 ;) (type $ii) (param $0 i32) (result i32) (func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
(return (return
(get_local $0) (get_local $0)
) )
) )
(func $start~anonymous|1 (; 1 ;) (type $ii) (param $0 i32) (result i32) (func $start~anonymous|1 (; 2 ;) (type $ii) (param $0 i32) (result i32)
(return (return
(get_local $0) (get_local $0)
) )
) )
(func $start~someName|2 (; 2 ;) (type $v) (func $start~someName|2 (; 3 ;) (type $v)
)
(func $function-expression/makeAdder<i32>~theAdder|3 (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(return
(i32.add
(get_local $0)
(get_local $1)
)
)
)
(func $function-expression/makeAdder<i32> (; 5 ;) (type $i) (result i32)
(return
(i32.const 3)
)
)
(func $function-expression/makeAdder<f32>~theAdder|4 (; 6 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(return
(f32.add
(get_local $0)
(get_local $1)
)
)
)
(func $function-expression/makeAdder<f32> (; 7 ;) (type $i) (result i32)
(return
(i32.const 4)
)
)
(func $function-expression/makeAdderArrow<i8>~anonymous|5 (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(return
(i32.shr_s
(i32.shl
(i32.add
(get_local $0)
(get_local $1)
)
(i32.const 24)
)
(i32.const 24)
)
)
)
(func $function-expression/makeAdderArrow<i8> (; 9 ;) (type $i) (result i32)
(return
(i32.const 5)
)
)
(func $start (; 10 ;) (type $v)
(if
(i32.eqz
(i32.eq
(call_indirect (type $ii)
(i32.const 1)
(get_global $function-expression/f1)
) )
(func $start (; 3 ;) (type $v)
(drop
(call $start~anonymous|0
(i32.const 1) (i32.const 1)
) )
) )
(drop (block
(call $start~anonymous|1 (call $abort
(i32.const 0)
(i32.const 4)
(i32.const 4)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(call_indirect (type $ii)
(i32.const 2)
(get_global $function-expression/f2)
)
(i32.const 2) (i32.const 2)
) )
) )
(call $start~someName|2) (block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 9)
(i32.const 0)
)
(unreachable)
)
)
(call_indirect (type $v)
(get_global $function-expression/f3)
)
(set_global $function-expression/i32Adder
(call $function-expression/makeAdder<i32>)
)
(if
(i32.eqz
(i32.eq
(call_indirect (type $iii)
(i32.const 4)
(i32.const 2)
(get_global $function-expression/i32Adder)
)
(i32.const 6)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 22)
(i32.const 0)
)
(unreachable)
)
)
(set_global $function-expression/f32Adder
(call $function-expression/makeAdder<f32>)
)
(if
(i32.eqz
(f32.eq
(call_indirect (type $fff)
(f32.const 1.5)
(f32.const 2.5)
(get_global $function-expression/f32Adder)
)
(f32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 25)
(i32.const 0)
)
(unreachable)
)
)
(set_global $function-expression/i8Adder
(call $function-expression/makeAdderArrow<i8>)
)
(if
(i32.eqz
(i32.eq
(call_indirect (type $iii)
(i32.const 127)
(i32.const 127)
(get_global $function-expression/i8Adder)
)
(i32.const -2)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 34)
(i32.const 0)
)
(unreachable)
)
)
(set_global $function-expression/f1
(get_global $function-expression/f2)
)
(if
(i32.eqz
(i32.eq
(call_indirect (type $ii)
(i32.const 4)
(get_global $function-expression/f1)
)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 37)
(i32.const 0)
)
(unreachable)
)
)
) )
) )

@ -1,6 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $iiv (func (param i32 i32))) (type $iiv (func (param i32 i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $retain-i32/si (mut i32) (i32.const 0)) (global $retain-i32/si (mut i32) (i32.const 0))

@ -1,6 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $iiv (func (param i32 i32))) (type $iiv (func (param i32 i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $retain-i32/si (mut i32) (i32.const 0)) (global $retain-i32/si (mut i32) (i32.const 0))

@ -6,7 +6,7 @@
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/allocator_arena/ptr1 (mut i32) (i32.const 0)) (global $std/allocator_arena/ptr1 (mut i32) (i32.const 0))
(global $std/allocator_arena/ptr2 (mut i32) (i32.const 0)) (global $std/allocator_arena/ptr2 (mut i32) (i32.const 0))
(global $std/allocator_arena/i (mut i32) (i32.const 0)) (global $std/allocator_arena/i (mut i32) (i32.const 0))
@ -35,7 +35,7 @@
(i32.add (i32.add
(i32.add (i32.add
(tee_local $1 (tee_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(get_local $0) (get_local $0)
) )
@ -92,7 +92,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(get_local $1) (get_local $1)
@ -2360,7 +2360,7 @@
(nop) (nop)
) )
(func "$(lib)/allocator/arena/reset_memory" (; 7 ;) (type $v) (func "$(lib)/allocator/arena/reset_memory" (; 7 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
@ -2371,7 +2371,7 @@
) )
) )
(func $start (; 8 ;) (type $v) (func $start (; 8 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)

@ -7,10 +7,10 @@
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global "$(lib)/allocator/arena/AL_BITS" i32 (i32.const 3)) (global "$(lib)/allocator/common/alignment/BITS" i32 (i32.const 3))
(global "$(lib)/allocator/arena/AL_SIZE" i32 (i32.const 8)) (global "$(lib)/allocator/common/alignment/SIZE" i32 (i32.const 8))
(global "$(lib)/allocator/arena/AL_MASK" i32 (i32.const 7)) (global "$(lib)/allocator/common/alignment/MASK" i32 (i32.const 7))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/allocator_arena/size i32 (i32.const 42)) (global $std/allocator_arena/size i32 (i32.const 42))
(global $std/allocator_arena/ptr1 (mut i32) (i32.const 0)) (global $std/allocator_arena/ptr1 (mut i32) (i32.const 0))
(global $std/allocator_arena/ptr2 (mut i32) (i32.const 0)) (global $std/allocator_arena/ptr2 (mut i32) (i32.const 0))
@ -37,7 +37,7 @@
) )
) )
(set_local $1 (set_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(set_local $2 (set_local $2
(i32.and (i32.and
@ -117,7 +117,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(return (return
@ -777,6 +777,7 @@
) )
(br $break|2) (br $break|2)
) )
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -1000,6 +1001,8 @@
) )
(br $break|2) (br $break|2)
) )
)
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -1195,6 +1198,8 @@
) )
(br $break|2) (br $break|2)
) )
)
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -1363,6 +1368,7 @@
(br $break|2) (br $break|2)
) )
) )
)
(if (if
(i32.and (i32.and
(get_local $2) (get_local $2)
@ -2662,7 +2668,7 @@
(func "$(lib)/allocator/arena/free_memory" (; 6 ;) (type $iv) (param $0 i32) (func "$(lib)/allocator/arena/free_memory" (; 6 ;) (type $iv) (param $0 i32)
) )
(func "$(lib)/allocator/arena/reset_memory" (; 7 ;) (type $v) (func "$(lib)/allocator/arena/reset_memory" (; 7 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
@ -2676,7 +2682,7 @@
) )
) )
(func $start (; 8 ;) (type $v) (func $start (; 8 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)

@ -1,14 +1,15 @@
(module (module
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiv (func (param i32 i32)))
(type $iiiv (func (param i32 i32 i32))) (type $iiiv (func (param i32 i32 i32)))
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $iiv (func (param i32 i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/array/arr (mut i32) (i32.const 0)) (global $std/array/arr (mut i32) (i32.const 0))
(global $std/array/i (mut i32) (i32.const 0)) (global $std/array/i (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 64)) (global $HEAP_BASE i32 (i32.const 64))
@ -37,7 +38,7 @@
(i32.add (i32.add
(i32.add (i32.add
(tee_local $1 (tee_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(get_local $0) (get_local $0)
) )
@ -94,7 +95,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(get_local $1) (get_local $1)
@ -2803,7 +2804,27 @@
) )
(i32.const -1) (i32.const -1)
) )
(func "$(lib)/array/Array#splice" (; 15 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) (func "$(lib)/array/Array#indexOf|trampoline" (; 15 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/array/Array#indexOf"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/array/Array#splice" (; 16 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(if (if
(i32.lt_s (i32.lt_s
(get_local $2) (get_local $2)
@ -2904,8 +2925,8 @@
) )
) )
) )
(func $start (; 16 ;) (type $v) (func $start (; 17 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
@ -3854,10 +3875,11 @@
) )
) )
(set_global $std/array/i (set_global $std/array/i
(call "$(lib)/array/Array#indexOf" (call "$(lib)/array/Array#indexOf|trampoline"
(get_global $std/array/arr) (get_global $std/array/arr)
(i32.const 44) (i32.const 44)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(if (if
@ -3873,10 +3895,11 @@
) )
) )
(set_global $std/array/i (set_global $std/array/i
(call "$(lib)/array/Array#indexOf" (call "$(lib)/array/Array#indexOf|trampoline"
(get_global $std/array/arr) (get_global $std/array/arr)
(i32.const 42) (i32.const 42)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(if (if
@ -3895,10 +3918,11 @@
) )
) )
(set_global $std/array/i (set_global $std/array/i
(call "$(lib)/array/Array#indexOf" (call "$(lib)/array/Array#indexOf|trampoline"
(get_global $std/array/arr) (get_global $std/array/arr)
(i32.const 45) (i32.const 45)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(if (if

@ -2,17 +2,18 @@
(type $i (func (result i32))) (type $i (func (result i32)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiv (func (param i32 i32)))
(type $iiiv (func (param i32 i32 i32))) (type $iiiv (func (param i32 i32 i32)))
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $iiv (func (param i32 i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global "$(lib)/allocator/arena/AL_BITS" i32 (i32.const 3)) (global "$(lib)/allocator/common/alignment/BITS" i32 (i32.const 3))
(global "$(lib)/allocator/arena/AL_SIZE" i32 (i32.const 8)) (global "$(lib)/allocator/common/alignment/SIZE" i32 (i32.const 8))
(global "$(lib)/allocator/arena/AL_MASK" i32 (i32.const 7)) (global "$(lib)/allocator/common/alignment/MASK" i32 (i32.const 7))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/array/arr (mut i32) (i32.const 0)) (global $std/array/arr (mut i32) (i32.const 0))
(global $std/array/i (mut i32) (i32.const 0)) (global $std/array/i (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 64)) (global $HEAP_BASE i32 (i32.const 64))
@ -38,7 +39,7 @@
) )
) )
(set_local $1 (set_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(set_local $2 (set_local $2
(i32.and (i32.and
@ -118,7 +119,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(return (return
@ -436,6 +437,7 @@
) )
(br $break|2) (br $break|2)
) )
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -659,6 +661,8 @@
) )
(br $break|2) (br $break|2)
) )
)
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -854,6 +858,8 @@
) )
(br $break|2) (br $break|2)
) )
)
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -1022,6 +1028,7 @@
(br $break|2) (br $break|2)
) )
) )
)
(if (if
(i32.and (i32.and
(get_local $2) (get_local $2)
@ -3143,7 +3150,27 @@
(i32.const -1) (i32.const -1)
) )
) )
(func "$(lib)/array/Array#splice" (; 15 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) (func "$(lib)/array/Array#indexOf|trampoline" (; 15 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/array/Array#indexOf"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/array/Array#splice" (; 16 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(if (if
@ -3252,8 +3279,8 @@
) )
) )
) )
(func $start (; 16 ;) (type $v) (func $start (; 17 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
@ -4322,10 +4349,11 @@
) )
) )
(set_global $std/array/i (set_global $std/array/i
(call "$(lib)/array/Array#indexOf" (call "$(lib)/array/Array#indexOf|trampoline"
(get_global $std/array/arr) (get_global $std/array/arr)
(i32.const 44) (i32.const 44)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(if (if
@ -4346,10 +4374,11 @@
) )
) )
(set_global $std/array/i (set_global $std/array/i
(call "$(lib)/array/Array#indexOf" (call "$(lib)/array/Array#indexOf|trampoline"
(get_global $std/array/arr) (get_global $std/array/arr)
(i32.const 42) (i32.const 42)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(if (if
@ -4370,10 +4399,11 @@
) )
) )
(set_global $std/array/i (set_global $std/array/i
(call "$(lib)/array/Array#indexOf" (call "$(lib)/array/Array#indexOf|trampoline"
(get_global $std/array/arr) (get_global $std/array/arr)
(i32.const 45) (i32.const 45)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(if (if

@ -49,6 +49,7 @@
) )
(func $start (; 3 ;) (type $v) (func $start (; 3 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 i32)
(set_global $std/carray/arr (set_global $std/carray/arr
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
) )
@ -199,14 +200,19 @@
(if (if
(block (result i32) (block (result i32)
(call "$(lib)/array/CArray#__set" (call "$(lib)/array/CArray#__set"
(get_global $std/carray/arr)
(i32.const 3)
(tee_local $0 (tee_local $0
(get_global $std/carray/arr)
)
(tee_local $1
(i32.const 3)
)
(i32.const 9000) (i32.const 9000)
) )
)
(i32.ne (i32.ne
(call "$(lib)/array/CArray#__get"
(get_local $0) (get_local $0)
(get_local $1)
)
(i32.const 9000) (i32.const 9000)
) )
) )

@ -51,6 +51,7 @@
) )
(func $start (; 3 ;) (type $v) (func $start (; 3 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 i32)
(set_global $std/carray/arr (set_global $std/carray/arr
(get_global $HEAP_BASE) (get_global $HEAP_BASE)
) )
@ -231,13 +232,18 @@
(i32.eq (i32.eq
(block (result i32) (block (result i32)
(call "$(lib)/array/CArray#__set" (call "$(lib)/array/CArray#__set"
(get_global $std/carray/arr)
(i32.const 3)
(tee_local $0 (tee_local $0
(get_global $std/carray/arr)
)
(tee_local $1
(i32.const 3)
)
(i32.const 9000) (i32.const 9000)
) )
) (call "$(lib)/array/CArray#__get"
(get_local $0) (get_local $0)
(get_local $1)
)
) )
(i32.const 9000) (i32.const 9000)
) )

@ -2,7 +2,7 @@
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $ifv (func (param i32 f32))) (type $ifv (func (param i32 f32)))
(type $v (func)) (type $v (func))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/new/aClass (mut i32) (i32.const 0)) (global $std/new/aClass (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4)) (global $HEAP_BASE i32 (i32.const 4))
(memory $0 1) (memory $0 1)
@ -28,7 +28,7 @@
(i32.add (i32.add
(i32.add (i32.add
(tee_local $1 (tee_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(get_local $0) (get_local $0)
) )
@ -85,7 +85,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(get_local $1) (get_local $1)
@ -107,7 +107,7 @@
) )
(func $start (; 2 ;) (type $v) (func $start (; 2 ;) (type $v)
(local $0 i32) (local $0 i32)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)

@ -3,10 +3,10 @@
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $ifv (func (param i32 f32))) (type $ifv (func (param i32 f32)))
(type $v (func)) (type $v (func))
(global "$(lib)/allocator/arena/AL_BITS" i32 (i32.const 3)) (global "$(lib)/allocator/common/alignment/BITS" i32 (i32.const 3))
(global "$(lib)/allocator/arena/AL_SIZE" i32 (i32.const 8)) (global "$(lib)/allocator/common/alignment/SIZE" i32 (i32.const 8))
(global "$(lib)/allocator/arena/AL_MASK" i32 (i32.const 7)) (global "$(lib)/allocator/common/alignment/MASK" i32 (i32.const 7))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/new/aClass (mut i32) (i32.const 0)) (global $std/new/aClass (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4)) (global $HEAP_BASE i32 (i32.const 4))
(memory $0 1) (memory $0 1)
@ -29,7 +29,7 @@
) )
) )
(set_local $1 (set_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(set_local $2 (set_local $2
(i32.and (i32.and
@ -109,7 +109,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(return (return
@ -133,7 +133,7 @@
) )
(func $start (; 2 ;) (type $v) (func $start (; 2 ;) (type $v)
(local $0 i32) (local $0 i32)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)

@ -1,6 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $II (func (param i64) (result i64))) (type $II (func (param i64) (result i64)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))

@ -1,6 +1,6 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $II (func (param i64) (result i64))) (type $II (func (param i64) (result i64)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))

@ -1,12 +1,12 @@
(module (module
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiiv (func (param i32 i32 i32))) (type $iiiv (func (param i32 i32 i32)))
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/set/set (mut i32) (i32.const 0)) (global $std/set/set (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 56)) (global $HEAP_BASE i32 (i32.const 56))
(memory $0 1) (memory $0 1)
@ -34,7 +34,7 @@
(i32.add (i32.add
(i32.add (i32.add
(tee_local $1 (tee_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(get_local $0) (get_local $0)
) )
@ -91,7 +91,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(get_local $1) (get_local $1)
@ -2273,7 +2273,7 @@
) )
) )
(func $start (; 10 ;) (type $v) (func $start (; 10 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)

@ -2,15 +2,15 @@
(type $i (func (result i32))) (type $i (func (result i32)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiiv (func (param i32 i32 i32))) (type $iiiv (func (param i32 i32 i32)))
(type $iv (func (param i32))) (type $iv (func (param i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global "$(lib)/allocator/arena/AL_BITS" i32 (i32.const 3)) (global "$(lib)/allocator/common/alignment/BITS" i32 (i32.const 3))
(global "$(lib)/allocator/arena/AL_SIZE" i32 (i32.const 8)) (global "$(lib)/allocator/common/alignment/SIZE" i32 (i32.const 8))
(global "$(lib)/allocator/arena/AL_MASK" i32 (i32.const 7)) (global "$(lib)/allocator/common/alignment/MASK" i32 (i32.const 7))
(global "$(lib)/allocator/arena/OFFSET" (mut i32) (i32.const 0)) (global "$(lib)/allocator/arena/offset" (mut i32) (i32.const 0))
(global $std/set/set (mut i32) (i32.const 0)) (global $std/set/set (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 56)) (global $HEAP_BASE i32 (i32.const 56))
(memory $0 1) (memory $0 1)
@ -35,7 +35,7 @@
) )
) )
(set_local $1 (set_local $1
(get_global "$(lib)/allocator/arena/OFFSET") (get_global "$(lib)/allocator/arena/offset")
) )
(set_local $2 (set_local $2
(i32.and (i32.and
@ -115,7 +115,7 @@
) )
) )
) )
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(get_local $2) (get_local $2)
) )
(return (return
@ -433,6 +433,7 @@
) )
(br $break|2) (br $break|2)
) )
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -656,6 +657,8 @@
) )
(br $break|2) (br $break|2)
) )
)
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -851,6 +854,8 @@
) )
(br $break|2) (br $break|2)
) )
)
(block
(set_local $3 (set_local $3
(i32.load (i32.load
(get_local $1) (get_local $1)
@ -1019,6 +1024,7 @@
(br $break|2) (br $break|2)
) )
) )
)
(if (if
(i32.and (i32.and
(get_local $2) (get_local $2)
@ -2593,7 +2599,7 @@
) )
) )
(func $start (; 10 ;) (type $v) (func $start (; 10 ;) (type $v)
(set_global "$(lib)/allocator/arena/OFFSET" (set_global "$(lib)/allocator/arena/offset"
(i32.and (i32.and
(i32.add (i32.add
(get_global $HEAP_BASE) (get_global $HEAP_BASE)

@ -1,9 +1,11 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $iii (func (param i32 i32) (result i32))) (type $iii (func (param i32 i32) (result i32)))
(type $i (func (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $iiF (func (param i32 i32) (result f64))) (type $iiF (func (param i32 i32) (result f64)))
(type $iiiF (func (param i32 i32 i32) (result f64)))
(type $iF (func (param i32) (result f64))) (type $iF (func (param i32) (result f64)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
@ -217,7 +219,27 @@
) )
) )
) )
(func "$(lib)/string/String#endsWith" (; 4 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func "$(lib)/string/String#startsWith|trampoline" (; 4 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/string/String#startsWith"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/string/String#endsWith" (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32) (local $3 i32)
(if (if
(i32.eqz (i32.eqz
@ -302,7 +324,27 @@
) )
) )
) )
(func "$(lib)/string/String#indexOf" (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func "$(lib)/string/String#endsWith|trampoline" (; 6 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 2147483647)
)
)
(call "$(lib)/string/String#endsWith"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/string/String#indexOf" (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
@ -407,7 +449,7 @@
) )
(i32.const -1) (i32.const -1)
) )
(func "$(lib)/string/String#includes" (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func "$(lib)/string/String#includes" (; 8 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(i32.ne (i32.ne
(call "$(lib)/string/String#indexOf" (call "$(lib)/string/String#indexOf"
(get_local $0) (get_local $0)
@ -417,10 +459,50 @@
(i32.const -1) (i32.const -1)
) )
) )
(func $std/string/getString (; 7 ;) (type $i) (result i32) (func "$(lib)/string/String#includes|trampoline" (; 9 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/string/String#includes"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/string/String#indexOf|trampoline" (; 10 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/string/String#indexOf"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func $std/string/getString (; 11 ;) (type $i) (result i32)
(get_global $std/string/str) (get_global $std/string/str)
) )
(func "$(lib)/string/parse<f64>" (; 8 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (func "$(lib)/string/parse<f64>" (; 12 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -785,13 +867,32 @@
(get_local $5) (get_local $5)
) )
) )
(func "$(lib)/string/parseInt" (; 9 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (func "$(lib)/string/parseInt" (; 13 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
(call "$(lib)/string/parse<f64>" (call "$(lib)/string/parse<f64>"
(get_local $0) (get_local $0)
(get_local $1) (get_local $1)
) )
) )
(func "$(lib)/string/parseFloat" (; 10 ;) (type $iF) (param $0 i32) (result f64) (func "$(lib)/string/parseInt|trampoline" (; 14 ;) (type $iiiF) (param $0 i32) (param $1 i32) (param $2 i32) (result f64)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $2)
)
)
(unreachable)
)
(set_local $1
(i32.const 0)
)
)
(call "$(lib)/string/parseInt"
(get_local $0)
(get_local $1)
)
)
(func "$(lib)/string/parseFloat" (; 15 ;) (type $iF) (param $0 i32) (result f64)
(local $1 i32) (local $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -1043,7 +1144,7 @@
(get_local $4) (get_local $4)
) )
) )
(func $start (; 11 ;) (type $v) (func $start (; 16 ;) (type $v)
(if (if
(i32.ne (i32.ne
(get_global $std/string/str) (get_global $std/string/str)
@ -1096,10 +1197,11 @@
) )
(if (if
(i32.eqz (i32.eqz
(call "$(lib)/string/String#startsWith" (call "$(lib)/string/String#startsWith|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 108) (i32.const 108)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(block (block
@ -1114,10 +1216,11 @@
) )
(if (if
(i32.eqz (i32.eqz
(call "$(lib)/string/String#endsWith" (call "$(lib)/string/String#endsWith|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 128) (i32.const 128)
(i32.const 2147483647) (i32.const 0)
(i32.const 0)
) )
) )
(block (block
@ -1132,10 +1235,11 @@
) )
(if (if
(i32.eqz (i32.eqz
(call "$(lib)/string/String#includes" (call "$(lib)/string/String#includes|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 144) (i32.const 144)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(block (block
@ -1150,10 +1254,11 @@
) )
(if (if
(i32.ne (i32.ne
(call "$(lib)/string/String#indexOf" (call "$(lib)/string/String#indexOf|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 156) (i32.const 156)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(i32.const 2) (i32.const 2)
) )
@ -1169,10 +1274,11 @@
) )
(if (if
(i32.ne (i32.ne
(call "$(lib)/string/String#indexOf" (call "$(lib)/string/String#indexOf|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 164) (i32.const 164)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(i32.const -1) (i32.const -1)
) )
@ -1188,9 +1294,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 172) (i32.const 172)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 0) (f64.const 0)
) )
@ -1206,9 +1313,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 180) (i32.const 180)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 1) (f64.const 1)
) )
@ -1224,9 +1332,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 188) (i32.const 188)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 5) (f64.const 5)
) )
@ -1242,9 +1351,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 204) (i32.const 204)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 455) (f64.const 455)
) )
@ -1260,9 +1370,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 220) (i32.const 220)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 3855) (f64.const 3855)
) )
@ -1278,9 +1389,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 236) (i32.const 236)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 3855) (f64.const 3855)
) )
@ -1296,9 +1408,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 252) (i32.const 252)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 11) (f64.const 11)
) )
@ -1314,9 +1427,10 @@
) )
(if (if
(f64.ne (f64.ne
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 264) (i32.const 264)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 1) (f64.const 1)
) )

@ -1,9 +1,11 @@
(module (module
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $iii (func (param i32 i32) (result i32))) (type $iii (func (param i32 i32) (result i32)))
(type $i (func (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $iiF (func (param i32 i32) (result f64))) (type $iiF (func (param i32 i32) (result f64)))
(type $iiiF (func (param i32 i32 i32) (result f64)))
(type $iF (func (param i32) (result f64))) (type $iF (func (param i32) (result f64)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
@ -274,7 +276,27 @@
) )
) )
) )
(func "$(lib)/string/String#endsWith" (; 4 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func "$(lib)/string/String#startsWith|trampoline" (; 4 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/string/String#startsWith"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/string/String#endsWith" (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
@ -378,7 +400,27 @@
) )
) )
) )
(func "$(lib)/string/String#indexOf" (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func "$(lib)/string/String#endsWith|trampoline" (; 6 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 2147483647)
)
)
(call "$(lib)/string/String#endsWith"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/string/String#indexOf" (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
@ -508,7 +550,7 @@
(i32.const -1) (i32.const -1)
) )
) )
(func "$(lib)/string/String#includes" (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func "$(lib)/string/String#includes" (; 8 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(return (return
(i32.ne (i32.ne
(call "$(lib)/string/String#indexOf" (call "$(lib)/string/String#indexOf"
@ -520,12 +562,52 @@
) )
) )
) )
(func $std/string/getString (; 7 ;) (type $i) (result i32) (func "$(lib)/string/String#includes|trampoline" (; 9 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/string/String#includes"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func "$(lib)/string/String#indexOf|trampoline" (; 10 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $3)
)
)
(unreachable)
)
(set_local $2
(i32.const 0)
)
)
(call "$(lib)/string/String#indexOf"
(get_local $0)
(get_local $1)
(get_local $2)
)
)
(func $std/string/getString (; 11 ;) (type $i) (result i32)
(return (return
(get_global $std/string/str) (get_global $std/string/str)
) )
) )
(func "$(lib)/string/parse<f64>" (; 8 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (func "$(lib)/string/parse<f64>" (; 12 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -701,6 +783,7 @@
(br $case6|0) (br $case6|0)
) )
) )
(block
(set_local $3 (set_local $3
(i32.add (i32.add
(get_local $3) (get_local $3)
@ -719,6 +802,8 @@
(br $break|0) (br $break|0)
) )
) )
)
(block
(set_local $3 (set_local $3
(i32.add (i32.add
(get_local $3) (get_local $3)
@ -737,6 +822,8 @@
(br $break|0) (br $break|0)
) )
) )
)
(block
(set_local $3 (set_local $3
(i32.add (i32.add
(get_local $3) (get_local $3)
@ -754,10 +841,13 @@
) )
(br $break|0) (br $break|0)
) )
)
(block
(set_local $1 (set_local $1
(i32.const 10) (i32.const 10)
) )
) )
)
(set_local $1 (set_local $1
(i32.const 10) (i32.const 10)
) )
@ -927,7 +1017,7 @@
) )
) )
) )
(func "$(lib)/string/parseInt" (; 9 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (func "$(lib)/string/parseInt" (; 13 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
(return (return
(call "$(lib)/string/parse<f64>" (call "$(lib)/string/parse<f64>"
(get_local $0) (get_local $0)
@ -935,7 +1025,26 @@
) )
) )
) )
(func "$(lib)/string/parseFloat" (; 10 ;) (type $iF) (param $0 i32) (result f64) (func "$(lib)/string/parseInt|trampoline" (; 14 ;) (type $iiiF) (param $0 i32) (param $1 i32) (param $2 i32) (result f64)
(block $N=1
(block $N=0
(block $N=invalid
(br_table $N=0 $N=1 $N=invalid
(get_local $2)
)
)
(unreachable)
)
(set_local $1
(i32.const 0)
)
)
(call "$(lib)/string/parseInt"
(get_local $0)
(get_local $1)
)
)
(func "$(lib)/string/parseFloat" (; 15 ;) (type $iF) (param $0 i32) (result f64)
(local $1 i32) (local $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -1218,7 +1327,7 @@
) )
) )
) )
(func $start (; 11 ;) (type $v) (func $start (; 16 ;) (type $v)
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
@ -1277,10 +1386,11 @@
) )
(if (if
(i32.eqz (i32.eqz
(call "$(lib)/string/String#startsWith" (call "$(lib)/string/String#startsWith|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 108) (i32.const 108)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(block (block
@ -1295,10 +1405,11 @@
) )
(if (if
(i32.eqz (i32.eqz
(call "$(lib)/string/String#endsWith" (call "$(lib)/string/String#endsWith|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 128) (i32.const 128)
(i32.const 2147483647) (i32.const 0)
(i32.const 0)
) )
) )
(block (block
@ -1313,10 +1424,11 @@
) )
(if (if
(i32.eqz (i32.eqz
(call "$(lib)/string/String#includes" (call "$(lib)/string/String#includes|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 144) (i32.const 144)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
) )
(block (block
@ -1332,10 +1444,11 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(call "$(lib)/string/String#indexOf" (call "$(lib)/string/String#indexOf|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 156) (i32.const 156)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(i32.const 2) (i32.const 2)
) )
@ -1353,10 +1466,11 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(call "$(lib)/string/String#indexOf" (call "$(lib)/string/String#indexOf|trampoline"
(get_global $std/string/str) (get_global $std/string/str)
(i32.const 164) (i32.const 164)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(i32.const -1) (i32.const -1)
) )
@ -1374,9 +1488,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 172) (i32.const 172)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 0) (f64.const 0)
) )
@ -1394,9 +1509,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 180) (i32.const 180)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 1) (f64.const 1)
) )
@ -1414,9 +1530,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 188) (i32.const 188)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 5) (f64.const 5)
) )
@ -1434,9 +1551,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 204) (i32.const 204)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 455) (f64.const 455)
) )
@ -1454,9 +1572,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 220) (i32.const 220)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 3855) (f64.const 3855)
) )
@ -1474,9 +1593,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 236) (i32.const 236)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 3855) (f64.const 3855)
) )
@ -1494,9 +1614,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 252) (i32.const 252)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 11) (f64.const 11)
) )
@ -1514,9 +1635,10 @@
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
(call "$(lib)/string/parseInt" (call "$(lib)/string/parseInt|trampoline"
(i32.const 264) (i32.const 264)
(i32.const 0) (i32.const 0)
(i32.const 0)
) )
(f64.const 1) (f64.const 1)
) )

@ -0,0 +1,8 @@
type foo = () => void;
type foo = (() => void) | null;
type foo = (a: i32) => i32;
type foo = (a?: i32) => i32;
type foo = (this: AClass, a: i32) => i32;
type foo = () => () => void;
type foo = () => (() => void) | null;
type foo = (this: AClass, a: i32) => ((this: BClass, b?: f32) => i32) | null;

@ -0,0 +1,8 @@
type foo = () => void;
type foo = (() => void) | null;
type foo = (a: i32) => i32;
type foo = (a?: i32) => i32;
type foo = (this: AClass, a: i32) => i32;
type foo = () => () => void;
type foo = () => (() => void) | null;
type foo = (this: AClass, a: i32) => ((this: BClass, b?: f32) => i32) | null;

@ -5,8 +5,9 @@
], ],
"defaultSeverity": "warning", "defaultSeverity": "warning",
"rules": { "rules": {
"as-diagnostics": true,
"as-types": { "severity": "error" }, "as-types": { "severity": "error" },
"as-internal-case": true,
"as-internal-diagnostics": true,
"adjacent-overload-signatures": true, "adjacent-overload-signatures": true,
"ban-types": [ true, ["Object"], ["any"], ["undefined"], ["never"] ], "ban-types": [ true, ["Object"], ["any"], ["undefined"], ["never"] ],
"curly": [true, "ignore-same-line"], "curly": [true, "ignore-same-line"],