a3e7a35cb1
Refactor FIR builders code for ForExpression
27 lines
1.0 KiB
Plaintext
Vendored
27 lines
1.0 KiB
Plaintext
Vendored
FILE: fib.kt
|
|
public final fun fibIterative(n: R|kotlin/Int|): R|kotlin/Int| {
|
|
when () {
|
|
CMP(<, R|<local>/n|.R|kotlin/Int.compareTo|(Int(2))) -> {
|
|
^fibIterative Int(1)
|
|
}
|
|
}
|
|
|
|
lvar current: R|kotlin/Int| = Int(1)
|
|
lvar prev: R|kotlin/Int| = Int(1)
|
|
{
|
|
lval <iterator>: R|kotlin/collections/IntIterator| = Int(2).R|kotlin/Int.rangeTo|(R|<local>/n|).R|kotlin/ranges/IntProgression.iterator|()
|
|
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/IntIterator.hasNext: R|kotlin/Boolean|>|()) {
|
|
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
|
{
|
|
lval temp: R|kotlin/Int| = R|<local>/current|
|
|
R|<local>/current| = R|<local>/current|.R|kotlin/Int.plus|(R|<local>/prev|)
|
|
R|<local>/prev| = R|<local>/temp|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
^fibIterative R|<local>/current|
|
|
}
|