Implement unsigned comparisons

This commit is contained in:
Ilya Gorbunov
2018-05-04 07:39:39 +03:00
parent e4216099b3
commit 89e4fdfa9c
6 changed files with 32 additions and 17 deletions
+7 -1
View File
@@ -86,7 +86,13 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
*/""")
out.print(" public ")
if (otherType == type) out.print("override ")
out.println("operator fun compareTo(other: ${otherType.capitalized}): Int = TODO()")
out.print("operator fun compareTo(other: ${otherType.capitalized}): Int = ")
if (otherType == type && maxByDomainCapacity(type, UnsignedType.UINT) == type) {
out.println("${className.toLowerCase()}Compare(this.data, other.data)")
} else {
val ctype = maxByDomainCapacity(maxByDomainCapacity(type, otherType), UnsignedType.UINT)
out.println("${convert("this", type, ctype)}.compareTo(${convert("other", otherType, ctype)})")
}
}
out.println()
}