This commit is contained in:
Dmitry Petrov
2016-08-24 17:11:01 +03:00
committed by Dmitry Petrov
parent 03a666690b
commit 4709aaafaa
12 changed files with 375 additions and 32 deletions
+13
View File
@@ -0,0 +1,13 @@
fun testIterable(ss: List<String>) {
for (s in ss) {
println(s)
}
}
fun testDestructuring(pp: List<Pair<Int, String>>) {
for ((i, s) in pp) {
println(i)
println(s)
}
}
+43
View File
@@ -0,0 +1,43 @@
IrFile /for.kt
IrFunction public fun testIterable(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val s: kotlin.String
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
CALL .println type=kotlin.Unit operator=null
message: GET_VAR s type=kotlin.String operator=null
IrFunction public fun testDestructuring(/*0*/ pp: kotlin.collections.List<kotlin.Pair<kotlin.Int, kotlin.String>>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>>
CALL .iterator type=kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> operator=FOR_LOOP_ITERATOR
$this: GET_VAR pp type=kotlin.collections.List<kotlin.Pair<kotlin.Int, kotlin.String>> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val tmp1_loop_parameter: kotlin.Pair<kotlin.Int, kotlin.String>
CALL .next type=kotlin.Pair<kotlin.Int, kotlin.String> operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> operator=null
VAR val i: kotlin.Int
CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1)
$this: GET_VAR tmp1_loop_parameter type=kotlin.Pair<kotlin.Int, kotlin.String> operator=null
VAR val s: kotlin.String
CALL .component2 type=kotlin.String operator=COMPONENT_N(index=2)
$this: GET_VAR tmp1_loop_parameter type=kotlin.Pair<kotlin.Int, kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
CALL .println type=kotlin.Unit operator=null
message: GET_VAR i type=kotlin.Int operator=null
CALL .println type=kotlin.Unit operator=null
message: GET_VAR s type=kotlin.String operator=null
+33
View File
@@ -0,0 +1,33 @@
fun testForBreak1(ss: List<String>) {
for (s in ss) {
break
}
}
fun testForBreak2(ss: List<String>) {
OUTER@for (s1 in ss) {
INNER@for (s2 in ss) {
break@OUTER
break@INNER
break
}
break@OUTER
}
}
fun testForContinue1(ss: List<String>) {
for (s in ss) {
continue
}
}
fun testForContinue2(ss: List<String>) {
OUTER@for (s1 in ss) {
INNER@for (s2 in ss) {
continue@OUTER
continue@INNER
continue
}
continue@OUTER
}
}
+95
View File
@@ -0,0 +1,95 @@
IrFile /forWithBreakContinue.kt
IrFunction public fun testForBreak1(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val s: kotlin.String
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
IrFunction public fun testForBreak2(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val s1: kotlin.String
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp1_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val s2: kotlin.String
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=1
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
IrFunction public fun testForContinue1(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val s: kotlin.String
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
IrFunction public fun testForContinue2(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val s1: kotlin.String
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp1_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val s2: kotlin.String
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=1
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
+15
View File
@@ -0,0 +1,15 @@
object FiveTimes
class IntCell(var value: Int)
interface IReceiver {
operator fun FiveTimes.iterator() = IntCell(5)
operator fun IntCell.hasNext() = value > 0
operator fun IntCell.next() = value--
}
fun IReceiver.test() {
for (i in FiveTimes) {
println(i)
}
}
@@ -0,0 +1,24 @@
IrFile /forWithImplicitReceivers.kt
DUMMY FiveTimes
DUMMY IntCell
DUMMY IReceiver
IrFunction public fun IReceiver.test(): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP
VAR val tmp0_iterator: IntCell
CALL .iterator type=IntCell operator=FOR_LOOP_ITERATOR
$this: $RECEIVER of: test type=IReceiver
$receiver: GET_OBJECT FiveTimes type=FiveTimes
WHILE operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: $RECEIVER of: test type=IReceiver
$receiver: GET_VAR tmp0_iterator type=IntCell operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
VAR val i: kotlin.Int
CALL .next type=kotlin.Int operator=FOR_LOOP_NEXT
$this: $RECEIVER of: test type=IReceiver
$receiver: GET_VAR tmp0_iterator type=IntCell operator=null
BLOCK type=<no-type> hasResult=false operator=null
CALL .println type=kotlin.Unit operator=null
message: GET_VAR i type=kotlin.Int operator=null