mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Implement unary operator overloads (#124)
This commit is contained in:
parent
0054eae491
commit
567a5fb064
483
src/compiler.ts
483
src/compiler.ts
@ -2561,12 +2561,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.LT);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.LT);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2660,12 +2668,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.GT);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.GT);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2759,12 +2775,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.LE);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.LE);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2858,12 +2882,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.GE);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.GE);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2963,7 +2995,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftExpr = this.compileExpressionRetainType(left, contextualType, WrapMode.NONE);
|
||||
leftType = this.currentType;
|
||||
|
||||
if (operator == Token.EQUALS_EQUALS) { // check operator overload
|
||||
// check operator overload
|
||||
if (operator == Token.EQUALS_EQUALS && this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.EQ);
|
||||
@ -3049,7 +3082,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftExpr = this.compileExpressionRetainType(left, contextualType, WrapMode.NONE);
|
||||
leftType = this.currentType;
|
||||
|
||||
if (operator == Token.EXCLAMATION_EQUALS) { // check operator overload
|
||||
// check operator overload
|
||||
if (operator == Token.EXCLAMATION_EQUALS && this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.NE);
|
||||
@ -3139,12 +3173,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.ADD);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.ADD);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3227,12 +3269,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.SUB);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.SUB);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3316,12 +3366,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.MUL);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.MUL);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3405,12 +3463,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.POW);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.POW);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3498,12 +3564,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.DIV);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.DIV);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3606,12 +3680,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.REM);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.REM);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3787,7 +3869,26 @@ export class Compiler extends DiagnosticEmitter {
|
||||
expr = module.createBinary(BinaryOp.ShlI64, leftExpr, rightExpr);
|
||||
break;
|
||||
}
|
||||
case TypeKind.USIZE: // TODO: check operator overload
|
||||
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: {
|
||||
expr = module.createBinary(
|
||||
this.options.isWasm64
|
||||
@ -3857,7 +3958,25 @@ export class Compiler extends DiagnosticEmitter {
|
||||
expr = module.createBinary(BinaryOp.ShrU64, leftExpr, rightExpr);
|
||||
break;
|
||||
}
|
||||
case TypeKind.USIZE: { // TODO: check operator overload
|
||||
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(
|
||||
this.options.isWasm64
|
||||
? BinaryOp.ShrU64
|
||||
@ -3906,7 +4025,26 @@ export class Compiler extends DiagnosticEmitter {
|
||||
expr = module.createBinary(BinaryOp.ShrU64, leftExpr, rightExpr);
|
||||
break;
|
||||
}
|
||||
case TypeKind.USIZE: // TODO: operator overload?
|
||||
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: {
|
||||
expr = module.createBinary(
|
||||
this.options.isWasm64
|
||||
@ -3938,12 +4076,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overloadd
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_AND);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_AND);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4027,12 +4173,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_OR);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_OR);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4119,12 +4273,20 @@ export class Compiler extends DiagnosticEmitter {
|
||||
leftType = this.currentType;
|
||||
|
||||
// check operator overload
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_XOR);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
let classReference = leftType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.BITWISE_XOR);
|
||||
if (overload) {
|
||||
expr = this.compileBinaryOverload(overload, left, right, expression);
|
||||
break;
|
||||
} else {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return this.module.createUnreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6390,6 +6552,19 @@ export class Compiler extends DiagnosticEmitter {
|
||||
);
|
||||
return 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) {
|
||||
case TypeKind.I8:
|
||||
case TypeKind.I16:
|
||||
@ -6543,13 +6718,24 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
switch (expression.operator) {
|
||||
case Token.PLUS: {
|
||||
// check operator overload
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
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(
|
||||
expression.operand,
|
||||
contextualType == Type.void
|
||||
@ -6561,13 +6747,6 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
}
|
||||
case Token.MINUS: {
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
}
|
||||
if (expression.operand.kind == NodeKind.LITERAL && (
|
||||
(<LiteralExpression>expression.operand).literalKind == LiteralKind.INTEGER ||
|
||||
(<LiteralExpression>expression.operand).literalKind == LiteralKind.FLOAT
|
||||
@ -6597,12 +6776,22 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
}
|
||||
case TypeKind.USIZE: {
|
||||
// check operator overload
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
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
|
||||
}
|
||||
@ -6638,13 +6827,6 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
}
|
||||
case Token.PLUS_PLUS: {
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
}
|
||||
compound = true;
|
||||
expr = this.compileExpression(
|
||||
expression.operand,
|
||||
@ -6666,12 +6848,22 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
}
|
||||
case TypeKind.USIZE: {
|
||||
// check operator overload
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
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
|
||||
}
|
||||
@ -6706,13 +6898,6 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
}
|
||||
case Token.MINUS_MINUS: {
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
}
|
||||
compound = true;
|
||||
expr = this.compileExpression(
|
||||
expression.operand,
|
||||
@ -6734,12 +6919,22 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
}
|
||||
case TypeKind.USIZE: {
|
||||
// check operator overload
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
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
|
||||
}
|
||||
@ -6782,18 +6977,24 @@ export class Compiler extends DiagnosticEmitter {
|
||||
ConversionKind.NONE,
|
||||
WrapMode.NONE
|
||||
);
|
||||
|
||||
if (this.currentType.kind == TypeKind.USIZE && this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
// check operator overload
|
||||
let classReference = this.currentType.classReference;
|
||||
if (classReference) {
|
||||
let overload = classReference.lookupOverload(OperatorKind.NOT);
|
||||
if (overload) {
|
||||
expr = this.compileUnaryOverload(overload, expression.operand, expression);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expr = this.makeIsFalseish(expr, this.currentType);
|
||||
this.currentType = Type.bool;
|
||||
break;
|
||||
}
|
||||
case Token.TILDE: {
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
}
|
||||
expr = this.compileExpression(
|
||||
expression.operand,
|
||||
contextualType == Type.void
|
||||
@ -6818,12 +7019,22 @@ export class Compiler extends DiagnosticEmitter {
|
||||
break;
|
||||
}
|
||||
case TypeKind.USIZE: {
|
||||
// check operator overload
|
||||
if (this.currentType.is(TypeFlags.REFERENCE)) {
|
||||
this.error(
|
||||
DiagnosticCode.Operation_not_supported,
|
||||
expression.range
|
||||
);
|
||||
return module.createUnreachable();
|
||||
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
|
||||
}
|
||||
|
@ -210,11 +210,45 @@ function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): O
|
||||
break;
|
||||
}
|
||||
case CharCode.PLUS: {
|
||||
if (arg.length == 1) return OperatorKind.ADD;
|
||||
switch (decoratorKind) {
|
||||
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;
|
||||
}
|
||||
case CharCode.MINUS: {
|
||||
if (arg.length == 1) return OperatorKind.SUB;
|
||||
switch (decoratorKind) {
|
||||
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;
|
||||
}
|
||||
case CharCode.ASTERISK: {
|
||||
@ -249,20 +283,35 @@ function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): O
|
||||
break;
|
||||
}
|
||||
case CharCode.EXCLAMATION: {
|
||||
if (arg == "!=") return OperatorKind.NE;
|
||||
switch (arg) {
|
||||
case "!": {
|
||||
if (decoratorKind == DecoratorKind.OPERATOR_PREFIX) return OperatorKind.NOT;
|
||||
break;
|
||||
}
|
||||
case "!=": return OperatorKind.NE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CharCode.GREATERTHAN: {
|
||||
switch (arg) {
|
||||
case ">" : return OperatorKind.GT;
|
||||
case ">=": return OperatorKind.GE;
|
||||
case ">" : return OperatorKind.GT;
|
||||
case ">=": return OperatorKind.GE;
|
||||
case ">>": return OperatorKind.BITWISE_SHR;
|
||||
case ">>>": return OperatorKind.BITWISE_SHR_U;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CharCode.LESSTHAN: {
|
||||
switch (arg) {
|
||||
case "<" : return OperatorKind.LT;
|
||||
case "<=": return OperatorKind.LE;
|
||||
case "<" : return OperatorKind.LT;
|
||||
case "<=": return OperatorKind.LE;
|
||||
case "<<": return OperatorKind.BITWISE_SHL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CharCode.TILDE: {
|
||||
if (decoratorKind == DecoratorKind.OPERATOR_PREFIX && arg.length == 1) {
|
||||
return OperatorKind.BITWISE_NOT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -819,7 +868,9 @@ export class Program extends DiagnosticEmitter {
|
||||
var decoratorFlags = DecoratorFlags.NONE;
|
||||
if (decorators) {
|
||||
decoratorFlags = this.filterDecorators(decorators,
|
||||
DecoratorFlags.OPERATOR_BINARY |
|
||||
DecoratorFlags.OPERATOR_BINARY |
|
||||
DecoratorFlags.OPERATOR_PREFIX |
|
||||
DecoratorFlags.OPERATOR_POSTFIX |
|
||||
DecoratorFlags.INLINE
|
||||
);
|
||||
}
|
||||
|
@ -54,6 +54,20 @@
|
||||
(global $std/operator-overloading/leq1 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/leq2 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/leq (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/shr (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/sres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/shu (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ures (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/shl (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/pos (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/pres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/neg (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/nres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/not (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/res (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/excl (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/bres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/incdec (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ais1 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ais2 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ais (mut i32) (i32.const 0))
|
||||
@ -2016,7 +2030,152 @@
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $start (; 20 ;) (type $v)
|
||||
(func $std/operator-overloading/Tester.shr (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.shr_s
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.shu (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shr_u
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.shl (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.shl
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.neg (; 23 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.not (; 24 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.xor
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.excl (; 25 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.eqz
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eqz
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester#inc (; 26 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $std/operator-overloading/Tester#dec (; 27 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $start (; 28 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
@ -2075,7 +2234,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 87)
|
||||
(i32.const 137)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2124,7 +2283,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 93)
|
||||
(i32.const 143)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2174,7 +2333,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 99)
|
||||
(i32.const 149)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2224,7 +2383,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 105)
|
||||
(i32.const 155)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2273,7 +2432,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 111)
|
||||
(i32.const 161)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2323,7 +2482,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 117)
|
||||
(i32.const 167)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2373,7 +2532,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 123)
|
||||
(i32.const 173)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2423,7 +2582,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 129)
|
||||
(i32.const 179)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2473,7 +2632,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 135)
|
||||
(i32.const 185)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2508,7 +2667,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 141)
|
||||
(i32.const 191)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2540,7 +2699,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 147)
|
||||
(i32.const 197)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2558,7 +2717,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 151)
|
||||
(i32.const 201)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2579,7 +2738,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 155)
|
||||
(i32.const 205)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2614,7 +2773,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 161)
|
||||
(i32.const 211)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2649,7 +2808,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 167)
|
||||
(i32.const 217)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2684,7 +2843,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 173)
|
||||
(i32.const 223)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2719,7 +2878,416 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 179)
|
||||
(i32.const 229)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/shr
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/sres
|
||||
(call $std/operator-overloading/Tester.shr
|
||||
(get_global $std/operator-overloading/shr)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 234)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/shu
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const -8)
|
||||
(i32.const -16)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/ures
|
||||
(call $std/operator-overloading/Tester.shu
|
||||
(get_global $std/operator-overloading/shu)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/ures)
|
||||
)
|
||||
(i32.const 536870911)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/ures)
|
||||
)
|
||||
(i32.const 536870910)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 239)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/shl
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/sres
|
||||
(call $std/operator-overloading/Tester.shl
|
||||
(get_global $std/operator-overloading/shl)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 244)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/pos
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
(i32.const -2)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/pres
|
||||
(get_global $std/operator-overloading/pos)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/pres)
|
||||
)
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/pos)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/pres)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/pos)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 249)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/neg
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const -1)
|
||||
(i32.const -2)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/nres
|
||||
(call $std/operator-overloading/Tester.neg
|
||||
(get_global $std/operator-overloading/neg)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/nres)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/neg)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/nres)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/neg)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 254)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/not
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 255)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/res
|
||||
(call $std/operator-overloading/Tester.not
|
||||
(get_global $std/operator-overloading/not)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/res)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/not)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/res)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/not)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 259)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/excl
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/bres
|
||||
(call $std/operator-overloading/Tester.excl
|
||||
(get_global $std/operator-overloading/excl)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $std/operator-overloading/bres)
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eqz
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/excl)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eqz
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/excl)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 264)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $std/operator-overloading/bres)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 265)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/incdec
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/incdec
|
||||
(call $std/operator-overloading/Tester#inc
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 271)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/incdec
|
||||
(call $std/operator-overloading/Tester#dec
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eqz
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 274)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2788,7 +3356,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 193)
|
||||
(i32.const 288)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2857,7 +3425,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 207)
|
||||
(i32.const 302)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -78,6 +78,56 @@ class Tester {
|
||||
static lessEquals(a: Tester, b: Tester): bool {
|
||||
return a.x <= b.x && a.y <= b.y;
|
||||
}
|
||||
|
||||
@operator('>>')
|
||||
static shr(value: Tester, shift: i32): Tester {
|
||||
return new Tester(value.x >> shift, value.y >> shift);
|
||||
}
|
||||
|
||||
@operator('>>>')
|
||||
static shu(value: Tester, shift: i32): Tester {
|
||||
return new Tester(value.x >>> shift, value.y >>> shift);
|
||||
}
|
||||
|
||||
@operator('<<')
|
||||
static shl(value: Tester, shift: i32): Tester {
|
||||
return new Tester(value.x << shift, value.y << shift);
|
||||
}
|
||||
|
||||
// unary opterators
|
||||
@operator.prefix('~')
|
||||
static not(value: Tester): Tester {
|
||||
return new Tester(~value.x, ~value.y);
|
||||
}
|
||||
|
||||
@operator.prefix('!')
|
||||
static excl(value: Tester): bool {
|
||||
return !value.x && !value.y;
|
||||
}
|
||||
|
||||
@operator.prefix('+')
|
||||
static pos(value: Tester): Tester {
|
||||
return new Tester(+value.x, +value.y);
|
||||
}
|
||||
|
||||
@operator.prefix('-')
|
||||
static neg(value: Tester): Tester {
|
||||
return new Tester(-value.x, -value.y);
|
||||
}
|
||||
|
||||
@operator.prefix('++')
|
||||
inc(): this {
|
||||
++this.x;
|
||||
++this.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
@operator.prefix('--')
|
||||
dec(): this {
|
||||
--this.x;
|
||||
--this.y;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// check additional
|
||||
@ -178,6 +228,51 @@ var leq2 = new Tester(4, 3);
|
||||
var leq = leq1 <= leq2;
|
||||
assert(leq == true);
|
||||
|
||||
// check right shift
|
||||
var shr = new Tester(8, 16);
|
||||
var sres = shr >> 3;
|
||||
assert(sres.x == 1 && sres.y == 2);
|
||||
|
||||
// check right shift
|
||||
var shu = new Tester(-8, -16);
|
||||
var ures = shu >>> 3;
|
||||
assert(ures.x == 536870911 && ures.y == 536870910);
|
||||
|
||||
// check left shift
|
||||
var shl = new Tester(1, 2);
|
||||
sres = shl << 3;
|
||||
assert(sres.x == 8 && sres.y == 16);
|
||||
|
||||
// check unary positive
|
||||
var pos = new Tester(1, -2);
|
||||
var pres = +pos;
|
||||
assert(pres.x == pos.x && pres.y == pos.y);
|
||||
|
||||
// check unary negative
|
||||
var neg = new Tester(-1, -2);
|
||||
var nres = -neg;
|
||||
assert(nres.x == -neg.x && nres.y == -neg.y);
|
||||
|
||||
// check unary not "~"
|
||||
var not = new Tester(0xFF, 0x10);
|
||||
var res = ~not;
|
||||
assert(res.x == ~not.x && res.y == ~not.y);
|
||||
|
||||
// check unary exclamation "!"
|
||||
var excl = new Tester(0, 0);
|
||||
var bres = !excl;
|
||||
assert(bres == (!excl.x && !excl.y));
|
||||
assert(bres == true);
|
||||
|
||||
//
|
||||
var incdec = new Tester(0, 1);
|
||||
|
||||
++incdec;
|
||||
assert(incdec.x == 1 && incdec.y == 2);
|
||||
|
||||
--incdec;
|
||||
assert(incdec.x == 0 && incdec.y == 1);
|
||||
|
||||
// check inlined static
|
||||
class TesterInlineStatic {
|
||||
constructor(public x: i32, public y: i32) {
|
||||
|
@ -59,6 +59,20 @@
|
||||
(global $std/operator-overloading/leq1 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/leq2 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/leq (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/shr (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/sres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/shu (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ures (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/shl (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/pos (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/pres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/neg (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/nres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/not (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/res (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/excl (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/bres (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/incdec (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ais1 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ais2 (mut i32) (i32.const 0))
|
||||
(global $std/operator-overloading/ais (mut i32) (i32.const 0))
|
||||
@ -2263,7 +2277,168 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/TesterInlineStatic#constructor (; 20 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $std/operator-overloading/Tester.shr (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(return
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.shr_s
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shr_s
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.shu (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(return
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shr_u
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.shl (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(return
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.shl
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.shl
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.neg (; 23 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.not (; 24 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.xor
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester.excl (; 25 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(return
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.eqz
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eqz
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester#inc (; 26 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.add
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/Tester#dec (; 27 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/TesterInlineStatic#constructor (; 28 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(nop)
|
||||
(tee_local $0
|
||||
@ -2291,7 +2466,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std/operator-overloading/TesterInlineInstance#constructor (; 21 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(func $std/operator-overloading/TesterInlineInstance#constructor (; 29 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(nop)
|
||||
(tee_local $0
|
||||
@ -2319,7 +2494,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 22 ;) (type $v)
|
||||
(func $start (; 30 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
@ -2381,7 +2556,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 87)
|
||||
(i32.const 137)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2431,7 +2606,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 93)
|
||||
(i32.const 143)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2481,7 +2656,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 99)
|
||||
(i32.const 149)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2531,7 +2706,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 105)
|
||||
(i32.const 155)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2581,7 +2756,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 111)
|
||||
(i32.const 161)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2631,7 +2806,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 117)
|
||||
(i32.const 167)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2681,7 +2856,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 123)
|
||||
(i32.const 173)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2731,7 +2906,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 129)
|
||||
(i32.const 179)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2781,7 +2956,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 135)
|
||||
(i32.const 185)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2818,7 +2993,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 141)
|
||||
(i32.const 191)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2855,7 +3030,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 147)
|
||||
(i32.const 197)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2878,7 +3053,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 151)
|
||||
(i32.const 201)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2901,7 +3076,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 155)
|
||||
(i32.const 205)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2938,7 +3113,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 161)
|
||||
(i32.const 211)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -2975,7 +3150,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 167)
|
||||
(i32.const 217)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3012,7 +3187,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 173)
|
||||
(i32.const 223)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3049,7 +3224,421 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 179)
|
||||
(i32.const 229)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/shr
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/sres
|
||||
(call $std/operator-overloading/Tester.shr
|
||||
(get_global $std/operator-overloading/shr)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 234)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/shu
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const -8)
|
||||
(i32.const -16)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/ures
|
||||
(call $std/operator-overloading/Tester.shu
|
||||
(get_global $std/operator-overloading/shu)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/ures)
|
||||
)
|
||||
(i32.const 536870911)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/ures)
|
||||
)
|
||||
(i32.const 536870910)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 239)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/shl
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/sres
|
||||
(call $std/operator-overloading/Tester.shl
|
||||
(get_global $std/operator-overloading/shl)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/sres)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 244)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/pos
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
(i32.const -2)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/pres
|
||||
(get_global $std/operator-overloading/pos)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/pres)
|
||||
)
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/pos)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/pres)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/pos)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 249)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/neg
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const -1)
|
||||
(i32.const -2)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/nres
|
||||
(call $std/operator-overloading/Tester.neg
|
||||
(get_global $std/operator-overloading/neg)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/nres)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/neg)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/nres)
|
||||
)
|
||||
(i32.sub
|
||||
(i32.const 0)
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/neg)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 254)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/not
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 255)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/res
|
||||
(call $std/operator-overloading/Tester.not
|
||||
(get_global $std/operator-overloading/not)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/res)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/not)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/res)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/not)
|
||||
)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 259)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/excl
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/bres
|
||||
(call $std/operator-overloading/Tester.excl
|
||||
(get_global $std/operator-overloading/excl)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(get_global $std/operator-overloading/bres)
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eqz
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/excl)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.eqz
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/excl)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 264)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(get_global $std/operator-overloading/bres)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 265)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/incdec
|
||||
(call $std/operator-overloading/Tester#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/incdec
|
||||
(call $std/operator-overloading/Tester#inc
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 271)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/operator-overloading/incdec
|
||||
(call $std/operator-overloading/Tester#dec
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(if (result i32)
|
||||
(tee_local $0
|
||||
(i32.eq
|
||||
(i32.load
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/operator-overloading/incdec)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 274)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3124,7 +3713,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 193)
|
||||
(i32.const 288)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -3199,7 +3788,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 207)
|
||||
(i32.const 302)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user