Mark builtins and stdlib functions with 'infix'

This commit is contained in:
Yan Zhulanow
2015-09-29 19:22:33 +03:00
parent 1238e93b9f
commit d28ecc2316
7 changed files with 95 additions and 86 deletions
@@ -109,6 +109,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
val typeParams = ArrayList<String>()
val returns = FamilyProperty<String>()
val operator = FamilyProperty<Boolean>()
val infix = FamilyProperty<Boolean>()
val body = object : FamilyProperty<String>() {
override fun onKeySet(key: Family) = include(key)
}
@@ -374,6 +375,8 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
builder.append("public ")
if (inline[f] == true)
builder.append("inline ")
if (infix[f] == true)
builder.append("infix ")
if (operator[f] == true)
builder.append("operator ")
@@ -21,6 +21,8 @@ fun ranges(): List<GenericFunction> {
}
templates add f("step(step: SUM)") {
infix(true)
only(RangesOfPrimitives, ProgressionsOfPrimitives)
exclude(PrimitiveType.Boolean)
doc(ProgressionsOfPrimitives) { "Returns a progression that goes over the same range with the given step." }
@@ -48,6 +50,8 @@ fun ranges(): List<GenericFunction> {
}
fun downTo(fromType: PrimitiveType, toType: PrimitiveType) = f("downTo(to: $toType)") {
infix(true)
sourceFile(SourceFile.Ranges)
only(Primitives)
only(fromType)
@@ -81,6 +85,8 @@ fun ranges(): List<GenericFunction> {
templates addAll primitivePermutations.map { downTo(it.first, it.second) }
fun until(fromType: PrimitiveType, toType: PrimitiveType) = f("until(to: $toType)") {
infix(true)
sourceFile(SourceFile.Ranges)
only(Primitives)
only(fromType)