Remove duplicated sources of built-ins

BuiltInsSerializer now serializes built-ins found in two source roots:
core/builtins/native and core/builtins/src

Add return types to some declarations in core/builtins/src, because now that
BuiltInsSerializer processes them, it launches lazy resolution which can't
always deduce the return type
This commit is contained in:
Alexander Udalov
2014-01-16 23:19:43 +04:00
parent 3b4c341046
commit 61ad9fba4a
232 changed files with 156 additions and 648 deletions
@@ -32,10 +32,10 @@ fun integerProgressionIterator(kind: ProgressionKind): String {
return """class ${t}ProgressionIterator(start: $t, end: $t, val increment: $incrementType) : ${t}Iterator() {
private var next = start$toInt
private val finalElement = ProgressionUtil.getProgressionFinalElement(start$toInt, end$toInt, increment)$toType
private var hasNext = if (increment > 0) start <= end else start >= end
private val finalElement: $t = ProgressionUtil.getProgressionFinalElement(start$toInt, end$toInt, increment)$toType
private var hasNext: Boolean = if (increment > 0) start <= end else start >= end
override fun hasNext() = hasNext
override fun hasNext(): Boolean = hasNext
override fun next$t(): $t {
val value = next
@@ -56,7 +56,7 @@ fun floatingPointProgressionIterator(kind: ProgressionKind): String {
return """class ${t}ProgressionIterator(start: $t, val end: $t, val increment: $t) : ${t}Iterator() {
private var next = start
override fun hasNext() = if (increment > 0) next <= end else next >= end
override fun hasNext(): Boolean = if (increment > 0) next <= end else next >= end
override fun next$t(): $t {
val value = next
@@ -45,11 +45,11 @@ class GenerateProgressions(val out: PrintWriter) {
val constructor = checkNaN + checkZero
val hashCode = when (kind) {
BYTE, CHAR, SHORT -> " = 31 * (31 * start.toInt() + end) + increment"
INT -> " = 31 * (31 * start + end) + increment"
LONG -> " = (31 * (31 * ${hashLong("start")} + ${hashLong("end")}) + ${hashLong("increment")}).toInt()"
FLOAT -> " = 31 * (31 * ${floatToIntBits("start")} + ${floatToIntBits("end")}) + ${floatToIntBits("increment")}"
DOUBLE -> ": Int {\n" +
BYTE, CHAR, SHORT -> "= 31 * (31 * start.toInt() + end) + increment"
INT -> "= 31 * (31 * start + end) + increment"
LONG -> "= (31 * (31 * ${hashLong("start")} + ${hashLong("end")}) + ${hashLong("increment")}).toInt()"
FLOAT -> "= 31 * (31 * ${floatToIntBits("start")} + ${floatToIntBits("end")}) + ${floatToIntBits("increment")}"
DOUBLE -> "{\n" +
" var temp = ${doubleToLongBits("start")}\n" +
" var result = ${hashLong("temp")}\n" +
" temp = ${doubleToLongBits("end")}\n" +
@@ -74,9 +74,9 @@ class GenerateProgressions(val out: PrintWriter) {
fun equals(other: Any?): Boolean =
other is $progression && ${compare("start")} && ${compare("end")} && ${compare("increment")}
fun hashCode()$hashCode
fun hashCode(): Int $hashCode
fun toString() = ${"if (increment > 0) \"\$start..\$end step \$increment\" else \"\$start downTo \$end step \${-increment}\""}
fun toString(): String = ${"if (increment > 0) \"\$start..\$end step \$increment\" else \"\$start downTo \$end step \${-increment}\""}
}""")
out.println()
}
@@ -45,11 +45,11 @@ class GenerateRanges(val out: PrintWriter) {
fun compare(v: String) = areEqualNumbers(kind, v)
val hashCode = when (kind) {
BYTE, CHAR, SHORT -> " = 31 * start.toInt() + end"
INT -> " = 31 * start + end"
LONG -> " = (31 * ${hashLong("start")} + ${hashLong("end")}).toInt()"
FLOAT -> " = 31 * ${floatToIntBits("start")} + ${floatToIntBits("end")}"
DOUBLE -> ": Int {\n" +
BYTE, CHAR, SHORT -> "= 31 * start.toInt() + end"
INT -> "= 31 * start + end"
LONG -> "= (31 * ${hashLong("start")} + ${hashLong("end")}).toInt()"
FLOAT -> "= 31 * ${floatToIntBits("start")} + ${floatToIntBits("end")}"
DOUBLE -> "{\n" +
" var temp = ${doubleToLongBits("start")}\n" +
" val result = ${hashLong("temp")}\n" +
" temp = ${doubleToLongBits("end")}\n" +
@@ -62,14 +62,14 @@ class GenerateRanges(val out: PrintWriter) {
override val increment: $incrementType
get() = $increment
override fun contains(item: $t) = start <= item && item <= end
override fun contains(item: $t): Boolean = start <= item && item <= end
override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(start, end, $increment)
fun equals(other: Any?): Boolean =
other is $range && ${compare("start")} && ${compare("end")}
fun hashCode()$hashCode
fun hashCode(): Int $hashCode
class object {
public val EMPTY: $range = $range($emptyBounds)