Enum classes lowering.

This commit is contained in:
Dmitry Petrov
2016-09-28 15:11:37 +03:00
parent af76840826
commit fc754e533d
48 changed files with 1053 additions and 222 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ FILE /classes.kt
CLASS ENUM_CLASS TestEnumClass
CONSTRUCTOR private constructor TestEnumClass()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='TestEnumClass'
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun values(): kotlin.Array<TestEnumClass>
SYNTHETIC_BODY kind=ENUM_VALUES
+15 -15
View File
@@ -2,12 +2,12 @@ FILE /enum.kt
CLASS ENUM_CLASS TestEnum1
CONSTRUCTOR private constructor TestEnum1()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='TestEnum1'
ENUM_ENTRY enum entry TEST1
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum1()' TEST1
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum1()'
ENUM_ENTRY enum entry TEST2
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum1()' TEST2
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum1()'
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun values(): kotlin.Array<TestEnum1>
SYNTHETIC_BODY kind=ENUM_VALUES
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun valueOf(value: kotlin.String): TestEnum1
@@ -15,7 +15,7 @@ FILE /enum.kt
CLASS ENUM_CLASS TestEnum2
CONSTRUCTOR private constructor TestEnum2(x: kotlin.Int)
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='TestEnum2'
PROPERTY public final val x: kotlin.Int
FIELD PROPERTY_BACKING_FIELD public final val x: kotlin.Int
@@ -27,13 +27,13 @@ FILE /enum.kt
GET_FIELD 'x: Int' type=kotlin.Int origin=null
receiver: THIS of 'TestEnum2' type=TestEnum2
ENUM_ENTRY enum entry TEST1
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum2(Int)' TEST1
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum2(Int)'
x: CONST Int type=kotlin.Int value='1'
ENUM_ENTRY enum entry TEST2
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum2(Int)' TEST2
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum2(Int)'
x: CONST Int type=kotlin.Int value='2'
ENUM_ENTRY enum entry TEST3
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum2(Int)' TEST3
init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum2(Int)'
x: CONST Int type=kotlin.Int value='3'
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun values(): kotlin.Array<TestEnum2>
SYNTHETIC_BODY kind=ENUM_VALUES
@@ -42,14 +42,14 @@ FILE /enum.kt
CLASS ENUM_CLASS TestEnum3
CONSTRUCTOR private constructor TestEnum3()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='TestEnum3'
ENUM_ENTRY enum entry TEST
init: ENUM_CONSTRUCTOR_CALL 'constructor TEST()' TEST
init: ENUM_CONSTRUCTOR_CALL 'constructor TEST()'
class: CLASS ENUM_ENTRY TEST
CONSTRUCTOR private constructor TEST()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor TestEnum3()' super
ENUM_CONSTRUCTOR_CALL 'constructor TestEnum3()'
INSTANCE_INITIALIZER_CALL classDescriptor='TEST'
FUN public open override fun foo(): kotlin.Unit
BLOCK_BODY
@@ -63,7 +63,7 @@ FILE /enum.kt
CLASS ENUM_CLASS TestEnum4
CONSTRUCTOR private constructor TestEnum4(x: kotlin.Int)
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='TestEnum4'
PROPERTY public final val x: kotlin.Int
FIELD PROPERTY_BACKING_FIELD public final val x: kotlin.Int
@@ -75,11 +75,11 @@ FILE /enum.kt
GET_FIELD 'x: Int' type=kotlin.Int origin=null
receiver: THIS of 'TestEnum4' type=TestEnum4
ENUM_ENTRY enum entry TEST1
init: ENUM_CONSTRUCTOR_CALL 'constructor TEST1()' TEST1
init: ENUM_CONSTRUCTOR_CALL 'constructor TEST1()'
class: CLASS ENUM_ENTRY TEST1
CONSTRUCTOR private constructor TEST1()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor TestEnum4(Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor TestEnum4(Int)'
x: CONST Int type=kotlin.Int value='1'
INSTANCE_INITIALIZER_CALL classDescriptor='TEST1'
FUN public open override fun foo(): kotlin.Unit
@@ -87,11 +87,11 @@ FILE /enum.kt
CALL 'println(Any?): Unit' type=kotlin.Unit origin=null
message: GET_ENUM 'TEST1' type=TestEnum4
ENUM_ENTRY enum entry TEST2
init: ENUM_CONSTRUCTOR_CALL 'constructor TEST2()' TEST2
init: ENUM_CONSTRUCTOR_CALL 'constructor TEST2()'
class: CLASS ENUM_ENTRY TEST2
CONSTRUCTOR private constructor TEST2()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor TestEnum4(Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor TestEnum4(Int)'
x: CONST Int type=kotlin.Int value='2'
INSTANCE_INITIALIZER_CALL classDescriptor='TEST2'
PROPERTY public final val z: kotlin.Int
@@ -0,0 +1,21 @@
// WITH_RUNTIME
enum class Test1(val x: Int) {
ZERO, ONE(1);
constructor() : this(0)
}
enum class Test2(val x: Int) {
ZERO {
override fun foo() {
println("ZERO")
}
},
ONE(1) {
override fun foo() {
println("ONE")
}
};
constructor() : this(0)
abstract fun foo()
}
@@ -0,0 +1,74 @@
FILE /enumWithSecondaryCtor.kt
CLASS ENUM_CLASS Test1
CONSTRUCTOR private constructor Test1(x: kotlin.Int)
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='Test1'
PROPERTY public final val x: kotlin.Int
FIELD PROPERTY_BACKING_FIELD public final val x: kotlin.Int
EXPRESSION_BODY
GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR public final fun <get-x>(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-x>(): Int'
GET_FIELD 'x: Int' type=kotlin.Int origin=null
receiver: THIS of 'Test1' type=Test1
ENUM_ENTRY enum entry ZERO
init: ENUM_CONSTRUCTOR_CALL 'constructor Test1(Int)'
ENUM_ENTRY enum entry ONE
init: ENUM_CONSTRUCTOR_CALL 'constructor Test1(Int)'
x: CONST Int type=kotlin.Int value='1'
CONSTRUCTOR private constructor Test1()
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'constructor Test1(Int)'
x: CONST Int type=kotlin.Int value='0'
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun values(): kotlin.Array<Test1>
SYNTHETIC_BODY kind=ENUM_VALUES
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun valueOf(value: kotlin.String): Test1
SYNTHETIC_BODY kind=ENUM_VALUEOF
CLASS ENUM_CLASS Test2
CONSTRUCTOR private constructor Test2(x: kotlin.Int)
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='Test2'
PROPERTY public final val x: kotlin.Int
FIELD PROPERTY_BACKING_FIELD public final val x: kotlin.Int
EXPRESSION_BODY
GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR public final fun <get-x>(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-x>(): Int'
GET_FIELD 'x: Int' type=kotlin.Int origin=null
receiver: THIS of 'Test2' type=Test2
ENUM_ENTRY enum entry ZERO
init: ENUM_CONSTRUCTOR_CALL 'constructor ZERO()'
class: CLASS ENUM_ENTRY ZERO
CONSTRUCTOR private constructor ZERO()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Test2(Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='ZERO'
FUN public open override fun foo(): kotlin.Unit
BLOCK_BODY
CALL 'println(Any?): Unit' type=kotlin.Unit origin=null
message: CONST String type=kotlin.String value='ZERO'
ENUM_ENTRY enum entry ONE
init: ENUM_CONSTRUCTOR_CALL 'constructor ONE()'
class: CLASS ENUM_ENTRY ONE
CONSTRUCTOR private constructor ONE()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Test2(Int)'
x: CONST Int type=kotlin.Int value='1'
INSTANCE_INITIALIZER_CALL classDescriptor='ONE'
FUN public open override fun foo(): kotlin.Unit
BLOCK_BODY
CALL 'println(Any?): Unit' type=kotlin.Unit origin=null
message: CONST String type=kotlin.String value='ONE'
CONSTRUCTOR private constructor Test2()
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'constructor Test2(Int)'
x: CONST Int type=kotlin.Int value='0'
FUN public abstract fun foo(): kotlin.Unit
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun values(): kotlin.Array<Test2>
SYNTHETIC_BODY kind=ENUM_VALUES
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun valueOf(value: kotlin.String): Test2
SYNTHETIC_BODY kind=ENUM_VALUEOF
+2 -2
View File
@@ -2,10 +2,10 @@ FILE /values.kt
CLASS ENUM_CLASS Enum
CONSTRUCTOR private constructor Enum()
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
INSTANCE_INITIALIZER_CALL classDescriptor='Enum'
ENUM_ENTRY enum entry A
init: ENUM_CONSTRUCTOR_CALL 'constructor Enum()' A
init: ENUM_CONSTRUCTOR_CALL 'constructor Enum()'
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun values(): kotlin.Array<Enum>
SYNTHETIC_BODY kind=ENUM_VALUES
FUN ENUM_CLASS_SPECIAL_MEMBER public final fun valueOf(value: kotlin.String): Enum