diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b4f2f66d0..49597efacf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,6 +50,8 @@ jobs: run: npm ci --no-audit - name: Clean distribution files run: npm run clean + - name: Check sources + run: npm run check - name: Test sources run: | if [[ `node bin/asc --version` != *"-dev" ]]; then diff --git a/package-lock.json b/package-lock.json index e62c732fbb..fca9cf4d2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,22 +5,28 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", - "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", "dev": true, "requires": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.8.3" } }, + "@babel/helper-validator-identifier": { + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", + "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==", + "dev": true + }, "@babel/highlight": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", - "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz", + "integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==", "dev": true, "requires": { + "@babel/helper-validator-identifier": "^7.9.0", "chalk": "^2.0.0", - "esutils": "^2.0.2", "js-tokens": "^4.0.0" } }, @@ -1313,12 +1319,6 @@ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, "events": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/events/-/events-3.1.0.tgz", @@ -3579,9 +3579,9 @@ "dev": true }, "resolve": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", - "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", "dev": true, "requires": { "path-parse": "^1.0.6" diff --git a/src/ast.ts b/src/ast.ts index 420d2a7923..8d33ce4fff 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -98,7 +98,6 @@ export enum NodeKind { FIELDDECLARATION, FUNCTIONDECLARATION, IMPORTDECLARATION, - INDEXSIGNATUREDECLARATION, INTERFACEDECLARATION, METHODDECLARATION, NAMESPACEDECLARATION, @@ -109,35 +108,26 @@ export enum NodeKind { DECORATOR, EXPORTMEMBER, SWITCHCASE, + INDEXSIGNATURE, COMMENT } /** Base class of all nodes. */ export abstract class Node { - /** Node kind indicator. */ - kind: NodeKind; - /** Source range. */ - range: Range; + constructor( + /** Kind of this node. */ + public kind: NodeKind, + /** Source range. */ + public range: Range + ) {} // types - static createTypeName( - name: IdentifierExpression, - range: Range - ): TypeName { - var node = new TypeName(); - node.kind = NodeKind.TYPENAME; - node.range = range; - node.identifier = name; - node.next = null; - return node; - } - static createSimpleTypeName( name: string, range: Range ): TypeName { - return Node.createTypeName(Node.createIdentifierExpression(name, range), range); + return new TypeName(Node.createIdentifierExpression(name, range), null, range); } static createNamedType( @@ -146,13 +136,7 @@ export abstract class Node { isNullable: bool, range: Range ): NamedTypeNode { - var node = new NamedTypeNode(); - node.kind = NodeKind.NAMEDTYPE; - node.range = range; - node.name = name; - node.typeArguments = typeArguments; - node.isNullable = isNullable; - return node; + return new NamedTypeNode(name, typeArguments, isNullable, range); } static createFunctionType( @@ -162,25 +146,13 @@ export abstract class Node { isNullable: bool, range: Range ): FunctionTypeNode { - var node = new FunctionTypeNode(); - node.kind = NodeKind.FUNCTIONTYPE; - node.range = range; - node.parameters = parameters; - node.returnType = returnType; - node.explicitThisType = explicitThisType; - node.isNullable = isNullable; - return node; + return new FunctionTypeNode(parameters, returnType, explicitThisType, isNullable, range); } static createOmittedType( range: Range ): NamedTypeNode { - return Node.createNamedType( - Node.createSimpleTypeName("", range), - null, - false, - range - ); + return new NamedTypeNode(Node.createSimpleTypeName("", range), null, false, range); } static createTypeParameter( @@ -189,30 +161,17 @@ export abstract class Node { defaultType: NamedTypeNode | null, range: Range ): TypeParameterNode { - var node = new TypeParameterNode(); - node.kind = NodeKind.TYPEPARAMETER; - node.range = range; - node.name = name; - node.extendsType = extendsType; - node.defaultType = defaultType; - return node; + return new TypeParameterNode(name, extendsType, defaultType, range); } static createParameter( + parameterKind: ParameterKind, name: IdentifierExpression, type: TypeNode, initializer: Expression | null, - kind: ParameterKind, range: Range ): ParameterNode { - var node = new ParameterNode(); - node.kind = NodeKind.PARAMETER; - node.range = range; - node.name = name; - node.type = type; - node.initializer = initializer; - node.parameterKind = kind; - return node; + return new ParameterNode(parameterKind, name, type, initializer, range); } // special @@ -222,63 +181,38 @@ export abstract class Node { args: Expression[] | null, range: Range ): DecoratorNode { - var node = new DecoratorNode(); - node.kind = NodeKind.DECORATOR; - node.range = range; - node.name = name; - node.arguments = args; - node.decoratorKind = DecoratorKind.fromNode(name); - return node; + return new DecoratorNode(DecoratorKind.fromNode(name), name, args, range); } static createComment( + commentKind: CommentKind, text: string, - kind: CommentKind, range: Range ): CommentNode { - var node = new CommentNode(); - node.kind = NodeKind.COMMENT; - node.range = range; - node.commentKind = kind; - node.text = text; - return node; + return new CommentNode(commentKind, text, range); } // expressions static createIdentifierExpression( - name: string, + text: string, range: Range, isQuoted: bool = false ): IdentifierExpression { - var node = new IdentifierExpression(); - node.kind = NodeKind.IDENTIFIER; - node.range = range; - node.text = name; - node.isQuoted = isQuoted; - return node; + return new IdentifierExpression(text, isQuoted, range); } static createEmptyIdentifierExpression( range: Range ): IdentifierExpression { - var node = new IdentifierExpression(); - node.kind = NodeKind.IDENTIFIER; - node.range = range; - node.text = ""; - return node; + return new IdentifierExpression("", false, range); } static createArrayLiteralExpression( - elements: (Expression | null)[], + elementExpressions: (Expression | null)[], range: Range ): ArrayLiteralExpression { - var node = new ArrayLiteralExpression(); - node.kind = NodeKind.LITERAL; - node.range = range; - node.literalKind = LiteralKind.ARRAY; - node.elementExpressions = elements; - return node; + return new ArrayLiteralExpression(elementExpressions, range); } static createAssertionExpression( @@ -287,13 +221,7 @@ export abstract class Node { toType: TypeNode | null, range: Range ): AssertionExpression { - var node = new AssertionExpression(); - node.kind = NodeKind.ASSERTION; - node.range = range; - node.assertionKind = assertionKind; - node.expression = expression; - node.toType = toType; - return node; + return new AssertionExpression(assertionKind, expression, toType, range); } static createBinaryExpression( @@ -302,104 +230,62 @@ export abstract class Node { right: Expression, range: Range ): BinaryExpression { - var node = new BinaryExpression(); - node.kind = NodeKind.BINARY; - node.range = range; - node.operator = operator; - node.left = left; - node.right = right; - return node; + return new BinaryExpression(operator, left, right, range); } static createCallExpression( expression: Expression, - typeArgs: TypeNode[] | null, + typeArguments: TypeNode[] | null, args: Expression[], range: Range ): CallExpression { - var node = new CallExpression(); - node.kind = NodeKind.CALL; - node.range = range; - node.expression = expression; - node.typeArguments = typeArgs; - node.arguments = args; - return node; + return new CallExpression(expression, typeArguments, args, range); } static createClassExpression( declaration: ClassDeclaration ): ClassExpression { - var node = new ClassExpression(); - node.kind = NodeKind.CLASS; - node.range = declaration.range; - node.declaration = declaration; - return node; + return new ClassExpression(declaration); } static createCommaExpression( expressions: Expression[], range: Range ): CommaExpression { - var node = new CommaExpression(); - node.kind = NodeKind.COMMA; - node.range = range; - node.expressions = expressions; - return node; + return new CommaExpression(expressions, range); } static createConstructorExpression( range: Range ): ConstructorExpression { - var node = new ConstructorExpression(); - node.kind = NodeKind.CONSTRUCTOR; - node.range = range; - node.text = "constructor"; - return node; + return new ConstructorExpression(range); } static createElementAccessExpression( expression: Expression, - element: Expression, + elementExpression: Expression, range: Range ): ElementAccessExpression { - var node = new ElementAccessExpression(); - node.kind = NodeKind.ELEMENTACCESS; - node.range = range; - node.expression = expression; - node.elementExpression = element; - return node; + return new ElementAccessExpression(expression, elementExpression, range); } static createFalseExpression( range: Range ): FalseExpression { - var node = new FalseExpression(); - node.kind = NodeKind.FALSE; - node.range = range; - node.text = "false"; - return node; + return new FalseExpression(range); } static createFloatLiteralExpression( value: f64, range: Range ): FloatLiteralExpression { - var node = new FloatLiteralExpression(); - node.kind = NodeKind.LITERAL; - node.literalKind = LiteralKind.FLOAT; - node.range = range; - node.value = value; - return node; + return new FloatLiteralExpression(value, range); } static createFunctionExpression( declaration: FunctionDeclaration ): FunctionExpression { - var node = new FunctionExpression(); - node.kind = NodeKind.FUNCTION; - node.range = declaration.range; - node.declaration = declaration; - return node; + return new FunctionExpression(declaration); } static createInstanceOfExpression( @@ -407,49 +293,29 @@ export abstract class Node { isType: TypeNode, range: Range ): InstanceOfExpression { - var node = new InstanceOfExpression(); - node.kind = NodeKind.INSTANCEOF; - node.range = range; - node.expression = expression; - node.isType = isType; - return node; + return new InstanceOfExpression(expression, isType, range); } static createIntegerLiteralExpression( value: i64, range: Range ): IntegerLiteralExpression { - var node = new IntegerLiteralExpression(); - node.kind = NodeKind.LITERAL; - node.literalKind = LiteralKind.INTEGER; - node.range = range; - node.value = value; - return node; + return new IntegerLiteralExpression(value, range); } static createNewExpression( typeName: TypeName, - typeArgs: TypeNode[] | null, + typeArguments: TypeNode[] | null, args: Expression[], range: Range ): NewExpression { - var node = new NewExpression(); - node.kind = NodeKind.NEW; - node.range = range; - node.typeName = typeName; - node.typeArguments = typeArgs; - node.arguments = args; - return node; + return new NewExpression(typeName, typeArguments, args, range); } static createNullExpression( range: Range ): NullExpression { - var node = new NullExpression(); - node.kind = NodeKind.NULL; - node.range = range; - node.text = "null"; - return node; + return new NullExpression(range); } static createObjectLiteralExpression( @@ -457,24 +323,14 @@ export abstract class Node { values: Expression[], range: Range ): ObjectLiteralExpression { - var node = new ObjectLiteralExpression(); - node.kind = NodeKind.LITERAL; - node.literalKind = LiteralKind.OBJECT; - node.range = range; - node.names = names; - node.values = values; - return node; + return new ObjectLiteralExpression(names, values, range); } static createParenthesizedExpression( expression: Expression, range: Range ): ParenthesizedExpression { - var node = new ParenthesizedExpression(); - node.kind = NodeKind.PARENTHESIZED; - node.range = range; - node.expression = expression; - return node; + return new ParenthesizedExpression(expression, range); } static createPropertyAccessExpression( @@ -482,26 +338,15 @@ export abstract class Node { property: IdentifierExpression, range: Range ): PropertyAccessExpression { - var node = new PropertyAccessExpression(); - node.kind = NodeKind.PROPERTYACCESS; - node.range = range; - node.expression = expression; - node.property = property; - return node; + return new PropertyAccessExpression(expression, property, range); } static createRegexpLiteralExpression( pattern: string, - flags: string, + patternFlags: string, range: Range ): RegexpLiteralExpression { - var node = new RegexpLiteralExpression(); - node.kind = NodeKind.LITERAL; - node.literalKind = LiteralKind.REGEXP; - node.range = range; - node.pattern = pattern; - node.patternFlags = flags; - return node; + return new RegexpLiteralExpression(pattern, patternFlags, range); } static createTernaryExpression( @@ -510,55 +355,32 @@ export abstract class Node { ifElse: Expression, range: Range ): TernaryExpression { - var node = new TernaryExpression(); - node.kind = NodeKind.TERNARY; - node.range = range; - node.condition = condition; - node.ifThen = ifThen; - node.ifElse = ifElse; - return node; + return new TernaryExpression(condition, ifThen, ifElse, range); } static createStringLiteralExpression( value: string, range: Range ): StringLiteralExpression { - var node = new StringLiteralExpression(); - node.kind = NodeKind.LITERAL; - node.literalKind = LiteralKind.STRING; - node.range = range; - node.value = value; - return node; + return new StringLiteralExpression(value, range); } static createSuperExpression( range: Range ): SuperExpression { - var node = new SuperExpression(); - node.kind = NodeKind.SUPER; - node.range = range; - node.text = "super"; - return node; + return new SuperExpression(range); } static createThisExpression( range: Range ): ThisExpression { - var node = new ThisExpression(); - node.kind = NodeKind.THIS; - node.range = range; - node.text = "this"; - return node; + return new ThisExpression(range); } static createTrueExpression( range: Range ): TrueExpression { - var node = new TrueExpression(); - node.kind = NodeKind.TRUE; - node.range = range; - node.text = "true"; - return node; + return new TrueExpression(range); } static createUnaryPostfixExpression( @@ -566,12 +388,7 @@ export abstract class Node { operand: Expression, range: Range ): UnaryPostfixExpression { - var node = new UnaryPostfixExpression(); - node.kind = NodeKind.UNARYPOSTFIX; - node.range = range; - node.operator = operator; - node.operand = operand; - return node; + return new UnaryPostfixExpression(operator, operand, range); } static createUnaryPrefixExpression( @@ -579,12 +396,7 @@ export abstract class Node { operand: Expression, range: Range ): UnaryPrefixExpression { - var node = new UnaryPrefixExpression(); - node.kind = NodeKind.UNARYPREFIX; - node.range = range; - node.operator = operator; - node.operand = operand; - return node; + return new UnaryPrefixExpression(operator, operand, range); } // statements @@ -593,56 +405,34 @@ export abstract class Node { statements: Statement[], range: Range ): BlockStatement { - var node = new BlockStatement(); - node.kind = NodeKind.BLOCK; - node.range = range; - node.statements = statements; - return node; + return new BlockStatement(statements, range); } static createBreakStatement( label: IdentifierExpression | null, range: Range ): BreakStatement { - var node = new BreakStatement(); - node.kind = NodeKind.BREAK; - node.range = range; - node.label = label; - return node; + return new BreakStatement(label, range); } static createClassDeclaration( - identifier: IdentifierExpression, - typeParameters: TypeParameterNode[] | null, - extendsType: NamedTypeNode | null, // can't be a function - implementsTypes: NamedTypeNode[] | null, // can't be functions - members: DeclarationStatement[], + name: IdentifierExpression, decorators: DecoratorNode[] | null, flags: CommonFlags, + typeParameters: TypeParameterNode[] | null, + extendsType: NamedTypeNode | null, + implementsTypes: NamedTypeNode[] | null, + members: DeclarationStatement[], range: Range ): ClassDeclaration { - var node = new ClassDeclaration(); - node.kind = NodeKind.CLASSDECLARATION; - node.range = range; - node.flags = flags; - node.name = identifier; - node.typeParameters = typeParameters; - node.extendsType = extendsType; - node.implementsTypes = implementsTypes; - node.members = members; - node.decorators = decorators; - return node; + return new ClassDeclaration(name, decorators, flags, typeParameters, extendsType, implementsTypes, members, range); } static createContinueStatement( label: IdentifierExpression | null, range: Range ): ContinueStatement { - var node = new ContinueStatement(); - node.kind = NodeKind.CONTINUE; - node.range = range; - node.label = label; - return node; + return new ContinueStatement(label, range); } static createDoStatement( @@ -650,53 +440,32 @@ export abstract class Node { condition: Expression, range: Range ): DoStatement { - var node = new DoStatement(); - node.kind = NodeKind.DO; - node.range = range; - node.statement = statement; - node.condition = condition; - return node; + return new DoStatement(statement, condition, range); } static createEmptyStatement( range: Range ): EmptyStatement { - var node = new EmptyStatement(); - node.kind = NodeKind.EMPTY; - node.range = range; - return node; + return new EmptyStatement(range); } static createEnumDeclaration( name: IdentifierExpression, - members: EnumValueDeclaration[], decorators: DecoratorNode[] | null, flags: CommonFlags, + values: EnumValueDeclaration[], range: Range ): EnumDeclaration { - var node = new EnumDeclaration(); - node.kind = NodeKind.ENUMDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.values = members; - node.decorators = decorators; - return node; + return new EnumDeclaration(name, decorators, flags, values, range); } static createEnumValueDeclaration( name: IdentifierExpression, - initializer: Expression | null, flags: CommonFlags, + initializer: Expression | null, range: Range ): EnumValueDeclaration { - var node = new EnumValueDeclaration(); - node.kind = NodeKind.ENUMVALUEDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.initializer = initializer; - return node; + return new EnumValueDeclaration(name, flags, initializer, range); } static createExportStatement( @@ -705,35 +474,14 @@ export abstract class Node { isDeclare: bool, range: Range ): ExportStatement { - var node = new ExportStatement(); - node.kind = NodeKind.EXPORT; - node.range = range; - node.members = members; - node.path = path; - if (path) { - let normalizedPath = normalizePath(path.value); - if (path.value.startsWith(".")) { // relative - normalizedPath = resolvePath(normalizedPath, range.source.internalPath); - } else { // absolute - if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath; - } - node.internalPath = normalizedPath; - } else { - node.internalPath = null; - } - node.isDeclare = isDeclare; - return node; + return new ExportStatement(members, path, isDeclare, range); } static createExportDefaultStatement( declaration: DeclarationStatement, range: Range ): ExportDefaultStatement { - var node = new ExportDefaultStatement(); - node.kind = NodeKind.EXPORTDEFAULT; - node.declaration = declaration; - node.range = range; - return node; + return new ExportDefaultStatement(declaration, range); } static createExportImportStatement( @@ -741,36 +489,22 @@ export abstract class Node { externalName: IdentifierExpression, range: Range ): ExportImportStatement { - var node = new ExportImportStatement(); - node.kind = NodeKind.EXPORTIMPORT; - node.range = range; - node.name = name; - node.externalName = externalName; - return node; + return new ExportImportStatement(name, externalName, range); } static createExportMember( - name: IdentifierExpression, - externalName: IdentifierExpression | null, + localName: IdentifierExpression, + exportedName: IdentifierExpression | null, range: Range ): ExportMember { - var node = new ExportMember(); - node.kind = NodeKind.EXPORTMEMBER; - node.range = range; - node.localName = name; - if (!externalName) externalName = name; - node.exportedName = externalName; - return node; + if (!exportedName) exportedName = localName; + return new ExportMember(localName, exportedName, range); } static createExpressionStatement( expression: Expression ): ExpressionStatement { - var node = new ExpressionStatement(); - node.kind = NodeKind.EXPRESSION; - node.range = expression.range; - node.expression = expression; - return node; + return new ExpressionStatement(expression); } static createIfStatement( @@ -779,55 +513,23 @@ export abstract class Node { ifFalse: Statement | null, range: Range ): IfStatement { - var node = new IfStatement(); - node.kind = NodeKind.IF; - node.range = range; - node.condition = condition; - node.ifTrue = ifTrue; - node.ifFalse = ifFalse; - return node; + return new IfStatement(condition, ifTrue, ifFalse, range); } static createImportStatement( - decls: ImportDeclaration[] | null, + declarations: ImportDeclaration[] | null, path: StringLiteralExpression, range: Range ): ImportStatement { - var node = new ImportStatement(); - node.kind = NodeKind.IMPORT; - node.range = range; - node.declarations = decls; - node.namespaceName = null; - node.path = path; - var normalizedPath = normalizePath(path.value); - if (path.value.startsWith(".")) { // relative in project - normalizedPath = resolvePath(normalizedPath, range.source.internalPath); - } else { // absolute in library - if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath; - } - node.internalPath = normalizedPath; - return node; + return new ImportStatement(declarations, null, path, range); } - static createImportStatementWithWildcard( - identifier: IdentifierExpression, + static createWildcardImportStatement( + namespaceName: IdentifierExpression, path: StringLiteralExpression, range: Range ): ImportStatement { - var node = new ImportStatement(); - node.kind = NodeKind.IMPORT; - node.range = range; - node.declarations = null; - node.namespaceName = identifier; - node.path = path; - var normalizedPath = normalizePath(path.value); - if (path.value.startsWith(".")) { - normalizedPath = resolvePath(normalizedPath, range.source.internalPath); - } else { - if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath; - } - node.internalPath = normalizedPath; - return node; + return new ImportStatement(null, namespaceName, path, range); } static createImportDeclaration( @@ -835,53 +537,32 @@ export abstract class Node { name: IdentifierExpression | null, range: Range ): ImportDeclaration { - var node = new ImportDeclaration(); - node.kind = NodeKind.IMPORTDECLARATION; - node.range = range; - node.foreignName = foreignName; if (!name) name = foreignName; - node.name = name; - return node; + return new ImportDeclaration(name, foreignName, range); } static createInterfaceDeclaration( name: IdentifierExpression, - typeParameters: TypeParameterNode[] | null, - extendsType: NamedTypeNode | null, // can't be a function - members: DeclarationStatement[], decorators: DecoratorNode[] | null, flags: CommonFlags, + typeParameters: TypeParameterNode[] | null, + extendsType: NamedTypeNode | null, + implementsTypes: NamedTypeNode[] | null, + members: DeclarationStatement[], range: Range ): InterfaceDeclaration { - var node = new InterfaceDeclaration(); - node.kind = NodeKind.INTERFACEDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.typeParameters = typeParameters; - node.extendsType = extendsType; - node.members = members; - node.decorators = decorators; - return node; + return new InterfaceDeclaration(name, decorators, flags, typeParameters, extendsType, implementsTypes, members, range); } static createFieldDeclaration( name: IdentifierExpression, - type: TypeNode | null, - initializer: Expression | null, decorators: DecoratorNode[] | null, flags: CommonFlags, + type: TypeNode | null, + initializer: Expression | null, range: Range ): FieldDeclaration { - var node = new FieldDeclaration(); - node.kind = NodeKind.FIELDDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.type = type; - node.initializer = initializer; - node.decorators = decorators; - return node; + return new FieldDeclaration(name, decorators, flags, type, initializer, -1, range); } static createForStatement( @@ -891,14 +572,7 @@ export abstract class Node { statement: Statement, range: Range ): ForStatement { - var node = new ForStatement(); - node.kind = NodeKind.FOR; - node.range = range; - node.initializer = initializer; - node.condition = condition; - node.incrementor = incrementor; - node.statement = statement; - return node; + return new ForStatement(initializer, condition, incrementor, statement, range); } static createForOfStatement( @@ -907,100 +581,58 @@ export abstract class Node { statement: Statement, range: Range ): ForOfStatement { - var node = new ForOfStatement(); - node.kind = NodeKind.FOROF; - node.range = range; - node.variable = variable; - node.iterable = iterable; - node.statement = statement; - return node; + return new ForOfStatement(variable, iterable, statement, range); } static createFunctionDeclaration( name: IdentifierExpression, + decorators: DecoratorNode[] | null, + flags: CommonFlags, typeParameters: TypeParameterNode[] | null, signature: FunctionTypeNode, body: Statement | null, - decorators: DecoratorNode[] | null, - flags: CommonFlags, arrowKind: ArrowKind, range: Range ): FunctionDeclaration { - var node = new FunctionDeclaration(); - node.kind = NodeKind.FUNCTIONDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.typeParameters = typeParameters; - node.signature = signature; - node.body = body; - node.decorators = decorators; - node.arrowKind = arrowKind; - return node; - } - - static createIndexSignatureDeclaration( + return new FunctionDeclaration(name, decorators, flags, typeParameters, signature, body, arrowKind, range); + } + + static createIndexSignature( keyType: NamedTypeNode, valueType: TypeNode, flags: CommonFlags, range: Range - ): IndexSignatureDeclaration { - var node = new IndexSignatureDeclaration(); - node.kind = NodeKind.INDEXSIGNATUREDECLARATION; - node.range = range; - node.keyType = keyType; - node.valueType = valueType; - node.flags = flags; - return node; + ): IndexSignatureNode { + return new IndexSignatureNode(keyType, valueType, flags, range); } static createMethodDeclaration( name: IdentifierExpression, + decorators: DecoratorNode[] | null, + flags: CommonFlags, typeParameters: TypeParameterNode[] | null, signature: FunctionTypeNode, body: Statement | null, - decorators: DecoratorNode[] | null, - flags: CommonFlags, range: Range ): MethodDeclaration { - var node = new MethodDeclaration(); - node.kind = NodeKind.METHODDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.typeParameters = typeParameters; - node.signature = signature; - node.body = body; - node.decorators = decorators; - return node; + return new MethodDeclaration(name, decorators, flags, typeParameters, signature, body, range); } static createNamespaceDeclaration( name: IdentifierExpression, - members: Statement[], decorators: DecoratorNode[] | null, flags: CommonFlags, + members: Statement[], range: Range ): NamespaceDeclaration { - var node = new NamespaceDeclaration(); - node.kind = NodeKind.NAMESPACEDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.members = members; - node.decorators = decorators; - return node; + return new NamespaceDeclaration(name, decorators, flags, members, range); } static createReturnStatement( value: Expression | null, range: Range ): ReturnStatement { - var node = new ReturnStatement(); - node.kind = NodeKind.RETURN; - node.range = range; - node.value = value; - return node; + return new ReturnStatement(value, range); } static createSwitchStatement( @@ -1008,12 +640,7 @@ export abstract class Node { cases: SwitchCase[], range: Range ): SwitchStatement { - var node = new SwitchStatement(); - node.kind = NodeKind.SWITCH; - node.range = range; - node.condition = condition; - node.cases = cases; - return node; + return new SwitchStatement(condition, cases, range); } static createSwitchCase( @@ -1021,23 +648,14 @@ export abstract class Node { statements: Statement[], range: Range ): SwitchCase { - var node = new SwitchCase(); - node.kind = NodeKind.SWITCHCASE; - node.range = range; - node.label = label; - node.statements = statements; - return node; + return new SwitchCase(label, statements, range); } static createThrowStatement( value: Expression, range: Range ): ThrowStatement { - var node = new ThrowStatement(); - node.kind = NodeKind.THROW; - node.range = range; - node.value = value; - return node; + return new ThrowStatement(value, range); } static createTryStatement( @@ -1047,76 +665,44 @@ export abstract class Node { finallyStatements: Statement[] | null, range: Range ): TryStatement { - var node = new TryStatement(); - node.kind = NodeKind.TRY; - node.range = range; - node.statements = statements; - node.catchVariable = catchVariable; - node.catchStatements = catchStatements; - node.finallyStatements = finallyStatements; - return node; + return new TryStatement(statements, catchVariable, catchStatements, finallyStatements, range); } static createTypeDeclaration( name: IdentifierExpression, - typeParameters: TypeParameterNode[] | null, - alias: TypeNode, decorators: DecoratorNode[] | null, flags: CommonFlags, + typeParameters: TypeParameterNode[] | null, + type: TypeNode, range: Range ): TypeDeclaration { - var node = new TypeDeclaration(); - node.kind = NodeKind.TYPEDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.typeParameters = typeParameters; - node.type = alias; - node.decorators = decorators; - return node; + return new TypeDeclaration(name, decorators, flags, typeParameters, type, range); } static createVariableStatement( - declarations: VariableDeclaration[], decorators: DecoratorNode[] | null, + declarations: VariableDeclaration[], range: Range ): VariableStatement { - var node = new VariableStatement(); - node.kind = NodeKind.VARIABLE; - node.range = range; - node.declarations = declarations; - node.decorators = decorators; - return node; + return new VariableStatement(decorators, declarations, range); } static createVariableDeclaration( name: IdentifierExpression, - type: TypeNode | null, - initializer: Expression | null, decorators: DecoratorNode[] | null, flags: CommonFlags, + type: TypeNode | null, + initializer: Expression | null, range: Range ): VariableDeclaration { - var node = new VariableDeclaration(); - node.kind = NodeKind.VARIABLEDECLARATION; - node.range = range; - node.flags = flags; - node.name = name; - node.type = type; - node.initializer = initializer; - node.decorators = decorators; // inherited - return node; + return new VariableDeclaration(name, decorators, flags, type, initializer, range); } static createVoidStatement( expression: Expression, range: Range ): VoidStatement { - var node = new VoidStatement(); - node.kind = NodeKind.VOID; - node.range = range; - node.expression = expression; - return node; + return new VoidStatement(expression, range); } static createWhileStatement( @@ -1124,12 +710,7 @@ export abstract class Node { statement: Statement, range: Range ): WhileStatement { - var node = new WhileStatement(); - node.kind = NodeKind.WHILE; - node.range = range; - node.condition = condition; - node.statement = statement; - return node; + return new WhileStatement(condition, statement, range); } /** Tests if this node is a literal of the specified kind. */ @@ -1181,10 +762,16 @@ export abstract class Node { // types export abstract class TypeNode extends Node { - // kind varies - - /** Whether nullable or not. */ - isNullable: bool; + constructor( + /** Kind of the type node. */ + kind: NodeKind, + /** Whether nullable or not. */ + public isNullable: bool, + /** Source range. */ + range: Range + ) { + super(kind, range); + } /** Tests if this type has a generic component matching one of the given type parameters. */ hasGenericComponent(typeParameterNodes: TypeParameterNode[]): bool { @@ -1221,19 +808,34 @@ export abstract class TypeNode extends Node { /** Represents a type name. */ export class TypeName extends Node { - /** Identifier of this part. */ - identifier: IdentifierExpression; - /** Next part of the type name or `null` if this is the last part. */ - next: TypeName | null; + constructor( + /** Identifier of this part. */ + public identifier: IdentifierExpression, + /** Next part of the type name or `null` if this is the last part. */ + public next: TypeName | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.TYPENAME, range); + } } /** Represents a named type. */ export class NamedTypeNode extends TypeNode { - /** Type name. */ - name: TypeName; - /** Type argument references. */ - typeArguments: TypeNode[] | null; + constructor( + /** Type name. */ + public name: TypeName, + /** Type argument references. */ + public typeArguments: TypeNode[] | null, + /** Whether nullable or not. */ + isNullable: bool, + /** Source range. */ + range: Range + ) { + super(NodeKind.NAMEDTYPE, isNullable, range); + } + /** Checks if this type node has type arguments. */ get hasTypeArguments(): bool { var typeArguments = this.typeArguments; return typeArguments !== null && typeArguments.length > 0; @@ -1242,22 +844,36 @@ export class NamedTypeNode extends TypeNode { /** Represents a function type. */ export class FunctionTypeNode extends TypeNode { - /** Accepted parameters. */ - parameters: ParameterNode[]; - /** Return type. */ - returnType: TypeNode; - /** Explicitly provided this type, if any. */ - explicitThisType: NamedTypeNode | null; // can't be a function + constructor( + /** Function parameters. */ + public parameters: ParameterNode[], + /** Return type. */ + public returnType: TypeNode, + /** Explicitly provided this type, if any. */ + public explicitThisType: NamedTypeNode | null, // can't be a function + /** Whether nullable or not. */ + isNullable: bool, + /** Source range. */ + range: Range + ) { + super(NodeKind.FUNCTIONTYPE, isNullable, range); + } } /** Represents a type parameter. */ export class TypeParameterNode extends Node { - /** Identifier reference. */ - name: IdentifierExpression; - /** Extended type reference, if any. */ - extendsType: NamedTypeNode | null; // can't be a function - /** Default type if omitted, if any. */ - defaultType: NamedTypeNode | null; // can't be a function + constructor( + /** Identifier reference. */ + public name: IdentifierExpression, + /** Extended type reference, if any. */ + public extendsType: NamedTypeNode | null, // can't be a function + /** Default type if omitted, if any. */ + public defaultType: NamedTypeNode | null, // can't be a function + /** Source range. */ + range: Range + ) { + super(NodeKind.TYPEPARAMETER, range); + } } /** Represents the kind of a parameter. */ @@ -1272,14 +888,21 @@ export enum ParameterKind { /** Represents a function parameter. */ export class ParameterNode extends Node { - /** Parameter kind. */ - parameterKind: ParameterKind; - /** Parameter name. */ - name: IdentifierExpression; - /** Parameter type. */ - type: TypeNode; - /** Initializer expression, if present. */ - initializer: Expression | null; + constructor( + /** Parameter kind. */ + public parameterKind: ParameterKind, + /** Parameter name. */ + public name: IdentifierExpression, + /** Parameter type. */ + public type: TypeNode, + /** Initializer expression, if any. */ + public initializer: Expression | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.PARAMETER, range); + } + /** Implicit field declaration, if applicable. */ implicitFieldDeclaration: FieldDeclaration | null = null; /** Common flags indicating specific traits. */ @@ -1383,19 +1006,25 @@ export namespace DecoratorKind { /** Represents a decorator. */ export class DecoratorNode extends Node { - /** Built-in kind, if applicable. */ - decoratorKind: DecoratorKind; - /** Name expression. */ - name: Expression; - /** Argument expressions. */ - arguments: Expression[] | null; + constructor( + /** Built-in decorator kind, or custom. */ + public decoratorKind: DecoratorKind, + /** Name expression. */ + public name: Expression, + /** Argument expressions. */ + public args: Expression[] | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.DECORATOR, range); + } } /** Comment kinds. */ export enum CommentKind { /** Line comment. */ LINE, - /** Triple-slash comment. */ + /** Triple-slash line comment. */ TRIPLE, /** Block comment. */ BLOCK @@ -1403,10 +1032,16 @@ export enum CommentKind { /** Represents a comment. */ export class CommentNode extends Node { - /** Comment kind. */ - commentKind: CommentKind; - /** Comment text. */ - text: string; + constructor( + /** Comment kind. */ + public commentKind: CommentKind, + /** Comment text. */ + public text: string, + /** Source range. */ + range: Range + ) { + super(NodeKind.COMMENT, range); + } } // expressions @@ -1416,10 +1051,16 @@ export abstract class Expression extends Node { } /** Represents an identifier expression. */ export class IdentifierExpression extends Expression { - /** Textual name. */ - text: string; - /** Whether quoted or not. */ - isQuoted: bool; + constructor( + /** Textual name. */ + public text: string, + /** Whether quoted or not. */ + public isQuoted: bool, + /** Source range. */ + range: Range + ) { + super(NodeKind.IDENTIFIER, range); + } } /** Indicates the kind of a literal. */ @@ -1434,52 +1075,86 @@ export enum LiteralKind { /** Base class of all literal expressions. */ export abstract class LiteralExpression extends Expression { - /** Specific literal kind. */ - literalKind: LiteralKind; + constructor( + /** Specific literal kind. */ + public literalKind: LiteralKind, + /** Source range. */ + range: Range + ) { + super(NodeKind.LITERAL, range); + } } /** Represents an `[]` literal expression. */ export class ArrayLiteralExpression extends LiteralExpression { - /** Nested element expressions. */ - elementExpressions: (Expression | null)[]; + constructor( + /** Nested element expressions. */ + public elementExpressions: (Expression | null)[], + /** Source range. */ + range: Range + ) { + super(LiteralKind.ARRAY, range); + } } /** Indicates the kind of an assertion. */ export enum AssertionKind { + /** A prefix assertion, i.e. `expr`. */ PREFIX, + /** An as assertion, i.e. `expr as T`. */ AS, + /** A non-null assertion, i.e. `!expr`. */ NONNULL, + /** A const assertion, i.e. `expr as const`. */ CONST } /** Represents an assertion expression. */ export class AssertionExpression extends Expression { - /** Specific kind of this assertion. */ - assertionKind: AssertionKind; - /** Expression being asserted. */ - expression: Expression; - /** Target type. */ - toType: TypeNode | null; + constructor( + /** Specific kind of this assertion. */ + public assertionKind: AssertionKind, + /** Expression being asserted. */ + public expression: Expression, + /** Target type, if applicable. */ + public toType: TypeNode | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.ASSERTION, range); + } } /** Represents a binary expression. */ export class BinaryExpression extends Expression { - /** Operator token. */ - operator: Token; - /** Left-hand side expression */ - left: Expression; - /** Right-hand side expression. */ - right: Expression; + constructor( + /** Operator token. */ + public operator: Token, + /** Left-hand side expression */ + public left: Expression, + /** Right-hand side expression. */ + public right: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.BINARY, range); + } } /** Represents a call expression. */ export class CallExpression extends Expression { - /** Called expression. Usually an identifier or property access expression. */ - expression: Expression; - /** Provided type arguments. */ - typeArguments: TypeNode[] | null; - /** Provided arguments. */ - arguments: Expression[]; + constructor( + /** Called expression. Usually an identifier or property access expression. */ + public expression: Expression, + /** Provided type arguments. */ + public typeArguments: TypeNode[] | null, + /** Provided arguments. */ + public args: Expression[], + /** Source range. */ + range: Range + ) { + super(NodeKind.CALL, range); + } /** Gets the type arguments range for reporting. */ get typeArgumentsRange(): Range { @@ -1495,7 +1170,7 @@ export class CallExpression extends Expression { /** Gets the arguments range for reporting. */ get argumentsRange(): Range { - var args = this.arguments; + var args = this.args; var numArguments = args.length; if (numArguments) { return Range.join(args[0].range, args[numArguments - 1].range); @@ -1506,62 +1181,113 @@ export class CallExpression extends Expression { /** Represents a class expression using the 'class' keyword. */ export class ClassExpression extends Expression { - /** Inline class declaration. */ - declaration: ClassDeclaration; + constructor( + /** Inline class declaration. */ + public declaration: ClassDeclaration + ) { + super(NodeKind.CLASS, declaration.range); + } } /** Represents a comma expression composed of multiple expressions. */ export class CommaExpression extends Expression { - /** Sequential expressions. */ - expressions: Expression[]; + constructor( + /** Sequential expressions. */ + public expressions: Expression[], + /** Source range. */ + range: Range + ) { + super(NodeKind.COMMA, range); + } } /** Represents a `constructor` expression. */ export class ConstructorExpression extends IdentifierExpression { + constructor( + /** Source range. */ + range: Range + ) { + super("constructor", false, range); + this.kind = NodeKind.CONSTRUCTOR; + } } /** Represents an element access expression, e.g., array access. */ export class ElementAccessExpression extends Expression { - /** Expression being accessed. */ - expression: Expression; - /** Element of the expression being accessed. */ - elementExpression: Expression; + constructor( + /** Expression being accessed. */ + public expression: Expression, + /** Element of the expression being accessed. */ + public elementExpression: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.ELEMENTACCESS, range); + } } /** Represents a float literal expression. */ export class FloatLiteralExpression extends LiteralExpression { - /** Float value. */ - value: f64; + constructor( + /** Float value. */ + public value: f64, + /** Source range. */ + range: Range + ) { + super(LiteralKind.FLOAT, range); + } } /** Represents a function expression using the 'function' keyword. */ export class FunctionExpression extends Expression { - /** Inline function declaration. */ - declaration: FunctionDeclaration; + constructor( + /** Inline function declaration. */ + public declaration: FunctionDeclaration + ) { + super(NodeKind.FUNCTION, declaration.range); + } } /** Represents an `instanceof` expression. */ export class InstanceOfExpression extends Expression { - /** Expression being asserted. */ - expression: Expression; - /** Type to test for. */ - isType: TypeNode; + constructor( + /** Expression being asserted. */ + public expression: Expression, + /** Type to test for. */ + public isType: TypeNode, + /** Source range. */ + range: Range + ) { + super(NodeKind.INSTANCEOF, range); + } } /** Represents an integer literal expression. */ export class IntegerLiteralExpression extends LiteralExpression { - /** Integer value. */ - value: i64; + constructor( + /** Integer value. */ + public value: i64, + /** Source range. */ + range: Range + ) { + super(LiteralKind.INTEGER, range); + } } /** Represents a `new` expression. Like a call but with its own kind. */ export class NewExpression extends Expression { - /** Type being constructed. */ - typeName: TypeName; - /** Provided type arguments. */ - typeArguments: TypeNode[] | null; - /** Provided arguments. */ - arguments: Expression[]; + constructor( + /** Type being constructed. */ + public typeName: TypeName, + /** Provided type arguments. */ + public typeArguments: TypeNode[] | null, + /** Provided arguments. */ + public args: Expression[], + /** Source range. */ + range: Range + ) { + super(NodeKind.NEW, range); + } /** Gets the type arguments range for reporting. */ get typeArgumentsRange(): Range { @@ -1575,7 +1301,7 @@ export class NewExpression extends Expression { /** Gets the arguments range for reporting. */ get argumentsRange(): Range { - var args = this.arguments; + var args = this.args; var numArguments = args.length; if (numArguments) { return Range.join(args[0].range, args[numArguments - 1].range); @@ -1586,84 +1312,183 @@ export class NewExpression extends Expression { /** Represents a `null` expression. */ export class NullExpression extends IdentifierExpression { + constructor( + /** Source range. */ + range: Range + ) { + super("null", false, range); + this.kind = NodeKind.NULL; + } } /** Represents an object literal expression. */ export class ObjectLiteralExpression extends LiteralExpression { - /** Field names. */ - names: IdentifierExpression[]; - /** Field values. */ - values: Expression[]; + constructor( + /** Field names. */ + public names: IdentifierExpression[], + /** Field values. */ + public values: Expression[], + /** Source range. */ + range: Range + ) { + super(LiteralKind.OBJECT, range); + } } /** Represents a parenthesized expression. */ export class ParenthesizedExpression extends Expression { - /** Expression in parenthesis. */ - expression: Expression; + constructor( + /** Expression in parenthesis. */ + public expression: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.PARENTHESIZED, range); + } } /** Represents a property access expression. */ export class PropertyAccessExpression extends Expression { - /** Expression being accessed. */ - expression: Expression; - /** Property of the expression being accessed. */ - property: IdentifierExpression; + constructor( + /** Expression being accessed. */ + public expression: Expression, + /** Property of the expression being accessed. */ + public property: IdentifierExpression, + /** Source range. */ + range: Range + ) { + super(NodeKind.PROPERTYACCESS, range); + } } /** Represents a regular expression literal expression. */ export class RegexpLiteralExpression extends LiteralExpression { - /** Regular expression pattern. */ - pattern: string; - /** Regular expression flags. */ - patternFlags: string; + constructor( + /** Regular expression pattern. */ + public pattern: string, + /** Regular expression flags. */ + public patternFlags: string, + /** Source range. */ + range: Range + ) { + super(LiteralKind.REGEXP, range); + } } /** Represents a ternary expression, i.e., short if notation. */ export class TernaryExpression extends Expression { - /** Condition expression. */ - condition: Expression; - /** Expression executed when condition is `true`. */ - ifThen: Expression; - /** Expression executed when condition is `false`. */ - ifElse: Expression; + constructor( + /** Condition expression. */ + public condition: Expression, + /** Expression executed when condition is `true`. */ + public ifThen: Expression, + /** Expression executed when condition is `false`. */ + public ifElse: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.TERNARY, range); + } } /** Represents a string literal expression. */ export class StringLiteralExpression extends LiteralExpression { - /** String value without quotes. */ - value: string; + constructor( + /** String value without quotes. */ + public value: string, + /** Source range. */ + range: Range + ) { + super(LiteralKind.STRING, range); + } } /** Represents a `super` expression. */ export class SuperExpression extends IdentifierExpression { + constructor( + /** Source range. */ + range: Range + ) { + super("super", false, range); + this.kind = NodeKind.SUPER; + } } /** Represents a `this` expression. */ export class ThisExpression extends IdentifierExpression { + constructor( + /** Source range. */ + range: Range + ) { + super("this", false, range); + this.kind = NodeKind.THIS; + } } /** Represents a `true` expression. */ export class TrueExpression extends IdentifierExpression { + constructor( + /** Source range. */ + range: Range + ) { + super("true", false, range); + this.kind = NodeKind.TRUE; + } } /** Represents a `false` expression. */ export class FalseExpression extends IdentifierExpression { + constructor( + /** Source range. */ + range: Range + ) { + super("false", false, range); + this.kind = NodeKind.FALSE; + } } /** Base class of all unary expressions. */ export abstract class UnaryExpression extends Expression { - /** Operator token. */ - operator: Token; - /** Operand expression. */ - operand: Expression; + constructor( + /** Unary expression kind. */ + kind: NodeKind, + /** Operator token. */ + public operator: Token, + /** Operand expression. */ + public operand: Expression, + /** Source range. */ + range: Range + ) { + super(kind, range); + } } /** Represents a unary postfix expression, e.g. a postfix increment. */ export class UnaryPostfixExpression extends UnaryExpression { + constructor( + /** Operator token. */ + operator: Token, + /** Operand expression. */ + operand: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.UNARYPOSTFIX, operator, operand, range); + } } /** Represents a unary prefix expression, e.g. a negation. */ export class UnaryPrefixExpression extends UnaryExpression { + constructor( + /** Operator token. */ + operator: Token, + /** Operand expression. */ + operand: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.UNARYPREFIX, operator, operand, range); + } } // statements @@ -1685,38 +1510,33 @@ export enum SourceKind { /** A top-level source node. */ export class Source extends Node { - /** Source kind. */ - sourceKind: SourceKind; - /** Normalized path with file extension. */ - normalizedPath: string; + constructor( + /** Source kind. */ + public sourceKind: SourceKind, + /** Normalized path with file extension. */ + public normalizedPath: string, + /** Full source text. */ + public text: string + ) { + super(NodeKind.SOURCE, changetype(0)); // ¯\(ツ)/¯ + this.range = new Range(this, 0, text.length); + var internalPath = mangleInternalPath(normalizedPath); + this.internalPath = internalPath; + var pos = internalPath.lastIndexOf(PATH_DELIMITER); + this.simplePath = pos >= 0 ? internalPath.substring(pos + 1) : internalPath; + } + /** Path used internally. */ internalPath: string; /** Simple path (last part without extension). */ simplePath: string; /** Contained statements. */ - statements: Statement[]; - /** Full source text. */ - text: string; + statements: Statement[] = new Array(); /** Source map index. */ debugInfoIndex: i32 = -1; /** Re-exported sources. */ exportPaths: string[] | null = null; - /** Constructs a new source node. */ - constructor(normalizedPath: string, text: string, kind: SourceKind) { - super(); - this.kind = NodeKind.SOURCE; - this.sourceKind = kind; - this.normalizedPath = normalizedPath; - var internalPath = mangleInternalPath(this.normalizedPath); - this.internalPath = internalPath; - var pos = internalPath.lastIndexOf(PATH_DELIMITER); - this.simplePath = pos >= 0 ? internalPath.substring(pos + 1) : internalPath; - this.statements = new Array(); - this.range = new Range(this, 0, text.length); - this.text = text; - } - /** Checks if this source represents native code. */ get isNative(): bool { return this.internalPath == LIBRARY_SUBST; @@ -1771,12 +1591,20 @@ export class Source extends Node { /** Base class of all declaration statements. */ export abstract class DeclarationStatement extends Statement { - /** Simple name being declared. */ - name: IdentifierExpression; - /** Array of decorators. */ - decorators: DecoratorNode[] | null = null; - /** Common flags indicating specific traits. */ - flags: CommonFlags = CommonFlags.NONE; + constructor( + /** Declaration node kind. */ + kind: NodeKind, + /** Simple name being declared. */ + public name: IdentifierExpression, + /** Array of decorators, if any. */ + public decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + public flags: CommonFlags, + /** Source range. */ + range: Range + ) { + super(kind, range); + } /** Tests if this node has the specified flag or flags. */ is(flag: CommonFlags): bool { return (this.flags & flag) == flag; } @@ -1786,44 +1614,93 @@ export abstract class DeclarationStatement extends Statement { set(flag: CommonFlags): void { this.flags |= flag; } } -/** Represents an index signature declaration. */ -export class IndexSignatureDeclaration extends DeclarationStatement { - /** Key type. */ - keyType: NamedTypeNode; - /** Value type. */ - valueType: TypeNode; +/** Represents an index signature. */ +export class IndexSignatureNode extends Node { + constructor( + /** Key type. */ + public keyType: NamedTypeNode, + /** Value type. */ + public valueType: TypeNode, + /** Common flags indicating specific traits. */ + public flags: CommonFlags, + /** Source range. */ + range: Range + ) { + super(NodeKind.INDEXSIGNATURE, range); + } } /** Base class of all variable-like declaration statements. */ export abstract class VariableLikeDeclarationStatement extends DeclarationStatement { - /** Variable type. */ - type: TypeNode | null; - /** Variable initializer. */ - initializer: Expression | null; + constructor( + /** Variable-like declaration node kind. */ + kind: NodeKind, + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Annotated type node, if any. */ + public type: TypeNode | null, + /** Initializer expression, if any. */ + public initializer: Expression | null, + /** Source range. */ + range: Range + ) { + super(kind, name, decorators, flags, range); + } } /** Represents a block statement. */ export class BlockStatement extends Statement { - /** Contained statements. */ - statements: Statement[]; + constructor( + /** Contained statements. */ + public statements: Statement[], + /** Source range. */ + range: Range + ) { + super(NodeKind.BLOCK, range); + } } /** Represents a `break` statement. */ export class BreakStatement extends Statement { - /** Target label, if applicable. */ - label: IdentifierExpression | null; + constructor( + /** Target label, if any. */ + public label: IdentifierExpression | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.BREAK, range); + } } /** Represents a `class` declaration. */ export class ClassDeclaration extends DeclarationStatement { - /** Accepted type parameters. */ - typeParameters: TypeParameterNode[] | null; - /** Base class type being extended, if any. */ - extendsType: NamedTypeNode | null; // can't be a function - /** Interface types being implemented, if any. */ - implementsTypes: NamedTypeNode[] | null; // can't be functions - /** Class member declarations. */ - members: DeclarationStatement[]; + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Accepted type parameters. */ + public typeParameters: TypeParameterNode[] | null, + /** Base class type being extended, if any. */ + public extendsType: NamedTypeNode | null, // can't be a function + /** Interface types being implemented, if any. */ + public implementsTypes: NamedTypeNode[] | null, // can't be functions + /** Class member declarations. */ + public members: DeclarationStatement[], + /** Source range. */ + range: Range + ) { + super(NodeKind.CLASSDECLARATION, name, decorators, flags, range); + } + + /** Index signature, if present. */ + indexSignature: IndexSignatureNode | null = null; get isGeneric(): bool { var typeParameters = this.typeParameters; @@ -1833,98 +1710,208 @@ export class ClassDeclaration extends DeclarationStatement { /** Represents a `continue` statement. */ export class ContinueStatement extends Statement { - /** Target label, if applicable. */ - label: IdentifierExpression | null; + constructor( + /** Target label, if applicable. */ + public label: IdentifierExpression | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.CONTINUE, range); + } } /** Represents a `do` statement. */ export class DoStatement extends Statement { - /** Statement being looped over. */ - statement: Statement; - /** Condition when to repeat. */ - condition: Expression; + constructor( + /** Statement being looped over. */ + public statement: Statement, + /** Condition when to repeat. */ + public condition: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.DO, range); + } } /** Represents an empty statement, i.e., a semicolon terminating nothing. */ export class EmptyStatement extends Statement { + constructor( + /** Source range. */ + range: Range + ) { + super(NodeKind.EMPTY, range); + } } /** Represents an `enum` declaration. */ export class EnumDeclaration extends DeclarationStatement { - /** Enum value declarations. */ - values: EnumValueDeclaration[]; + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Enum value declarations. */ + public values: EnumValueDeclaration[], + /** Source range. */ + range: Range + ) { + super(NodeKind.ENUMDECLARATION, name, decorators, flags, range); + } } /** Represents a value of an `enum` declaration. */ export class EnumValueDeclaration extends VariableLikeDeclarationStatement { + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Initializer expression, if any. */ + initializer: Expression | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.ENUMVALUEDECLARATION, name, null, flags, null, initializer, range); + } } /** Represents an `export import` statement of an interface. */ export class ExportImportStatement extends Statement { - /** Identifier being imported. */ - name: IdentifierExpression; - /** Identifier being exported. */ - externalName: IdentifierExpression; + constructor( + /** Identifier being imported. */ + public name: IdentifierExpression, + /** Identifier being exported. */ + public externalName: IdentifierExpression, + /** Source range. */ + range: Range + ) { + super(NodeKind.EXPORTIMPORT, range); + } } /** Represents a member of an `export` statement. */ export class ExportMember extends Node { - /** Local identifier. */ - localName: IdentifierExpression; - /** Exported identifier. */ - exportedName: IdentifierExpression; + constructor( + /** Local identifier. */ + public localName: IdentifierExpression, + /** Exported identifier. */ + public exportedName: IdentifierExpression, + /** Source range. */ + range: Range + ) { + super(NodeKind.EXPORTMEMBER, range); + } } /** Represents an `export` statement. */ export class ExportStatement extends Statement { - /** Array of members if a set of named exports, or `null` if a file export. */ - members: ExportMember[] | null; - /** Path being exported from, if applicable. */ - path: StringLiteralExpression | null; + constructor( + /** Array of members if a set of named exports, or `null` if a file export. */ + public members: ExportMember[] | null, + /** Path being exported from, if applicable. */ + public path: StringLiteralExpression | null, + /** Whether this is a declared export. */ + public isDeclare: bool, + /** Source range. */ + range: Range + ) { + super(NodeKind.EXPORT, range); + if (path) { + let normalizedPath = normalizePath(path.value); + if (path.value.startsWith(".")) { // relative + normalizedPath = resolvePath(normalizedPath, range.source.internalPath); + } else { // absolute + if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath; + } + this.internalPath = normalizedPath; + } else { + this.internalPath = null; + } + } + /** Internal path being referenced, if `path` is set. */ internalPath: string | null; - /** Whether this is a declared export. */ - isDeclare: bool; } /** Represents an `export default` statement. */ export class ExportDefaultStatement extends Statement { - /** Declaration being exported as default. */ - declaration: DeclarationStatement; + constructor( + /** Declaration being exported as default. */ + public declaration: DeclarationStatement, + /** Source range. */ + range: Range + ) { + super(NodeKind.EXPORTDEFAULT, range); + } } /** Represents an expression that is used as a statement. */ export class ExpressionStatement extends Statement { - /** Expression being used as a statement.*/ - expression: Expression; + constructor( + /** Expression being used as a statement.*/ + public expression: Expression + ) { + super(NodeKind.EXPRESSION, expression.range); + } } /** Represents a field declaration within a `class`. */ export class FieldDeclaration extends VariableLikeDeclarationStatement { - /** Parameter index if declared as a constructor parameter, otherwise `-1`. */ - parameterIndex: i32 = -1; + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Annotated type node, if any. */ + type: TypeNode | null, + /** Initializer expression, if any. */ + initializer: Expression | null, + /** Parameter index if declared as a constructor parameter, otherwise `-1`. */ + public parameterIndex: i32, + /** Source range. */ + range: Range + ) { + super(NodeKind.FIELDDECLARATION, name, decorators, flags, type, initializer, range); + } } /** Represents a `for` statement. */ export class ForStatement extends Statement { - /** Initializer statement, if present. Either a `VariableStatement` or `ExpressionStatement`. */ - initializer: Statement | null; - /** Condition expression, if present. */ - condition: Expression | null; - /** Incrementor expression, if present. */ - incrementor: Expression | null; - /** Statement being looped over. */ - statement: Statement; + constructor( + /** Initializer statement, if present. Either a `VariableStatement` or `ExpressionStatement`. */ + public initializer: Statement | null, + /** Condition expression, if present. */ + public condition: Expression | null, + /** Incrementor expression, if present. */ + public incrementor: Expression | null, + /** Statement being looped over. */ + public statement: Statement, + /** Source range. */ + range: Range + ) { + super(NodeKind.FOR, range); + } } /** Represents a `for..of` statement. */ export class ForOfStatement extends Statement { - /** Variable statement. Either a `VariableStatement` or `ExpressionStatement` of `IdentifierExpression`. */ - variable: Statement; - /** Iterable expression being iterated. */ - iterable: Expression; - /** Statement being looped over. */ - statement: Statement; + constructor( + /** Variable statement. Either a `VariableStatement` or `ExpressionStatement` of `IdentifierExpression`. */ + public variable: Statement, + /** Iterable expression being iterated. */ + public iterable: Expression, + /** Statement being looped over. */ + public statement: Statement, + /** Source range. */ + range: Range + ) { + super(NodeKind.FOROF, range); + } } /** Indicates the kind of an array function. */ @@ -1939,15 +1926,28 @@ export const enum ArrowKind { /** Represents a `function` declaration. */ export class FunctionDeclaration extends DeclarationStatement { - /** Type parameters, if any. */ - typeParameters: TypeParameterNode[] | null; - /** Function signature. */ - signature: FunctionTypeNode; - /** Body statement. Usually a block. */ - body: Statement | null; - /** Arrow function kind, if applicable. */ - arrowKind: ArrowKind; + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Type parameters, if any. */ + public typeParameters: TypeParameterNode[] | null, + /** Function signature. */ + public signature: FunctionTypeNode, + /** Body statement. Usually a block. */ + public body: Statement | null, + /** Arrow function kind, if applicable. */ + public arrowKind: ArrowKind, + /** Source range. */ + range: Range + ) { + super(NodeKind.FUNCTIONDECLARATION, name, decorators, flags, range); + } + /** Gets if this function is generic. */ get isGeneric(): bool { var typeParameters = this.typeParameters; return typeParameters != null && typeParameters.length > 0; @@ -1955,13 +1955,13 @@ export class FunctionDeclaration extends DeclarationStatement { /** Clones this function declaration. */ clone(): FunctionDeclaration { - return Node.createFunctionDeclaration( + return new FunctionDeclaration( this.name, + this.decorators, + this.flags, this.typeParameters, this.signature, this.body, - this.decorators, - this.flags, this.arrowKind, this.range ); @@ -1970,118 +1970,274 @@ export class FunctionDeclaration extends DeclarationStatement { /** Represents an `if` statement. */ export class IfStatement extends Statement { - /** Condition. */ - condition: Expression; - /** Statement executed when condition is `true`. */ - ifTrue: Statement; - /** Statement executed when condition is `false`. */ - ifFalse: Statement | null; + constructor( + /** Condition. */ + public condition: Expression, + /** Statement executed when condition is `true`. */ + public ifTrue: Statement, + /** Statement executed when condition is `false`. */ + public ifFalse: Statement | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.IF, range); + } } /** Represents an `import` declaration part of an {@link ImportStatement}. */ export class ImportDeclaration extends DeclarationStatement { - /** Identifier being imported. */ - foreignName: IdentifierExpression; + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Identifier being imported. */ + public foreignName: IdentifierExpression, + /** Source range. */ + range: Range + ) { + super(NodeKind.IMPORTDECLARATION, name, null, CommonFlags.NONE, range); + } } /** Represents an `import` statement. */ export class ImportStatement extends Statement { - /** Array of member declarations or `null` if an asterisk import. */ - declarations: ImportDeclaration[] | null; - /** Name of the local namespace, if an asterisk import. */ - namespaceName: IdentifierExpression | null; - /** Path being imported from. */ - path: StringLiteralExpression; + constructor( + /** Array of member declarations or `null` if an asterisk import. */ + public declarations: ImportDeclaration[] | null, + /** Name of the local namespace, if an asterisk import. */ + public namespaceName: IdentifierExpression | null, + /** Path being imported from. */ + public path: StringLiteralExpression, + /** Source range. */ + range: Range + ) { + super(NodeKind.IMPORT, range); + var normalizedPath = normalizePath(path.value); + if (path.value.startsWith(".")) { // relative in project + normalizedPath = resolvePath(normalizedPath, range.source.internalPath); + } else { // absolute in library + if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath; + } + this.internalPath = normalizedPath; + } + /** Internal path being referenced. */ internalPath: string; } /** Represents an `interfarce` declaration. */ export class InterfaceDeclaration extends ClassDeclaration { + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Accepted type parameters. */ + typeParameters: TypeParameterNode[] | null, + /** Base class type being extended, if any. */ + extendsType: NamedTypeNode | null, // can't be a function + /** Interface types being implemented, if any. */ + implementsTypes: NamedTypeNode[] | null, // can't be functions + /** Class member declarations. */ + members: DeclarationStatement[], + /** Source range. */ + range: Range + ) { + super(name, decorators, flags, typeParameters, extendsType, implementsTypes, members, range); + this.kind = NodeKind.INTERFACEDECLARATION; + } } /** Represents a method declaration within a `class`. */ export class MethodDeclaration extends FunctionDeclaration { + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Type parameters, if any. */ + typeParameters: TypeParameterNode[] | null, + /** Function signature. */ + signature: FunctionTypeNode, + /** Body statement. Usually a block. */ + body: Statement | null, + /** Source range. */ + range: Range + ) { + super(name, decorators, flags, typeParameters, signature, body, ArrowKind.NONE, range); + this.kind = NodeKind.METHODDECLARATION; + } } /** Represents a `namespace` declaration. */ export class NamespaceDeclaration extends DeclarationStatement { - /** Array of namespace members. */ - members: Statement[]; + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Array of namespace members. */ + public members: Statement[], + /** Source range. */ + range: Range + ) { + super(NodeKind.NAMESPACEDECLARATION, name, decorators, flags, range); + } } /** Represents a `return` statement. */ export class ReturnStatement extends Statement { - /** Value expression being returned, if present. */ - value: Expression | null; + constructor( + /** Value expression being returned, if present. */ + public value: Expression | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.RETURN, range); + } } /** Represents a single `case` within a `switch` statement. */ export class SwitchCase extends Node { - /** Label expression. `null` indicates the default case. */ - label: Expression | null; - /** Contained statements. */ - statements: Statement[]; + constructor( + /** Label expression. `null` indicates the default case. */ + public label: Expression | null, + /** Contained statements. */ + public statements: Statement[], + /** Source range. */ + range: Range + ) { + super(NodeKind.SWITCHCASE, range); + } } /** Represents a `switch` statement. */ export class SwitchStatement extends Statement { - /** Condition expression. */ - condition: Expression; - /** Contained cases. */ - cases: SwitchCase[]; + constructor( + /** Condition expression. */ + public condition: Expression, + /** Contained cases. */ + public cases: SwitchCase[], + /** Source range. */ + range: Range + ) { + super(NodeKind.SWITCH, range); + } } /** Represents a `throw` statement. */ export class ThrowStatement extends Statement { - /** Value expression being thrown. */ - value: Expression; + constructor( + /** Value expression being thrown. */ + public value: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.THROW, range); + } } /** Represents a `try` statement. */ export class TryStatement extends Statement { - /** Contained statements. */ - statements: Statement[]; - /** Exception variable name, if a `catch` clause is present. */ - catchVariable: IdentifierExpression | null; - /** Statements being executed on catch, if a `catch` clause is present. */ - catchStatements: Statement[] | null; - /** Statements being executed afterwards, if a `finally` clause is present. */ - finallyStatements: Statement[] | null; + constructor( + /** Contained statements. */ + public statements: Statement[], + /** Exception variable name, if a `catch` clause is present. */ + public catchVariable: IdentifierExpression | null, + /** Statements being executed on catch, if a `catch` clause is present. */ + public catchStatements: Statement[] | null, + /** Statements being executed afterwards, if a `finally` clause is present. */ + public finallyStatements: Statement[] | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.TRY, range); + } } /** Represents a `type` declaration. */ export class TypeDeclaration extends DeclarationStatement { - /** Type parameters, if any. */ - typeParameters: TypeParameterNode[] | null; - /** Type being aliased. */ - type: TypeNode; + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Type parameters, if any. */ + public typeParameters: TypeParameterNode[] | null, + /** Type being aliased. */ + public type: TypeNode, + /** Source range. */ + range: Range + ) { + super(NodeKind.TYPEDECLARATION, name, decorators, flags, range); + } } /** Represents a variable declaration part of a {@link VariableStatement}. */ export class VariableDeclaration extends VariableLikeDeclarationStatement { + constructor( + /** Simple name being declared. */ + name: IdentifierExpression, + /** Array of decorators, if any. */ + decorators: DecoratorNode[] | null, + /** Common flags indicating specific traits. */ + flags: CommonFlags, + /** Annotated type node, if any. */ + type: TypeNode | null, + /** Initializer expression, if any. */ + initializer: Expression | null, + /** Source range. */ + range: Range + ) { + super(NodeKind.VARIABLEDECLARATION, name, decorators, flags, type, initializer, range); + } } /** Represents a variable statement wrapping {@link VariableDeclaration}s. */ export class VariableStatement extends Statement { - /** Array of decorators. */ - decorators: DecoratorNode[] | null; - /** Array of member declarations. */ - declarations: VariableDeclaration[]; + constructor( + /** Array of decorators. */ + public decorators: DecoratorNode[] | null, + /** Array of member declarations. */ + public declarations: VariableDeclaration[], + /** Source range. */ + range: Range + ) { + super(NodeKind.VARIABLE, range); + } } /** Represents a void statement dropping an expression's value. */ export class VoidStatement extends Statement { - /** Expression being dropped. */ - expression: Expression; + constructor( + /** Expression being dropped. */ + public expression: Expression, + /** Source range. */ + range: Range + ) { + super(NodeKind.VOID, range); + } } /** Represents a `while` statement. */ export class WhileStatement extends Statement { - /** Condition expression. */ - condition: Expression; - /** Statement being looped over. */ - statement: Statement; + constructor( + /** Condition expression. */ + public condition: Expression, + /** Statement being looped over. */ + public statement: Statement, + /** Source range. */ + range: Range + ) { + super(NodeKind.WHILE, range); + } } /** Finds the first decorator matching the specified kind. */ diff --git a/src/builtins.ts b/src/builtins.ts index 8f08bc6a68..d19fd5d438 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -613,20 +613,22 @@ export namespace BuiltinNames { /** Builtin compilation context. */ export class BuiltinContext { - /** Compiler reference. */ - compiler: Compiler; - /** Prototype being called. */ - prototype: FunctionPrototype; - /** Provided type arguments. */ - typeArguments: Type[] | null; - /** Provided operands. */ - operands: Expression[]; - /** Contextual type. */ - contextualType: Type; - /** Respective call expression. */ - reportNode: CallExpression; - /** Whether originating from inline assembly. */ - contextIsExact: bool; + constructor( + /** Compiler reference. */ + public compiler: Compiler, + /** Prototype being called. */ + public prototype: FunctionPrototype, + /** Provided type arguments. */ + public typeArguments: Type[] | null, + /** Provided operands. */ + public operands: Expression[], + /** Contextual type. */ + public contextualType: Type, + /** Respective call expression. */ + public reportNode: CallExpression, + /** Whether originating from inline assembly. */ + public contextIsExact: bool + ) {} } /** Global builtins map. */ diff --git a/src/compiler.ts b/src/compiler.ts index 4eb2d776f1..e93e6e6848 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -398,6 +398,12 @@ export class Compiler extends DiagnosticEmitter { if (options.hasFeature(Feature.REFERENCE_TYPES)) featureFlags |= FeatureFlags.ReferenceTypes; if (options.hasFeature(Feature.MULTI_VALUE)) featureFlags |= FeatureFlags.MultiValue; module.setFeatures(featureFlags); + + // set up the main start function + var startFunctionInstance = program.makeNativeFunction(BuiltinNames.start, new Signature(program, [], Type.void)); + startFunctionInstance.internalName = BuiltinNames.start; + this.currentFlow = startFunctionInstance.flow; + this.currentBody = new Array(); } /** Performs compilation of the underlying {@link Program} to a {@link Module}. */ @@ -409,12 +415,11 @@ export class Compiler extends DiagnosticEmitter { // initialize lookup maps, built-ins, imports, exports, etc. this.program.initialize(); - // set up the main start function - var startFunctionInstance = program.makeNativeFunction(BuiltinNames.start, new Signature(program, [], Type.void)); - startFunctionInstance.internalName = BuiltinNames.start; - var startFunctionBody = new Array(); - this.currentFlow = startFunctionInstance.flow; - this.currentBody = startFunctionBody; + // obtain the main start function + var startFunctionInstance = this.currentFlow.actualFunction; + assert(startFunctionInstance.internalName == BuiltinNames.start); + var startFunctionBody = this.currentBody; + assert(startFunctionBody.length == 0); // add mutable heap and rtti base dummies if (options.isWasm64) { @@ -1774,7 +1779,7 @@ export class Compiler extends DiagnosticEmitter { addMemorySegment(buffer: Uint8Array, alignment: i32 = 16): MemorySegment { assert(isPowerOf2(alignment)); var memoryOffset = i64_align(this.memoryOffset, alignment); - var segment = MemorySegment.create(buffer, memoryOffset); + var segment = new MemorySegment(buffer, memoryOffset); this.memorySegments.push(segment); this.memoryOffset = i64_add(memoryOffset, i64_new(buffer.length, 0)); return segment; @@ -2014,7 +2019,7 @@ export class Compiler extends DiagnosticEmitter { case NodeKind.FUNCTIONDECLARATION: case NodeKind.METHODDECLARATION: case NodeKind.INTERFACEDECLARATION: - case NodeKind.INDEXSIGNATUREDECLARATION: + case NodeKind.INDEXSIGNATURE: case NodeKind.TYPEDECLARATION: break; default: { // otherwise a top-level statement that is part of the start function's body let stmt = this.compileStatement(statement); @@ -2889,7 +2894,7 @@ export class Compiler extends DiagnosticEmitter { var value = statement.value; var message: Expression | null = null; if (value.kind == NodeKind.NEW) { - let newArgs = (value).arguments; + let newArgs = (value).args; if (newArgs.length) message = newArgs[0]; // FIXME: naively assumes type string } stmts.push( @@ -6400,7 +6405,7 @@ export class Compiler extends DiagnosticEmitter { let superCall = this.compileCallDirect( this.ensureConstructor(baseClassInstance, expression), - expression.arguments, + expression.args, expression, module.local_get(thisLocal.index, nativeSizeType), Constraints.WILL_RETAIN @@ -6456,7 +6461,7 @@ export class Compiler extends DiagnosticEmitter { } return this.compileCallDirect( functionInstance, - expression.arguments, + expression.args, expression, thisArg, constraints @@ -6574,7 +6579,7 @@ export class Compiler extends DiagnosticEmitter { return this.compileCallIndirect( assert(signature), // FIXME: bootstrap can't see this yet indexArg, - expression.arguments, + expression.args, expression, 0, contextualType == Type.void @@ -6609,18 +6614,18 @@ export class Compiler extends DiagnosticEmitter { expression ); } - var ctx = new BuiltinContext(); - ctx.compiler = this; - ctx.prototype = prototype; - ctx.typeArguments = typeArguments; - ctx.operands = expression.arguments; - ctx.contextualType = contextualType; - ctx.reportNode = expression; - ctx.contextIsExact = false; var internalName = prototype.internalName; if (builtins.has(internalName)) { let fn = assert(builtins.get(internalName)); - return fn(ctx); + return fn(new BuiltinContext( + this, + prototype, + typeArguments, + expression.args, + contextualType, + expression, + false + )); } this.error( DiagnosticCode.Not_implemented, @@ -9059,7 +9064,7 @@ export class Compiler extends DiagnosticEmitter { } if (!classInstance) return module.unreachable(); if (contextualType == Type.void) constraints |= Constraints.WILL_DROP; - return this.compileInstantiate(classInstance, expression.arguments, constraints, expression); + return this.compileInstantiate(classInstance, expression.args, constraints, expression); } /** Gets the compiled constructor of the specified class or generates one if none is present. */ @@ -10608,7 +10613,7 @@ function mangleImportName( var program = element.program; var decorator = assert(findDecorator(DecoratorKind.EXTERNAL, declaration.decorators)); - var args = decorator.arguments; + var args = decorator.args; if (args !== null && args.length > 0) { let arg = args[0]; // if one argument is given, override just the element name diff --git a/src/definitions.ts b/src/definitions.ts index 0f9b80b5dd..a3668c7cdc 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -57,7 +57,7 @@ export abstract class ExportsWalker { /** Constructs a new Element walker. */ constructor(program: Program, includePrivate: bool = false) { this.program = program; - this.includePrivate; + this.includePrivate = includePrivate; } /** Walks all elements and calls the respective handlers. */ diff --git a/src/extra/ast.ts b/src/extra/ast.ts index 5389a86a5a..5e4cdb3ced 100644 --- a/src/extra/ast.ts +++ b/src/extra/ast.ts @@ -66,13 +66,13 @@ import { VariableStatement, WhileStatement, + DeclarationStatement, ClassDeclaration, EnumDeclaration, EnumValueDeclaration, FieldDeclaration, FunctionDeclaration, ImportDeclaration, - IndexSignatureDeclaration, InterfaceDeclaration, MethodDeclaration, NamespaceDeclaration, @@ -84,7 +84,7 @@ import { ParameterKind, ExportMember, SwitchCase, - DeclarationStatement, + IndexSignatureNode, isTypeOmitted } from "../ast"; @@ -315,10 +315,6 @@ export class ASTBuilder { this.visitImportDeclaration(node); break; } - case NodeKind.INDEXSIGNATUREDECLARATION: { - this.visitIndexSignatureDeclaration(node); - break; - } case NodeKind.INTERFACEDECLARATION: { this.visitInterfaceDeclaration(node); break; @@ -358,6 +354,10 @@ export class ASTBuilder { this.visitSwitchCase(node); break; } + case NodeKind.INDEXSIGNATURE: { + this.visitIndexSignature(node); + break; + } default: assert(false); } } @@ -556,7 +556,7 @@ export class ASTBuilder { visitCallExpression(node: CallExpression): void { this.visitNode(node.expression); - this.visitArguments(node.typeArguments, node.arguments); + this.visitArguments(node.typeArguments, node.args); } private visitArguments(typeArguments: TypeNode[] | null, args: Expression[]): void { @@ -772,7 +772,7 @@ export class ASTBuilder { visitNewExpression(node: NewExpression): void { this.sb.push("new "); this.visitTypeName(node.typeName); - this.visitArguments(node.typeArguments, node.arguments); + this.visitArguments(node.typeArguments, node.args); } visitParenthesizedExpression(node: ParenthesizedExpression): void { @@ -823,13 +823,13 @@ export class ASTBuilder { // statements - visitNodeAndTerminate(statement: Statement): void { - this.visitNode(statement); + visitNodeAndTerminate(node: Node): void { + this.visitNode(node); var sb = this.sb; if ( - !sb.length || // leading EmptyStatement - statement.kind == NodeKind.VARIABLE || // potentially assigns a FunctionExpression - statement.kind == NodeKind.EXPRESSION // potentially assigns a FunctionExpression + !sb.length || // leading EmptyStatement + node.kind == NodeKind.VARIABLE || // potentially assigns a FunctionExpression + node.kind == NodeKind.EXPRESSION // potentially assigns a FunctionExpression ) { sb.push(";\n"); } else { @@ -931,11 +931,16 @@ export class ASTBuilder { } } } + var indexSignature = node.indexSignature; var members = node.members; var numMembers = members.length; - if (numMembers) { + if (indexSignature !== null || numMembers) { sb.push(" {\n"); let indentLevel = ++this.indentLevel; + if (indexSignature) { + indent(sb, indentLevel); + this.visitNodeAndTerminate(indexSignature); + } for (let i = 0, k = members.length; i < k; ++i) { let member = members[i]; if (member.kind != NodeKind.FIELDDECLARATION || (member).parameterIndex < 0) { @@ -1305,7 +1310,7 @@ export class ASTBuilder { this.visitStringLiteralExpression(node.path); } - visitIndexSignatureDeclaration(node: IndexSignatureDeclaration): void { + visitIndexSignature(node: IndexSignatureNode): void { var sb = this.sb; sb.push("[key: "); this.visitTypeNode(node.keyType); @@ -1576,7 +1581,7 @@ export class ASTBuilder { var sb = this.sb; sb.push("@"); this.visitNode(node.name); - var args = node.arguments; + var args = node.args; if (args) { sb.push("("); let numArgs = args.length; diff --git a/src/flow.ts b/src/flow.ts index 8662757955..4a5caa880e 100644 --- a/src/flow.ts +++ b/src/flow.ts @@ -184,56 +184,40 @@ export const enum ConditionKind { /** A control flow evaluator. */ export class Flow { - /** Parent flow. */ - parent: Flow | null; - /** Flow flags indicating specific conditions. */ - flags: FlowFlags; - /** Function this flow belongs to. */ - parentFunction: Function; - /** The label we break to when encountering a continue statement. */ - continueLabel: string | null; - /** The label we break to when encountering a break statement. */ - breakLabel: string | null; - /** The current return type. */ - returnType: Type; - /** The current contextual type arguments. */ - contextualTypeArguments: Map | null; - /** Scoped local variables. */ - scopedLocals: Map | null = null; - /** Local flags. */ - localFlags: LocalFlags[]; - /** Function being inlined, when inlining. */ - inlineFunction: Function | null; - /** The label we break to when encountering a return statement, when inlining. */ - inlineReturnLabel: string | null; - /** Creates the parent flow of the specified function. */ - static create(parentFunction: Function): Flow { - var flow = new Flow(); - flow.parent = null; - flow.flags = FlowFlags.NONE; - flow.parentFunction = parentFunction; - flow.continueLabel = null; - flow.breakLabel = null; - flow.returnType = parentFunction.signature.returnType; - flow.contextualTypeArguments = parentFunction.contextualTypeArguments; - flow.localFlags = []; - flow.inlineFunction = null; - flow.inlineReturnLabel = null; - return flow; + static createParent(parentFunction: Function): Flow { + return new Flow(parentFunction); } /** Creates an inline flow within `parentFunction`. */ static createInline(parentFunction: Function, inlineFunction: Function): Flow { - var flow = Flow.create(parentFunction); + var flow = new Flow(parentFunction); flow.inlineFunction = inlineFunction; flow.inlineReturnLabel = inlineFunction.internalName + "|inlined." + (inlineFunction.nextInlineId++).toString(); - flow.returnType = inlineFunction.signature.returnType; - flow.contextualTypeArguments = inlineFunction.contextualTypeArguments; return flow; } - private constructor() { } + private constructor( + /** Function this flow belongs to. */ + public parentFunction: Function + ) {} + + /** Parent flow. */ + parent: Flow | null = null; + /** Flow flags indicating specific conditions. */ + flags: FlowFlags = FlowFlags.NONE; + /** The label we break to when encountering a continue statement. */ + continueLabel: string | null = null; + /** The label we break to when encountering a break statement. */ + breakLabel: string | null = null; + /** Scoped local variables. */ + scopedLocals: Map | null = null; + /** Local flags. */ + localFlags: LocalFlags[] = []; + /** Function being inlined, when inlining. */ + inlineFunction: Function | null = null; + /** The label we break to when encountering a return statement, when inlining. */ + inlineReturnLabel: string | null = null; /** Tests if this is an inline flow. */ get isInline(): bool { @@ -247,6 +231,16 @@ export class Flow { return this.parentFunction; } + /** Gets the current return type. */ + get returnType(): Type { + return this.actualFunction.signature.returnType; + } + + /** Gets the current contextual type arguments. */ + get contextualTypeArguments(): Map | null { + return this.actualFunction.contextualTypeArguments; + } + /** Tests if this flow has the specified flag or flags. */ is(flag: FlowFlags): bool { return (this.flags & flag) == flag; } /** Tests if this flow has one of the specified flags. */ @@ -258,9 +252,8 @@ export class Flow { /** Forks this flow to a child flow. */ fork(resetBreakContext: bool = false): Flow { - var branch = new Flow(); + var branch = new Flow(this.parentFunction); branch.parent = this; - branch.parentFunction = this.parentFunction; if (resetBreakContext) { branch.flags = this.flags & ~( FlowFlags.BREAKS | @@ -273,8 +266,6 @@ export class Flow { branch.continueLabel = this.continueLabel; branch.breakLabel = this.breakLabel; } - branch.returnType = this.returnType; - branch.contextualTypeArguments = this.contextualTypeArguments; branch.localFlags = this.localFlags.slice(); branch.inlineFunction = this.inlineFunction; branch.inlineReturnLabel = this.inlineReturnLabel; diff --git a/src/module.ts b/src/module.ts index 052dbd811d..a114ea3e8c 100644 --- a/src/module.ts +++ b/src/module.ts @@ -486,42 +486,35 @@ export enum ExpressionRunnerFlags { } export class MemorySegment { - - buffer: Uint8Array; - offset: i64; - - static create(buffer: Uint8Array, offset: i64): MemorySegment { - var segment = new MemorySegment(); - segment.buffer = buffer; - segment.offset = offset; - return segment; - } + constructor( + /** Segment data. */ + public buffer: Uint8Array, + /** Segment offset. */ + public offset: i64 + ) {} } export class Module { - - ref: ModuleRef; + constructor( + /** Binaryen module reference. */ + public ref: ModuleRef + ) { + this.lit = binaryen._malloc(binaryen._BinaryenSizeofLiteral()); + } private lit: usize; static create(): Module { - var module = new Module(); - module.ref = binaryen._BinaryenModuleCreate(); - module.lit = binaryen._malloc(binaryen._BinaryenSizeofLiteral()); - return module; + return new Module(binaryen._BinaryenModuleCreate()); } static createFrom(buffer: Uint8Array): Module { - var module = new Module(); var cArr = allocU8Array(buffer); - module.ref = binaryen._BinaryenModuleRead(cArr, buffer.length); + var module = new Module(binaryen._BinaryenModuleRead(cArr, buffer.length)); binaryen._free(changetype(cArr)); - module.lit = binaryen._malloc(binaryen._BinaryenSizeofLiteral()); return module; } - private constructor() { } - // constants i32(value: i32): ExpressionRef { @@ -1643,13 +1636,11 @@ export class Module { binaryPtr = assert(binaryen.__i32_load(out)); var binaryLen = binaryen.__i32_load(out + 4); sourceMapPtr = binaryen.__i32_load(out + 8); // may be NULL - var ret = new BinaryModule(); - ret.output = readBuffer(binaryPtr, binaryLen); - ret.sourceMap = readString(sourceMapPtr); + var binary = new BinaryModule(readBuffer(binaryPtr, binaryLen), readString(sourceMapPtr)); if (cStr) binaryen._free(cStr); binaryen._free(binaryPtr); if (sourceMapPtr) binaryen._free(sourceMapPtr); - return ret; + return binary; } toText(): string { @@ -2100,19 +2091,17 @@ export function getEventResults(event: EventRef): NativeType { } export class Relooper { - - module: Module; - ref: RelooperRef; + constructor( + /** Module this relooper belongs to. */ + public module: Module, + /** Binaryen relooper reference. */ + public ref: RelooperRef + ) {} static create(module: Module): Relooper { - var relooper = new Relooper(); - relooper.module = module; - relooper.ref = binaryen._RelooperCreate(module.ref); - return relooper; + return new Relooper(module, binaryen._RelooperCreate(module.ref)); } - private constructor() {} - addBlock(code: ExpressionRef): RelooperBlockRef { return binaryen._RelooperAddBlock(this.ref, code); } @@ -2435,10 +2424,12 @@ export function readString(ptr: usize): string | null { /** Result structure of {@link Module#toBinary}. */ export class BinaryModule { - /** WebAssembly binary. */ - output: Uint8Array; - /** Source map, if generated. */ - sourceMap: string | null; + constructor( + /** WebAssembly binary. */ + public output: Uint8Array, + /** Source map, if generated. */ + public sourceMap: string | null + ) {} } /** Tests if an expression needs an explicit 'unreachable' when it is the terminating statement. */ diff --git a/src/parser.ts b/src/parser.ts index a4ee53026b..bca0ea5707 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -70,7 +70,7 @@ import { IfStatement, ImportDeclaration, ImportStatement, - IndexSignatureDeclaration, + IndexSignatureNode, NamespaceDeclaration, ParameterNode, ParameterKind, @@ -101,7 +101,7 @@ export class Parser extends DiagnosticEmitter { /** Optional handler to intercept comments while tokenizing. */ onComment: CommentHandler | null = null; /** Current file being parsed. */ - currentSource: Source; + currentSource: Source | null = null; /** Dependency map **/ dependees: Map = new Map(); /** An array of parsed sources. */ @@ -135,15 +135,15 @@ export class Parser extends DiagnosticEmitter { // create the source element var source = new Source( - normalizedPath, - text, isEntry ? SourceKind.USER_ENTRY : path.startsWith(LIBRARY_PREFIX) ? path.indexOf(PATH_DELIMITER, LIBRARY_PREFIX.length) < 0 ? SourceKind.LIBRARY_ENTRY : SourceKind.LIBRARY - : SourceKind.USER + : SourceKind.USER, + normalizedPath, + text ); this.sources.push(source); @@ -663,13 +663,16 @@ export class Parser extends DiagnosticEmitter { } else { isSignature = false; // not yet known do { + let paramStart: i32 = -1; let kind = ParameterKind.DEFAULT; if (tn.skip(Token.DOT_DOT_DOT)) { + paramStart = tn.tokenPos; isSignature = true; tn.discard(state); kind = ParameterKind.REST; } if (tn.skip(Token.THIS)) { + if (paramStart < 0) paramStart = tn.tokenPos; if (tn.skip(Token.COLON)) { isSignature = true; tn.discard(state); @@ -690,6 +693,7 @@ export class Parser extends DiagnosticEmitter { return null; } } else if (tn.skipIdentifier()) { + if (paramStart < 0) paramStart = tn.tokenPos; let name = Node.createIdentifierExpression(tn.readIdentifier(), tn.range(tn.tokenPos, tn.pos)); if (tn.skip(Token.QUESTION)) { isSignature = true; @@ -711,10 +715,7 @@ export class Parser extends DiagnosticEmitter { this.tryParseSignatureIsSignature = isSignature; return null; } - let param = new ParameterNode(); - param.parameterKind = kind; - param.name = name; - param.type = type; + let param = Node.createParameter(kind, name, type, null, tn.range(paramStart, tn.pos)); if (!parameters) parameters = [ param ]; else parameters.push(param); } else { @@ -725,10 +726,7 @@ export class Parser extends DiagnosticEmitter { } } if (isSignature) { - let param = new ParameterNode(); - param.parameterKind = kind; - param.name = name; - param.type = Node.createOmittedType(tn.range().atEnd); + let param = Node.createParameter(kind, name, Node.createOmittedType(tn.range(tn.pos)), null, tn.range(paramStart, tn.pos)); if (!parameters) parameters = [ param ]; else parameters.push(param); this.error( @@ -776,10 +774,13 @@ export class Parser extends DiagnosticEmitter { isSignature = true; tn.discard(state); if (firstParamNameNoType) { // now we know - let param = new ParameterNode(); - param.parameterKind = firstParamKind; - param.name = firstParamNameNoType; - param.type = Node.createOmittedType(firstParamNameNoType.range.atEnd); + let param = Node.createParameter( + firstParamKind, + firstParamNameNoType, + Node.createOmittedType(firstParamNameNoType.range.atEnd), + null, + firstParamNameNoType.range + ); if (!parameters) parameters = [ param ]; else parameters.push(param); this.error( @@ -872,14 +873,14 @@ export class Parser extends DiagnosticEmitter { // at ('const' | 'let' | 'var'): VariableDeclaration (',' VariableDeclaration)* ';'? - var members = new Array(); + var declarations = new Array(); do { - let member = this.parseVariableDeclaration(tn, flags, decorators, isFor); - if (!member) return null; - members.push(member); + let declaration = this.parseVariableDeclaration(tn, flags, decorators, isFor); + if (!declaration) return null; + declarations.push(declaration); } while (tn.skip(Token.COMMA)); - var ret = Node.createVariableStatement(members, decorators, tn.range(startPos, tn.pos)); + var ret = Node.createVariableStatement(decorators, declarations, tn.range(startPos, tn.pos)); tn.skip(Token.SEMICOLON); return ret; } @@ -951,10 +952,10 @@ export class Parser extends DiagnosticEmitter { } return Node.createVariableDeclaration( identifier, - type, - initializer, parentDecorators, flags, + type, + initializer, range ); } @@ -1002,9 +1003,9 @@ export class Parser extends DiagnosticEmitter { } var ret = Node.createEnumDeclaration( identifier, - members, decorators, flags, + members, tn.range(startPos, tn.pos) ); tn.skip(Token.SEMICOLON); @@ -1033,8 +1034,8 @@ export class Parser extends DiagnosticEmitter { } return Node.createEnumValueDeclaration( identifier, - value, parentFlags, + value, Range.join(identifier.range, tn.range()) ); } @@ -1332,14 +1333,14 @@ export class Parser extends DiagnosticEmitter { if (!initializer) return null; } let param = Node.createParameter( - identifier, - type, - initializer, isRest ? ParameterKind.REST : isOptional ? ParameterKind.OPTIONAL : ParameterKind.DEFAULT, + identifier, + type, + initializer, Range.join(assert(startRange), tn.range()) ); param.flags |= accessFlags; @@ -1473,11 +1474,11 @@ export class Parser extends DiagnosticEmitter { var ret = Node.createFunctionDeclaration( name, + decorators, + flags, typeParameters, signature, body, - decorators, - flags, ArrowKind.NONE, tn.range(startPos, tn.pos) ); @@ -1588,10 +1589,10 @@ export class Parser extends DiagnosticEmitter { var declaration = Node.createFunctionDeclaration( name, null, + CommonFlags.NONE, + null, signature, body, - null, - CommonFlags.NONE, arrowKind, tn.range(startPos, tn.pos) ); @@ -1687,30 +1688,37 @@ export class Parser extends DiagnosticEmitter { assert(!implementsTypes); declaration = Node.createInterfaceDeclaration( identifier, + decorators, + flags, typeParameters, extendsType, + null, members, - decorators, - flags, tn.range(startPos, tn.pos) ); } else { declaration = Node.createClassDeclaration( identifier, + decorators, + flags, typeParameters, extendsType, implementsTypes, members, - decorators, - flags, tn.range(startPos, tn.pos) ); } if (!tn.skip(Token.CLOSEBRACE)) { do { let member = this.parseClassMember(tn, declaration); - if (member) members.push(member); - else { + if (member) { + if (member.kind == NodeKind.INDEXSIGNATURE) { + declaration.indexSignature = member; + } else { + assert(member instanceof DeclarationStatement); + members.push(member); + } + } else { this.skipStatement(tn); if (tn.skip(Token.ENDOFFILE)) { this.error( @@ -1750,19 +1758,25 @@ export class Parser extends DiagnosticEmitter { var members = new Array(); var declaration = Node.createClassDeclaration( name, - [], null, + CommonFlags.NONE, null, - members, null, - CommonFlags.NONE, + null, + members, tn.range(startPos, tn.pos) ); if (!tn.skip(Token.CLOSEBRACE)) { do { let member = this.parseClassMember(tn, declaration); - if (member) members.push(member); - else { + if (member) { + if (member.kind == NodeKind.INDEXSIGNATURE) { + declaration.indexSignature = member; + } else { + assert(declaration instanceof DeclarationStatement); + members.push(member); + } + } else { this.skipStatement(tn); if (tn.skip(Token.ENDOFFILE)) { this.error( @@ -1781,7 +1795,7 @@ export class Parser extends DiagnosticEmitter { parseClassMember( tn: Tokenizer, parent: ClassDeclaration - ): DeclarationStatement | null { + ): Node | null { // before: // ('public' | 'private' | 'protected')? @@ -2007,7 +2021,7 @@ export class Parser extends DiagnosticEmitter { tn.range(abstractStart, abstractEnd), "abstract" ); // recoverable } - let retIndex = this.parseIndexSignatureDeclaration(tn, flags, decorators); + let retIndex = this.parseIndexSignature(tn, flags, decorators); if (!retIndex) { if (flags & CommonFlags.READONLY) { this.error( @@ -2067,10 +2081,10 @@ export class Parser extends DiagnosticEmitter { )) { let implicitFieldDeclaration = Node.createFieldDeclaration( parameter.name, - parameter.type, - null, // initialized via parameter null, parameter.flags | CommonFlags.INSTANCE, + parameter.type, + null, // initialized via parameter parameter.range ); implicitFieldDeclaration.parameterIndex = i; @@ -2167,11 +2181,11 @@ export class Parser extends DiagnosticEmitter { let retMethod = Node.createMethodDeclaration( name, + decorators, + flags, typeParameters, signature, body, - decorators, - flags, tn.range(startPos, tn.pos) ); tn.skip(Token.SEMICOLON); @@ -2245,10 +2259,10 @@ export class Parser extends DiagnosticEmitter { } let retField = Node.createFieldDeclaration( name, - type, - initializer, decorators, flags, + type, + initializer, range ); tn.skip(Token.SEMICOLON); @@ -2257,11 +2271,11 @@ export class Parser extends DiagnosticEmitter { return null; } - parseIndexSignatureDeclaration( + parseIndexSignature( tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, - ): IndexSignatureDeclaration | null { + ): IndexSignatureNode | null { // at: '[': 'key' ':' Type ']' ':' Type @@ -2297,7 +2311,7 @@ export class Parser extends DiagnosticEmitter { ); return null; } - return Node.createIndexSignatureDeclaration(keyType, valueType, flags, tn.range(start, tn.pos)); + return Node.createIndexSignature(keyType, valueType, flags, tn.range(start, tn.pos)); } else { this.error( DiagnosticCode._0_expected, @@ -2346,9 +2360,9 @@ export class Parser extends DiagnosticEmitter { let members = new Array(); let declaration = Node.createNamespaceDeclaration( identifier, - members, decorators, flags, + members, tn.range(startPos, tn.pos) ); while (!tn.skip(Token.CLOSEBRACE)) { @@ -2392,6 +2406,7 @@ export class Parser extends DiagnosticEmitter { // at 'export': '{' ExportMember (',' ExportMember)* }' ('from' StringLiteral)? ';'? var path: StringLiteralExpression | null = null; + var currentSource = assert(this.currentSource); if (tn.skip(Token.OPENBRACE)) { let members = new Array(); while (!tn.skip(Token.CLOSEBRACE)) { @@ -2424,7 +2439,7 @@ export class Parser extends DiagnosticEmitter { let ret = Node.createExportStatement(members, path, isDeclare, tn.range(startPos, tn.pos)); let internalPath = ret.internalPath; if (internalPath !== null && !this.seenlog.has(internalPath)) { - this.dependees.set(internalPath, this.currentSource); + this.dependees.set(internalPath, currentSource); this.backlog.push(internalPath); this.seenlog.add(internalPath); } @@ -2441,7 +2456,7 @@ export class Parser extends DiagnosticEmitter { if (!exportPaths) source.exportPaths = [ internalPath ]; else if (!exportPaths.includes(internalPath)) exportPaths.push(internalPath); if (!this.seenlog.has(internalPath)) { - this.dependees.set(internalPath, this.currentSource); + this.dependees.set(internalPath, currentSource); this.backlog.push(internalPath); } tn.skip(Token.SEMICOLON); @@ -2606,13 +2621,13 @@ export class Parser extends DiagnosticEmitter { let ret: ImportStatement; if (namespaceName) { assert(!members); - ret = Node.createImportStatementWithWildcard(namespaceName, path, tn.range(startPos, tn.pos)); + ret = Node.createWildcardImportStatement(namespaceName, path, tn.range(startPos, tn.pos)); } else { ret = Node.createImportStatement(members, path, tn.range(startPos, tn.pos)); } let internalPath = ret.internalPath; if (!this.seenlog.has(internalPath)) { - this.dependees.set(internalPath, this.currentSource); + this.dependees.set(internalPath, assert(this.currentSource)); this.backlog.push(internalPath); } tn.skip(Token.SEMICOLON); @@ -3357,10 +3372,10 @@ export class Parser extends DiagnosticEmitter { if (!type) return null; let ret = Node.createTypeDeclaration( name, - typeParameters, - type, decorators, flags, + typeParameters, + type, tn.range(startPos, tn.pos) ); tn.skip(Token.SEMICOLON); @@ -3700,10 +3715,10 @@ export class Parser extends DiagnosticEmitter { Node.createEmptyIdentifierExpression(tn.range(startPos)), [ Node.createParameter( + ParameterKind.DEFAULT, identifier, Node.createOmittedType(identifier.range.atEnd), null, - ParameterKind.DEFAULT, identifier.range ) ], diff --git a/src/program.ts b/src/program.ts index 1f7819972c..8215c87781 100644 --- a/src/program.ts +++ b/src/program.ts @@ -415,6 +415,23 @@ export namespace OperatorKind { /** Represents an AssemblyScript program. */ export class Program extends DiagnosticEmitter { + /** Constructs a new program, optionally inheriting parser diagnostics. */ + constructor( + /** Compiler options. */ + public options: Options, + /** Shared array of diagnostic messages (emitted so far). */ + diagnostics: DiagnosticMessage[] | null = null + ) { + super(diagnostics); + var nativeSource = new Source(SourceKind.LIBRARY_ENTRY, LIBRARY_SUBST + ".wasm", "[native code]"); + this.nativeSource = nativeSource; + var nativeFile = new File(this, nativeSource); + this.nativeFile = nativeFile; + this.filesByName.set(nativeFile.internalName, nativeFile); + this.parser = new Parser(this.diagnostics, this.sources); + this.resolver = new Resolver(this); + } + /** Parser instance. */ parser: Parser; /** Resolver instance. */ @@ -423,14 +440,18 @@ export class Program extends DiagnosticEmitter { sources: Source[] = []; /** Diagnostic offset used where successively obtaining the next diagnostic. */ diagnosticsOffset: i32 = 0; - /** Compiler options. */ - options: Options; /** Special native code source. */ nativeSource: Source; /** Special native code file. */ nativeFile: File; + /** Next class id. */ + nextClassId: u32 = 0; + /** Next signature id. */ + nextSignatureId: i32 = 0; + /** An indicator if the program has been initialized. */ + initialized: bool = false; - // lookup maps + // Lookup maps /** Files by unique internal name. */ filesByName: Map = new Map(); @@ -447,102 +468,254 @@ export class Program extends DiagnosticEmitter { /** A set of unique function signatures contained in the program, by id. */ uniqueSignatures: Signature[] = new Array(0); - // standard references - - /** ArrayBufferView reference. */ - arrayBufferViewInstance: Class; - /** ArrayBuffer instance reference. */ - arrayBufferInstance: Class; - /** Array prototype reference. */ - arrayPrototype: ClassPrototype; - /** Static array prototype reference. */ - staticArrayPrototype: ClassPrototype; - /** Set prototype reference. */ - setPrototype: ClassPrototype; - /** Map prototype reference. */ - mapPrototype: ClassPrototype; - /** Int8Array prototype. */ - i8ArrayPrototype: ClassPrototype; - /** Int16Array prototype. */ - i16ArrayPrototype: ClassPrototype; - /** Int32Array prototype. */ - i32ArrayPrototype: ClassPrototype; - /** Int64Array prototype. */ - i64ArrayPrototype: ClassPrototype; - /** Uint8Array prototype. */ - u8ArrayPrototype: ClassPrototype; - /** Uint8ClampedArray prototype. */ - u8ClampedArrayPrototype: ClassPrototype; - /** Uint16Array prototype. */ - u16ArrayPrototype: ClassPrototype; - /** Uint32Array prototype. */ - u32ArrayPrototype: ClassPrototype; - /** Uint64Array prototype. */ - u64ArrayPrototype: ClassPrototype; - /** Float32Array prototype. */ - f32ArrayPrototype: ClassPrototype; - /** Float64Array prototype. */ - f64ArrayPrototype: ClassPrototype; - /** String instance reference. */ - stringInstance: Class; - /** Abort function reference, if not explicitly disabled. */ - abortInstance: Function | null; - - // runtime references - - /** RT `__alloc(size: usize, id: u32): usize` */ - allocInstance: Function; - /** RT `__realloc(ptr: usize, newSize: usize): usize` */ - reallocInstance: Function; - /** RT `__free(ptr: usize): void` */ - freeInstance: Function; - /** RT `__retain(ptr: usize): usize` */ - retainInstance: Function; - /** RT `__release(ptr: usize): void` */ - releaseInstance: Function; - /** RT `__collect(): void` */ - collectInstance: Function; - /** RT `__visit(ptr: usize, cookie: u32): void` */ - visitInstance: Function; - /** RT `__typeinfo(id: u32): RTTIFlags` */ - typeinfoInstance: Function; - /** RT `__instanceof(ptr: usize, superId: u32): bool` */ - instanceofInstance: Function; - /** RT `__allocBuffer(size: usize, id: u32, data: usize = 0): usize` */ - allocBufferInstance: Function; - /** RT `__allocArray(length: i32, alignLog2: usize, id: u32, data: usize = 0): usize` */ - allocArrayInstance: Function; + // Standard library - /** Next class id. */ - nextClassId: u32 = 0; - /** Next signature id. */ - nextSignatureId: i32 = 0; - /** An indicator if the program has been initialized. */ - initialized: bool = false; + /** Gets the standard `ArrayBufferView` instance. */ + get arrayBufferViewInstance(): Class { + var cached = this._arrayBufferViewInstance; + if (!cached) this._arrayBufferViewInstance = cached = this.requireClass(CommonNames.ArrayBufferView); + return cached; + } + private _arrayBufferViewInstance: Class | null = null; + + /** Gets the standard `ArrayBuffer` instance. */ + get arrayBufferInstance(): Class { + var cached = this._arrayBufferInstance; + if (!cached) this._arrayBufferInstance = cached = this.requireClass(CommonNames.ArrayBuffer); + return cached; + } + private _arrayBufferInstance: Class | null = null; + + /** Gets the standard `Array` prototype. */ + get arrayPrototype(): ClassPrototype { + var cached = this._arrayPrototype; + if (!cached) this._arrayPrototype = cached = this.require(CommonNames.Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _arrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `StaticArray` prototype. */ + get staticArrayPrototype(): ClassPrototype { + var cached = this._staticArrayPrototype; + if (!cached) this._staticArrayPrototype = cached = this.require(CommonNames.StaticArray, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _staticArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Set` prototype. */ + get setPrototype(): ClassPrototype { + var cached = this._setPrototype; + if (!cached) this._setPrototype = cached = this.require(CommonNames.Set, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _setPrototype: ClassPrototype | null = null; + + /** Gets the standard `Map` prototype. */ + get mapPrototype(): ClassPrototype { + var cached = this._mapPrototype; + if (!cached) this._mapPrototype = cached = this.require(CommonNames.Map, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _mapPrototype: ClassPrototype | null = null; + + /** Gets the standard `Int8Array` prototype. */ + get int8ArrayPrototype(): ClassPrototype { + var cached = this._int8ArrayPrototype; + if (!cached) this._int8ArrayPrototype = cached = this.require(CommonNames.Int8Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _int8ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Int16Array` prototype. */ + get int16ArrayPrototype(): ClassPrototype { + var cached = this._int16ArrayPrototype; + if (!cached) this._int16ArrayPrototype = cached = this.require(CommonNames.Int16Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _int16ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Int32Array` prototype. */ + get int32ArrayPrototype(): ClassPrototype { + var cached = this._int32ArrayPrototype; + if (!cached) this._int32ArrayPrototype = cached = this.require(CommonNames.Int32Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _int32ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Int64Array` prototype. */ + get int64ArrayPrototype(): ClassPrototype { + var cached = this._int64ArrayPrototype; + if (!cached) this._int64ArrayPrototype = cached = this.require(CommonNames.Int64Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _int64ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Uint8Array` prototype. */ + get uint8ArrayPrototype(): ClassPrototype { + var cached = this._uint8ArrayPrototype; + if (!cached) this._uint8ArrayPrototype = cached = this.require(CommonNames.Uint8Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _uint8ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Uint8ClampedArray` prototype. */ + get uint8ClampedArrayPrototype(): ClassPrototype { + var cached = this._uint8ClampedArrayPrototype; + if (!cached) this._uint8ClampedArrayPrototype = cached = this.require(CommonNames.Uint8ClampedArray, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _uint8ClampedArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Uint16Array` prototype. */ + get uint16ArrayPrototype(): ClassPrototype { + var cached = this._uint16ArrayPrototype; + if (!cached) this._uint16ArrayPrototype = cached = this.require(CommonNames.Uint16Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _uint16ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Uint32Array` prototype. */ + get uint32ArrayPrototype(): ClassPrototype { + var cached = this._uint32ArrayPrototype; + if (!cached) this._uint32ArrayPrototype = cached = this.require(CommonNames.Uint32Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _uint32ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Uint64Array` prototype. */ + get uint64ArrayPrototype(): ClassPrototype { + var cached = this._uint64ArrayPrototype; + if (!cached) this._uint64ArrayPrototype = cached = this.require(CommonNames.Uint64Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _uint64ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Float32Array` prototype. */ + get float32ArrayPrototype(): ClassPrototype { + var cached = this._float32ArrayPrototype; + if (!cached) this._float32ArrayPrototype = cached = this.require(CommonNames.Float32Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _float32ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `Float64Array` prototype. */ + get float64ArrayPrototype(): ClassPrototype { + var cached = this._float64ArrayPrototype; + if (!cached) this._float64ArrayPrototype = cached = this.require(CommonNames.Float64Array, ElementKind.CLASS_PROTOTYPE); + return cached; + } + private _float64ArrayPrototype: ClassPrototype | null = null; + + /** Gets the standard `String` instance. */ + get stringInstance(): Class { + var cached = this._stringInstance; + if (!cached) this._stringInstance = cached = this.requireClass(CommonNames.String); + return cached; + } + private _stringInstance: Class | null = null; + + /** Gets the standard `abort` instance, if not explicitly disabled. */ + get abortInstance(): Function | null { + return this.lookupFunction(CommonNames.abort); + } + + // Runtime interface + + /** Gets the runtime `__alloc(size: usize, id: u32): usize` instance. */ + get allocInstance(): Function { + var cached = this._allocInstance; + if (!cached) this._allocInstance = cached = this.requireFunction(CommonNames.alloc); + return cached; + } + private _allocInstance: Function | null = null; + + /** Gets the runtime `__realloc(ptr: usize, newSize: usize): usize` instance. */ + get reallocInstance(): Function { + var cached = this._reallocInstance; + if (!cached) this._reallocInstance = cached = this.requireFunction(CommonNames.realloc); + return cached; + } + private _reallocInstance: Function | null = null; + + /** Gets the runtime `__free(ptr: usize): void` instance. */ + get freeInstance(): Function { + var cached = this._freeInstance; + if (!cached) this._freeInstance = cached = this.requireFunction(CommonNames.free); + return cached; + } + private _freeInstance: Function | null = null; + + /** Gets the runtime `__retain(ptr: usize): usize` instance. */ + get retainInstance(): Function { + var cached = this._retainInstance; + if (!cached) this._retainInstance = cached = this.requireFunction(CommonNames.retain); + return cached; + } + private _retainInstance: Function | null = null; + + /** Gets the runtime `__release(ptr: usize): void` instance. */ + get releaseInstance(): Function { + var cached = this._releaseInstance; + if (!cached) this._releaseInstance = cached = this.requireFunction(CommonNames.release); + return cached; + } + private _releaseInstance: Function | null = null; + + /** Gets the runtime `__collect(): void` instance. */ + get collectInstance(): Function { + var cached = this._collectInstance; + if (!cached) this._collectInstance = cached = this.requireFunction(CommonNames.collect); + return cached; + } + private _collectInstance: Function | null = null; + + /** Gets the runtime `__visit(ptr: usize, cookie: u32): void` instance. */ + get visitInstance(): Function { + var cached = this._visitInstance; + if (!cached) this._visitInstance = cached = this.requireFunction(CommonNames.visit); + return cached; + } + private _visitInstance: Function | null = null; + + /** Gets the runtime `__typeinfo(id: u32): RTTIFlags` instance. */ + get typeinfoInstance(): Function { + var cached = this._typeinfoInstance; + if (!cached) this._typeinfoInstance = cached = this.requireFunction(CommonNames.typeinfo); + return cached; + } + private _typeinfoInstance: Function | null = null; + + /** Gets the runtime `__instanceof(ptr: usize, superId: u32): bool` instance. */ + get instanceofInstance(): Function { + var cached = this._instanceofInstance; + if (!cached) this._instanceofInstance = cached = this.requireFunction(CommonNames.instanceof_); + return cached; + } + private _instanceofInstance: Function | null = null; + + /** Gets the runtime `__allocBuffer(size: usize, id: u32, data: usize = 0): usize` instance. */ + get allocBufferInstance(): Function { + var cached = this._allocBufferInstance; + if (!cached) this._allocBufferInstance = cached = this.requireFunction(CommonNames.allocBuffer); + return cached; + } + private _allocBufferInstance: Function | null = null; + + /** Gets the runtime `__allocArray(length: i32, alignLog2: usize, id: u32, data: usize = 0): usize` instance. */ + get allocArrayInstance(): Function { + var cached = this._allocArrayInstance; + if (!cached) this._allocArrayInstance = cached = this.requireFunction(CommonNames.allocArray); + return cached; + } + private _allocArrayInstance: Function | null = null; + + // Utility /** Tests whether this is a WASI program. */ get isWasi(): bool { return this.elementsByName.has(CommonNames.ASC_WASI); } - /** Constructs a new program, optionally inheriting parser diagnostics. */ - constructor( - /** Compiler options. */ - options: Options, - /** Shared array of diagnostic messages (emitted so far). */ - diagnostics: DiagnosticMessage[] | null = null - ) { - super(diagnostics); - this.options = options; - var nativeSource = new Source(LIBRARY_SUBST + ".wasm", "[native code]", SourceKind.LIBRARY_ENTRY); - this.nativeSource = nativeSource; - var nativeFile = new File(this, nativeSource); - this.nativeFile = nativeFile; - this.filesByName.set(nativeFile.internalName, nativeFile); - this.parser = new Parser(this.diagnostics, this.sources); - this.resolver = new Resolver(this); - } - /** Obtains the source matching the specified internal path. */ getSource(internalPath: string): string | null { var sources = this.sources; @@ -583,7 +756,7 @@ export class Program extends DiagnosticEmitter { var range = this.nativeSource.range; return Node.createVariableDeclaration( Node.createIdentifierExpression(name, range), - null, null, null, flags, range + null, flags, null, null, range ); } @@ -598,9 +771,9 @@ export class Program extends DiagnosticEmitter { var identifier = Node.createIdentifierExpression(name, range); return Node.createTypeDeclaration( identifier, - null, + null, flags, null, Node.createOmittedType(range), - null, flags, range + range ); } @@ -627,7 +800,7 @@ export class Program extends DiagnosticEmitter { } return Node.createFunctionDeclaration( Node.createIdentifierExpression(name, range), - null, signature, null, null, flags, ArrowKind.NONE, range + null, flags, null, signature, null, ArrowKind.NONE, range ); } @@ -641,7 +814,7 @@ export class Program extends DiagnosticEmitter { var range = this.nativeSource.range; return Node.createNamespaceDeclaration( Node.createIdentifierExpression(name, range), - [], null, flags, range + null, flags, [], range ); } @@ -944,12 +1117,8 @@ export class Program extends DiagnosticEmitter { } // register ArrayBuffer (id=0), String (id=1), ArrayBufferView (id=2) - assert(this.nextClassId == 0); - this.arrayBufferInstance = this.requireClass(CommonNames.ArrayBuffer); assert(this.arrayBufferInstance.id == 0); - this.stringInstance = this.requireClass(CommonNames.String); assert(this.stringInstance.id == 1); - this.arrayBufferViewInstance = this.requireClass(CommonNames.ArrayBufferView); assert(this.arrayBufferViewInstance.id == 2); // register classes backing basic types @@ -969,19 +1138,6 @@ export class Program extends DiagnosticEmitter { if (options.hasFeature(Feature.SIMD)) this.registerWrapperClass(Type.v128, CommonNames.V128); if (options.hasFeature(Feature.REFERENCE_TYPES)) this.registerWrapperClass(Type.anyref, CommonNames.Anyref); - // register views but don't instantiate them yet - this.i8ArrayPrototype = this.require(CommonNames.Int8Array, ElementKind.CLASS_PROTOTYPE); - this.i16ArrayPrototype = this.require(CommonNames.Int16Array, ElementKind.CLASS_PROTOTYPE); - this.i32ArrayPrototype = this.require(CommonNames.Int32Array, ElementKind.CLASS_PROTOTYPE); - this.i64ArrayPrototype = this.require(CommonNames.Int64Array, ElementKind.CLASS_PROTOTYPE); - this.u8ArrayPrototype = this.require(CommonNames.Uint8Array, ElementKind.CLASS_PROTOTYPE); - this.u8ClampedArrayPrototype = this.require(CommonNames.Uint8ClampedArray, ElementKind.CLASS_PROTOTYPE); - this.u16ArrayPrototype = this.require(CommonNames.Uint16Array, ElementKind.CLASS_PROTOTYPE); - this.u32ArrayPrototype = this.require(CommonNames.Uint32Array, ElementKind.CLASS_PROTOTYPE); - this.u64ArrayPrototype = this.require(CommonNames.Uint64Array, ElementKind.CLASS_PROTOTYPE); - this.f32ArrayPrototype = this.require(CommonNames.Float32Array, ElementKind.CLASS_PROTOTYPE); - this.f64ArrayPrototype = this.require(CommonNames.Float64Array, ElementKind.CLASS_PROTOTYPE); - // resolve prototypes of extended classes or interfaces var resolver = this.resolver; for (let i = 0, k = queuedExtends.length; i < k; ++i) { @@ -1124,24 +1280,6 @@ export class Program extends DiagnosticEmitter { } } - // register stdlib components - this.arrayPrototype = this.require(CommonNames.Array, ElementKind.CLASS_PROTOTYPE); - this.staticArrayPrototype = this.require(CommonNames.StaticArray, ElementKind.CLASS_PROTOTYPE); - this.setPrototype = this.require(CommonNames.Set, ElementKind.CLASS_PROTOTYPE); - this.mapPrototype = this.require(CommonNames.Map, ElementKind.CLASS_PROTOTYPE); - this.abortInstance = this.lookupFunction(CommonNames.abort); // can be disabled - this.allocInstance = this.requireFunction(CommonNames.alloc); - this.reallocInstance = this.requireFunction(CommonNames.realloc); - this.freeInstance = this.requireFunction(CommonNames.free); - this.retainInstance = this.requireFunction(CommonNames.retain); - this.releaseInstance = this.requireFunction(CommonNames.release); - this.collectInstance = this.requireFunction(CommonNames.collect); - this.typeinfoInstance = this.requireFunction(CommonNames.typeinfo); - this.instanceofInstance = this.requireFunction(CommonNames.instanceof_); - this.visitInstance = this.requireFunction(CommonNames.visit); - this.allocBufferInstance = this.requireFunction(CommonNames.allocBuffer); - this.allocArrayInstance = this.requireFunction(CommonNames.allocArray); - // mark module exports, i.e. to apply proper wrapping behavior on the boundaries // TODO: for (let file of this.filesByName.values()) { for (let _values = Map_values(this.filesByName), i = 0, k = _values.length; i < k; ++i) { @@ -1257,8 +1395,8 @@ export class Program extends DiagnosticEmitter { /** Requires that a global library element of the specified kind is present and returns it. */ private require(name: string, kind: ElementKind): Element { var element = this.lookupGlobal(name); - if (!element) throw new Error("missing " + name); - if (element.kind != kind) throw new Error("unexpected " + name); + if (!element) throw new Error("Missing standard library component: " + name); + if (element.kind != kind) throw Error("Invalid standard library component: " + name); return element; } @@ -1266,7 +1404,7 @@ export class Program extends DiagnosticEmitter { private requireClass(name: string): Class { var prototype = this.require(name, ElementKind.CLASS_PROTOTYPE); var resolved = this.resolver.resolveClass(prototype, null); - if (!resolved) throw new Error("invalid " + name); + if (!resolved) throw new Error("Invalid standard library class: " + name); return resolved; } @@ -1281,7 +1419,7 @@ export class Program extends DiagnosticEmitter { private requireFunction(name: string, typeArguments: Type[] | null = null): Function { var prototype = this.require(name, ElementKind.FUNCTION_PROTOTYPE); var resolved = this.resolver.resolveFunction(prototype, typeArguments); - if (!resolved) throw new Error("invalid " + name); + if (!resolved) throw new Error("Invalid standard library function: " + name); return resolved; } @@ -1607,7 +1745,7 @@ export class Program extends DiagnosticEmitter { } break; } - case NodeKind.INDEXSIGNATUREDECLARATION: break; // ignored for now + case NodeKind.INDEXSIGNATURE: break; // ignored for now default: assert(false); // class member expected } } @@ -1704,10 +1842,10 @@ export class Program extends DiagnosticEmitter { case DecoratorKind.OPERATOR_BINARY: case DecoratorKind.OPERATOR_PREFIX: case DecoratorKind.OPERATOR_POSTFIX: { - let args = decorator.arguments; + let args = decorator.args; let numArgs = args ? args.length : 0; if (numArgs == 1) { - let firstArg = (decorator.arguments)[0]; + let firstArg = (decorator.args)[0]; if (firstArg.isLiteralKind(LiteralKind.STRING)) { let text = (firstArg).value; let kind = OperatorKind.fromDecorator(decorator.decoratorKind, text); @@ -2175,6 +2313,8 @@ export class Program extends DiagnosticEmitter { this.initializeProperty( Node.createMethodDeclaration( declaration.name, + declaration.decorators, + declaration.flags | CommonFlags.GET, null, Node.createFunctionType( [], @@ -2184,8 +2324,6 @@ export class Program extends DiagnosticEmitter { declaration.range ), null, - declaration.decorators, - declaration.flags | CommonFlags.GET, declaration.range ), parent @@ -2194,14 +2332,16 @@ export class Program extends DiagnosticEmitter { this.initializeProperty( Node.createMethodDeclaration( declaration.name, + declaration.decorators, + declaration.flags | CommonFlags.SET, null, Node.createFunctionType( [ Node.createParameter( + ParameterKind.DEFAULT, declaration.name, typeNode, null, - ParameterKind.DEFAULT, declaration.name.range ) ], @@ -2211,8 +2351,6 @@ export class Program extends DiagnosticEmitter { declaration.range ), null, - declaration.decorators, - declaration.flags | CommonFlags.SET, declaration.range ), parent @@ -2988,9 +3126,9 @@ export abstract class VariableLikeElement extends TypedElement { /** Constant value kind. */ constantValueKind: ConstantValueKind = ConstantValueKind.NONE; /** Constant integer value, if applicable. */ - constantIntegerValue: i64; + constantIntegerValue: i64 = i64_zero; /** Constant float value, if applicable. */ - constantFloatValue: f64; + constantFloatValue: f64 = 0; /** Constructs a new variable-like element. */ protected constructor( @@ -3352,7 +3490,7 @@ export class Function extends TypedElement { this.localsByIndex[local.index] = local; } } - this.flow = Flow.create(this); + this.flow = Flow.createParent(this); registerConcreteElement(program, this); } @@ -3666,10 +3804,11 @@ export class Property extends VariableLikeElement { parent, Node.createVariableDeclaration( prototype.identifierNode, - null, null, null, + null, prototype.is(CommonFlags.INSTANCE) ? CommonFlags.INSTANCE : CommonFlags.NONE, + null, null, prototype.identifierNode.range ) ); @@ -4141,23 +4280,23 @@ export class Class extends TypedElement { var prototype = current.prototype; switch (prototype.name.charCodeAt(0)) { case CharCode.F: { - if (prototype == program.f32ArrayPrototype) return Type.f32; - if (prototype == program.f64ArrayPrototype) return Type.f64; + if (prototype == program.float32ArrayPrototype) return Type.f32; + if (prototype == program.float64ArrayPrototype) return Type.f64; break; } case CharCode.I: { - if (prototype == program.i8ArrayPrototype) return Type.i8; - if (prototype == program.i16ArrayPrototype) return Type.i16; - if (prototype == program.i32ArrayPrototype) return Type.i32; - if (prototype == program.i64ArrayPrototype) return Type.i64; + if (prototype == program.int8ArrayPrototype) return Type.i8; + if (prototype == program.int16ArrayPrototype) return Type.i16; + if (prototype == program.int32ArrayPrototype) return Type.i32; + if (prototype == program.int64ArrayPrototype) return Type.i64; break; } case CharCode.U: { - if (prototype == program.u8ArrayPrototype) return Type.u8; - if (prototype == program.u8ClampedArrayPrototype) return Type.u8; - if (prototype == program.u16ArrayPrototype) return Type.u16; - if (prototype == program.u32ArrayPrototype) return Type.u32; - if (prototype == program.u64ArrayPrototype) return Type.u64; + if (prototype == program.uint8ArrayPrototype) return Type.u8; + if (prototype == program.uint8ClampedArrayPrototype) return Type.u8; + if (prototype == program.uint16ArrayPrototype) return Type.u16; + if (prototype == program.uint32ArrayPrototype) return Type.u32; + if (prototype == program.uint64ArrayPrototype) return Type.u64; break; } } diff --git a/src/resolver.ts b/src/resolver.ts index fd79e42d40..a41489bf0a 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -764,7 +764,7 @@ export class Resolver extends DiagnosticEmitter { let parameterNodes = prototype.functionTypeNode.parameters; let numParameters = parameterNodes.length; - let argumentNodes = node.arguments; + let argumentNodes = node.args; let numArguments = argumentNodes.length; // infer types with generic components while updating contextual types @@ -2400,9 +2400,9 @@ export class Resolver extends DiagnosticEmitter { // `unchecked` behaves like parenthesized if ( functionPrototype.internalName == BuiltinNames.unchecked && - node.arguments.length > 0 + node.args.length > 0 ) { - return this.resolveExpression(node.arguments[0], ctxFlow, ctxType, reportMode); + return this.resolveExpression(node.args[0], ctxFlow, ctxType, reportMode); } let instance = this.maybeInferCall(node, functionPrototype, ctxFlow, reportMode); if (!instance) return null; diff --git a/src/tokenizer.ts b/src/tokenizer.ts index c0565c1f86..4feeeb0d1d 100644 --- a/src/tokenizer.ts +++ b/src/tokenizer.ts @@ -988,11 +988,14 @@ export class Tokenizer extends DiagnosticEmitter { mark(): State { var state = reusableState; - if (state) reusableState = null; - else state = new State(); - state.pos = this.pos; - state.token = this.token; - state.tokenPos = this.tokenPos; + if (state) { + reusableState = null; + state.pos = this.pos; + state.token = this.token; + state.tokenPos = this.tokenPos; + } else { + state = new State(this.pos, this.token, this.tokenPos); + } return state; } @@ -1570,12 +1573,14 @@ export class Tokenizer extends DiagnosticEmitter { /** 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; + constructor( + /** Current position. */ + public pos: i32, + /** Current token. */ + public token: Token, + /** Current token's position. */ + public tokenPos: i32 + ) {} } // Reusable state object to reduce allocations diff --git a/src/tsconfig.json b/src/tsconfig.json index 1a580affdb..23d36c7d41 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -4,7 +4,8 @@ "outDir": "../out", "allowJs": false, "sourceMap": true, - "target": "ES2016" + "target": "ES2016", + "strict": true }, "include": [ "./**/*.ts" diff --git a/std/assembly/map.ts b/std/assembly/map.ts index 0e82f9f96c..f79ae8dd1f 100644 --- a/std/assembly/map.ts +++ b/std/assembly/map.ts @@ -63,28 +63,27 @@ function ENTRY_SIZE(): usize { export class Map { - // buckets holding references to the respective first entry within - private buckets: ArrayBuffer; // usize[bucketsMask + 1] - private bucketsMask: u32; + // buckets referencing their respective first entry, usize[bucketsMask + 1] + private buckets: ArrayBuffer = new ArrayBuffer(INITIAL_CAPACITY * BUCKET_SIZE); + private bucketsMask: u32 = INITIAL_CAPACITY - 1; - // entries in insertion order - private entries: ArrayBuffer; // MapEntry[entriesCapacity] - private entriesCapacity: i32; - private entriesOffset: i32; - private entriesCount: i32; - - get size(): i32 { return this.entriesCount; } + // entries in insertion order, MapEntry[entriesCapacity] + private entries: ArrayBuffer = new ArrayBuffer(INITIAL_CAPACITY * ENTRY_SIZE()); + private entriesCapacity: i32 = INITIAL_CAPACITY; + private entriesOffset: i32 = 0; + private entriesCount: i32 = 0; constructor() { - this.clear(); + } + + get size(): i32 { + return this.entriesCount; } clear(): void { - const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE; - this.buckets = new ArrayBuffer(bucketsSize); + this.buckets = new ArrayBuffer(INITIAL_CAPACITY * BUCKET_SIZE); this.bucketsMask = INITIAL_CAPACITY - 1; - const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE(); - this.entries = new ArrayBuffer(entriesSize); + this.entries = new ArrayBuffer(INITIAL_CAPACITY * ENTRY_SIZE()); this.entriesCapacity = INITIAL_CAPACITY; this.entriesOffset = 0; this.entriesCount = 0; diff --git a/std/assembly/set.ts b/std/assembly/set.ts index 17925f702b..191f8759cd 100644 --- a/std/assembly/set.ts +++ b/std/assembly/set.ts @@ -60,26 +60,27 @@ function ENTRY_SIZE(): usize { export class Set { - // buckets holding references to the respective first entry within - private buckets: ArrayBuffer; // usize[bucketsMask + 1] - private bucketsMask: u32; + // buckets referencing their respective first entry, usize[bucketsMask + 1] + private buckets: ArrayBuffer = new ArrayBuffer(INITIAL_CAPACITY * BUCKET_SIZE); + private bucketsMask: u32 = INITIAL_CAPACITY - 1; - // entries in insertion order - private entries: ArrayBuffer; // SetEntry[entriesCapacity] - private entriesCapacity: i32; - private entriesOffset: i32; - private entriesCount: i32; + // entries in insertion order, SetEntry[entriesCapacity] + private entries: ArrayBuffer = new ArrayBuffer(INITIAL_CAPACITY * ENTRY_SIZE()); + private entriesCapacity: i32 = INITIAL_CAPACITY; + private entriesOffset: i32 = 0; + private entriesCount: i32 = 0; - get size(): i32 { return this.entriesCount; } + constructor() { + } - constructor() { this.clear(); } + get size(): i32 { + return this.entriesCount; + } clear(): void { - const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE; - this.buckets = new ArrayBuffer(bucketsSize); + this.buckets = new ArrayBuffer(INITIAL_CAPACITY * BUCKET_SIZE); this.bucketsMask = INITIAL_CAPACITY - 1; - const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE(); - this.entries = new ArrayBuffer(entriesSize); + this.entries = new ArrayBuffer(INITIAL_CAPACITY * ENTRY_SIZE()); this.entriesCapacity = INITIAL_CAPACITY; this.entriesOffset = 0; this.entriesCount = 0; diff --git a/std/assembly/shared/typeinfo.ts b/std/assembly/shared/typeinfo.ts index eee22a614c..7dd0e437cf 100644 --- a/std/assembly/shared/typeinfo.ts +++ b/std/assembly/shared/typeinfo.ts @@ -16,9 +16,9 @@ @unmanaged export class Typeinfo { /** Flags describing the shape of this class type. */ - flags: TypeinfoFlags; + flags: TypeinfoFlags = TypeinfoFlags.NONE; /** Base class id or `0` if none. */ - base: u32; + base: u32 = 0; } /** Runtime type information flags. */ diff --git a/tests/compiler/builtins.optimized.wat b/tests/compiler/builtins.optimized.wat index a586c3d0e6..750312598a 100644 --- a/tests/compiler/builtins.optimized.wat +++ b/tests/compiler/builtins.optimized.wat @@ -592,9 +592,9 @@ i32.const 5 f64.const 0 f64.const 0 - f64.const 23 - f64.const 24 - f64.const 24 + f64.const 15 + f64.const 16 + f64.const 16 call $~lib/builtins/trace i32.const 1216 i32.const 1216 diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index dd72474616..8b87cf4bdd 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -1727,11 +1727,11 @@ local.set $0 i32.const 0 local.set $1 - i32.const 23 + i32.const 15 local.set $6 - i32.const 24 + i32.const 16 local.set $7 - i32.const 24 + i32.const 16 local.set $8 i32.const 128 i32.const 5 @@ -1771,7 +1771,7 @@ unreachable end local.get $6 - i32.const 23 + i32.const 15 i32.eq i32.eqz if diff --git a/tests/compiler/std/map.optimized.wat b/tests/compiler/std/map.optimized.wat index fb5b50733e..36f41bfa7e 100644 --- a/tests/compiler/std/map.optimized.wat +++ b/tests/compiler/std/map.optimized.wat @@ -30,11 +30,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 1024) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") - (data (i32.const 1072) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") - (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") - (data (i32.const 1184) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") - (data (i32.const 1248) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") + (data (i32.const 1024) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") + (data (i32.const 1072) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") + (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") + (data (i32.const 1184) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") + (data (i32.const 1232) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") (data (i32.const 1296) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00m\00a\00p\00.\00t\00s") (data (i32.const 1344) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00K\00e\00y\00 \00d\00o\00e\00s\00 \00n\00o\00t\00 \00e\00x\00i\00s\00t") (data (i32.const 1408) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00~\00l\00i\00b\00/\00m\00a\00p\00.\00t\00s") @@ -44,17 +44,6 @@ (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) (export "memory" (memory $0)) (start $~start) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 1556 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -68,7 +57,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -90,7 +79,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -133,7 +122,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -229,7 +218,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -243,7 +232,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -316,7 +305,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -371,7 +360,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -386,7 +375,7 @@ i32.ne if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -434,7 +423,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -517,7 +506,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -534,7 +523,7 @@ i32.lt_u if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -562,7 +551,7 @@ i32.lt_u if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -702,8 +691,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 1200 - i32.const 1152 + i32.const 1088 + i32.const 1040 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -776,7 +765,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -828,7 +817,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -861,7 +850,7 @@ i32.and if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -932,7 +921,7 @@ global.get $~lib/rt/tlsf/collectLock if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1023,7 +1012,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1039,7 +1028,7 @@ i32.lt_u if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1073,6 +1062,68 @@ i32.const 16 i32.add ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.const 1556 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load offset=4 + local.tee $2 + i32.const -268435456 + i32.and + local.get $2 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 1152 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.add + i32.store offset=4 + local.get $1 + call $~lib/rt/rtrace/onincrement + local.get $1 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 1152 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + end + local.get $0 + ) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 1556 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 @@ -1231,65 +1282,14 @@ end end ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - local.get $0 - i32.const 1556 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - local.tee $1 - i32.load offset=4 - local.tee $2 - i32.const -268435456 - i32.and - local.get $2 - i32.const 1 - i32.add - i32.const -268435456 - i32.and - i32.ne - if - i32.const 0 - i32.const 1264 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $1 - local.get $2 - i32.const 1 - i32.add - i32.store offset=4 - local.get $1 - call $~lib/rt/rtrace/onincrement - local.get $1 - i32.load - i32.const 1 - i32.and - if - i32.const 0 - i32.const 1264 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - end - local.get $0 - ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 1073741808 i32.gt_u if - i32.const 1040 - i32.const 1088 + i32.const 1200 + i32.const 1248 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1305,39 +1305,6 @@ call $~lib/rt/pure/__retain local.tee $0 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store - local.get $0 - i32.const 3 - i32.store offset=4 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/util/hash/hash8 (param $0 i32) (result i32) local.get $0 i32.const -2128831035 @@ -1645,7 +1612,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -1961,7 +1928,7 @@ i32.shr_u i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 14 i32.const 48 @@ -2004,7 +1971,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -2125,7 +2092,7 @@ i32.const 1073741808 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -2228,7 +2195,7 @@ i32.const 268435452 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -2374,39 +2341,6 @@ call $~lib/array/Array#set:length local.get $0 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store - local.get $0 - i32.const 3 - i32.store offset=4 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (result i32) (local $0 i32) i32.const 24 @@ -2414,16 +2348,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -2432,8 +2368,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#__get (param $0 i32) (param $1 i32) (result i32) local.get $1 @@ -3084,30 +3018,65 @@ call $~lib/map/Map#rehash end ) - (func $std/map/testNumeric - (local $0 i32) + (func $~lib/map/Map#clear (param $0 i32) (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - i32.const 24 - i32.const 3 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store + local.get $0 + i32.const 3 + i32.store offset=4 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) + (func $std/map/testNumeric + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + i32.const 24 + i32.const 3 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -3115,8 +3084,6 @@ local.get $0 i32.const 0 i32.store offset=20 - local.get $0 - call $~lib/map/Map#clear loop $for-loop|1 local.get $1 i32.const 24 @@ -3312,16 +3279,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $1 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $1 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $1 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $1 i32.const 0 @@ -3329,8 +3298,6 @@ local.get $1 i32.const 0 i32.store offset=20 - local.get $1 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $5 loop $for-loop|4 @@ -3858,7 +3825,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -3902,7 +3869,7 @@ i32.const 1073741808 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -4320,16 +4287,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -4337,8 +4306,6 @@ local.get $0 i32.const 0 i32.store offset=20 - local.get $0 - call $~lib/map/Map#clear loop $for-loop|1 local.get $1 i32.const 255 @@ -4520,16 +4487,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $1 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $1 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $1 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $1 i32.const 0 @@ -4537,8 +4506,6 @@ local.get $1 i32.const 0 i32.store offset=20 - local.get $1 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $5 loop $for-loop|4 @@ -5122,7 +5089,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -5217,7 +5184,7 @@ i32.const 536870904 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -5641,28 +5608,28 @@ i32.const 11 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain - local.tee $0 - i32.const 0 + local.tee $2 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store - local.get $0 - i32.const 0 + local.get $2 + i32.const 3 i32.store offset=4 - local.get $0 - i32.const 0 + local.get $2 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 - local.get $0 - i32.const 0 + local.get $2 + i32.const 4 i32.store offset=12 - local.get $0 + local.get $2 i32.const 0 i32.store offset=16 - local.get $0 + local.get $2 i32.const 0 i32.store offset=20 - local.get $0 - call $~lib/map/Map#clear loop $for-loop|1 - local.get $1 + local.get $3 i32.const 16 i32.shl i32.const 16 @@ -5670,8 +5637,8 @@ i32.const 100 i32.lt_s if - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has if i32.const 0 @@ -5681,9 +5648,9 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 - local.get $1 + local.get $2 + local.get $3 + local.get $3 i32.const 16 i32.shl i32.const 16 @@ -5692,8 +5659,8 @@ i32.add call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has i32.eqz if @@ -5704,10 +5671,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#get - local.get $1 + local.get $3 i32.const 16 i32.shl i32.const 16 @@ -5723,14 +5690,14 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $3 i32.const 1 i32.add - local.set $1 + local.set $3 br $for-loop|1 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 100 i32.ne @@ -5743,9 +5710,9 @@ unreachable end i32.const 0 - local.set $1 + local.set $3 loop $for-loop|3 - local.get $1 + local.get $3 i32.const 16 i32.shl i32.const 16 @@ -5753,8 +5720,8 @@ i32.const 100 i32.lt_s if - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has i32.eqz if @@ -5765,10 +5732,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#get - local.get $1 + local.get $3 i32.const 16 i32.shl i32.const 16 @@ -5784,9 +5751,9 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 - local.get $1 + local.get $2 + local.get $3 + local.get $3 i32.const 16 i32.shl i32.const 16 @@ -5795,8 +5762,8 @@ i32.add call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has i32.eqz if @@ -5807,10 +5774,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#get - local.get $1 + local.get $3 i32.const 16 i32.shl i32.const 16 @@ -5826,14 +5793,14 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $3 i32.const 1 i32.add - local.set $1 + local.set $3 br $for-loop|3 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 100 i32.ne @@ -5845,10 +5812,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $2 call $~lib/map/Map#keys local.set $4 - local.get $0 + local.get $2 call $~lib/map/Map#values local.set $6 i32.const 24 @@ -5856,16 +5823,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $3 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $3 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $3 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $3 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $3 i32.const 0 @@ -5873,17 +5842,16 @@ local.get $3 i32.const 0 i32.store offset=20 - local.get $3 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $5 loop $for-loop|4 - local.get $2 + local.get $0 local.get $4 i32.load offset=12 i32.lt_s if - local.get $2 + local.get $0 + local.tee $1 local.get $4 i32.load offset=12 i32.ge_u @@ -5897,18 +5865,18 @@ end local.get $4 i32.load offset=4 - local.get $2 + local.get $1 i32.const 1 i32.shl i32.add i32.load16_s - local.set $1 + local.set $0 local.get $6 - local.get $2 + local.get $1 call $~lib/array/Array#__get local.set $7 + local.get $2 local.get $0 - local.get $1 call $~lib/map/Map#has i32.eqz if @@ -5919,7 +5887,7 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $2 local.get $7 i32.const 20 i32.sub @@ -5934,22 +5902,22 @@ unreachable end local.get $3 - local.get $1 - local.get $1 + local.get $0 + local.get $0 call $~lib/map/Map#set call $~lib/rt/pure/__release local.get $5 local.get $7 i32.const 20 i32.sub - local.tee $1 - local.get $1 + local.tee $0 + local.get $0 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $2 + local.get $1 i32.const 1 i32.add - local.set $2 + local.set $0 br $for-loop|4 end end @@ -5978,9 +5946,9 @@ unreachable end i32.const 0 - local.set $2 + local.set $0 loop $for-loop|6 - local.get $2 + local.get $0 i32.const 16 i32.shl i32.const 16 @@ -5988,8 +5956,8 @@ i32.const 50 i32.lt_s if - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#has i32.eqz if @@ -6000,10 +5968,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#get - local.get $2 + local.get $0 i32.const 16 i32.shl i32.const 16 @@ -6019,11 +5987,11 @@ call $~lib/builtins/abort unreachable end - local.get $0 local.get $2 - call $~lib/map/Map#delete local.get $0 + call $~lib/map/Map#delete local.get $2 + local.get $0 call $~lib/map/Map#has if i32.const 0 @@ -6033,14 +6001,14 @@ call $~lib/builtins/abort unreachable end - local.get $2 + local.get $0 i32.const 1 i32.add - local.set $2 + local.set $0 br $for-loop|6 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 50 i32.ne @@ -6053,9 +6021,9 @@ unreachable end i32.const 0 - local.set $2 + local.set $0 loop $for-loop|8 - local.get $2 + local.get $0 i32.const 16 i32.shl i32.const 16 @@ -6063,8 +6031,8 @@ i32.const 50 i32.lt_s if - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#has if i32.const 0 @@ -6074,9 +6042,9 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $2 local.get $2 + local.get $0 + local.get $0 i32.const 16 i32.shl i32.const 16 @@ -6085,8 +6053,8 @@ i32.add call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#has i32.eqz if @@ -6097,11 +6065,11 @@ call $~lib/builtins/abort unreachable end - local.get $0 local.get $2 - call $~lib/map/Map#delete local.get $0 + call $~lib/map/Map#delete local.get $2 + local.get $0 call $~lib/map/Map#has if i32.const 0 @@ -6111,14 +6079,14 @@ call $~lib/builtins/abort unreachable end - local.get $2 + local.get $0 i32.const 1 i32.add - local.set $2 + local.set $0 br $for-loop|8 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 50 i32.ne @@ -6130,9 +6098,9 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $2 call $~lib/map/Map#clear - local.get $0 + local.get $2 i32.load offset=20 if i32.const 0 @@ -6150,7 +6118,7 @@ call $~lib/rt/pure/__release local.get $5 call $~lib/rt/pure/__release - local.get $0 + local.get $2 call $~lib/rt/pure/__release ) (func $~lib/map/Map#has (param $0 i32) (param $1 i32) (result i32) @@ -6404,7 +6372,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -6449,7 +6417,7 @@ i32.const 536870904 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -6869,35 +6837,35 @@ i32.const 14 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain - local.tee $0 - i32.const 0 + local.tee $2 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store - local.get $0 - i32.const 0 + local.get $2 + i32.const 3 i32.store offset=4 - local.get $0 - i32.const 0 + local.get $2 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 - local.get $0 - i32.const 0 + local.get $2 + i32.const 4 i32.store offset=12 - local.get $0 + local.get $2 i32.const 0 i32.store offset=16 - local.get $0 + local.get $2 i32.const 0 i32.store offset=20 - local.get $0 - call $~lib/map/Map#clear loop $for-loop|1 - local.get $1 + local.get $3 i32.const 65535 i32.and i32.const 100 i32.lt_u if - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has if i32.const 0 @@ -6907,17 +6875,17 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 - local.get $1 + local.get $2 + local.get $3 + local.get $3 i32.const 65535 i32.and i32.const 10 i32.add call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has i32.eqz if @@ -6928,10 +6896,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#get - local.get $1 + local.get $3 i32.const 65535 i32.and i32.const 10 @@ -6945,14 +6913,14 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $3 i32.const 1 i32.add - local.set $1 + local.set $3 br $for-loop|1 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 100 i32.ne @@ -6965,16 +6933,16 @@ unreachable end i32.const 0 - local.set $1 + local.set $3 loop $for-loop|3 - local.get $1 + local.get $3 i32.const 65535 i32.and i32.const 100 i32.lt_u if - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has i32.eqz if @@ -6985,10 +6953,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#get - local.get $1 + local.get $3 i32.const 65535 i32.and i32.const 10 @@ -7002,17 +6970,17 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 - local.get $1 + local.get $2 + local.get $3 + local.get $3 i32.const 65535 i32.and i32.const 20 i32.add call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#has i32.eqz if @@ -7023,10 +6991,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 + local.get $2 + local.get $3 call $~lib/map/Map#get - local.get $1 + local.get $3 i32.const 65535 i32.and i32.const 20 @@ -7040,14 +7008,14 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $3 i32.const 1 i32.add - local.set $1 + local.set $3 br $for-loop|3 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 100 i32.ne @@ -7059,10 +7027,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $2 call $~lib/map/Map#keys local.set $4 - local.get $0 + local.get $2 call $~lib/map/Map#values local.set $6 i32.const 24 @@ -7070,16 +7038,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $3 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $3 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $3 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $3 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $3 i32.const 0 @@ -7087,17 +7057,16 @@ local.get $3 i32.const 0 i32.store offset=20 - local.get $3 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $5 loop $for-loop|4 - local.get $2 + local.get $0 local.get $4 i32.load offset=12 i32.lt_s if - local.get $2 + local.get $0 + local.tee $1 local.get $4 i32.load offset=12 i32.ge_u @@ -7111,18 +7080,18 @@ end local.get $4 i32.load offset=4 - local.get $2 + local.get $1 i32.const 1 i32.shl i32.add i32.load16_u - local.set $1 + local.set $0 local.get $6 - local.get $2 + local.get $1 call $~lib/array/Array#__get local.set $7 + local.get $2 local.get $0 - local.get $1 call $~lib/map/Map#has i32.eqz if @@ -7133,7 +7102,7 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $2 local.get $7 i32.const 20 i32.sub @@ -7148,22 +7117,22 @@ unreachable end local.get $3 - local.get $1 - local.get $1 + local.get $0 + local.get $0 call $~lib/map/Map#set call $~lib/rt/pure/__release local.get $5 local.get $7 i32.const 20 i32.sub - local.tee $1 - local.get $1 + local.tee $0 + local.get $0 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $2 + local.get $1 i32.const 1 i32.add - local.set $2 + local.set $0 br $for-loop|4 end end @@ -7192,16 +7161,16 @@ unreachable end i32.const 0 - local.set $2 + local.set $0 loop $for-loop|6 - local.get $2 + local.get $0 i32.const 65535 i32.and i32.const 50 i32.lt_u if - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#has i32.eqz if @@ -7212,10 +7181,10 @@ call $~lib/builtins/abort unreachable end - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#get - local.get $2 + local.get $0 i32.const 65535 i32.and i32.const 20 @@ -7229,11 +7198,11 @@ call $~lib/builtins/abort unreachable end - local.get $0 local.get $2 - call $~lib/map/Map#delete local.get $0 + call $~lib/map/Map#delete local.get $2 + local.get $0 call $~lib/map/Map#has if i32.const 0 @@ -7243,14 +7212,14 @@ call $~lib/builtins/abort unreachable end - local.get $2 + local.get $0 i32.const 1 i32.add - local.set $2 + local.set $0 br $for-loop|6 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 50 i32.ne @@ -7263,16 +7232,16 @@ unreachable end i32.const 0 - local.set $2 + local.set $0 loop $for-loop|8 - local.get $2 + local.get $0 i32.const 65535 i32.and i32.const 50 i32.lt_u if - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#has if i32.const 0 @@ -7282,17 +7251,17 @@ call $~lib/builtins/abort unreachable end - local.get $0 - local.get $2 local.get $2 + local.get $0 + local.get $0 i32.const 65535 i32.and i32.const 10 i32.add call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $0 local.get $2 + local.get $0 call $~lib/map/Map#has i32.eqz if @@ -7303,11 +7272,11 @@ call $~lib/builtins/abort unreachable end - local.get $0 local.get $2 - call $~lib/map/Map#delete local.get $0 + call $~lib/map/Map#delete local.get $2 + local.get $0 call $~lib/map/Map#has if i32.const 0 @@ -7317,14 +7286,14 @@ call $~lib/builtins/abort unreachable end - local.get $2 + local.get $0 i32.const 1 i32.add - local.set $2 + local.set $0 br $for-loop|8 end end - local.get $0 + local.get $2 i32.load offset=20 i32.const 50 i32.ne @@ -7336,9 +7305,9 @@ call $~lib/builtins/abort unreachable end - local.get $0 + local.get $2 call $~lib/map/Map#clear - local.get $0 + local.get $2 i32.load offset=20 if i32.const 0 @@ -7356,7 +7325,7 @@ call $~lib/rt/pure/__release local.get $5 call $~lib/rt/pure/__release - local.get $0 + local.get $2 call $~lib/rt/pure/__release ) (func $~lib/map/Map#has (param $0 i32) (param $1 i32) (result i32) @@ -7379,7 +7348,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -7945,7 +7914,7 @@ i32.const 268435452 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -8039,16 +8008,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -8056,8 +8027,6 @@ local.get $0 i32.const 0 i32.store offset=20 - local.get $0 - call $~lib/map/Map#clear loop $for-loop|0 local.get $1 i32.const 100 @@ -8225,16 +8194,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $1 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $1 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $1 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $1 i32.const 0 @@ -8242,8 +8213,6 @@ local.get $1 i32.const 0 i32.store offset=20 - local.get $1 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $5 loop $for-loop|2 @@ -8490,39 +8459,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store - local.get $0 - i32.const 3 - i32.store offset=4 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/util/hash/hash64 (param $0 i64) (result i32) (local $1 i32) local.get $0 @@ -8875,7 +8811,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -8970,7 +8906,7 @@ i32.const 134217726 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -9102,39 +9038,6 @@ call $~lib/array/Array#set:length local.get $0 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store - local.get $0 - i32.const 3 - i32.store offset=4 - i32.const 96 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/array/Array#__get (param $0 i32) (param $1 i32) (result i64) local.get $1 local.get $0 @@ -9477,6 +9380,39 @@ call $~lib/map/Map#rehash end ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store + local.get $0 + i32.const 3 + i32.store offset=4 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i64) (local $1 i32) @@ -9491,16 +9427,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $1 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $1 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $1 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $1 i32.const 0 @@ -9508,8 +9446,6 @@ local.get $1 i32.const 0 i32.store offset=20 - local.get $1 - call $~lib/map/Map#clear loop $for-loop|0 local.get $0 i64.const 100 @@ -9682,16 +9618,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $2 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $2 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $2 - i32.const 0 + i32.const 96 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $2 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $2 i32.const 0 @@ -9699,8 +9637,6 @@ local.get $2 i32.const 0 i32.store offset=20 - local.get $2 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $6 loop $for-loop|2 @@ -9987,7 +9923,7 @@ i32.const 134217726 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -10081,16 +10017,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $1 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $1 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $1 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $1 i32.const 0 @@ -10098,8 +10036,6 @@ local.get $1 i32.const 0 i32.store offset=20 - local.get $1 - call $~lib/map/Map#clear loop $for-loop|0 local.get $0 i64.const 100 @@ -10272,16 +10208,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $2 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $2 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $2 - i32.const 0 + i32.const 96 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $2 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $2 i32.const 0 @@ -10289,8 +10227,6 @@ local.get $2 i32.const 0 i32.store offset=20 - local.get $2 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $6 loop $for-loop|2 @@ -10830,7 +10766,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -10876,7 +10812,7 @@ i32.const 268435452 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -11291,16 +11227,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $1 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $1 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $1 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $1 i32.const 0 @@ -11308,8 +11246,6 @@ local.get $1 i32.const 0 i32.store offset=20 - local.get $1 - call $~lib/map/Map#clear loop $for-loop|0 local.get $0 f32.const 100 @@ -11482,16 +11418,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $2 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $2 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $2 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $2 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $2 i32.const 0 @@ -11499,8 +11437,6 @@ local.get $2 i32.const 0 i32.store offset=20 - local.get $2 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $6 loop $for-loop|2 @@ -12056,7 +11992,7 @@ if i32.const 1360 i32.const 1424 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -12102,7 +12038,7 @@ i32.const 134217726 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1472 i32.const 57 i32.const 60 @@ -12553,16 +12489,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $1 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $1 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $1 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $1 i32.const 0 @@ -12570,8 +12508,6 @@ local.get $1 i32.const 0 i32.store offset=20 - local.get $1 - call $~lib/map/Map#clear loop $for-loop|0 local.get $0 f64.const 100 @@ -12744,16 +12680,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $2 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $2 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $2 - i32.const 0 + i32.const 96 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $2 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $2 i32.const 0 @@ -12761,8 +12699,6 @@ local.get $2 i32.const 0 i32.store offset=20 - local.get $2 - call $~lib/map/Map#clear call $~lib/map/Map#constructor local.set $6 loop $for-loop|2 @@ -13057,7 +12993,7 @@ i32.and if i32.const 0 - i32.const 1264 + i32.const 1152 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -13106,7 +13042,7 @@ i32.and if i32.const 0 - i32.const 1264 + i32.const 1152 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -13121,7 +13057,7 @@ i32.le_u if i32.const 0 - i32.const 1264 + i32.const 1152 i32.const 136 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/map.untouched.wat b/tests/compiler/std/map.untouched.wat index 8a09e76627..3ed60db6e5 100644 --- a/tests/compiler/std/map.untouched.wat +++ b/tests/compiler/std/map.untouched.wat @@ -2,8 +2,8 @@ (type $i32_=>_i32 (func (param i32) (result i32))) (type $i32_i32_=>_none (func (param i32 i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_none (func (param i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) + (type $i32_=>_none (func (param i32))) (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $none_=>_none (func)) (type $i32_i64_=>_i32 (func (param i32 i64) (result i32))) @@ -31,11 +31,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 16) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") - (data (i32.const 64) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") - (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") - (data (i32.const 176) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") - (data (i32.const 240) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") + (data (i32.const 16) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") + (data (i32.const 64) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") + (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") + (data (i32.const 176) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") + (data (i32.const 224) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") (data (i32.const 288) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00m\00a\00p\00.\00t\00s\00") (data (i32.const 336) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00K\00e\00y\00 \00d\00o\00e\00s\00 \00n\00o\00t\00 \00e\00x\00i\00s\00t\00") (data (i32.const 400) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00~\00l\00i\00b\00/\00m\00a\00p\00.\00t\00s\00") @@ -50,17 +50,6 @@ (global $~lib/heap/__heap_base i32 (i32.const 548)) (export "memory" (memory $0)) (start $~start) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -83,7 +72,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -110,7 +99,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -164,7 +153,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -296,7 +285,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -313,7 +302,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -408,7 +397,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -473,7 +462,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -491,7 +480,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -550,7 +539,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -671,7 +660,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -696,7 +685,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -729,7 +718,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -960,8 +949,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 192 - i32.const 144 + i32.const 80 + i32.const 32 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -1057,7 +1046,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -1122,7 +1111,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -1271,7 +1260,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -1364,7 +1353,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1411,7 +1400,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1432,7 +1421,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 518 i32.const 18 call $~lib/builtins/abort @@ -1453,7 +1442,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1489,6 +1478,82 @@ i32.const 16 i32.add ) + (func $~lib/rt/pure/increment (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + i32.eq + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 1 + drop + local.get $0 + call $~lib/rt/rtrace/onincrement + i32.const 1 + drop + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/increment + end + local.get $0 + ) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) @@ -1702,71 +1767,6 @@ end end ) - (func $~lib/rt/pure/increment (param $0 i32) - (local $1 i32) - local.get $0 - i32.load offset=4 - local.set $1 - local.get $1 - i32.const 268435455 - i32.const -1 - i32.xor - i32.and - local.get $1 - i32.const 1 - i32.add - i32.const 268435455 - i32.const -1 - i32.xor - i32.and - i32.eq - i32.eqz - if - i32.const 0 - i32.const 256 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.store offset=4 - i32.const 1 - drop - local.get $0 - call $~lib/rt/rtrace/onincrement - i32.const 1 - drop - local.get $0 - i32.load - i32.const 1 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 256 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/increment - end - local.get $0 - ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) @@ -1774,8 +1774,8 @@ i32.const 1073741808 i32.gt_u if - i32.const 32 - i32.const 80 + i32.const 192 + i32.const 240 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1796,46 +1796,6 @@ call $~lib/rt/pure/__release local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -1848,15 +1808,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1865,8 +1835,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/util/hash/hash8 (param $0 i32) (result i32) i32.const -2128831035 @@ -2277,7 +2245,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -2322,7 +2290,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -2409,7 +2377,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -3843,7 +3811,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 14 i32.const 48 @@ -4044,7 +4012,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -4217,46 +4185,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -4269,39 +4197,10 @@ end local.get $0 i32.const 0 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - i32.const 0 - i32.store offset=8 - local.get $0 - i32.const 0 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - local.get $0 - call $~lib/map/Map#clear - local.get $0 - ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 + i32.const 4 + i32.const 4 + i32.mul call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 i32.store local.get $0 i32.const 4 @@ -4309,15 +4208,11 @@ i32.sub i32.store offset=4 local.get $0 - local.tee $2 i32.const 0 - i32.const 48 + i32.const 4 + i32.const 8 + i32.mul call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 i32.store offset=8 local.get $0 i32.const 4 @@ -4328,6 +4223,7 @@ local.get $0 i32.const 0 i32.store offset=20 + local.get $0 ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 @@ -4341,15 +4237,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -4358,8 +4264,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -5255,6 +5159,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 i32) @@ -5764,46 +5712,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -5816,15 +5724,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -5833,8 +5751,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/map/Map#find (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -6230,7 +6146,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -6275,7 +6191,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -6513,46 +6429,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -6565,15 +6441,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -6582,8 +6468,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -7048,8 +6932,52 @@ end i32.const 1 ) - (func $std/map/testNumeric - (local $0 i32) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) + (func $std/map/testNumeric + (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -7535,46 +7463,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -7587,15 +7475,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -7604,8 +7502,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/util/hash/hash16 (param $0 i32) (result i32) (local $1 i32) @@ -8047,7 +7943,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -8092,7 +7988,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -8330,46 +8226,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -8382,15 +8238,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -8399,8 +8265,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -8883,6 +8747,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 i32) @@ -9392,46 +9300,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -9444,15 +9312,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -9461,8 +9339,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/map/Map#find (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -9874,7 +9750,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -9919,7 +9795,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -10157,46 +10033,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -10209,15 +10045,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -10226,8 +10072,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -10704,6 +10548,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 i32) @@ -11261,7 +11149,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -11497,6 +11385,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 i32) @@ -11960,46 +11892,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -12012,15 +11904,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -12029,8 +11931,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/map/Map#find (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -12450,7 +12350,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -12495,7 +12395,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -12733,46 +12633,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -12785,15 +12645,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -12802,8 +12672,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -13286,8 +13154,52 @@ end i32.const 1 ) - (func $std/map/testNumeric - (local $0 i32) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) + (func $std/map/testNumeric + (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -13749,46 +13661,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -13801,15 +13673,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -13818,8 +13700,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/util/hash/hash64 (param $0 i64) (result i32) (local $1 i32) @@ -14345,7 +14225,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -14390,7 +14270,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -14628,46 +14508,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 96 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -14680,15 +14520,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 24 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -14697,8 +14547,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -15196,6 +15044,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 i64) @@ -15667,46 +15559,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -15719,15 +15571,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -15736,8 +15598,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/map/Map#find (param $0 i32) (param $1 i64) (param $2 i32) (result i32) (local $3 i32) @@ -16175,7 +16035,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -16220,7 +16080,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -16458,46 +16318,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 96 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -16510,15 +16330,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 24 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -16527,8 +16357,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -17026,6 +16854,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 i64) @@ -17497,46 +17369,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -17549,15 +17381,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -17566,8 +17408,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/map/Map#find (param $0 i32) (param $1 f32) (param $2 i32) (result i32) (local $3 i32) @@ -17961,7 +17801,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -18006,7 +17846,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -18214,75 +18054,35 @@ i32.const 12 i32.mul i32.add - local.set $7 - local.get $7 - i32.load offset=8 - i32.const 1 - i32.and - i32.eqz - if - local.get $3 - local.get $4 - local.tee $8 - i32.const 1 - i32.add - local.set $4 - local.get $8 - local.get $7 - i32.load offset=4 - call $~lib/array/Array#__set - end - local.get $5 - i32.const 1 - i32.add - local.set $5 - br $for-loop|0 - end - end - local.get $3 - local.get $4 - call $~lib/array/Array#set:length - local.get $3 - ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 + local.set $7 + local.get $7 + i32.load offset=8 + i32.const 1 + i32.and + i32.eqz + if + local.get $3 + local.get $4 + local.tee $8 + i32.const 1 + i32.add + local.set $4 + local.get $8 + local.get $7 + i32.load offset=4 + call $~lib/array/Array#__set + end + local.get $5 + i32.const 1 + i32.add + local.set $5 + br $for-loop|0 + end + end + local.get $3 + local.get $4 + call $~lib/array/Array#set:length + local.get $3 ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 @@ -18296,15 +18096,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -18313,8 +18123,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -18779,6 +18587,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 f32) @@ -19250,46 +19102,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -19302,15 +19114,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -19319,8 +19141,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/map/Map#find (param $0 i32) (param $1 f64) (param $2 i32) (result i32) (local $3 i32) @@ -19730,7 +19550,7 @@ if i32.const 352 i32.const 416 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -19775,7 +19595,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 464 i32.const 57 i32.const 60 @@ -20013,46 +19833,6 @@ call $~lib/array/Array#set:length local.get $3 ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 96 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -20065,15 +19845,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 24 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -20082,8 +19872,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 @@ -20560,6 +20348,50 @@ end i32.const 1 ) + (func $~lib/map/Map#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/map/testNumeric (local $0 i32) (local $1 f64) @@ -21046,6 +20878,11 @@ (func $~start call $start:std/map ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/finalize (param $0 i32) i32.const 0 drop @@ -21077,7 +20914,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -21103,7 +20940,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -21120,7 +20957,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 136 i32.const 16 call $~lib/builtins/abort @@ -21141,11 +20978,6 @@ i32.store offset=4 end ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base @@ -21163,7 +20995,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 69 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/set.optimized.wat b/tests/compiler/std/set.optimized.wat index d466d43d4e..ceb2ad6dcf 100644 --- a/tests/compiler/std/set.optimized.wat +++ b/tests/compiler/std/set.optimized.wat @@ -29,11 +29,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 1024) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") - (data (i32.const 1072) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") - (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") - (data (i32.const 1184) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") - (data (i32.const 1248) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") + (data (i32.const 1024) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") + (data (i32.const 1072) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") + (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") + (data (i32.const 1184) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") + (data (i32.const 1232) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") (data (i32.const 1296) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00s\00e\00t\00.\00t\00s") (data (i32.const 1344) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") (data (i32.const 1392) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e") @@ -41,17 +41,6 @@ (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) (export "memory" (memory $0)) (start $~start) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 1444 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -65,7 +54,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -87,7 +76,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -130,7 +119,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -226,7 +215,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -240,7 +229,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -313,7 +302,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -368,7 +357,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -383,7 +372,7 @@ i32.ne if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -431,7 +420,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -514,7 +503,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -531,7 +520,7 @@ i32.lt_u if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -559,7 +548,7 @@ i32.lt_u if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -699,8 +688,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 1200 - i32.const 1152 + i32.const 1088 + i32.const 1040 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -773,7 +762,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -825,7 +814,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -858,7 +847,7 @@ i32.and if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -929,7 +918,7 @@ global.get $~lib/rt/tlsf/collectLock if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1020,7 +1009,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1036,7 +1025,7 @@ i32.lt_u if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1070,6 +1059,68 @@ i32.const 16 i32.add ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.const 1444 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load offset=4 + local.tee $2 + i32.const -268435456 + i32.and + local.get $2 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 1152 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.add + i32.store offset=4 + local.get $1 + call $~lib/rt/rtrace/onincrement + local.get $1 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 1152 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + end + local.get $0 + ) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 1444 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 @@ -1228,65 +1279,14 @@ end end ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - local.get $0 - i32.const 1444 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - local.tee $1 - i32.load offset=4 - local.tee $2 - i32.const -268435456 - i32.and - local.get $2 - i32.const 1 - i32.add - i32.const -268435456 - i32.and - i32.ne - if - i32.const 0 - i32.const 1264 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $1 - local.get $2 - i32.const 1 - i32.add - i32.store offset=4 - local.get $1 - call $~lib/rt/rtrace/onincrement - local.get $1 - i32.load - i32.const 1 - i32.and - if - i32.const 0 - i32.const 1264 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - end - local.get $0 - ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 1073741808 i32.gt_u if - i32.const 1040 - i32.const 1088 + i32.const 1200 + i32.const 1248 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1302,39 +1302,6 @@ call $~lib/rt/pure/__retain local.tee $0 ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store - local.get $0 - i32.const 3 - i32.store offset=4 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (result i32) (local $0 i32) i32.const 24 @@ -1342,16 +1309,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1360,8 +1329,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash8 (param $0 i32) (result i32) local.get $0 @@ -1952,7 +1919,7 @@ i32.shr_u i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 14 i32.const 48 @@ -1995,7 +1962,7 @@ i32.eqz if i32.const 0 - i32.const 1152 + i32.const 1040 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -2116,7 +2083,7 @@ i32.const 1073741808 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -2275,6 +2242,39 @@ call $~lib/set/Set#rehash end ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store + local.get $0 + i32.const 3 + i32.store offset=4 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 i32) @@ -2599,16 +2599,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -2617,8 +2619,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#has (param $0 i32) (param $1 i32) (result i32) local.get $0 @@ -2883,7 +2883,7 @@ i32.const 1073741808 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -3356,16 +3356,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -3374,8 +3376,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash16 (param $0 i32) (result i32) local.get $0 @@ -3753,7 +3753,7 @@ i32.const 536870904 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -4241,16 +4241,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -4259,8 +4261,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#has (param $0 i32) (param $1 i32) (result i32) local.get $0 @@ -4526,7 +4526,7 @@ i32.const 536870904 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -5004,16 +5004,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -5022,8 +5024,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash32 (param $0 i32) (result i32) local.get $0 @@ -5407,7 +5407,7 @@ i32.const 268435452 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -5875,16 +5875,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -5893,8 +5895,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -5933,7 +5933,7 @@ i32.const 268435452 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -6314,39 +6314,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store - local.get $0 - i32.const 3 - i32.store offset=4 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (result i32) (local $0 i32) i32.const 24 @@ -6354,16 +6321,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -6372,8 +6341,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash64 (param $0 i64) (result i32) (local $1 i32) @@ -6792,7 +6759,7 @@ i32.const 134217726 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -6953,6 +6920,39 @@ call $~lib/set/Set#rehash end ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store + local.get $0 + i32.const 3 + i32.store offset=4 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $0 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $0 + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i64) (local $1 i32) @@ -7262,16 +7262,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -7280,8 +7282,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -7320,7 +7320,7 @@ i32.const 134217726 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -7709,16 +7709,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -7727,8 +7729,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 f32) (param $2 i32) (result i32) local.get $0 @@ -8035,7 +8035,7 @@ i32.const 268435452 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -8539,16 +8539,18 @@ call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 64 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -8557,8 +8559,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 f64) (param $2 i32) (result i32) local.get $0 @@ -8865,7 +8865,7 @@ i32.const 134217726 i32.gt_u if - i32.const 1040 + i32.const 1200 i32.const 1360 i32.const 57 i32.const 60 @@ -9391,7 +9391,7 @@ i32.and if i32.const 0 - i32.const 1264 + i32.const 1152 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -9440,7 +9440,7 @@ i32.and if i32.const 0 - i32.const 1264 + i32.const 1152 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -9455,7 +9455,7 @@ i32.le_u if i32.const 0 - i32.const 1264 + i32.const 1152 i32.const 136 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/set.untouched.wat b/tests/compiler/std/set.untouched.wat index 1a14648c53..19396fdf08 100644 --- a/tests/compiler/std/set.untouched.wat +++ b/tests/compiler/std/set.untouched.wat @@ -28,11 +28,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 16) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") - (data (i32.const 64) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") - (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") - (data (i32.const 176) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") - (data (i32.const 240) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") + (data (i32.const 16) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") + (data (i32.const 64) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") + (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") + (data (i32.const 176) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") + (data (i32.const 224) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") (data (i32.const 288) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00s\00e\00t\00.\00t\00s\00") (data (i32.const 336) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") (data (i32.const 384) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00") @@ -45,17 +45,6 @@ (global $~lib/heap/__heap_base i32 (i32.const 436)) (export "memory" (memory $0)) (start $~start) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -78,7 +67,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -105,7 +94,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -159,7 +148,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -291,7 +280,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -308,7 +297,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -403,7 +392,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -468,7 +457,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -486,7 +475,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -545,7 +534,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -666,7 +655,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -691,7 +680,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -724,7 +713,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -955,8 +944,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 192 - i32.const 144 + i32.const 80 + i32.const 32 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -1052,7 +1041,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -1117,7 +1106,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -1266,7 +1255,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -1359,7 +1348,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1406,7 +1395,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1427,7 +1416,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 518 i32.const 18 call $~lib/builtins/abort @@ -1448,7 +1437,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1484,6 +1473,82 @@ i32.const 16 i32.add ) + (func $~lib/rt/pure/increment (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + i32.eq + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 1 + drop + local.get $0 + call $~lib/rt/rtrace/onincrement + i32.const 1 + drop + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/increment + end + local.get $0 + ) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) @@ -1697,71 +1762,6 @@ end end ) - (func $~lib/rt/pure/increment (param $0 i32) - (local $1 i32) - local.get $0 - i32.load offset=4 - local.set $1 - local.get $1 - i32.const 268435455 - i32.const -1 - i32.xor - i32.and - local.get $1 - i32.const 1 - i32.add - i32.const 268435455 - i32.const -1 - i32.xor - i32.and - i32.eq - i32.eqz - if - i32.const 0 - i32.const 256 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.store offset=4 - i32.const 1 - drop - local.get $0 - call $~lib/rt/rtrace/onincrement - i32.const 1 - drop - local.get $0 - i32.load - i32.const 1 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 256 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/increment - end - local.get $0 - ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) @@ -1769,8 +1769,8 @@ i32.const 1073741808 i32.gt_u if - i32.const 32 - i32.const 80 + i32.const 192 + i32.const 240 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1791,46 +1791,6 @@ call $~lib/rt/pure/__release local.get $3 ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -1843,15 +1803,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1860,8 +1830,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash8 (param $0 i32) (result i32) i32.const -2128831035 @@ -2258,7 +2226,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -2345,7 +2313,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 32 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -3779,7 +3747,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 14 i32.const 48 @@ -4070,11 +4038,55 @@ end i32.const 1 ) - (func $std/set/testNumeric - (local $0 i32) + (func $~lib/set/Set#clear (param $0 i32) (local $1 i32) (local $2 i32) - (local $3 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) + (func $std/set/testNumeric + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -4426,46 +4438,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -4478,15 +4450,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -4495,8 +4477,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -4880,7 +4860,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -5174,6 +5154,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 i32) @@ -5522,46 +5546,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -5574,15 +5558,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -5591,8 +5585,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash16 (param $0 i32) (result i32) (local $1 i32) @@ -6016,7 +6008,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -6316,6 +6308,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 i32) @@ -6672,47 +6708,7 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) - (func $~lib/set/Set#constructor (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -6724,15 +6720,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -6741,8 +6747,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -7138,7 +7142,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -7436,6 +7440,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 i32) @@ -7784,46 +7832,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -7836,15 +7844,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -7853,8 +7871,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash32 (param $0 i32) (result i32) (local $1 i32) @@ -8298,7 +8314,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -8598,6 +8614,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 i32) @@ -8934,46 +8994,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -8986,15 +9006,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -9003,8 +9033,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -9406,7 +9434,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -9706,6 +9734,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 i32) @@ -10042,46 +10114,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -10094,15 +10126,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -10111,8 +10153,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/util/hash/hash64 (param $0 i64) (result i32) (local $1 i32) @@ -10616,7 +10656,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -10921,6 +10961,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 i64) @@ -11258,46 +11342,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -11310,15 +11354,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -11327,8 +11381,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 i64) (param $2 i32) (result i32) (local $3 i32) @@ -11744,7 +11796,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -12020,34 +12072,78 @@ i32.const 1 i32.add i32.const 4 - local.tee $5 + local.tee $5 + local.get $0 + i32.load offset=20 + local.tee $6 + local.get $5 + local.get $6 + i32.gt_u + select + i32.ge_u + if (result i32) + local.get $0 + i32.load offset=20 + local.get $0 + i32.load offset=12 + i32.const 3 + i32.mul + i32.const 4 + i32.div_s + i32.lt_s + else + i32.const 0 + end + if + local.get $0 + local.get $4 + call $~lib/set/Set#rehash + end + i32.const 1 + ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 local.get $0 - i32.load offset=20 - local.tee $6 - local.get $5 - local.get $6 - i32.gt_u - select - i32.ge_u - if (result i32) - local.get $0 - i32.load offset=20 - local.get $0 - i32.load offset=12 - i32.const 3 - i32.mul - i32.const 4 - i32.div_s - i32.lt_s - else - i32.const 0 - end - if - local.get $0 - local.get $4 - call $~lib/set/Set#rehash - end - i32.const 1 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 ) (func $std/set/testNumeric (local $0 i32) @@ -12386,46 +12482,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 32 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -12438,15 +12494,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -12455,8 +12521,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 f32) (param $2 i32) (result i32) (local $3 i32) @@ -12839,7 +12903,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -13133,6 +13197,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 8 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 f32) @@ -13470,46 +13578,6 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/set/Set#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/pure/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 64 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/pure/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/set/Set#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -13522,15 +13590,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -13539,8 +13617,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/set/Set#clear - local.get $0 ) (func $~lib/set/Set#find (param $0 i32) (param $1 f64) (param $2 i32) (result i32) (local $3 i32) @@ -13935,7 +14011,7 @@ i32.shr_u i32.gt_u if - i32.const 32 + i32.const 192 i32.const 352 i32.const 57 i32.const 60 @@ -14233,6 +14309,50 @@ end i32.const 1 ) + (func $~lib/set/Set#clear (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + local.tee $1 + i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $2 + local.get $1 + i32.load + call $~lib/rt/pure/__release + local.get $2 + i32.store + local.get $0 + i32.const 4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + local.tee $2 + i32.const 0 + i32.const 4 + i32.const 16 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $1 + local.get $2 + i32.load offset=8 + call $~lib/rt/pure/__release + local.get $1 + i32.store offset=8 + local.get $0 + i32.const 4 + i32.store offset=12 + local.get $0 + i32.const 0 + i32.store offset=16 + local.get $0 + i32.const 0 + i32.store offset=20 + ) (func $std/set/testNumeric (local $0 i32) (local $1 f64) @@ -14585,6 +14705,11 @@ (func $~start call $start:std/set ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/finalize (param $0 i32) i32.const 0 drop @@ -14616,7 +14741,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -14642,7 +14767,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -14659,7 +14784,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 136 i32.const 16 call $~lib/builtins/abort @@ -14680,11 +14805,6 @@ i32.store offset=4 end ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base @@ -14702,7 +14822,7 @@ i32.eqz if i32.const 0 - i32.const 256 + i32.const 144 i32.const 69 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index d52f3c51f4..4d2afc686c 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -5,7 +5,6 @@ (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i32_=>_none (func (param i32))) (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) @@ -327,39 +326,6 @@ call $~lib/memory/memory.fill local.get $1 ) - (func $~lib/map/Map<~lib/string/String,usize>#clear (param $0 i32) - (local $1 i32) - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load - drop - local.get $0 - local.get $1 - i32.store - local.get $0 - i32.const 3 - i32.store offset=4 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $0 - i32.load offset=8 - drop - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/string/String#get:length (param $0 i32) (result i32) local.get $0 i32.const 16 @@ -1039,7 +1005,7 @@ if i32.const 1232 i32.const 1296 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -1053,16 +1019,18 @@ i32.const 3 call $~lib/rt/stub/__alloc local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1071,23 +1039,23 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map<~lib/string/String,usize>#clear - local.get $0 global.set $~lib/symbol/stringToId i32.const 24 i32.const 4 call $~lib/rt/stub/__alloc local.tee $0 - i32.const 0 + i32.const 16 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 3 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 48 + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1096,8 +1064,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map<~lib/string/String,usize>#clear - local.get $0 global.set $~lib/symbol/idToString end global.get $~lib/symbol/nextId @@ -1138,7 +1104,7 @@ if i32.const 1232 i32.const 1296 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index 75214dc83f..f54cf796b1 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -1,10 +1,10 @@ (module (type $i32_=>_i32 (func (param i32) (result i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_=>_none (func (param i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $none_=>_none (func)) + (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_none (func (param i32 i32))) (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32 i32) (result i32))) @@ -438,46 +438,6 @@ call $~lib/rt/stub/__release local.get $3 ) - (func $~lib/map/Map<~lib/string/String,usize>#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/stub/__release - local.get $2 - i32.store - local.get $0 - i32.const 4 - i32.const 1 - i32.sub - i32.store offset=4 - local.get $0 - local.tee $2 - i32.const 0 - i32.const 48 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/stub/__release - local.get $1 - i32.store offset=8 - local.get $0 - i32.const 4 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - ) (func $~lib/map/Map<~lib/string/String,usize>#constructor (param $0 i32) (result i32) local.get $0 i32.eqz @@ -490,39 +450,10 @@ end local.get $0 i32.const 0 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - i32.const 0 - i32.store offset=8 - local.get $0 - i32.const 0 - i32.store offset=12 - local.get $0 - i32.const 0 - i32.store offset=16 - local.get $0 - i32.const 0 - i32.store offset=20 - local.get $0 - call $~lib/map/Map<~lib/string/String,usize>#clear - local.get $0 - ) - (func $~lib/map/Map#clear (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - local.tee $1 - i32.const 0 - i32.const 16 + i32.const 4 + i32.const 4 + i32.mul call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $2 - local.get $1 - i32.load - call $~lib/rt/stub/__release - local.get $2 i32.store local.get $0 i32.const 4 @@ -530,15 +461,11 @@ i32.sub i32.store offset=4 local.get $0 - local.tee $2 i32.const 0 - i32.const 48 + i32.const 4 + i32.const 12 + i32.mul call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $1 - local.get $2 - i32.load offset=8 - call $~lib/rt/stub/__release - local.get $1 i32.store offset=8 local.get $0 i32.const 4 @@ -549,6 +476,7 @@ local.get $0 i32.const 0 i32.store offset=20 + local.get $0 ) (func $~lib/map/Map#constructor (param $0 i32) (result i32) local.get $0 @@ -562,15 +490,25 @@ end local.get $0 i32.const 0 + i32.const 4 + i32.const 4 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - i32.const 0 + i32.const 4 + i32.const 1 + i32.sub i32.store offset=4 local.get $0 i32.const 0 + i32.const 4 + i32.const 12 + i32.mul + call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - i32.const 0 + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -579,8 +517,6 @@ i32.const 0 i32.store offset=20 local.get $0 - call $~lib/map/Map#clear - local.get $0 ) (func $~lib/string/String#get:length (param $0 i32) (result i32) local.get $0 @@ -960,7 +896,7 @@ if i32.const 224 i32.const 288 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable @@ -1803,7 +1739,7 @@ if i32.const 224 i32.const 288 - i32.const 111 + i32.const 110 i32.const 17 call $~lib/builtins/abort unreachable diff --git a/tslint.json b/tslint.json index e075f8c784..9ad6e5b4c9 100644 --- a/tslint.json +++ b/tslint.json @@ -1,6 +1,6 @@ { "extends": "./lib/lint", - "defaultSeverity": "warning", + "defaultSeverity": "error", "rules": { "as-internal-case": {}, "as-internal-diagnostics": {},