Introduce special IrDeclarationOrigin's for for-loop variables

FOR_LOOP_ITERATOR
 - temporary variable for for-loop iterator

FOR_LOOP_VARIABLE
 - `x` in `for (x in xs)`

FOR_LOOP_IMPLICIT_VARIABLE
 - temporary variable for for-loop with destructuring, e.g.:
   for ((x, y) in xys)
   =>
   for (tmp in xys) {
     val (x, y) = tmp
   }
This commit is contained in:
Dmitry Petrov
2017-07-12 17:34:39 +03:00
parent 1cab0d09ab
commit a687dea898
9 changed files with 41 additions and 33 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ CONTENT
5 GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null
6 CALL 'rangeTo(Int): IntRange' type=kotlin.ranges.IntRange origin=RANGE
7 CALL 'iterator(): IntIterator' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR
8 VAR IR_TEMPORARY_VARIABLE val tmp0_iterator: kotlin.collections.IntIterator
8 VAR FOR_LOOP_ITERATOR val tmp0_iterator: kotlin.collections.IntIterator
9 WHILE label=null origin=FOR_LOOP_INNER_WHILE
OUTGOING -> BB 1
While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE
@@ -26,7 +26,7 @@ INCOMING <- BB 1
CONTENT
1 GET_VAR 'tmp0_iterator: IntIterator' type=kotlin.collections.IntIterator origin=null
2 CALL 'next(): Int' type=kotlin.Int origin=FOR_LOOP_NEXT
3 VAR val j: kotlin.Int
3 VAR FOR_LOOP_VARIABLE val j: kotlin.Int
4 SET_VAR 'result: Int' type=kotlin.Unit origin=MULTEQ
OUTGOING -> BB 1
While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE
+2 -2
View File
@@ -11,7 +11,7 @@ CONTENT
7 CALL 'div(Int): Int' type=kotlin.Int origin=DIV
8 CALL 'rangeTo(Int): IntRange' type=kotlin.ranges.IntRange origin=RANGE
9 CALL 'iterator(): IntIterator' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR
10 VAR IR_TEMPORARY_VARIABLE val tmp0_iterator: kotlin.collections.IntIterator
10 VAR FOR_LOOP_ITERATOR val tmp0_iterator: kotlin.collections.IntIterator
11 WHILE label=null origin=FOR_LOOP_INNER_WHILE
OUTGOING -> BB 1
While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE
@@ -28,7 +28,7 @@ INCOMING <- BB 1
CONTENT
1 GET_VAR 'tmp0_iterator: IntIterator' type=kotlin.collections.IntIterator origin=null
2 CALL 'next(): Int' type=kotlin.Int origin=FOR_LOOP_NEXT
3 VAR val m: kotlin.Int
3 VAR FOR_LOOP_VARIABLE val m: kotlin.Int
4 WHEN type=kotlin.Unit origin=null
5 GET_VAR 'value-parameter n: Int' type=kotlin.Int origin=null
6 GET_VAR 'm: Int' type=kotlin.Int origin=null