[IR] Remove IrFactory property from IrBlockBody and IrExpressionBody

in effort to simplify implementation classes when possible.

Those two properties always point to IrFactoryImpl, so it may as well
be used directly.

#KT-65773 In Progress
This commit is contained in:
Wojciech Litewka
2024-02-29 10:22:06 +01:00
committed by Space Team
parent 49db500369
commit 42668e2bf6
6 changed files with 7 additions and 38 deletions
@@ -8,7 +8,6 @@
package org.jetbrains.kotlin.ir.expressions package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.util.transformInPlace import org.jetbrains.kotlin.ir.util.transformInPlace
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -17,8 +16,6 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* Generated from: [org.jetbrains.kotlin.ir.generator.IrTree.blockBody] * Generated from: [org.jetbrains.kotlin.ir.generator.IrTree.blockBody]
*/ */
abstract class IrBlockBody : IrBody(), IrStatementContainer { abstract class IrBlockBody : IrBody(), IrStatementContainer {
abstract val factory: IrFactory
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R = override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitBlockBody(this, data) visitor.visitBlockBody(this, data)
@@ -8,7 +8,6 @@
package org.jetbrains.kotlin.ir.expressions package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -16,8 +15,6 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* Generated from: [org.jetbrains.kotlin.ir.generator.IrTree.expressionBody] * Generated from: [org.jetbrains.kotlin.ir.generator.IrTree.expressionBody]
*/ */
abstract class IrExpressionBody : IrBody() { abstract class IrExpressionBody : IrBody() {
abstract val factory: IrFactory
abstract var expression: IrExpression abstract var expression: IrExpression
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R = override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.IrImplementationDetail import org.jetbrains.kotlin.ir.IrImplementationDetail
import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrBlockBody
class IrBlockBodyImpl @IrImplementationDetail constructor( class IrBlockBodyImpl @IrImplementationDetail constructor(
@@ -16,7 +14,4 @@ class IrBlockBodyImpl @IrImplementationDetail constructor(
override val endOffset: Int override val endOffset: Int
) : IrBlockBody() { ) : IrBlockBody() {
override val statements: MutableList<IrStatement> = ArrayList(2) override val statements: MutableList<IrStatement> = ArrayList(2)
override val factory: IrFactory
get() = IrFactoryImpl
} }
@@ -1,24 +1,11 @@
/* /*
* Copyright 2010-2016 JetBrains s.r.o. * Copyright 2010-2024 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.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.jetbrains.kotlin.ir.expressions.impl package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.IrImplementationDetail import org.jetbrains.kotlin.ir.IrImplementationDetail
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
@@ -26,8 +13,4 @@ class IrExpressionBodyImpl @IrImplementationDetail constructor(
override val startOffset: Int, override val startOffset: Int,
override val endOffset: Int, override val endOffset: Int,
override var expression: IrExpression, override var expression: IrExpression,
) : IrExpressionBody() { ) : IrExpressionBody()
override val factory: IrFactory
get() = IrFactoryImpl
}
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -417,10 +417,10 @@ open class DeepCopyIrTreeWithSymbols(
throw IllegalArgumentException("Unsupported body type: $body") throw IllegalArgumentException("Unsupported body type: $body")
override fun visitExpressionBody(body: IrExpressionBody): IrExpressionBody = override fun visitExpressionBody(body: IrExpressionBody): IrExpressionBody =
body.factory.createExpressionBody(body.expression.transform()) IrFactoryImpl.createExpressionBody(body.expression.transform())
override fun visitBlockBody(body: IrBlockBody): IrBlockBody = override fun visitBlockBody(body: IrBlockBody): IrBlockBody =
body.factory.createBlockBody( IrFactoryImpl.createBlockBody(
body.startOffset, body.endOffset, body.startOffset, body.endOffset,
body.statements.memoryOptimizedMap { it.transform() } body.statements.memoryOptimizedMap { it.transform() }
) )
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -704,7 +704,6 @@ object IrTree : AbstractTreeBuilder() {
parent(body) parent(body)
+factory
+field("expression", expression) { +field("expression", expression) {
useFieldInIrFactory() useFieldInIrFactory()
} }
@@ -715,8 +714,6 @@ object IrTree : AbstractTreeBuilder() {
parent(body) parent(body)
parent(statementContainer) parent(statementContainer)
+factory
} }
val declarationReference: Element by element(Expression) { val declarationReference: Element by element(Expression) {
parent(expression) parent(expression)