Rewrite ProgressionUtil to Kotlin, move to "kotlin.internal"

Use reflection in ProgressionUtilTest instead of calling methods on the class
from the class path, because in the latter case we were just testing
ProgressionUtil from bootstrap runtime (which, presumably, always works
correctly since it's a bootstrap distribution)

With this change, compilable built-ins (under core/builtins/src) are fully
written in Kotlin
This commit is contained in:
Alexander Udalov
2014-02-14 20:32:38 +04:00
parent 4afdac3efa
commit 0490d4c989
7 changed files with 124 additions and 106 deletions
@@ -33,7 +33,7 @@ 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: $t = ProgressionUtil.getProgressionFinalElement(start$toInt, end$toInt, increment)$toType
private val finalElement: $t = getProgressionFinalElement(start$toInt, end$toInt, increment)$toType
private var hasNext: Boolean = if (increment > 0) start <= end else start >= end
override fun hasNext(): Boolean = hasNext
@@ -69,7 +69,7 @@ fun floatingPointProgressionIterator(kind: ProgressionKind): String {
class GenerateProgressionIterators(out: PrintWriter) : BuiltInsSourceGenerator(out) {
override fun generateBody() {
out.println("import jet.runtime.ProgressionUtil")
out.println("import kotlin.internal.getProgressionFinalElement")
out.println()
for (kind in ProgressionKind.values()) {
if (kind != FLOAT && kind != DOUBLE) {