FIR2IR: add two-statements block with iterator + while for 'for' loops

Before this commit we had two statements blocks for 'for' loops:
range variable declaration + iterator variable declaration + while loop.
However, BE requires a bit different loop structure to make lowerings
properly so in this commit iterator declaration & while loop were
extracted to separate block.
This commit is contained in:
Mikhail Glukhikh
2020-02-17 17:20:44 +03:00
parent 2bfce4f127
commit 56c819f06e
16 changed files with 336 additions and 300 deletions
@@ -105,15 +105,16 @@ FILE fqName:<root> fileName:/forWithImplicitReceivers.kt
FUN name:test visibility:public modality:FINAL <> ($receiver:<root>.IReceiver) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:<root>.IReceiver
BLOCK_BODY
VAR FOR_LOOP_ITERATOR name:tmp_1 type:<root>.IntCell [val]
CALL 'public open fun iterator (): <root>.IntCell [operator] declared in <root>.IReceiver' type=<root>.IntCell origin=null
$this: GET_VAR '<this>: <root>.IReceiver declared in <root>.test' type=<root>.IReceiver origin=null
WHILE label=null origin=FOR_LOOP_INNER_WHILE
condition: CALL 'public open fun hasNext (): kotlin.Boolean [operator] declared in <root>.IReceiver' type=kotlin.Boolean origin=null
$this: GET_VAR '<this>: <root>.IReceiver declared in <root>.test' type=<root>.IReceiver origin=null
body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
VAR name:i type:kotlin.Int [val]
CALL 'public open fun next (): kotlin.Int [operator] declared in <root>.IReceiver' type=kotlin.Int origin=null
$this: GET_VAR '<this>: <root>.IReceiver declared in <root>.test' type=<root>.IReceiver origin=null
CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null
message: GET_VAR 'val i: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
BLOCK type=kotlin.Unit origin=FOR_LOOP
VAR FOR_LOOP_ITERATOR name:tmp_1 type:<root>.IntCell [val]
CALL 'public open fun iterator (): <root>.IntCell [operator] declared in <root>.IReceiver' type=<root>.IntCell origin=null
$this: GET_VAR '<this>: <root>.IReceiver declared in <root>.test' type=<root>.IReceiver origin=null
WHILE label=null origin=FOR_LOOP_INNER_WHILE
condition: CALL 'public open fun hasNext (): kotlin.Boolean [operator] declared in <root>.IReceiver' type=kotlin.Boolean origin=null
$this: GET_VAR '<this>: <root>.IReceiver declared in <root>.test' type=<root>.IReceiver origin=null
body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
VAR name:i type:kotlin.Int [val]
CALL 'public open fun next (): kotlin.Int [operator] declared in <root>.IReceiver' type=kotlin.Int origin=null
$this: GET_VAR '<this>: <root>.IReceiver declared in <root>.test' type=<root>.IReceiver origin=null
CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null
message: GET_VAR 'val i: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null