Properties without accessors are generated as

IrGetBackingField / IrSetBackingField expressions.
This commit is contained in:
Dmitry Petrov
2016-09-05 15:06:38 +03:00
committed by Dmitry Petrov
parent a1ad828ea8
commit ceeccfa1b7
40 changed files with 359 additions and 122 deletions
@@ -16,7 +16,8 @@ FILE /arrayAugmentedAssignment1.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Any
SET_BACKING_FIELD x type=kotlin.Unit operator=null
GET_VAR x type=kotlin.IntArray operator=INITIALIZE_PROPERTY_FROM_PARAMETER
receiver: THIS public final class C type=C
value: GET_VAR x type=kotlin.IntArray operator=INITIALIZE_PROPERTY_FROM_PARAMETER
INSTANCE_INITIALIZER_CALL classDescriptor=C
PROPERTY public final val x: kotlin.IntArray
EXPRESSION_BODY
+2 -1
View File
@@ -4,7 +4,8 @@ FILE /assignments.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Any
SET_BACKING_FIELD x type=kotlin.Unit operator=null
GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
receiver: THIS public final class Ref type=Ref
value: GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
INSTANCE_INITIALIZER_CALL classDescriptor=Ref
PROPERTY public final var x: kotlin.Int
EXPRESSION_BODY
@@ -93,7 +93,8 @@ FILE /complexAugmentedAssignment.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Any
SET_BACKING_FIELD s type=kotlin.Unit operator=null
GET_VAR s type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
receiver: THIS public final class B type=B
value: GET_VAR s type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
INSTANCE_INITIALIZER_CALL classDescriptor=B
PROPERTY public final var s: kotlin.Int
EXPRESSION_BODY
+1 -1
View File
@@ -5,6 +5,6 @@ object B {
operator fun A.component2() = 2
}
fun B.test() { // <<< destructuring1.txt
fun B.test() {
val (x, y) = A
}
+32 -13
View File
@@ -1,13 +1,32 @@
FUN public fun B.test(): kotlin.Unit
BLOCK_BODY
BLOCK type=kotlin.Unit operator=DESTRUCTURING_DECLARATION
VAR val tmp0_container: A
GET_OBJECT A type=A
VAR val x: kotlin.Int
CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1)
$this: $RECEIVER of: test type=B
$receiver: GET_VAR tmp0_container type=A operator=null
VAR val y: kotlin.Int
CALL .component2 type=kotlin.Int operator=COMPONENT_N(index=2)
$this: $RECEIVER of: test type=B
$receiver: GET_VAR tmp0_container type=A operator=null
FILE /destructuring1.kt
CLASS OBJECT A
CONSTRUCTOR private constructor A()
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Any
INSTANCE_INITIALIZER_CALL classDescriptor=A
CLASS OBJECT B
CONSTRUCTOR private constructor B()
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Any
INSTANCE_INITIALIZER_CALL classDescriptor=B
FUN public final operator fun A.component1(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from=component1
CONST Int type=kotlin.Int value='1'
FUN public final operator fun A.component2(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from=component2
CONST Int type=kotlin.Int value='2'
FUN public fun B.test(): kotlin.Unit
BLOCK_BODY
BLOCK type=kotlin.Unit operator=DESTRUCTURING_DECLARATION
VAR val tmp0_container: A
GET_OBJECT A type=A
VAR val x: kotlin.Int
CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1)
$this: $RECEIVER of: test type=B
$receiver: GET_VAR tmp0_container type=A operator=null
VAR val y: kotlin.Int
CALL .component2 type=kotlin.Int operator=COMPONENT_N(index=2)
$this: $RECEIVER of: test type=B
$receiver: GET_VAR tmp0_container type=A operator=null
+2 -2
View File
@@ -5,13 +5,13 @@ FILE /field.kt
PROPERTY_SETTER public fun <set-testSimple>(/*0*/ value: kotlin.Int): kotlin.Unit
BLOCK_BODY
SET_BACKING_FIELD testSimple type=kotlin.Unit operator=EQ
GET_VAR value type=kotlin.Int operator=null
value: GET_VAR value type=kotlin.Int operator=null
PROPERTY public var testAugmented: kotlin.Int
EXPRESSION_BODY
CONST Int type=kotlin.Int value='0'
PROPERTY_SETTER public fun <set-testAugmented>(/*0*/ value: kotlin.Int): kotlin.Unit
BLOCK_BODY
SET_BACKING_FIELD testAugmented type=kotlin.Unit operator=PLUSEQ
CALL .plus type=kotlin.Int operator=PLUSEQ
value: CALL .plus type=kotlin.Int operator=PLUSEQ
$this: GET_BACKING_FIELD testAugmented type=kotlin.Int operator=PLUSEQ
other: GET_VAR value type=kotlin.Int operator=null
@@ -9,7 +9,8 @@ FILE /forWithImplicitReceivers.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Any
SET_BACKING_FIELD value type=kotlin.Unit operator=null
GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
receiver: THIS public final class IntCell type=IntCell
value: GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
INSTANCE_INITIALIZER_CALL classDescriptor=IntCell
PROPERTY public final var value: kotlin.Int
EXPRESSION_BODY
@@ -0,0 +1,19 @@
// FILE: Derived.kt
// IR_FILE: jvmInstanceFieldReference.txt
class Derived: Base() {
init {
value = 0
}
fun getValue() = value
fun setValue(value: Int) {
this.value = value
}
}
// FILE: Base.java
public class Base {
public int value;
}
@@ -0,0 +1,21 @@
FILE /Derived.kt
CLASS CLASS Derived
CONSTRUCTOR public constructor Derived()
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Base
INSTANCE_INITIALIZER_CALL classDescriptor=Derived
ANONYMOUS_INITIALIZER Derived
BLOCK_BODY
SET_BACKING_FIELD value type=kotlin.Unit operator=EQ
receiver: THIS public final class Derived : Base type=Derived
value: CONST Int type=kotlin.Int value='0'
FUN public final fun getValue(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from=getValue
GET_BACKING_FIELD value type=kotlin.Int operator=GET_PROPERTY
receiver: THIS public final class Derived : Base type=Derived
FUN public final fun setValue(/*0*/ value: kotlin.Int): kotlin.Unit
BLOCK_BODY
SET_BACKING_FIELD value type=kotlin.Unit operator=EQ
receiver: THIS public final class Derived : Base type=Derived
value: GET_VAR value type=kotlin.Int operator=null
@@ -3,14 +3,14 @@ FILE /jvmStaticFieldReference.kt
BLOCK_BODY
CALL .println type=kotlin.Unit operator=null
$this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
CALL .<get-out> type=java.io.PrintStream! operator=GET_PROPERTY
GET_BACKING_FIELD out type=java.io.PrintStream! operator=GET_PROPERTY
p0: CONST String type=kotlin.String value='testFun'
PROPERTY public var testProp: kotlin.Any
PROPERTY_GETTER public fun <get-testProp>(): kotlin.Any
BLOCK_BODY
CALL .println type=kotlin.Unit operator=null
$this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
CALL .<get-out> type=java.io.PrintStream! operator=GET_PROPERTY
GET_BACKING_FIELD out type=java.io.PrintStream! operator=GET_PROPERTY
p0: CONST String type=kotlin.String value='testProp/get'
RETURN type=kotlin.Nothing from=<get-testProp>
CONST Int type=kotlin.Int value='42'
@@ -18,7 +18,7 @@ FILE /jvmStaticFieldReference.kt
BLOCK_BODY
CALL .println type=kotlin.Unit operator=null
$this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
CALL .<get-out> type=java.io.PrintStream! operator=GET_PROPERTY
GET_BACKING_FIELD out type=java.io.PrintStream! operator=GET_PROPERTY
p0: CONST String type=kotlin.String value='testProp/set'
CLASS CLASS TestClass
CONSTRUCTOR public constructor TestClass()
@@ -31,12 +31,12 @@ FILE /jvmStaticFieldReference.kt
else: BLOCK type=kotlin.Int operator=null
CALL .println type=kotlin.Unit operator=null
$this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
CALL .<get-out> type=java.io.PrintStream! operator=GET_PROPERTY
GET_BACKING_FIELD out type=java.io.PrintStream! operator=GET_PROPERTY
p0: CONST String type=kotlin.String value='TestClass/test'
CONST Int type=kotlin.Int value='42'
ANONYMOUS_INITIALIZER TestClass
BLOCK_BODY
CALL .println type=kotlin.Unit operator=null
$this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
CALL .<get-out> type=java.io.PrintStream! operator=GET_PROPERTY
GET_BACKING_FIELD out type=java.io.PrintStream! operator=GET_PROPERTY
p0: CONST String type=kotlin.String value='TestClass/init'
+2 -1
View File
@@ -4,7 +4,8 @@ FILE /safeCalls.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Any
SET_BACKING_FIELD value type=kotlin.Unit operator=null
GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
receiver: THIS public final class Ref type=Ref
value: GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER
INSTANCE_INITIALIZER_CALL classDescriptor=Ref
PROPERTY public final var value: kotlin.Int
EXPRESSION_BODY
@@ -0,0 +1,14 @@
// FILE: Derived.kt
// IR_FILE: setFieldWithImplicitCast.txt
class Derived : Base() {
fun setValue(v: Any) {
if (v is String) {
value = v
}
}
}
// FILE: Base.java
public class Base {
public String value;
}
@@ -0,0 +1,16 @@
FILE /Derived.kt
CLASS CLASS Derived
CONSTRUCTOR public constructor Derived()
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL Base
INSTANCE_INITIALIZER_CALL classDescriptor=Derived
FUN public final fun setValue(/*0*/ v: kotlin.Any): kotlin.Unit
BLOCK_BODY
WHEN type=kotlin.Unit operator=IF
if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.String
GET_VAR v type=kotlin.Any operator=null
then: BLOCK type=kotlin.Unit operator=null
SET_BACKING_FIELD value type=kotlin.Unit operator=EQ
receiver: THIS public final class Derived : Base type=Derived
value: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String!
GET_VAR v type=kotlin.Any operator=null