[FIR2IR] Recognize postfix inc/dec blocks in sequence of statements

This commit is contained in:
Ivan Kochurkin
2021-10-25 14:19:13 +03:00
committed by TeamCityServer
parent c13822a2c5
commit 489c9ae11f
5 changed files with 89 additions and 45 deletions
@@ -5,11 +5,12 @@ FILE fqName:<root> fileName:/localFunction.kt
CONST Int type=kotlin.Int value=0
FUN LOCAL_FUNCTION name:local visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val]
GET_VAR 'var x: kotlin.Int [var] declared in <root>.outer' type=kotlin.Int origin=null
SET_VAR 'var x: kotlin.Int [var] declared in <root>.outer' type=kotlin.Unit origin=POSTFIX_INCR
CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.outer.local' type=kotlin.Int origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.outer.local' type=kotlin.Int origin=null
BLOCK type=kotlin.Int origin=POSTFIX_INCR
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val]
GET_VAR 'var x: kotlin.Int [var] declared in <root>.outer' type=kotlin.Int origin=null
SET_VAR 'var x: kotlin.Int [var] declared in <root>.outer' type=kotlin.Unit origin=POSTFIX_INCR
CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.outer.local' type=kotlin.Int origin=null
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.outer.local' type=kotlin.Int origin=null
CALL 'local final fun local (): kotlin.Unit declared in <root>.outer' type=kotlin.Unit origin=null
@@ -1,10 +1,13 @@
fun outer() {
var x: Int = 0
local fun local() {
val <unary>: Int = x
x = <unary>.inc()
<unary> /*~> Unit */
{ // BLOCK
val <unary>: Int = x
x = <unary>.inc()
<unary>
} /*~> Unit */
}
local()
}