Implement comparision operator overloads (#63)

This commit is contained in:
Max Graey
2018-04-04 01:01:59 +03:00
committed by Daniel Wirtz
parent 5823e35f37
commit 37825fc84d
5 changed files with 844 additions and 34 deletions

View File

@ -733,6 +733,26 @@ export class Program extends DiagnosticEmitter {
classPrototype.fnEquals = prototype.simpleName;
break;
}
case "!=": {
classPrototype.fnNotEquals = prototype.simpleName;
break;
}
case ">": {
classPrototype.fnGreaterThan = prototype.simpleName;
break;
}
case ">=": {
classPrototype.fnGreaterThanEquals = prototype.simpleName;
break;
}
case "<": {
classPrototype.fnLessThan = prototype.simpleName;
break;
}
case "<=": {
classPrototype.fnLessThanEquals = prototype.simpleName;
break;
}
default: {
this.error(
DiagnosticCode.Operation_not_supported,
@ -2944,6 +2964,16 @@ export class ClassPrototype extends Element {
fnBitwiseXor: string | null = null;
/** Overloaded equality comparison method, if any. */
fnEquals: string | null = null;
/** Overloaded non-equality comparison method, if any. */
fnNotEquals: string | null = null;
/** Overloaded greater comparison method, if any. */
fnGreaterThan: string | null = null;
/** Overloaded greater or equal comparison method, if any. */
fnGreaterThanEquals: string | null = null;
/** Overloaded less comparison method, if any. */
fnLessThan: string | null = null;
/** Overloaded less or equal comparison method, if any. */
fnLessThanEquals: string | null = null;
constructor(
program: Program,