IR: augmented assignment for array access expressions
This commit is contained in:
committed by
Dmitry Petrov
parent
0a57eb8ea4
commit
d7412c449e
@@ -0,0 +1,5 @@
|
||||
// <<< arrayAssignment.txt
|
||||
fun test() {
|
||||
val x = intArrayOf(1, 2, 3)
|
||||
x[1] = 0
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
IrFile /arrayAssignment.kt
|
||||
IrFunction public fun test(): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
VAR val x: kotlin.IntArray
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=
|
||||
elements: DUMMY vararg type=kotlin.Int
|
||||
VAR val tmp0: kotlin.IntArray
|
||||
GET_VAR x type=kotlin.IntArray
|
||||
VAR val tmp1: kotlin.Int
|
||||
LITERAL Int type=kotlin.Int value='1'
|
||||
CALL .set type=kotlin.Unit operator=EQ
|
||||
$this: GET_VAR tmp0 type=kotlin.IntArray
|
||||
index: GET_VAR tmp1 type=kotlin.Int
|
||||
value: LITERAL Int type=kotlin.Int value='0'
|
||||
+17
-4
@@ -1,6 +1,19 @@
|
||||
// <<< augmentedAssignment1.txt
|
||||
fun test(): Int {
|
||||
var p = 0
|
||||
|
||||
fun testVariable() {
|
||||
var x = 0
|
||||
x += 10
|
||||
return x
|
||||
}
|
||||
x += 1
|
||||
x -= 2
|
||||
x *= 3
|
||||
x /= 4
|
||||
x %= 5
|
||||
}
|
||||
|
||||
fun testProperty() {
|
||||
p += 1
|
||||
p -= 2
|
||||
p *= 3
|
||||
p /= 4
|
||||
p %= 5
|
||||
}
|
||||
|
||||
+45
-5
@@ -1,12 +1,52 @@
|
||||
IrFile /augmentedAssignment1.kt
|
||||
IrFunction public fun test(): kotlin.Int
|
||||
IrProperty public var p: kotlin.Int getter=null setter=null
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
LITERAL Int type=kotlin.Int value='0'
|
||||
IrFunction public fun testVariable(): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=kotlin.Int hasResult=true isDesugared=false
|
||||
VAR var x: kotlin.Int
|
||||
LITERAL Int type=kotlin.Int value='0'
|
||||
SET_VAR x type=<no-type>
|
||||
CALL .plus type=kotlin.Int operator=PLUSEQ
|
||||
$this: GET_VAR x type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='10'
|
||||
RETURN type=<no-type>
|
||||
GET_VAR x type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='1'
|
||||
SET_VAR x type=<no-type>
|
||||
CALL .minus type=kotlin.Int operator=MINUSEQ
|
||||
$this: GET_VAR x type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='2'
|
||||
SET_VAR x type=<no-type>
|
||||
CALL .times type=kotlin.Int operator=MULTEQ
|
||||
$this: GET_VAR x type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='3'
|
||||
SET_VAR x type=<no-type>
|
||||
CALL .div type=kotlin.Int operator=DIVEQ
|
||||
$this: GET_VAR x type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='4'
|
||||
SET_VAR x type=<no-type>
|
||||
CALL .mod type=kotlin.Int operator=PERCEQ
|
||||
$this: GET_VAR x type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='5'
|
||||
IrFunction public fun testProperty(): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=kotlin.Int hasResult=true isDesugared=false
|
||||
SET_PROPERTY .ptype=<no-type>
|
||||
$value: CALL .plus type=kotlin.Int operator=PLUSEQ
|
||||
$this: GET_PROPERTY .p type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='1'
|
||||
SET_PROPERTY .ptype=<no-type>
|
||||
$value: CALL .minus type=kotlin.Int operator=MINUSEQ
|
||||
$this: GET_PROPERTY .p type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='2'
|
||||
SET_PROPERTY .ptype=<no-type>
|
||||
$value: CALL .times type=kotlin.Int operator=MULTEQ
|
||||
$this: GET_PROPERTY .p type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='3'
|
||||
SET_PROPERTY .ptype=<no-type>
|
||||
$value: CALL .div type=kotlin.Int operator=DIVEQ
|
||||
$this: GET_PROPERTY .p type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='4'
|
||||
SET_PROPERTY .ptype=<no-type>
|
||||
$value: CALL .mod type=kotlin.Int operator=PERCEQ
|
||||
$this: GET_PROPERTY .p type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='5'
|
||||
|
||||
+22
-2
@@ -1,8 +1,28 @@
|
||||
// <<< augmentedAssignment2.txt
|
||||
|
||||
class A
|
||||
|
||||
operator fun A.plusAssign(s: String) {}
|
||||
operator fun A.minusAssign(s: String) {}
|
||||
operator fun A.timesAssign(s: String) {}
|
||||
operator fun A.divAssign(s: String) {}
|
||||
operator fun A.modAssign(s: String) {}
|
||||
|
||||
fun test() { // <<< augmentedAssignment2.txt
|
||||
val p = A()
|
||||
|
||||
fun testVariable() {
|
||||
val a = A()
|
||||
a += ""
|
||||
a += "+="
|
||||
a -= "-="
|
||||
a *= "*="
|
||||
a /= "/="
|
||||
a %= "*="
|
||||
}
|
||||
|
||||
fun testProperty() {
|
||||
p += "+="
|
||||
p -= "-="
|
||||
p *= "*="
|
||||
p /= "/="
|
||||
p %= "*="
|
||||
}
|
||||
|
||||
+58
-8
@@ -1,8 +1,58 @@
|
||||
IrFunction public fun test(): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
VAR val a: A
|
||||
CALL .<init> type=A operator=
|
||||
CALL .plusAssign type=kotlin.Unit operator=PLUSEQ
|
||||
$receiver: GET_VAR a type=A
|
||||
s: ? IrStringConcatenationExpressionImpl type=kotlin.String
|
||||
IrFile /augmentedAssignment2.kt
|
||||
DUMMY A
|
||||
IrFunction public operator fun A.plusAssign(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
IrFunction public operator fun A.minusAssign(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
IrFunction public operator fun A.timesAssign(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
IrFunction public operator fun A.divAssign(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
IrFunction public operator fun A.modAssign(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
IrProperty public val p: A getter=null setter=null
|
||||
IrExpressionBody
|
||||
CALL .<init> type=A operator=
|
||||
IrFunction public fun testVariable(): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
VAR val a: A
|
||||
CALL .<init> type=A operator=
|
||||
CALL .plusAssign type=kotlin.Unit operator=PLUSEQ
|
||||
$receiver: GET_VAR a type=A
|
||||
s: LITERAL String type=kotlin.String value='+='
|
||||
CALL .minusAssign type=kotlin.Unit operator=MINUSEQ
|
||||
$receiver: GET_VAR a type=A
|
||||
s: LITERAL String type=kotlin.String value='-='
|
||||
CALL .timesAssign type=kotlin.Unit operator=MULTEQ
|
||||
$receiver: GET_VAR a type=A
|
||||
s: LITERAL String type=kotlin.String value='*='
|
||||
CALL .divAssign type=kotlin.Unit operator=DIVEQ
|
||||
$receiver: GET_VAR a type=A
|
||||
s: LITERAL String type=kotlin.String value='/='
|
||||
CALL .modAssign type=kotlin.Unit operator=PERCEQ
|
||||
$receiver: GET_VAR a type=A
|
||||
s: LITERAL String type=kotlin.String value='*='
|
||||
IrFunction public fun testProperty(): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
CALL .plusAssign type=kotlin.Unit operator=PLUSEQ
|
||||
$receiver: GET_PROPERTY .p type=A
|
||||
s: LITERAL String type=kotlin.String value='+='
|
||||
CALL .minusAssign type=kotlin.Unit operator=MINUSEQ
|
||||
$receiver: GET_PROPERTY .p type=A
|
||||
s: LITERAL String type=kotlin.String value='-='
|
||||
CALL .timesAssign type=kotlin.Unit operator=MULTEQ
|
||||
$receiver: GET_PROPERTY .p type=A
|
||||
s: LITERAL String type=kotlin.String value='*='
|
||||
CALL .divAssign type=kotlin.Unit operator=DIVEQ
|
||||
$receiver: GET_PROPERTY .p type=A
|
||||
s: LITERAL String type=kotlin.String value='/='
|
||||
CALL .modAssign type=kotlin.Unit operator=PERCEQ
|
||||
$receiver: GET_PROPERTY .p type=A
|
||||
s: LITERAL String type=kotlin.String value='*='
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// <<< augmentedAssignmentArray.txt
|
||||
fun foo(): IntArray = intArrayOf(1, 2, 3)
|
||||
|
||||
fun testVariable() {
|
||||
var x = foo()
|
||||
x[0] += 1
|
||||
foo()[0] *= 2
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
IrFile /augmentedAssignmentArray.kt
|
||||
IrFunction public fun foo(): kotlin.IntArray
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=true
|
||||
RETURN type=<no-type>
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=
|
||||
elements: DUMMY vararg type=kotlin.Int
|
||||
IrFunction public fun testVariable(): kotlin.Unit
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false isDesugared=false
|
||||
VAR var x: kotlin.IntArray
|
||||
CALL .foo type=kotlin.IntArray operator=
|
||||
VAR val tmp0: kotlin.IntArray
|
||||
GET_VAR x type=kotlin.IntArray
|
||||
VAR val tmp1: kotlin.Int
|
||||
LITERAL Int type=kotlin.Int value='0'
|
||||
CALL .set type=kotlin.Unit operator=PLUSEQ
|
||||
$this: GET_VAR tmp0 type=kotlin.IntArray
|
||||
index: GET_VAR tmp1 type=kotlin.Int
|
||||
value: CALL .plus type=kotlin.Int operator=PLUSEQ
|
||||
$this: CALL .get type=kotlin.Int operator=PLUSEQ
|
||||
$this: GET_VAR tmp0 type=kotlin.IntArray
|
||||
index: GET_VAR tmp1 type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='1'
|
||||
VAR val tmp2: kotlin.IntArray
|
||||
CALL .foo type=kotlin.IntArray operator=
|
||||
VAR val tmp3: kotlin.Int
|
||||
LITERAL Int type=kotlin.Int value='0'
|
||||
CALL .set type=kotlin.Unit operator=MULTEQ
|
||||
$this: GET_VAR tmp2 type=kotlin.IntArray
|
||||
index: GET_VAR tmp3 type=kotlin.Int
|
||||
value: CALL .times type=kotlin.Int operator=MULTEQ
|
||||
$this: CALL .get type=kotlin.Int operator=MULTEQ
|
||||
$this: GET_VAR tmp2 type=kotlin.IntArray
|
||||
index: GET_VAR tmp3 type=kotlin.Int
|
||||
other: LITERAL Int type=kotlin.Int value='2'
|
||||
Reference in New Issue
Block a user