[FIR] Capture array and indices for postfix/prefix increment/decrement
of array element (including overloaded indexed access operators, e.g., `a[b, c]++`). This prevents double-evaluation of the array and indices expressions, which may have side-effects.
This commit is contained in:
committed by
teamcityserver
parent
eb631bc429
commit
a2a4d94834
+16
-24
@@ -96,38 +96,30 @@ FILE fqName:test fileName:/safeCallWithIncrementDecrement.kt
|
||||
FUN name:testArrayAccess visibility:public modality:FINAL <> (nc:test.C?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:nc index:0 type:test.C?
|
||||
BLOCK_BODY
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val]
|
||||
CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in test' type=kotlin.Int origin=null
|
||||
$receiver: BLOCK type=kotlin.Int? origin=SAFE_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:test.C? [val]
|
||||
GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null
|
||||
WHEN type=kotlin.Int? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_5: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun <get-p> (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY
|
||||
$receiver: GET_VAR 'val tmp_5: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null
|
||||
index: CONST Int type=kotlin.Int value=0
|
||||
CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit [operator] declared in test' type=kotlin.Unit origin=null
|
||||
$receiver: BLOCK type=kotlin.Int? origin=SAFE_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:test.C? [val]
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int? [val]
|
||||
BLOCK type=kotlin.Int? origin=SAFE_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:test.C? [val]
|
||||
GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null
|
||||
WHEN type=kotlin.Int? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_6: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null
|
||||
arg0: GET_VAR 'val tmp_5: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun <get-p> (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY
|
||||
$receiver: GET_VAR 'val tmp_6: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null
|
||||
index: CONST Int type=kotlin.Int value=0
|
||||
$receiver: GET_VAR 'val tmp_5: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Int [val]
|
||||
CONST Int type=kotlin.Int value=0
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val]
|
||||
CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in test' type=kotlin.Int origin=null
|
||||
$receiver: GET_VAR 'val tmp_4: kotlin.Int? [val] declared in test.testArrayAccess' type=kotlin.Int? origin=null
|
||||
index: GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null
|
||||
CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit [operator] declared in test' type=kotlin.Unit origin=null
|
||||
$receiver: GET_VAR 'val tmp_4: kotlin.Int? [val] declared in test.testArrayAccess' type=kotlin.Int? origin=null
|
||||
index: GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null
|
||||
value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'val tmp_4: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'val tmp_7: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
GET_VAR 'val tmp_4: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null
|
||||
GET_VAR 'val tmp_7: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null
|
||||
|
||||
Reference in New Issue
Block a user