Support parameter properties; Minor formatting

This commit is contained in:
dcodeIO 2018-03-25 00:21:58 +01:00
parent c80bf35747
commit 38a025950e
17 changed files with 314 additions and 234 deletions

View File

@ -5,7 +5,7 @@
[![Build Status](https://travis-ci.org/AssemblyScript/assemblyscript.svg?branch=master)](https://travis-ci.org/AssemblyScript/assemblyscript) [![Build Status](https://travis-ci.org/AssemblyScript/assemblyscript.svg?branch=master)](https://travis-ci.org/AssemblyScript/assemblyscript)
[![Snap Status](https://build.snapcraft.io/badge/AssemblyScript/assemblyscript.svg)](https://build.snapcraft.io/user/AssemblyScript/assemblyscript) [![Snap Status](https://build.snapcraft.io/badge/AssemblyScript/assemblyscript.svg)](https://build.snapcraft.io/user/AssemblyScript/assemblyscript)
**AssemblyScript** compiles strictly typed [TypeScript](http://www.typescriptlang.org) to [WebAssembly](http://webassembly.org) using [Binaryen](https://github.com/WebAssembly/binaryen). It generates minimal WebAssembly modules while being just an `npm install` away. **AssemblyScript** compiles strictly typed [TypeScript](http://www.typescriptlang.org) to [WebAssembly](http://webassembly.org) using [Binaryen](https://github.com/WebAssembly/binaryen). It generates lean and mean WebAssembly modules while being just an `npm install` away.
See [the AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) for further instructions and documentation. You can also try it out in [WebAssembly Studio](https://webassembly.studio)! See [the AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) for further instructions and documentation. You can also try it out in [WebAssembly Studio](https://webassembly.studio)!

2
dist/asc.js vendored

File diff suppressed because one or more lines are too long

2
dist/asc.js.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -80,9 +80,6 @@
"no-object-literal-type-assertion": { "no-object-literal-type-assertion": {
"severity": "error" "severity": "error"
}, },
"no-parameter-properties": {
"severity": "error"
},
"no-require-imports": { "no-require-imports": {
"severity": "error" "severity": "error"
}, },

View File

@ -1047,6 +1047,8 @@ export class ParameterNode extends Node {
type: CommonTypeNode; type: CommonTypeNode;
/** Initializer expression, if present. */ /** Initializer expression, if present. */
initializer: Expression | null; initializer: Expression | null;
/** Implicit field declaration, if applicable. */
implicitFieldDeclaration: FieldDeclaration | null = null;
} }
/** Represents a function signature. */ /** Represents a function signature. */
@ -1583,6 +1585,9 @@ export class ExpressionStatement extends Statement {
/** Represents a field declaration within a `class`. */ /** Represents a field declaration within a `class`. */
export class FieldDeclaration extends VariableLikeDeclarationStatement { export class FieldDeclaration extends VariableLikeDeclarationStatement {
kind = NodeKind.FIELDDECLARATION; kind = NodeKind.FIELDDECLARATION;
/** Parameter index within the constructor, if applicable. */
parameterIndex: i32 = -1;
} }
/** Represents a `for` statement. */ /** Represents a `for` statement. */

View File

@ -108,7 +108,8 @@ import {
ArrayLiteralExpression, ArrayLiteralExpression,
StringLiteralExpression, StringLiteralExpression,
UnaryPostfixExpression, UnaryPostfixExpression,
UnaryPrefixExpression UnaryPrefixExpression,
FieldDeclaration
} from "./ast"; } from "./ast";
import { import {
@ -5999,21 +6000,25 @@ export function makeAllocate(compiler: Compiler, classInstance: Class, reportNod
if (member.kind == ElementKind.FIELD) { if (member.kind == ElementKind.FIELD) {
let field = <Field>member; let field = <Field>member;
let fieldType = field.type; let fieldType = field.type;
let nativeFieldType = fieldType.toNativeType();
let fieldDeclaration = field.prototype.declaration; let fieldDeclaration = field.prototype.declaration;
assert(!field.isAny(CommonFlags.CONST)); assert(!field.isAny(CommonFlags.CONST));
if (fieldDeclaration.initializer) { // use initializer if (fieldDeclaration.initializer) { // use initializer
initializers.push(module.createStore(fieldType.byteSize, initializers.push(module.createStore(fieldType.byteSize,
module.createGetLocal(tempLocal.index, nativeSizeType), module.createGetLocal(tempLocal.index, nativeSizeType),
compiler.compileExpression(fieldDeclaration.initializer, fieldType), // reports compiler.compileExpression(fieldDeclaration.initializer, fieldType), // reports
fieldType.toNativeType(), nativeFieldType,
field.memoryOffset field.memoryOffset
)); ));
} else { // initialize with zero } else { // initialize with zero
// TODO: might be unnecessary if the ctor initializes the field // TODO: might be unnecessary if the ctor initializes the field
initializers.push(module.createStore(field.type.byteSize, let parameterIndex = (<FieldDeclaration>field.prototype.declaration).parameterIndex;
initializers.push(module.createStore(fieldType.byteSize,
module.createGetLocal(tempLocal.index, nativeSizeType), module.createGetLocal(tempLocal.index, nativeSizeType),
field.type.toNativeZero(module), parameterIndex >= 0 // initialized via parameter
field.type.toNativeType(), ? module.createGetLocal(1 + parameterIndex, nativeFieldType)
: fieldType.toNativeZero(module),
nativeFieldType,
field.memoryOffset field.memoryOffset
)); ));
} }

View File

@ -72,6 +72,7 @@ export enum DiagnosticCode {
Decorators_are_not_valid_here = 1206, Decorators_are_not_valid_here = 1206,
_abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration = 1242, _abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration = 1242,
A_class_may_only_extend_another_class = 1311, A_class_may_only_extend_another_class = 1311,
A_parameter_property_cannot_be_declared_using_a_rest_parameter = 1317,
Duplicate_identifier_0 = 2300, Duplicate_identifier_0 = 2300,
Cannot_find_name_0 = 2304, Cannot_find_name_0 = 2304,
Module_0_has_no_exported_member_1 = 2305, Module_0_has_no_exported_member_1 = 2305,
@ -176,6 +177,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
case 1206: return "Decorators are not valid here."; case 1206: return "Decorators are not valid here.";
case 1242: return "'abstract' modifier can only appear on a class, method, or property declaration."; case 1242: return "'abstract' modifier can only appear on a class, method, or property declaration.";
case 1311: return "A class may only extend another class."; case 1311: return "A class may only extend another class.";
case 1317: return "A parameter property cannot be declared using a rest parameter.";
case 2300: return "Duplicate identifier '{0}'."; case 2300: return "Duplicate identifier '{0}'.";
case 2304: return "Cannot find name '{0}'."; case 2304: return "Cannot find name '{0}'.";
case 2305: return "Module '{0}' has no exported member '{1}'."; case 2305: return "Module '{0}' has no exported member '{1}'.";

View File

@ -65,6 +65,7 @@
"Decorators are not valid here.": 1206, "Decorators are not valid here.": 1206,
"'abstract' modifier can only appear on a class, method, or property declaration.": 1242, "'abstract' modifier can only appear on a class, method, or property declaration.": 1242,
"A class may only extend another class.": 1311, "A class may only extend another class.": 1311,
"A parameter property cannot be declared using a rest parameter.": 1317,
"Duplicate identifier '{0}'.": 2300, "Duplicate identifier '{0}'.": 2300,
"Cannot find name '{0}'.": 2304, "Cannot find name '{0}'.": 2304,

View File

@ -799,8 +799,11 @@ export class ASTBuilder {
sb.push(" {\n"); sb.push(" {\n");
let indentLevel = ++this.indentLevel; let indentLevel = ++this.indentLevel;
for (let i = 0, k = members.length; i < k; ++i) { for (let i = 0, k = members.length; i < k; ++i) {
indent(sb, indentLevel); let member = members[i];
this.visitNodeAndTerminate(members[i]); if (member.kind != NodeKind.FIELDDECLARATION || (<FieldDeclaration>member).parameterIndex < 0) {
indent(sb, indentLevel);
this.visitNodeAndTerminate(member);
}
} }
indent(sb, --this.indentLevel); indent(sb, --this.indentLevel);
sb.push("}"); sb.push("}");
@ -1368,6 +1371,10 @@ export class ASTBuilder {
serializeParameter(node: ParameterNode): void { serializeParameter(node: ParameterNode): void {
var sb = this.sb; var sb = this.sb;
var kind = node.parameterKind; var kind = node.parameterKind;
var implicitFieldDeclaration = node.implicitFieldDeclaration;
if (implicitFieldDeclaration) {
this.serializeAccessModifiers(implicitFieldDeclaration);
}
if (kind == ParameterKind.REST) { if (kind == ParameterKind.REST) {
sb.push("..."); sb.push("...");
} }

View File

@ -967,7 +967,8 @@ export class Parser extends DiagnosticEmitter {
} }
parseParameters( parseParameters(
tn: Tokenizer tn: Tokenizer,
isConstructor: bool = false
): ParameterNode[] | null { ): ParameterNode[] | null {
// at '(': (Parameter (',' Parameter)*)? ')' // at '(': (Parameter (',' Parameter)*)? ')'
@ -979,7 +980,7 @@ export class Parser extends DiagnosticEmitter {
if (tn.peek() != Token.CLOSEPAREN) { if (tn.peek() != Token.CLOSEPAREN) {
do { do {
let param = this.parseParameter(tn); let param = this.parseParameter(tn, isConstructor);
if (!param) return null; if (!param) return null;
if (seenRest && !reportedRest) { if (seenRest && !reportedRest) {
this.error( this.error(
@ -1022,17 +1023,63 @@ export class Parser extends DiagnosticEmitter {
parseParameter( parseParameter(
tn: Tokenizer, tn: Tokenizer,
suppressErrors: bool = false isConstructor: bool = false
): ParameterNode | null { ): ParameterNode | null {
// before: '...'? Identifier '?'? (':' Type)? ('=' Expression)? // before: ('public' | 'private' | 'protected' | '...')? Identifier '?'? (':' Type)? ('=' Expression)?
var isRest = false; var isRest = false;
var isOptional = false; var isOptional = false;
var startRange: Range | null = null; var startRange: Range | null = null;
if (tn.skip(Token.DOT_DOT_DOT)) { var accessFlags: CommonFlags = CommonFlags.NONE;
isRest = true; if (tn.skip(Token.PUBLIC)) {
startRange = tn.range(); startRange = tn.range();
if (!isConstructor) {
this.error(
DiagnosticCode._0_modifier_cannot_be_used_here,
startRange, "public"
);
}
accessFlags |= CommonFlags.PUBLIC;
} else if (tn.skip(Token.PROTECTED)) {
startRange = tn.range();
if (!isConstructor) {
this.error(
DiagnosticCode._0_modifier_cannot_be_used_here,
startRange, "protected"
);
}
accessFlags |= CommonFlags.PROTECTED;
} else if (tn.skip(Token.PRIVATE)) {
startRange = tn.range();
if (!isConstructor) {
this.error(
DiagnosticCode._0_modifier_cannot_be_used_here,
startRange, "private"
);
}
accessFlags |= CommonFlags.PRIVATE;
}
if (tn.skip(Token.READONLY)) {
if (!startRange) startRange = tn.range();
if (!isConstructor) {
this.error(
DiagnosticCode._0_modifier_cannot_be_used_here,
startRange, "readonly"
);
}
accessFlags |= CommonFlags.READONLY;
}
if (tn.skip(Token.DOT_DOT_DOT)) {
if (accessFlags) {
this.error(
DiagnosticCode.A_parameter_property_cannot_be_declared_using_a_rest_parameter,
tn.range()
);
} else {
startRange = tn.range();
}
isRest = true;
} }
if (tn.skip(Token.IDENTIFIER)) { if (tn.skip(Token.IDENTIFIER)) {
if (!isRest) startRange = tn.range(); if (!isRest) startRange = tn.range();
@ -1071,7 +1118,7 @@ export class Parser extends DiagnosticEmitter {
initializer = this.parseExpression(tn, Precedence.COMMA + 1); initializer = this.parseExpression(tn, Precedence.COMMA + 1);
if (!initializer) return null; if (!initializer) return null;
} }
return Node.createParameter( let param = Node.createParameter(
identifier, identifier,
type, type,
initializer, initializer,
@ -1082,6 +1129,8 @@ export class Parser extends DiagnosticEmitter {
: ParameterKind.DEFAULT, : ParameterKind.DEFAULT,
Range.join(<Range>startRange, tn.range()) Range.join(<Range>startRange, tn.range())
); );
param.flags |= accessFlags;
return param;
} else { } else {
this.error( this.error(
DiagnosticCode.Identifier_expected, DiagnosticCode.Identifier_expected,
@ -1400,14 +1449,7 @@ export class Parser extends DiagnosticEmitter {
} }
var members = new Array<DeclarationStatement>(); var members = new Array<DeclarationStatement>();
if (!tn.skip(Token.CLOSEBRACE)) { var declaration = Node.createClassDeclaration(
do {
let member = this.parseClassMember(tn, flags);
if (!member) return null;
members.push(<DeclarationStatement>member);
} while (!tn.skip(Token.CLOSEBRACE));
}
return Node.createClassDeclaration(
identifier, identifier,
typeParameters, typeParameters,
extendsType, extendsType,
@ -1417,11 +1459,20 @@ export class Parser extends DiagnosticEmitter {
flags, flags,
tn.range(startPos, tn.pos) tn.range(startPos, tn.pos)
); );
if (!tn.skip(Token.CLOSEBRACE)) {
do {
let member = this.parseClassMember(tn, declaration);
if (!member) return null;
member.parent = declaration;
members.push(<DeclarationStatement>member);
} while (!tn.skip(Token.CLOSEBRACE));
}
return declaration;
} }
parseClassMember( parseClassMember(
tn: Tokenizer, tn: Tokenizer,
parentFlags: CommonFlags parent: ClassDeclaration
): DeclarationStatement | null { ): DeclarationStatement | null {
// before: // before:
@ -1440,7 +1491,7 @@ export class Parser extends DiagnosticEmitter {
decorators.push(<DecoratorNode>decorator); decorators.push(<DecoratorNode>decorator);
} }
var flags = parentFlags & CommonFlags.AMBIENT; // inherit var flags = parent.flags & CommonFlags.AMBIENT; // inherit
if (tn.skip(Token.PUBLIC)) { if (tn.skip(Token.PUBLIC)) {
flags |= CommonFlags.PUBLIC; flags |= CommonFlags.PUBLIC;
@ -1466,7 +1517,7 @@ export class Parser extends DiagnosticEmitter {
} else { } else {
flags |= CommonFlags.INSTANCE; flags |= CommonFlags.INSTANCE;
} }
if (parentFlags & CommonFlags.GENERIC) { if (parent.flags & CommonFlags.GENERIC) {
flags |= CommonFlags.GENERIC_CONTEXT; flags |= CommonFlags.GENERIC_CONTEXT;
} }
} }
@ -1575,10 +1626,32 @@ export class Parser extends DiagnosticEmitter {
// method: '(' Parameters (':' Type)? '{' Statement* '}' ';'? // method: '(' Parameters (':' Type)? '{' Statement* '}' ';'?
if (tn.skip(Token.OPENPAREN)) { if (tn.skip(Token.OPENPAREN)) {
let signatureStart = tn.tokenPos; let signatureStart = tn.tokenPos;
let parameters = this.parseParameters(tn); let parameters = this.parseParameters(tn, isConstructor);
if (!parameters) return null; if (!parameters) return null;
if (isConstructor) {
if (isGetter) { for (let i = 0, k = parameters.length; i < k; ++i) {
let parameter = parameters[i];
if (parameter.isAny(
CommonFlags.PUBLIC |
CommonFlags.PROTECTED |
CommonFlags.PRIVATE |
CommonFlags.READONLY
)) {
let implicitFieldDeclaration = Node.createFieldDeclaration(
parameter.name,
parameter.type,
null, // initialized via parameter
null,
parameter.flags | CommonFlags.INSTANCE,
parameter.range
);
implicitFieldDeclaration.parameterIndex = i;
implicitFieldDeclaration.parent = parent;
parameter.implicitFieldDeclaration = implicitFieldDeclaration;
parent.members.push(implicitFieldDeclaration);
}
}
} else if (isGetter) {
if (parameters.length) { if (parameters.length) {
this.error( this.error(
DiagnosticCode.A_get_accessor_cannot_have_parameters, DiagnosticCode.A_get_accessor_cannot_have_parameters,

View File

@ -111,46 +111,37 @@ export namespace Math {
Lg6 = 1.531383769920937332e-01, // 3FC39A09 D078C69F Lg6 = 1.531383769920937332e-01, // 3FC39A09 D078C69F
Lg7 = 1.479819860511658591e-01; // 3FC2F112 DF3E5244 Lg7 = 1.479819860511658591e-01; // 3FC2F112 DF3E5244
var u = reinterpret<u64>(x); var Ux = reinterpret<u64>(x);
var hfsq: f64, f: f64, s: f64, z: f64, R: f64, w: f64, t1: f64, t2: f64, dk: f64; var hx = <u32>(Ux >> 32);
var hx = <u32>(u >> 32);
var k = 0; var k = 0;
if (hx < 0x00100000 || <bool>(hx>>31)) { if (hx < 0x00100000 || <bool>(hx >> 31)) {
if (u<<1 == 0) { if (Ux << 1 == 0) return -1 / (x * x); // log(+-0)=-inf
return -1/(x*x); // log(+-0)=-inf if (hx >> 31) return (x - x) / 0.0; // log(-#) = NaN
}
if (hx>>31) {
return (x-x)/0.0; // log(-#) = NaN
}
// subnormal number, scale x up // subnormal number, scale x up
k -= 54; k -= 54;
x *= 1.8014398509481984e16; // 0x1p54 x *= 1.8014398509481984e16; // 0x1p54
u = reinterpret<u64>(x); Ux = reinterpret<u64>(x);
hx = <u32>(u>>32); hx = <u32>(Ux >> 32);
} else if (hx >= 0x7ff00000) { } else if (hx >= 0x7ff00000) return x;
return x; else if (hx == 0x3ff00000 && Ux << 32 == 0) return 0;
} else if (hx == 0x3ff00000 && u<<32 == 0) {
return 0;
}
// reduce x into [sqrt(2)/2, sqrt(2)] // reduce x into [sqrt(2)/2, sqrt(2)]
hx += 0x3ff00000 - 0x3fe6a09e; hx += 0x3ff00000 - 0x3fe6a09e;
k += (<i32>hx>>20) - 0x3ff; k += (<i32>hx >> 20) - 0x3ff;
hx = (hx&0x000fffff) + 0x3fe6a09e; hx = (hx & 0x000fffff) + 0x3fe6a09e;
u = <u64>hx<<32 | (u&0xffffffff); Ux = <u64>hx << 32 | (Ux & 0xffffffff);
x = reinterpret<f64>(u); x = reinterpret<f64>(Ux);
f = x - 1.0; var f = x - 1.0;
hfsq = 0.5*f*f; var hfsq = 0.5 * f * f;
s = f/(2.0+f); var s = f / (2.0 + f);
z = s*s; var z = s * s;
w = z*z; var w = z * z;
t1 = w*(Lg2+w*(Lg4+w*Lg6)); var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
t2 = z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
R = t2 + t1; var R = t2 + t1;
dk = k; var dk = k;
return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi; return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
} }
// export function log2(x: f64): f64 { // export function log2(x: f64): f64 {
@ -225,52 +216,41 @@ export namespace Mathf {
// software is freely granted, provided that this notice // software is freely granted, provided that this notice
// is preserved. // is preserved.
const const
ln2_hi: f32 = 6.9313812256e-01, // 0x3f317180 ln2_hi = <f32>6.9313812256e-01, // 0x3f317180
ln2_lo: f32 = 9.0580006145e-06, // 0x3717f7d1 ln2_lo = <f32>9.0580006145e-06, // 0x3717f7d1
Lg1: f32 = 0.66666662693, // 0xaaaaaa.0p-24 Lg1 = <f32>0.66666662693, // 0xaaaaaa.0p-24
Lg2: f32 = 0.40000972152, // 0xccce13.0p-25 Lg2 = <f32>0.40000972152, // 0xccce13.0p-25
Lg3: f32 = 0.28498786688, // 0x91e9ee.0p-25 Lg3 = <f32>0.28498786688, // 0x91e9ee.0p-25
Lg4: f32 = 0.24279078841; // 0xf89e26.0p-26 Lg4 = <f32>0.24279078841; // 0xf89e26.0p-26
var u = reinterpret<u32>(x); var ux = reinterpret<u32>(x);
var hfsq: f32, f: f32, s: f32, z: f32, R: f32, w: f32, t1: f32, t2: f32, dk: f32;
var ix = u;
var k = 0; var k = 0;
if (ix < 0x00800000 || <bool>(ix>>31)) { // x < 2**-126 if (ux < 0x00800000 || <bool>(ux >> 31)) { // x < 2**-126
if (ix<<1 == 0) { if (ux << 1 == 0) return -1 / (x * x); // log(+-0)=-inf
return -1/(x*x); // log(+-0)=-inf if (ux >> 31) return (x - x) / 0; // log(-#) = NaN
}
if (ix>>31) {
return (x-x)/<f32>0; // log(-#) = NaN
}
// subnormal number, scale up x // subnormal number, scale up x
k -= 25; k -= 25;
x *= 3.3554432; // 0x1p25f; x *= 3.3554432; // 0x1p25f;
u = reinterpret<u32>(x); ux = reinterpret<u32>(x);
ix = u; } else if (ux >= 0x7f800000) return x;
} else if (ix >= 0x7f800000) { else if (ux == 0x3f800000) return 0;
return x;
} else if (ix == 0x3f800000) {
return 0;
}
// reduce x into [sqrt(2)/2, sqrt(2)] // reduce x into [sqrt(2)/2, sqrt(2)]
ix += 0x3f800000 - 0x3f3504f3; ux += 0x3f800000 - 0x3f3504f3;
k += <u32>(<i32>ix>>23) - 0x7f; k += <u32>(<i32>ux >> 23) - 0x7f;
ix = (ix&0x007fffff) + 0x3f3504f3; ux = (ux & 0x007fffff) + 0x3f3504f3;
x = reinterpret<f32>(ix); x = reinterpret<f32>(ux);
f = x - 1.0; var f = x - 1.0;
s = f/(2.0 + f); var s = f / (2.0 + f);
z = s*s; var z = s * s;
w = z*z; var w = z * z;
t1= w*(Lg2+w*Lg4); var t1 = w * (Lg2 + w * Lg4);
t2= z*(Lg1+w*Lg3); var t2 = z * (Lg1 + w * Lg3);
R = t2 + t1; var R = t2 + t1;
hfsq = 0.5*f*f; var hfsq = <f32>0.5 * f * f;
dk = <f32>k; var dk = <f32>k;
return s*(hfsq+R) + dk*ln2_lo - hfsq + f + dk*ln2_hi; return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
} }
// export function log2(x: f32): f32 { // export function log2(x: f32): f32 {

View File

@ -258,10 +258,8 @@
) )
) )
(f64.mul (f64.mul
(tee_local $0 (f64.convert_s/i32
(f64.convert_s/i32 (get_local $2)
(get_local $2)
)
) )
(f64.const 1.9082149292705877e-10) (f64.const 1.9082149292705877e-10)
) )
@ -271,7 +269,9 @@
(get_local $4) (get_local $4)
) )
(f64.mul (f64.mul
(get_local $0) (f64.convert_s/i32
(get_local $2)
)
(f64.const 0.6931471803691238) (f64.const 0.6931471803691238)
) )
) )

View File

@ -16,17 +16,17 @@
(start $start) (start $start)
(func "$(lib)/math/Math.log" (; 3 ;) (type $FF) (param $0 f64) (result f64) (func "$(lib)/math/Math.log" (; 3 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64) (local $1 i64)
(local $2 f64) (local $2 i32)
(local $3 f64) (local $3 i32)
(local $4 f64) (local $4 i32)
(local $5 f64) (local $5 f64)
(local $6 f64) (local $6 f64)
(local $7 f64) (local $7 f64)
(local $8 f64) (local $8 f64)
(local $9 f64) (local $9 f64)
(local $10 f64) (local $10 f64)
(local $11 i32) (local $11 f64)
(local $12 i32) (local $12 f64)
(local $13 i32) (local $13 i32)
(nop) (nop)
(set_local $1 (set_local $1
@ -34,8 +34,7 @@
(get_local $0) (get_local $0)
) )
) )
(nop) (set_local $2
(set_local $11
(i32.wrap/i64 (i32.wrap/i64
(i64.shr_u (i64.shr_u
(get_local $1) (get_local $1)
@ -43,22 +42,22 @@
) )
) )
) )
(set_local $12 (set_local $3
(i32.const 0) (i32.const 0)
) )
(if (if
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $13 (tee_local $4
(i32.lt_u (i32.lt_u
(get_local $11) (get_local $2)
(i32.const 1048576) (i32.const 1048576)
) )
) )
(get_local $13) (get_local $4)
(i32.and (i32.and
(i32.shr_u (i32.shr_u
(get_local $11) (get_local $2)
(i32.const 31) (i32.const 31)
) )
(i32.const 1) (i32.const 1)
@ -87,7 +86,7 @@
) )
(if (if
(i32.shr_u (i32.shr_u
(get_local $11) (get_local $2)
(i32.const 31) (i32.const 31)
) )
(return (return
@ -100,9 +99,9 @@
) )
) )
) )
(set_local $12 (set_local $3
(i32.sub (i32.sub
(get_local $12) (get_local $3)
(i32.const 54) (i32.const 54)
) )
) )
@ -117,7 +116,7 @@
(get_local $0) (get_local $0)
) )
) )
(set_local $11 (set_local $2
(i32.wrap/i64 (i32.wrap/i64
(i64.shr_u (i64.shr_u
(get_local $1) (get_local $1)
@ -128,7 +127,7 @@
) )
(if (if
(i32.ge_u (i32.ge_u
(get_local $11) (get_local $2)
(i32.const 2146435072) (i32.const 2146435072)
) )
(return (return
@ -137,9 +136,9 @@
(if (if
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $13 (tee_local $4
(i32.eq (i32.eq
(get_local $11) (get_local $2)
(i32.const 1072693248) (i32.const 1072693248)
) )
) )
@ -150,7 +149,7 @@
) )
(i64.const 0) (i64.const 0)
) )
(get_local $13) (get_local $4)
) )
(i32.const 1) (i32.const 1)
) )
@ -160,31 +159,31 @@
) )
) )
) )
(set_local $11 (set_local $2
(i32.add (i32.add
(get_local $11) (get_local $2)
(i32.sub (i32.sub
(i32.const 1072693248) (i32.const 1072693248)
(i32.const 1072079006) (i32.const 1072079006)
) )
) )
) )
(set_local $12 (set_local $3
(i32.add (i32.add
(get_local $12) (get_local $3)
(i32.sub (i32.sub
(i32.shr_s (i32.shr_s
(get_local $11) (get_local $2)
(i32.const 20) (i32.const 20)
) )
(i32.const 1023) (i32.const 1023)
) )
) )
) )
(set_local $11 (set_local $2
(i32.add (i32.add
(i32.and (i32.and
(get_local $11) (get_local $2)
(i32.const 1048575) (i32.const 1048575)
) )
(i32.const 1072079006) (i32.const 1072079006)
@ -194,7 +193,7 @@
(i64.or (i64.or
(i64.shl (i64.shl
(i64.extend_u/i32 (i64.extend_u/i32
(get_local $11) (get_local $2)
) )
(i64.const 32) (i64.const 32)
) )
@ -209,53 +208,53 @@
(get_local $1) (get_local $1)
) )
) )
(set_local $3 (set_local $5
(f64.sub (f64.sub
(get_local $0) (get_local $0)
(f64.const 1) (f64.const 1)
) )
) )
(set_local $2 (set_local $6
(f64.mul (f64.mul
(f64.mul (f64.mul
(f64.const 0.5) (f64.const 0.5)
(get_local $3) (get_local $5)
) )
(get_local $3) (get_local $5)
)
)
(set_local $4
(f64.div
(get_local $3)
(f64.add
(f64.const 2)
(get_local $3)
)
)
)
(set_local $5
(f64.mul
(get_local $4)
(get_local $4)
) )
) )
(set_local $7 (set_local $7
(f64.mul (f64.div
(get_local $5)
(get_local $5) (get_local $5)
(f64.add
(f64.const 2)
(get_local $5)
)
) )
) )
(set_local $8 (set_local $8
(f64.mul (f64.mul
(get_local $7) (get_local $7)
(get_local $7)
)
)
(set_local $9
(f64.mul
(get_local $8)
(get_local $8)
)
)
(set_local $10
(f64.mul
(get_local $9)
(f64.add (f64.add
(f64.const 0.3999999999940942) (f64.const 0.3999999999940942)
(f64.mul (f64.mul
(get_local $7) (get_local $9)
(f64.add (f64.add
(f64.const 0.22222198432149784) (f64.const 0.22222198432149784)
(f64.mul (f64.mul
(get_local $7) (get_local $9)
(f64.const 0.15313837699209373) (f64.const 0.15313837699209373)
) )
) )
@ -263,21 +262,21 @@
) )
) )
) )
(set_local $9 (set_local $11
(f64.mul (f64.mul
(get_local $5) (get_local $8)
(f64.add (f64.add
(f64.const 0.6666666666666735) (f64.const 0.6666666666666735)
(f64.mul (f64.mul
(get_local $7) (get_local $9)
(f64.add (f64.add
(f64.const 0.2857142874366239) (f64.const 0.2857142874366239)
(f64.mul (f64.mul
(get_local $7) (get_local $9)
(f64.add (f64.add
(f64.const 0.1818357216161805) (f64.const 0.1818357216161805)
(f64.mul (f64.mul
(get_local $7) (get_local $9)
(f64.const 0.14798198605116586) (f64.const 0.14798198605116586)
) )
) )
@ -287,16 +286,14 @@
) )
) )
) )
(set_local $6 (set_local $12
(f64.add (f64.add
(get_local $9) (get_local $11)
(get_local $8) (get_local $10)
) )
) )
(set_local $10 (set_local $13
(f64.convert_s/i32 (get_local $3)
(get_local $12)
)
) )
(return (return
(f64.add (f64.add
@ -304,23 +301,27 @@
(f64.sub (f64.sub
(f64.add (f64.add
(f64.mul (f64.mul
(get_local $4) (get_local $7)
(f64.add (f64.add
(get_local $2)
(get_local $6) (get_local $6)
(get_local $12)
) )
) )
(f64.mul (f64.mul
(get_local $10) (f64.convert_s/i32
(get_local $13)
)
(f64.const 1.9082149292705877e-10) (f64.const 1.9082149292705877e-10)
) )
) )
(get_local $2) (get_local $6)
) )
(get_local $3) (get_local $5)
) )
(f64.mul (f64.mul
(get_local $10) (f64.convert_s/i32
(get_local $13)
)
(f64.const 0.6931471803691238) (f64.const 0.6931471803691238)
) )
) )
@ -328,8 +329,8 @@
) )
(func "$(lib)/math/Mathf.log" (; 4 ;) (type $ff) (param $0 f32) (result f32) (func "$(lib)/math/Mathf.log" (; 4 ;) (type $ff) (param $0 f32) (result f32)
(local $1 i32) (local $1 i32)
(local $2 f32) (local $2 i32)
(local $3 f32) (local $3 i32)
(local $4 f32) (local $4 f32)
(local $5 f32) (local $5 f32)
(local $6 f32) (local $6 f32)
@ -337,35 +338,30 @@
(local $8 f32) (local $8 f32)
(local $9 f32) (local $9 f32)
(local $10 f32) (local $10 f32)
(local $11 i32) (local $11 f32)
(local $12 i32) (local $12 f32)
(local $13 i32)
(nop) (nop)
(set_local $1 (set_local $1
(i32.reinterpret/f32 (i32.reinterpret/f32
(get_local $0) (get_local $0)
) )
) )
(nop) (set_local $2
(set_local $11
(get_local $1)
)
(set_local $12
(i32.const 0) (i32.const 0)
) )
(if (if
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $13 (tee_local $3
(i32.lt_u (i32.lt_u
(get_local $11) (get_local $1)
(i32.const 8388608) (i32.const 8388608)
) )
) )
(get_local $13) (get_local $3)
(i32.and (i32.and
(i32.shr_u (i32.shr_u
(get_local $11) (get_local $1)
(i32.const 31) (i32.const 31)
) )
(i32.const 1) (i32.const 1)
@ -377,7 +373,7 @@
(if (if
(i32.eq (i32.eq
(i32.shl (i32.shl
(get_local $11) (get_local $1)
(i32.const 1) (i32.const 1)
) )
(i32.const 0) (i32.const 0)
@ -394,7 +390,7 @@
) )
(if (if
(i32.shr_u (i32.shr_u
(get_local $11) (get_local $1)
(i32.const 31) (i32.const 31)
) )
(return (return
@ -407,9 +403,9 @@
) )
) )
) )
(set_local $12 (set_local $2
(i32.sub (i32.sub
(get_local $12) (get_local $2)
(i32.const 25) (i32.const 25)
) )
) )
@ -424,13 +420,10 @@
(get_local $0) (get_local $0)
) )
) )
(set_local $11
(get_local $1)
)
) )
(if (if
(i32.ge_u (i32.ge_u
(get_local $11) (get_local $1)
(i32.const 2139095040) (i32.const 2139095040)
) )
(return (return
@ -438,7 +431,7 @@
) )
(if (if
(i32.eq (i32.eq
(get_local $11) (get_local $1)
(i32.const 1065353216) (i32.const 1065353216)
) )
(return (return
@ -447,31 +440,31 @@
) )
) )
) )
(set_local $11 (set_local $1
(i32.add (i32.add
(get_local $11) (get_local $1)
(i32.sub (i32.sub
(i32.const 1065353216) (i32.const 1065353216)
(i32.const 1060439283) (i32.const 1060439283)
) )
) )
) )
(set_local $12 (set_local $2
(i32.add (i32.add
(get_local $12) (get_local $2)
(i32.sub (i32.sub
(i32.shr_s (i32.shr_s
(get_local $11) (get_local $1)
(i32.const 23) (i32.const 23)
) )
(i32.const 127) (i32.const 127)
) )
) )
) )
(set_local $11 (set_local $1
(i32.add (i32.add
(i32.and (i32.and
(get_local $11) (get_local $1)
(i32.const 8388607) (i32.const 8388607)
) )
(i32.const 1060439283) (i32.const 1060439283)
@ -479,34 +472,34 @@
) )
(set_local $0 (set_local $0
(f32.reinterpret/i32 (f32.reinterpret/i32
(get_local $11) (get_local $1)
) )
) )
(set_local $3 (set_local $4
(f32.sub (f32.sub
(get_local $0) (get_local $0)
(f32.const 1) (f32.const 1)
) )
) )
(set_local $4 (set_local $5
(f32.div (f32.div
(get_local $3) (get_local $4)
(f32.add (f32.add
(f32.const 2) (f32.const 2)
(get_local $3) (get_local $4)
) )
) )
) )
(set_local $5 (set_local $6
(f32.mul (f32.mul
(get_local $4) (get_local $5)
(get_local $4) (get_local $5)
) )
) )
(set_local $7 (set_local $7
(f32.mul (f32.mul
(get_local $5) (get_local $6)
(get_local $5) (get_local $6)
) )
) )
(set_local $8 (set_local $8
@ -523,7 +516,7 @@
) )
(set_local $9 (set_local $9
(f32.mul (f32.mul
(get_local $5) (get_local $6)
(f32.add (f32.add
(f32.const 0.6666666269302368) (f32.const 0.6666666269302368)
(f32.mul (f32.mul
@ -533,24 +526,24 @@
) )
) )
) )
(set_local $6 (set_local $10
(f32.add (f32.add
(get_local $9) (get_local $9)
(get_local $8) (get_local $8)
) )
) )
(set_local $2 (set_local $11
(f32.mul (f32.mul
(f32.mul (f32.mul
(f32.const 0.5) (f32.const 0.5)
(get_local $3) (get_local $4)
) )
(get_local $3) (get_local $4)
) )
) )
(set_local $10 (set_local $12
(f32.convert_s/i32 (f32.convert_s/i32
(get_local $12) (get_local $2)
) )
) )
(return (return
@ -559,23 +552,23 @@
(f32.sub (f32.sub
(f32.add (f32.add
(f32.mul (f32.mul
(get_local $4) (get_local $5)
(f32.add (f32.add
(get_local $2) (get_local $11)
(get_local $6) (get_local $10)
) )
) )
(f32.mul (f32.mul
(get_local $10) (get_local $12)
(f32.const 9.05800061445916e-06) (f32.const 9.05800061445916e-06)
) )
) )
(get_local $2) (get_local $11)
) )
(get_local $3) (get_local $4)
) )
(f32.mul (f32.mul
(get_local $10) (get_local $12)
(f32.const 0.6931381225585938) (f32.const 0.6931381225585938)
) )
) )

View File

@ -0,0 +1,9 @@
class MyClass {
constructor() {}
constructor(a: i32) {}
constructor(a: i32, b: i32) {}
}
class MyClassImplicit {
constructor(public a: i32, private readonly b: i32 = 2, c: i32 = 3) {}
}

View File

@ -0,0 +1,8 @@
class MyClass {
constructor() {}
constructor(a: i32) {}
constructor(a: i32, b: i32) {}
}
class MyClassImplicit {
constructor(public a: i32, private readonly b: i32 = 2, c: i32 = 3) {}
}