Mark builtins and stblib functions with 'operator'
This commit is contained in:
@@ -35,7 +35,7 @@ class GenerateArrayIterators(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
}
|
||||
for (kind in PrimitiveType.values()) {
|
||||
val s = kind.capitalized
|
||||
out.println("public fun iterator(array: ${s}Array): ${s}Iterator = Array${s}Iterator(array)")
|
||||
out.println("public operator fun iterator(array: ${s}Array): ${s}Iterator = Array${s}Iterator(array)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,15 +34,15 @@ class GenerateArrays(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
out.println(" */")
|
||||
out.println("public class ${s}Array(size: Int) : Cloneable {")
|
||||
out.println(" /** Returns the array element at the given [index]. This method can be called using the index operator. */")
|
||||
out.println(" public fun get(index: Int): $s")
|
||||
out.println(" public operator fun get(index: Int): $s")
|
||||
out.println(" /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */")
|
||||
out.println(" public fun set(index: Int, value: $s): Unit")
|
||||
out.println(" public operator fun set(index: Int, value: $s): Unit")
|
||||
out.println()
|
||||
out.println(" /** Returns the number of elements in the array. */")
|
||||
out.println(" public fun size(): Int")
|
||||
out.println()
|
||||
out.println(" /** Creates an iterator over the elements of the array. */")
|
||||
out.println(" public fun iterator(): ${s}Iterator")
|
||||
out.println(" public operator fun iterator(): ${s}Iterator")
|
||||
out.println()
|
||||
out.println(" public override fun clone(): ${s}Array")
|
||||
out.println("}")
|
||||
|
||||
@@ -77,7 +77,7 @@ class GenerateFunctions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
val suffix = if (i == 1) "" else "s"
|
||||
out.println(" /** Invokes the function with the specified argument${suffix}. */")
|
||||
}
|
||||
out.print(" public fun invoke(")
|
||||
out.print(" public operator fun invoke(")
|
||||
for (j in 1..i) {
|
||||
out.print("p$j: P$j")
|
||||
if (j < i) {
|
||||
|
||||
@@ -98,7 +98,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
out.println(" */")
|
||||
out.print(" public ")
|
||||
if (otherKind == thisKind) out.print("override ")
|
||||
out.println("fun compareTo(other: ${otherKind.capitalized}): Int")
|
||||
out.println("operator fun compareTo(other: ${otherKind.capitalized}): Int")
|
||||
}
|
||||
out.println()
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
for (otherKind in PrimitiveType.onlyNumeric) {
|
||||
val returnType = getOperatorReturnType(thisKind, otherKind)
|
||||
out.println(" /** $doc */")
|
||||
out.println(" public fun $name(other: ${otherKind.capitalized}): $returnType")
|
||||
out.println(" public operator fun $name(other: ${otherKind.capitalized}): $returnType")
|
||||
}
|
||||
out.println()
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
for (otherKind in PrimitiveType.onlyNumeric) {
|
||||
val returnType = if (otherKind.ordinal() > thisKind.ordinal()) otherKind else thisKind
|
||||
out.println(" /** Creates a range from this value to the specified [other] value. */")
|
||||
out.println(" public fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range")
|
||||
out.println(" public operator fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range")
|
||||
}
|
||||
out.println()
|
||||
|
||||
@@ -133,7 +133,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
val returnType = if (kind in listOf(PrimitiveType.SHORT, PrimitiveType.BYTE, PrimitiveType.CHAR) &&
|
||||
name in listOf("plus", "minus")) "Int" else kind.capitalized
|
||||
out.println(" /** $doc */")
|
||||
out.println(" public fun $name(): $returnType")
|
||||
out.println(" public operator fun $name(): $returnType")
|
||||
}
|
||||
out.println()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user