Psi2Ir: Fold constants when generating IR
This is necessary to avoid stack overflow errors on large constant expressions.
This commit is contained in:
committed by
Dmitry Petrov
parent
e87d816994
commit
8c9ad81c76
@@ -0,0 +1,4 @@
|
||||
val test: Int
|
||||
field = Companion.<get-MIN_VALUE>()
|
||||
get
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
FILE fqName:<root> fileName:/constFromBuiltins.kt
|
||||
PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun <get-MIN_VALUE> (): kotlin.Int declared in kotlin.Int.Companion' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=kotlin.Int.Companion
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// DUMP_EXTERNAL_CLASS: kotlin.Int
|
||||
|
||||
val test = Int.MIN_VALUE
|
||||
@@ -1,4 +1,4 @@
|
||||
val test: Int
|
||||
field = Companion.<get-MIN_VALUE>()
|
||||
field = -2147483648
|
||||
get
|
||||
|
||||
|
||||
+1
-2
@@ -2,8 +2,7 @@ FILE fqName:<root> fileName:/constFromBuiltins.kt
|
||||
PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun <get-MIN_VALUE> (): kotlin.Int declared in kotlin.Int.Companion' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=kotlin.Int.Companion
|
||||
CONST Int type=kotlin.Int value=-2147483648
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
val test: Int
|
||||
field = 2.plus(other = 2)
|
||||
get
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
FILE fqName:<root> fileName:/simple.kt
|
||||
PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
|
||||
$this: CONST Int type=kotlin.Int value=2
|
||||
other: CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DUMP_DEPENDENCIES
|
||||
|
||||
val test = 2 + 2
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
val test: Int
|
||||
field = 2.plus(other = 2)
|
||||
field = 4
|
||||
get
|
||||
|
||||
|
||||
+1
-3
@@ -2,9 +2,7 @@ FILE fqName:<root> fileName:/simple.kt
|
||||
PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
|
||||
$this: CONST Int type=kotlin.Int value=2
|
||||
other: CONST Int type=kotlin.Int value=2
|
||||
CONST Int type=kotlin.Int value=4
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
|
||||
Reference in New Issue
Block a user