Handle withIndex() on Iterables (including progressions) and Sequences
in ForLoopsLowering.
This commit is contained in:
committed by
max-kammerer
parent
a54d9482dd
commit
7adffe0007
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in (7 downTo 4).withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in listOf(4, 5, 6, 7).indices.withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
|
||||
// 2 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
// 0 getIndices
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in (4..7).withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in ((4..11).reversed() step 2).withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
// 0 reversed
|
||||
// 0 step
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in (4..7).reversed().withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
// 0 reversed
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in (4..11 step 2).reversed().withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
// 0 reversed
|
||||
// 0 step
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in (4..11 step 2).withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
// 0 step
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in (4 until 8).withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
fun box(): String {
|
||||
for ((_, _) in (4..7).withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 withIndex
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 0 getStep
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun box(): String {
|
||||
for (iv in (4..7).withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// We do not optimize `withIndex()` if the loop variable is not destructured
|
||||
|
||||
// 1 withIndex
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
fun box(): String {
|
||||
for ((i, v) in (4..7).withIndex().reversed()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// We do not optimize `withIndex().reversed()`
|
||||
|
||||
// 1 withIndex
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
// 1 component1
|
||||
// 1 component2
|
||||
// 1 reversed
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
fun box(): String {
|
||||
for ((outer, iv) in (4..7).withIndex().withIndex()) {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// We optimize the outer `withIndex()` and treat the inner one as an Iterable
|
||||
|
||||
// 1 withIndex
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
|
||||
// The ICONST_0 is for initializing the index in the lowered for-loop.
|
||||
// 1 ICONST_0
|
||||
Reference in New Issue
Block a user