mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-26 15:32:16 +00:00
Unify operator overloading and reuse arguments where possible; Update Binaryen; Update dist files
This commit is contained in:
parent
567a5fb064
commit
cea69a6de1
2
dist/assemblyscript.js
vendored
2
dist/assemblyscript.js
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js.map
vendored
2
dist/assemblyscript.js.map
vendored
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
@ -1496,9 +1496,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"binaryen": {
|
"binaryen": {
|
||||||
"version": "48.0.0-nightly.20180520",
|
"version": "48.0.0-nightly.20180605",
|
||||||
"resolved": "https://registry.npmjs.org/binaryen/-/binaryen-48.0.0-nightly.20180520.tgz",
|
"resolved": "https://registry.npmjs.org/binaryen/-/binaryen-48.0.0-nightly.20180605.tgz",
|
||||||
"integrity": "sha512-Zi1duoGYKYSLvaQqiVY9FWE3jSA+9swsBdpqiZf+20V5mf624HN4HZNXHyr/5g+82aNigG1mzkrG2EQfQKaNxw=="
|
"integrity": "sha512-P2Q7fl1k+SWUUhcO+nR0FvokwuTFTLU2JQhhSzGTSen70JFGArEAfr936sxiK/SGUQjBwXvHLoO6ggEYn82rbQ=="
|
||||||
},
|
},
|
||||||
"binaryextensions": {
|
"binaryextensions": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@protobufjs/utf8": "^1.1.0",
|
"@protobufjs/utf8": "^1.1.0",
|
||||||
"binaryen": "48.0.0-nightly.20180520",
|
"binaryen": "48.0.0-nightly.20180605",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"long": "^4.0.0",
|
"long": "^4.0.0",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
|
474
src/compiler.ts
474
src/compiler.ts
@ -2566,17 +2566,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.LT);
|
let overload = classReference.lookupOverload(OperatorKind.LT);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
||||||
rightType = this.currentType;
|
rightType = this.currentType;
|
||||||
@ -2673,17 +2672,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.GT);
|
let overload = classReference.lookupOverload(OperatorKind.GT);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
||||||
rightType = this.currentType;
|
rightType = this.currentType;
|
||||||
@ -2780,17 +2778,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.LE);
|
let overload = classReference.lookupOverload(OperatorKind.LE);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
||||||
rightType = this.currentType;
|
rightType = this.currentType;
|
||||||
@ -2887,17 +2884,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.GE);
|
let overload = classReference.lookupOverload(OperatorKind.GE);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
||||||
rightType = this.currentType;
|
rightType = this.currentType;
|
||||||
@ -3001,10 +2997,11 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.EQ);
|
let overload = classReference.lookupOverload(OperatorKind.EQ);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// still allow '==' with references
|
||||||
}
|
}
|
||||||
|
|
||||||
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
||||||
@ -3088,10 +3085,11 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.NE);
|
let overload = classReference.lookupOverload(OperatorKind.NE);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// still allow '!=' with references
|
||||||
}
|
}
|
||||||
|
|
||||||
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
rightExpr = this.compileExpressionRetainType(right, leftType, WrapMode.NONE);
|
||||||
@ -3178,17 +3176,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.ADD);
|
let overload = classReference.lookupOverload(OperatorKind.ADD);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
||||||
@ -3274,17 +3271,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.SUB);
|
let overload = classReference.lookupOverload(OperatorKind.SUB);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
||||||
@ -3371,17 +3367,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.MUL);
|
let overload = classReference.lookupOverload(OperatorKind.MUL);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType);
|
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType);
|
||||||
@ -3468,17 +3463,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.POW);
|
let overload = classReference.lookupOverload(OperatorKind.POW);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let instance: Function | null;
|
let instance: Function | null;
|
||||||
|
|
||||||
@ -3569,17 +3563,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.DIV);
|
let overload = classReference.lookupOverload(OperatorKind.DIV);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType);
|
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType);
|
||||||
@ -3685,17 +3678,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.REM);
|
let overload = classReference.lookupOverload(OperatorKind.REM);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType);
|
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType);
|
||||||
@ -3851,6 +3843,24 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
case Token.LESSTHAN_LESSTHAN: {
|
case Token.LESSTHAN_LESSTHAN: {
|
||||||
leftExpr = this.compileExpressionRetainType(left, contextualType.intType, WrapMode.NONE);
|
leftExpr = this.compileExpressionRetainType(left, contextualType.intType, WrapMode.NONE);
|
||||||
leftType = this.currentType;
|
leftType = this.currentType;
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = leftType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.BITWISE_SHL);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return this.module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
||||||
rightType = this.currentType;
|
rightType = this.currentType;
|
||||||
switch (this.currentType.kind) {
|
switch (this.currentType.kind) {
|
||||||
@ -3869,26 +3879,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = module.createBinary(BinaryOp.ShlI64, leftExpr, rightExpr);
|
expr = module.createBinary(BinaryOp.ShlI64, leftExpr, rightExpr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypeKind.USIZE: {
|
case TypeKind.USIZE:
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = leftType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_SHL);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return this.module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fall through
|
|
||||||
}
|
|
||||||
case TypeKind.ISIZE: {
|
case TypeKind.ISIZE: {
|
||||||
expr = module.createBinary(
|
expr = module.createBinary(
|
||||||
this.options.isWasm64
|
this.options.isWasm64
|
||||||
@ -3916,8 +3907,27 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
}
|
}
|
||||||
case Token.GREATERTHAN_GREATERTHAN_EQUALS: compound = true;
|
case Token.GREATERTHAN_GREATERTHAN_EQUALS: compound = true;
|
||||||
case Token.GREATERTHAN_GREATERTHAN: {
|
case Token.GREATERTHAN_GREATERTHAN: {
|
||||||
leftExpr = this.compileExpressionRetainType(left, contextualType.intType, WrapMode.WRAP); // !
|
leftExpr = this.compileExpressionRetainType(left, contextualType.intType, WrapMode.NONE);
|
||||||
leftType = this.currentType; // ^ must clear garbage bits
|
leftType = this.currentType;
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = leftType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.BITWISE_SHR);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return this.module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType); // must clear garbage bits
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.WRAP);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.WRAP);
|
||||||
rightType = this.currentType;
|
rightType = this.currentType;
|
||||||
switch (this.currentType.kind) {
|
switch (this.currentType.kind) {
|
||||||
@ -3959,24 +3969,6 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypeKind.USIZE: {
|
case TypeKind.USIZE: {
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = leftType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_SHR);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return this.module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expr = module.createBinary(
|
expr = module.createBinary(
|
||||||
this.options.isWasm64
|
this.options.isWasm64
|
||||||
? BinaryOp.ShrU64
|
? BinaryOp.ShrU64
|
||||||
@ -4003,8 +3995,27 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
}
|
}
|
||||||
case Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS: compound = true;
|
case Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS: compound = true;
|
||||||
case Token.GREATERTHAN_GREATERTHAN_GREATERTHAN: {
|
case Token.GREATERTHAN_GREATERTHAN_GREATERTHAN: {
|
||||||
leftExpr = this.compileExpressionRetainType(left, contextualType.intType, WrapMode.WRAP);
|
leftExpr = this.compileExpressionRetainType(left, contextualType.intType, WrapMode.NONE);
|
||||||
leftType = this.currentType; // ^ clear garbage bits
|
leftType = this.currentType;
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = leftType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.BITWISE_SHR_U);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return this.module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
leftExpr = this.ensureSmallIntegerWrap(leftExpr, leftType); // must clear garbage bits
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
||||||
rightType = this.currentType;
|
rightType = this.currentType;
|
||||||
switch (this.currentType.kind) {
|
switch (this.currentType.kind) {
|
||||||
@ -4025,26 +4036,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = module.createBinary(BinaryOp.ShrU64, leftExpr, rightExpr);
|
expr = module.createBinary(BinaryOp.ShrU64, leftExpr, rightExpr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypeKind.USIZE: {
|
case TypeKind.USIZE:
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = leftType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_SHR_U);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return this.module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fall through
|
|
||||||
}
|
|
||||||
case TypeKind.ISIZE: {
|
case TypeKind.ISIZE: {
|
||||||
expr = module.createBinary(
|
expr = module.createBinary(
|
||||||
this.options.isWasm64
|
this.options.isWasm64
|
||||||
@ -4081,17 +4073,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_AND);
|
let overload = classReference.lookupOverload(OperatorKind.BITWISE_AND);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
||||||
@ -4178,17 +4169,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_OR);
|
let overload = classReference.lookupOverload(OperatorKind.BITWISE_OR);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
||||||
@ -4278,17 +4268,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_XOR);
|
let overload = classReference.lookupOverload(OperatorKind.BITWISE_XOR);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
expr = this.compileBinaryOverload(overload, left, leftExpr, right, expression);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return this.module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
rightExpr = this.compileExpression(right, leftType, ConversionKind.IMPLICIT, WrapMode.NONE);
|
||||||
@ -4454,18 +4443,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
compileUnaryOverload(
|
compileUnaryOverload(
|
||||||
operatorInstance: Function,
|
operatorInstance: Function,
|
||||||
value: Expression,
|
value: Expression,
|
||||||
|
valueExpr: ExpressionRef,
|
||||||
reportNode: Node
|
reportNode: Node
|
||||||
): ExpressionRef {
|
): ExpressionRef {
|
||||||
// checks and recompiles the argument according to its actual annotated type
|
|
||||||
var argumentExpressions: Expression[];
|
var argumentExpressions: Expression[];
|
||||||
var thisArg: ExpressionRef = 0;
|
var thisArg: ExpressionRef = 0;
|
||||||
if (operatorInstance.is(CommonFlags.INSTANCE)) {
|
if (operatorInstance.is(CommonFlags.INSTANCE)) {
|
||||||
let parent = assert(operatorInstance.parent);
|
thisArg = valueExpr; // can reuse the previously evaluated expr as the this value here
|
||||||
assert(parent.kind == ElementKind.CLASS);
|
|
||||||
thisArg = this.compileExpression(value, (<Class>parent).type, ConversionKind.IMPLICIT, WrapMode.NONE);
|
|
||||||
argumentExpressions = [];
|
argumentExpressions = [];
|
||||||
} else {
|
} else {
|
||||||
argumentExpressions = [ value ];
|
argumentExpressions = [ value ]; // annotated type might differ -> recompile
|
||||||
}
|
}
|
||||||
return this.compileCallDirect(
|
return this.compileCallDirect(
|
||||||
operatorInstance,
|
operatorInstance,
|
||||||
@ -4479,19 +4466,19 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
compileBinaryOverload(
|
compileBinaryOverload(
|
||||||
operatorInstance: Function,
|
operatorInstance: Function,
|
||||||
left: Expression,
|
left: Expression,
|
||||||
|
leftExpr: ExpressionRef,
|
||||||
right: Expression,
|
right: Expression,
|
||||||
reportNode: Node
|
reportNode: Node
|
||||||
): ExpressionRef {
|
): ExpressionRef {
|
||||||
// checks and recompiles the arguments according to their actual annotated types
|
|
||||||
var argumentExpressions: Expression[];
|
var argumentExpressions: Expression[];
|
||||||
var thisArg: ExpressionRef = 0;
|
var thisArg: ExpressionRef = 0;
|
||||||
if (operatorInstance.is(CommonFlags.INSTANCE)) {
|
if (operatorInstance.is(CommonFlags.INSTANCE)) {
|
||||||
let parent = assert(operatorInstance.parent);
|
let parent = assert(operatorInstance.parent);
|
||||||
assert(parent.kind == ElementKind.CLASS);
|
assert(parent.kind == ElementKind.CLASS);
|
||||||
thisArg = this.compileExpression(left, (<Class>parent).type, ConversionKind.IMPLICIT, WrapMode.NONE);
|
thisArg = leftExpr; // can reuse the previously evaluated leftExpr as the this value here
|
||||||
argumentExpressions = [ right ];
|
argumentExpressions = [ right ];
|
||||||
} else {
|
} else {
|
||||||
argumentExpressions = [ left, right ];
|
argumentExpressions = [ left, right ]; // annotated type of LHS might differ -> recompile
|
||||||
}
|
}
|
||||||
var ret = this.compileCallDirect(
|
var ret = this.compileCallDirect(
|
||||||
operatorInstance,
|
operatorInstance,
|
||||||
@ -6533,10 +6520,8 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
ConversionKind.NONE,
|
ConversionKind.NONE,
|
||||||
WrapMode.NONE
|
WrapMode.NONE
|
||||||
);
|
);
|
||||||
if (getExpressionId(getValue) == ExpressionId.Unreachable) {
|
|
||||||
// shortcut if compiling the getter already failed
|
// shortcut if compiling the getter already failed
|
||||||
return getValue;
|
if (getExpressionId(getValue) == ExpressionId.Unreachable) return getValue;
|
||||||
}
|
|
||||||
var currentType = this.currentType;
|
var currentType = this.currentType;
|
||||||
|
|
||||||
var op: BinaryOp;
|
var op: BinaryOp;
|
||||||
@ -6545,26 +6530,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
|
|
||||||
switch (expression.operator) {
|
switch (expression.operator) {
|
||||||
case Token.PLUS_PLUS: {
|
case Token.PLUS_PLUS: {
|
||||||
if (currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
|
// TODO: check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
TODO
|
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = this.currentType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.POSTFIX_INC);
|
|
||||||
if (overload) {
|
|
||||||
return this.compileUnaryOverload(overload, expression.operand, expression);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
switch (currentType.kind) {
|
switch (currentType.kind) {
|
||||||
case TypeKind.I8:
|
case TypeKind.I8:
|
||||||
case TypeKind.I16:
|
case TypeKind.I16:
|
||||||
@ -6615,13 +6590,16 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Token.MINUS_MINUS: {
|
case Token.MINUS_MINUS: {
|
||||||
if (currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
|
// TODO: check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
);
|
);
|
||||||
return module.createUnreachable();
|
return this.module.createUnreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (currentType.kind) {
|
switch (currentType.kind) {
|
||||||
case TypeKind.I8:
|
case TypeKind.I8:
|
||||||
case TypeKind.I16:
|
case TypeKind.I16:
|
||||||
@ -6718,24 +6696,6 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
|
|
||||||
switch (expression.operator) {
|
switch (expression.operator) {
|
||||||
case Token.PLUS: {
|
case Token.PLUS: {
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = this.currentType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.PLUS);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileUnaryOverload(overload, expression.operand, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fall-through
|
|
||||||
expr = this.compileExpression(
|
expr = this.compileExpression(
|
||||||
expression.operand,
|
expression.operand,
|
||||||
contextualType == Type.void
|
contextualType == Type.void
|
||||||
@ -6744,6 +6704,25 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
ConversionKind.NONE,
|
ConversionKind.NONE,
|
||||||
WrapMode.NONE
|
WrapMode.NONE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = this.currentType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.PLUS);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileUnaryOverload(overload, expression.operand, expr, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// nop
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Token.MINUS: {
|
case Token.MINUS: {
|
||||||
@ -6755,7 +6734,9 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = this.compileLiteralExpression(<LiteralExpression>expression.operand, contextualType, true);
|
expr = this.compileLiteralExpression(<LiteralExpression>expression.operand, contextualType, true);
|
||||||
// compileExpression normally does this:
|
// compileExpression normally does this:
|
||||||
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
|
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
|
||||||
} else {
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
expr = this.compileExpression(
|
expr = this.compileExpression(
|
||||||
expression.operand,
|
expression.operand,
|
||||||
contextualType == Type.void
|
contextualType == Type.void
|
||||||
@ -6764,6 +6745,24 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
ConversionKind.NONE,
|
ConversionKind.NONE,
|
||||||
WrapMode.NONE
|
WrapMode.NONE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = this.currentType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.MINUS);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileUnaryOverload(overload, expression.operand, expr, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.currentType.kind) {
|
switch (this.currentType.kind) {
|
||||||
case TypeKind.I8:
|
case TypeKind.I8:
|
||||||
case TypeKind.I16:
|
case TypeKind.I16:
|
||||||
@ -6775,26 +6774,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = module.createBinary(BinaryOp.SubI32, module.createI32(0), expr);
|
expr = module.createBinary(BinaryOp.SubI32, module.createI32(0), expr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypeKind.USIZE: {
|
case TypeKind.USIZE:
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = this.currentType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.MINUS);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileUnaryOverload(overload, expression.operand, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fall-through
|
|
||||||
}
|
|
||||||
case TypeKind.ISIZE: {
|
case TypeKind.ISIZE: {
|
||||||
expr = module.createBinary(
|
expr = module.createBinary(
|
||||||
this.options.isWasm64
|
this.options.isWasm64
|
||||||
@ -6823,7 +6803,6 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = module.createUnreachable();
|
expr = module.createUnreachable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Token.PLUS_PLUS: {
|
case Token.PLUS_PLUS: {
|
||||||
@ -6836,6 +6815,24 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
ConversionKind.NONE,
|
ConversionKind.NONE,
|
||||||
WrapMode.NONE
|
WrapMode.NONE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = this.currentType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.PREFIX_INC);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileUnaryOverload(overload, expression.operand, expr, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.currentType.kind) {
|
switch (this.currentType.kind) {
|
||||||
case TypeKind.I8:
|
case TypeKind.I8:
|
||||||
case TypeKind.I16:
|
case TypeKind.I16:
|
||||||
@ -6847,26 +6844,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = module.createBinary(BinaryOp.AddI32, expr, this.module.createI32(1));
|
expr = module.createBinary(BinaryOp.AddI32, expr, this.module.createI32(1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypeKind.USIZE: {
|
case TypeKind.USIZE:
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = this.currentType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.PREFIX_INC);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileUnaryOverload(overload, expression.operand, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fall-through
|
|
||||||
}
|
|
||||||
case TypeKind.ISIZE: {
|
case TypeKind.ISIZE: {
|
||||||
expr = module.createBinary(
|
expr = module.createBinary(
|
||||||
this.options.isWasm64
|
this.options.isWasm64
|
||||||
@ -6907,6 +6885,24 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
ConversionKind.NONE,
|
ConversionKind.NONE,
|
||||||
WrapMode.NONE
|
WrapMode.NONE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = this.currentType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.PREFIX_DEC);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileUnaryOverload(overload, expression.operand, expr, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.currentType.kind) {
|
switch (this.currentType.kind) {
|
||||||
case TypeKind.I8:
|
case TypeKind.I8:
|
||||||
case TypeKind.I16:
|
case TypeKind.I16:
|
||||||
@ -6918,26 +6914,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = module.createBinary(BinaryOp.SubI32, expr, module.createI32(1));
|
expr = module.createBinary(BinaryOp.SubI32, expr, module.createI32(1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypeKind.USIZE: {
|
case TypeKind.USIZE:
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = this.currentType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.PREFIX_DEC);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileUnaryOverload(overload, expression.operand, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fall-through
|
|
||||||
}
|
|
||||||
case TypeKind.ISIZE: {
|
case TypeKind.ISIZE: {
|
||||||
expr = module.createBinary(
|
expr = module.createBinary(
|
||||||
this.options.isWasm64
|
this.options.isWasm64
|
||||||
@ -6978,16 +6955,17 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
WrapMode.NONE
|
WrapMode.NONE
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.currentType.kind == TypeKind.USIZE && this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
// check operator overload
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
let classReference = this.currentType.classReference;
|
let classReference = this.currentType.classReference;
|
||||||
if (classReference) {
|
if (classReference) {
|
||||||
let overload = classReference.lookupOverload(OperatorKind.NOT);
|
let overload = classReference.lookupOverload(OperatorKind.NOT);
|
||||||
if (overload) {
|
if (overload) {
|
||||||
expr = this.compileUnaryOverload(overload, expression.operand, expression);
|
expr = this.compileUnaryOverload(overload, expression.operand, expr, expression);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// allow '!' for references even without an overload
|
||||||
}
|
}
|
||||||
|
|
||||||
expr = this.makeIsFalseish(expr, this.currentType);
|
expr = this.makeIsFalseish(expr, this.currentType);
|
||||||
@ -7007,6 +6985,24 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
: ConversionKind.IMPLICIT,
|
: ConversionKind.IMPLICIT,
|
||||||
WrapMode.NONE
|
WrapMode.NONE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// check operator overload
|
||||||
|
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||||
|
let classReference = this.currentType.classReference;
|
||||||
|
if (classReference) {
|
||||||
|
let overload = classReference.lookupOverload(OperatorKind.BITWISE_NOT);
|
||||||
|
if (overload) {
|
||||||
|
expr = this.compileUnaryOverload(overload, expression.operand, expr, expression);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.error(
|
||||||
|
DiagnosticCode.Operation_not_supported,
|
||||||
|
expression.range
|
||||||
|
);
|
||||||
|
return module.createUnreachable();
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.currentType.kind) {
|
switch (this.currentType.kind) {
|
||||||
case TypeKind.I8:
|
case TypeKind.I8:
|
||||||
case TypeKind.I16:
|
case TypeKind.I16:
|
||||||
@ -7018,26 +7014,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
expr = module.createBinary(BinaryOp.XorI32, expr, module.createI32(-1));
|
expr = module.createBinary(BinaryOp.XorI32, expr, module.createI32(-1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypeKind.USIZE: {
|
case TypeKind.USIZE:
|
||||||
// check operator overload
|
|
||||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
|
||||||
let classReference = this.currentType.classReference;
|
|
||||||
if (classReference) {
|
|
||||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_NOT);
|
|
||||||
if (overload) {
|
|
||||||
expr = this.compileUnaryOverload(overload, expression.operand, expression);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
this.error(
|
|
||||||
DiagnosticCode.Operation_not_supported,
|
|
||||||
expression.range
|
|
||||||
);
|
|
||||||
return module.createUnreachable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fall-through
|
|
||||||
}
|
|
||||||
case TypeKind.ISIZE: {
|
case TypeKind.ISIZE: {
|
||||||
expr = module.createBinary(
|
expr = module.createBinary(
|
||||||
this.options.isWasm64
|
this.options.isWasm64
|
||||||
@ -7061,11 +7038,6 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Token.TYPEOF: {
|
case Token.TYPEOF: {
|
||||||
// it might make sense to implement typeof in a way that a generic function can detect
|
|
||||||
// whether its type argument is a class type or string. that could then be used, for
|
|
||||||
// example, to generate hash codes for sets and maps, depending on the kind of type
|
|
||||||
// parameter we have. ideally the comparison would not involve actual string comparison and
|
|
||||||
// limit available operations to hard-coded string literals.
|
|
||||||
this.error(
|
this.error(
|
||||||
DiagnosticCode.Operation_not_supported,
|
DiagnosticCode.Operation_not_supported,
|
||||||
expression.range
|
expression.range
|
||||||
|
131
src/program.ts
131
src/program.ts
@ -192,90 +192,52 @@ export enum OperatorKind {
|
|||||||
|
|
||||||
/** Returns the operator kind represented by the specified decorator and string argument. */
|
/** Returns the operator kind represented by the specified decorator and string argument. */
|
||||||
function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): OperatorKind {
|
function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): OperatorKind {
|
||||||
// TODO: currently handles binary only but some differ if unary prefix or postfix
|
|
||||||
assert(arg.length);
|
assert(arg.length);
|
||||||
|
switch (decoratorKind) {
|
||||||
|
case DecoratorKind.OPERATOR:
|
||||||
|
case DecoratorKind.OPERATOR_BINARY: {
|
||||||
switch (arg.charCodeAt(0)) {
|
switch (arg.charCodeAt(0)) {
|
||||||
case CharCode.OPENBRACKET: {
|
case CharCode.OPENBRACKET: {
|
||||||
switch (arg) {
|
if (arg == "[]") return OperatorKind.INDEXED_GET;
|
||||||
case "[]" : return OperatorKind.INDEXED_GET;
|
if (arg == "[]=") return OperatorKind.INDEXED_SET;
|
||||||
case "[]=": return OperatorKind.INDEXED_SET;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.OPENBRACE: {
|
case CharCode.OPENBRACE: {
|
||||||
switch (arg) {
|
if (arg == "{}") return OperatorKind.UNCHECKED_INDEXED_GET;
|
||||||
case "{}" : return OperatorKind.UNCHECKED_INDEXED_GET;
|
if (arg == "{}=") return OperatorKind.UNCHECKED_INDEXED_SET;
|
||||||
case "{}=": return OperatorKind.UNCHECKED_INDEXED_SET;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.PLUS: {
|
case CharCode.PLUS: {
|
||||||
switch (decoratorKind) {
|
if (arg == "+") return OperatorKind.ADD;
|
||||||
case DecoratorKind.OPERATOR_PREFIX: {
|
|
||||||
switch (arg) {
|
|
||||||
case "+": return OperatorKind.PLUS;
|
|
||||||
case "++": return OperatorKind.PREFIX_INC;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case DecoratorKind.OPERATOR_POSTFIX: {
|
|
||||||
if (arg == "++") return OperatorKind.POSTFIX_INC;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DecoratorKind.OPERATOR:
|
|
||||||
case DecoratorKind.OPERATOR_BINARY: {
|
|
||||||
if (arg.length == 1) return OperatorKind.ADD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.MINUS: {
|
case CharCode.MINUS: {
|
||||||
switch (decoratorKind) {
|
if (arg == "-") return OperatorKind.SUB;
|
||||||
case DecoratorKind.OPERATOR_PREFIX: {
|
|
||||||
switch (arg) {
|
|
||||||
case "-": return OperatorKind.MINUS;
|
|
||||||
case "--": return OperatorKind.PREFIX_DEC;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case DecoratorKind.OPERATOR_POSTFIX: {
|
|
||||||
if (arg == "--") return OperatorKind.POSTFIX_DEC;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DecoratorKind.OPERATOR:
|
|
||||||
case DecoratorKind.OPERATOR_BINARY: {
|
|
||||||
if (arg.length == 1) return OperatorKind.SUB;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.ASTERISK: {
|
case CharCode.ASTERISK: {
|
||||||
switch (arg) {
|
if (arg == "*") return OperatorKind.MUL;
|
||||||
case "*" : return OperatorKind.MUL;
|
if (arg == "**") return OperatorKind.POW;
|
||||||
case "**": return OperatorKind.POW;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.SLASH: {
|
case CharCode.SLASH: {
|
||||||
if (arg.length == 1) return OperatorKind.DIV;
|
if (arg == "/") return OperatorKind.DIV;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.PERCENT: {
|
case CharCode.PERCENT: {
|
||||||
if (arg.length == 1) return OperatorKind.REM;
|
if (arg == "%") return OperatorKind.REM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.AMPERSAND: {
|
case CharCode.AMPERSAND: {
|
||||||
if (arg.length == 1) return OperatorKind.BITWISE_AND;
|
if (arg == "&") return OperatorKind.BITWISE_AND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.BAR: {
|
case CharCode.BAR: {
|
||||||
if (arg.length == 1) return OperatorKind.BITWISE_OR;
|
if (arg == "|") return OperatorKind.BITWISE_OR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.CARET: {
|
case CharCode.CARET: {
|
||||||
if (arg.length == 1) return OperatorKind.BITWISE_XOR;
|
if (arg == "^") return OperatorKind.BITWISE_XOR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.EQUALS: {
|
case CharCode.EQUALS: {
|
||||||
@ -283,35 +245,58 @@ function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): O
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.EXCLAMATION: {
|
case CharCode.EXCLAMATION: {
|
||||||
switch (arg) {
|
if (arg == "!=") return OperatorKind.NE;
|
||||||
case "!": {
|
|
||||||
if (decoratorKind == DecoratorKind.OPERATOR_PREFIX) return OperatorKind.NOT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "!=": return OperatorKind.NE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.GREATERTHAN: {
|
case CharCode.GREATERTHAN: {
|
||||||
switch (arg) {
|
if (arg == ">") return OperatorKind.GT;
|
||||||
case ">" : return OperatorKind.GT;
|
if (arg == ">=") return OperatorKind.GE;
|
||||||
case ">=": return OperatorKind.GE;
|
if (arg == ">>") return OperatorKind.BITWISE_SHR;
|
||||||
case ">>": return OperatorKind.BITWISE_SHR;
|
if (arg == ">>>") return OperatorKind.BITWISE_SHR_U;
|
||||||
case ">>>": return OperatorKind.BITWISE_SHR_U;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CharCode.LESSTHAN: {
|
case CharCode.LESSTHAN: {
|
||||||
switch (arg) {
|
if (arg == "<") return OperatorKind.LT;
|
||||||
case "<" : return OperatorKind.LT;
|
if (arg == "<=") return OperatorKind.LE;
|
||||||
case "<=": return OperatorKind.LE;
|
if (arg == "<<") return OperatorKind.BITWISE_SHL;
|
||||||
case "<<": return OperatorKind.BITWISE_SHL;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DecoratorKind.OPERATOR_PREFIX: {
|
||||||
|
switch (arg.charCodeAt(0)) {
|
||||||
|
case CharCode.PLUS: {
|
||||||
|
if (arg == "+") return OperatorKind.PLUS;
|
||||||
|
if (arg == "++") return OperatorKind.PREFIX_INC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CharCode.MINUS: {
|
||||||
|
if (arg == "-") return OperatorKind.MINUS;
|
||||||
|
if (arg == "--") return OperatorKind.PREFIX_DEC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CharCode.EXCLAMATION: {
|
||||||
|
if (arg == "!") return OperatorKind.NOT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CharCode.TILDE: {
|
case CharCode.TILDE: {
|
||||||
if (decoratorKind == DecoratorKind.OPERATOR_PREFIX && arg.length == 1) {
|
if (arg == "~") return OperatorKind.BITWISE_NOT;
|
||||||
return OperatorKind.BITWISE_NOT;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DecoratorKind.OPERATOR_POSTFIX: {
|
||||||
|
switch (arg.charCodeAt(0)) {
|
||||||
|
case CharCode.PLUS: {
|
||||||
|
if (arg == "++") return OperatorKind.POSTFIX_INC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CharCode.MINUS: {
|
||||||
|
if (arg == "--") return OperatorKind.POSTFIX_DEC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@
|
|||||||
(f32.const 1.25)
|
(f32.const 1.25)
|
||||||
)
|
)
|
||||||
(set_global $builtins/f
|
(set_global $builtins/f
|
||||||
(f32.const 1.25)
|
(f32.const 1)
|
||||||
)
|
)
|
||||||
(set_global $builtins/f
|
(set_global $builtins/f
|
||||||
(f32.const 1.1180340051651)
|
(f32.const 1.1180340051651)
|
||||||
|
@ -2081,7 +2081,18 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester.neg (; 23 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester.pos (; 23 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
|
(call $std/operator-overloading/Tester#constructor
|
||||||
|
(i32.const 0)
|
||||||
|
(i32.load
|
||||||
|
(get_local $0)
|
||||||
|
)
|
||||||
|
(i32.load offset=4
|
||||||
|
(get_local $0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func $std/operator-overloading/Tester.neg (; 24 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(call $std/operator-overloading/Tester#constructor
|
(call $std/operator-overloading/Tester#constructor
|
||||||
(i32.const 0)
|
(i32.const 0)
|
||||||
(i32.sub
|
(i32.sub
|
||||||
@ -2098,7 +2109,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester.not (; 24 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester.not (; 25 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(call $std/operator-overloading/Tester#constructor
|
(call $std/operator-overloading/Tester#constructor
|
||||||
(i32.const 0)
|
(i32.const 0)
|
||||||
(i32.xor
|
(i32.xor
|
||||||
@ -2115,7 +2126,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester.excl (; 25 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester.excl (; 26 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(local $1 i32)
|
(local $1 i32)
|
||||||
(if (result i32)
|
(if (result i32)
|
||||||
(tee_local $1
|
(tee_local $1
|
||||||
@ -2133,7 +2144,7 @@
|
|||||||
(get_local $1)
|
(get_local $1)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester#inc (; 26 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester#inc (; 27 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(i32.store
|
(i32.store
|
||||||
(get_local $0)
|
(get_local $0)
|
||||||
(i32.add
|
(i32.add
|
||||||
@ -2154,7 +2165,7 @@
|
|||||||
)
|
)
|
||||||
(get_local $0)
|
(get_local $0)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester#dec (; 27 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester#dec (; 28 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(i32.store
|
(i32.store
|
||||||
(get_local $0)
|
(get_local $0)
|
||||||
(i32.sub
|
(i32.sub
|
||||||
@ -2175,7 +2186,7 @@
|
|||||||
)
|
)
|
||||||
(get_local $0)
|
(get_local $0)
|
||||||
)
|
)
|
||||||
(func $start (; 28 ;) (type $v)
|
(func $start (; 29 ;) (type $v)
|
||||||
(local $0 i32)
|
(local $0 i32)
|
||||||
(local $1 i32)
|
(local $1 i32)
|
||||||
(set_global $~lib/allocator/arena/startOffset
|
(set_global $~lib/allocator/arena/startOffset
|
||||||
@ -3021,8 +3032,10 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
(set_global $std/operator-overloading/pres
|
(set_global $std/operator-overloading/pres
|
||||||
|
(call $std/operator-overloading/Tester.pos
|
||||||
(get_global $std/operator-overloading/pos)
|
(get_global $std/operator-overloading/pos)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
(if
|
(if
|
||||||
(i32.eqz
|
(i32.eqz
|
||||||
(if (result i32)
|
(if (result i32)
|
||||||
|
@ -2334,7 +2334,20 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester.neg (; 23 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester.pos (; 23 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
|
(return
|
||||||
|
(call $std/operator-overloading/Tester#constructor
|
||||||
|
(i32.const 0)
|
||||||
|
(i32.load
|
||||||
|
(get_local $0)
|
||||||
|
)
|
||||||
|
(i32.load offset=4
|
||||||
|
(get_local $0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(func $std/operator-overloading/Tester.neg (; 24 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(return
|
(return
|
||||||
(call $std/operator-overloading/Tester#constructor
|
(call $std/operator-overloading/Tester#constructor
|
||||||
(i32.const 0)
|
(i32.const 0)
|
||||||
@ -2353,7 +2366,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester.not (; 24 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester.not (; 25 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(return
|
(return
|
||||||
(call $std/operator-overloading/Tester#constructor
|
(call $std/operator-overloading/Tester#constructor
|
||||||
(i32.const 0)
|
(i32.const 0)
|
||||||
@ -2372,7 +2385,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester.excl (; 25 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester.excl (; 26 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(local $1 i32)
|
(local $1 i32)
|
||||||
(return
|
(return
|
||||||
(if (result i32)
|
(if (result i32)
|
||||||
@ -2392,7 +2405,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester#inc (; 26 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester#inc (; 27 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(i32.store
|
(i32.store
|
||||||
(get_local $0)
|
(get_local $0)
|
||||||
(i32.add
|
(i32.add
|
||||||
@ -2415,7 +2428,7 @@
|
|||||||
(get_local $0)
|
(get_local $0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/Tester#dec (; 27 ;) (type $ii) (param $0 i32) (result i32)
|
(func $std/operator-overloading/Tester#dec (; 28 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(i32.store
|
(i32.store
|
||||||
(get_local $0)
|
(get_local $0)
|
||||||
(i32.sub
|
(i32.sub
|
||||||
@ -2438,7 +2451,7 @@
|
|||||||
(get_local $0)
|
(get_local $0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/TesterInlineStatic#constructor (; 28 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
(func $std/operator-overloading/TesterInlineStatic#constructor (; 29 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||||
(local $3 i32)
|
(local $3 i32)
|
||||||
(nop)
|
(nop)
|
||||||
(tee_local $0
|
(tee_local $0
|
||||||
@ -2466,7 +2479,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $std/operator-overloading/TesterInlineInstance#constructor (; 29 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
(func $std/operator-overloading/TesterInlineInstance#constructor (; 30 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||||
(local $3 i32)
|
(local $3 i32)
|
||||||
(nop)
|
(nop)
|
||||||
(tee_local $0
|
(tee_local $0
|
||||||
@ -2494,7 +2507,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(func $start (; 30 ;) (type $v)
|
(func $start (; 31 ;) (type $v)
|
||||||
(local $0 i32)
|
(local $0 i32)
|
||||||
(local $1 i32)
|
(local $1 i32)
|
||||||
(set_global $~lib/allocator/arena/startOffset
|
(set_global $~lib/allocator/arena/startOffset
|
||||||
@ -3367,8 +3380,10 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
(set_global $std/operator-overloading/pres
|
(set_global $std/operator-overloading/pres
|
||||||
|
(call $std/operator-overloading/Tester.pos
|
||||||
(get_global $std/operator-overloading/pos)
|
(get_global $std/operator-overloading/pos)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
(if
|
(if
|
||||||
(i32.eqz
|
(i32.eqz
|
||||||
(if (result i32)
|
(if (result i32)
|
||||||
|
@ -45,6 +45,17 @@
|
|||||||
0b0;
|
0b0;
|
||||||
0b1;
|
0b1;
|
||||||
0b1111111111111111111111111111111;
|
0b1111111111111111111111111111111;
|
||||||
|
0.0;
|
||||||
|
0.123;
|
||||||
|
.0;
|
||||||
|
.123;
|
||||||
|
12.34;
|
||||||
|
1e1;
|
||||||
|
1.0e1;
|
||||||
|
1e+1;
|
||||||
|
1.0e+1;
|
||||||
|
1e-1;
|
||||||
|
1.0e-1;
|
||||||
"123";
|
"123";
|
||||||
"1\"23";
|
"1\"23";
|
||||||
"1\"2\\3";
|
"1\"2\\3";
|
||||||
|
@ -45,6 +45,17 @@
|
|||||||
0;
|
0;
|
||||||
1;
|
1;
|
||||||
2147483647;
|
2147483647;
|
||||||
|
0;
|
||||||
|
0.123;
|
||||||
|
0;
|
||||||
|
0.123;
|
||||||
|
12.34;
|
||||||
|
10;
|
||||||
|
10;
|
||||||
|
10;
|
||||||
|
10;
|
||||||
|
0.1;
|
||||||
|
0.1;
|
||||||
"123";
|
"123";
|
||||||
"1\"23";
|
"1\"23";
|
||||||
"1\"2\\3";
|
"1\"2\\3";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user