[FIR][tree] introduce lazy expression to simplify code

^KT-56543
This commit is contained in:
Dmitrii Gridin
2023-03-22 14:22:22 +01:00
committed by Space Team
parent bc5c1b2a6c
commit a643dfbe83
19 changed files with 185 additions and 46 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -26,6 +26,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
val statement by element(Expression, annotationContainer)
val expression by element(Expression, statement)
val lazyExpression by element(Expression, expression)
val contextReceiver by element(Declaration)
@@ -83,6 +84,8 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
val whileLoop by element(Expression, loop)
val block by element(Expression, expression)
val lazyBlock by element(Expression, block)
val binaryLogicExpression by element(Expression, expression)
val jump by sealedElement(Expression, expression)
val loopJump by element(Expression, jump)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -173,7 +173,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
publicImplementation()
}
impl(block, "FirLazyBlock") {
impl(lazyBlock) {
val error = """error("FirLazyBlock should be calculated before accessing")"""
default("source") {
value = error
@@ -191,7 +191,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
value = error
withGetter = true
}
publicImplementation()
}
impl(errorLoop) {
@@ -204,7 +203,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
publicImplementation()
}
impl(expression, "FirLazyExpression") {
impl(lazyExpression) {
val error = """error("FirLazyExpression should be calculated before accessing")"""
default("typeRef") {
value = error
@@ -214,7 +213,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
value = error
withGetter = true
}
publicImplementation()
}
impl(functionCall) {