'while' and 'do-while' loop generator fixes.
Generate 'do-while' loop body as IrComposite, because variables declared in loop body should be visible in loop condition. Wrap 'do-while' loop in IrBlock so that variables declared in loop body are not visible outside of the loop. Generate 'while' and 'do-while' loops as expressions of type Unit.
This commit is contained in:
+38
-34
@@ -26,8 +26,8 @@ FILE /whileDoWhile.kt
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value='10'
|
||||
body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Int origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||
VAR IR_TEMPORARY_VARIABLE val tmp1: kotlin.Int
|
||||
GET_VAR 'x: Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
@@ -35,38 +35,41 @@ FILE /whileDoWhile.kt
|
||||
CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
$this: GET_VAR 'tmp1: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp1: Int' type=kotlin.Int origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value='0'
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||
VAR IR_TEMPORARY_VARIABLE val tmp2: kotlin.Int
|
||||
GET_VAR 'x: Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
SET_VAR 'x: Int' type=kotlin.Unit origin=POSTFIX_INCR
|
||||
CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
$this: GET_VAR 'tmp2: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp2: Int' type=kotlin.Int origin=null
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value='15'
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value='0'
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||
VAR IR_TEMPORARY_VARIABLE val tmp3: kotlin.Int
|
||||
VAR IR_TEMPORARY_VARIABLE val tmp2: kotlin.Int
|
||||
GET_VAR 'x: Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
SET_VAR 'x: Int' type=kotlin.Unit origin=POSTFIX_INCR
|
||||
CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
$this: GET_VAR 'tmp3: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp3: Int' type=kotlin.Int origin=null
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value='20'
|
||||
$this: GET_VAR 'tmp2: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp2: Int' type=kotlin.Int origin=null
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value='15'
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: COMPOSITE type=kotlin.Unit origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||
VAR IR_TEMPORARY_VARIABLE val tmp3: kotlin.Int
|
||||
GET_VAR 'x: Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
SET_VAR 'x: Int' type=kotlin.Unit origin=POSTFIX_INCR
|
||||
CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
$this: GET_VAR 'tmp3: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp3: Int' type=kotlin.Int origin=null
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value='20'
|
||||
FUN public fun testSmartcastInCondition(): kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR val a: kotlin.Any? = null
|
||||
@@ -80,7 +83,8 @@ FILE /whileDoWhile.kt
|
||||
condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean
|
||||
GET_VAR 'a: Any?' type=kotlin.Any? origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean
|
||||
GET_VAR 'a: Any?' type=kotlin.Any? origin=null
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: COMPOSITE type=kotlin.Unit origin=null
|
||||
condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean
|
||||
GET_VAR 'a: Any?' type=kotlin.Any? origin=null
|
||||
|
||||
Reference in New Issue
Block a user