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
@@ -90,7 +90,7 @@ FILE /forWithImplicitReceivers.kt
$receiver: VALUE_PARAMETER this@test: IReceiver
BLOCK_BODY
BLOCK type=kotlin.Unit origin=FOR_LOOP
VAR IR_TEMPORARY_VARIABLE val tmp0_iterator: IntCell
VAR FOR_LOOP_ITERATOR val tmp0_iterator: IntCell
CALL 'iterator() on FiveTimes: IntCell' type=IntCell origin=FOR_LOOP_ITERATOR
$this: GET_VAR 'this@test: IReceiver' type=IReceiver origin=null
$receiver: GET_OBJECT 'FiveTimes' type=FiveTimes
@@ -99,7 +99,7 @@ FILE /forWithImplicitReceivers.kt
$this: GET_VAR 'this@test: IReceiver' type=IReceiver origin=null
$receiver: GET_VAR 'tmp0_iterator: IntCell' type=IntCell origin=null
body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
VAR val i: kotlin.Int
VAR FOR_LOOP_VARIABLE val i: kotlin.Int
CALL 'next() on IntCell: Int' type=kotlin.Int origin=FOR_LOOP_NEXT
$this: GET_VAR 'this@test: IReceiver' type=IReceiver origin=null
$receiver: GET_VAR 'tmp0_iterator: IntCell' type=IntCell origin=null