[IR] Split files containing multiple Ir*Impl classes

To produce smaller diff when switching to auto-generated classes.

^KT-65773 In Progress
This commit is contained in:
Wojciech Litewka
2024-02-05 18:15:05 +01:00
committed by Space Team
parent 3d9194c82c
commit daeea1747d
15 changed files with 320 additions and 219 deletions
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.ir.IrImplementationDetail
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
import org.jetbrains.kotlin.ir.expressions.IrBody
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
@@ -83,75 +82,3 @@ class IrFunctionImpl @IrImplementationDetail constructor(
override var correspondingPropertySymbol: IrPropertySymbol? = null
}
class IrFunctionWithLateBindingImpl @IrImplementationDetail constructor(
override val startOffset: Int,
override val endOffset: Int,
override var origin: IrDeclarationOrigin,
override var name: Name,
override var visibility: DescriptorVisibility,
override var modality: Modality,
returnType: IrType,
override var isInline: Boolean,
override var isExternal: Boolean,
override var isTailrec: Boolean,
override var isSuspend: Boolean,
override var isOperator: Boolean,
override var isInfix: Boolean,
override var isExpect: Boolean,
override var isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override val factory: IrFactory = IrFactoryImpl
) : IrFunctionWithLateBinding() {
private var _symbol: IrSimpleFunctionSymbol? = null
override val symbol: IrSimpleFunctionSymbol
get() = _symbol ?: error("$this has not acquired a symbol yet")
@ObsoleteDescriptorBasedAPI
override val descriptor
get() = _symbol?.descriptor ?: this.toIrBasedDescriptor()
override fun acquireSymbol(symbol: IrSimpleFunctionSymbol): IrFunctionWithLateBinding {
assert(_symbol == null) { "$this already has symbol _symbol" }
_symbol = symbol
symbol.bind(this)
return this
}
override val isBound: Boolean
get() = _symbol != null
override val containerSource: DeserializedContainerSource?
get() = null
override lateinit var parent: IrDeclarationParent
override var annotations: List<IrConstructorCall> = emptyList()
override var returnType: IrType = returnType
get() = if (field === IrUninitializedType) {
throw ReturnTypeIsNotInitializedException(this)
} else {
field
}
override var typeParameters: List<IrTypeParameter> = emptyList()
override var dispatchReceiverParameter: IrValueParameter? = null
override var extensionReceiverParameter: IrValueParameter? = null
override var valueParameters: List<IrValueParameter> = emptyList()
override var contextReceiverParametersCount: Int = 0
override var body: IrBody? = null
override var metadata: MetadataSource? = null
override var overriddenSymbols: List<IrSimpleFunctionSymbol> = emptyList()
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
override var correspondingPropertySymbol: IrPropertySymbol? = null
}
@@ -0,0 +1,95 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.declarations.impl
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.ir.IrImplementationDetail
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
import org.jetbrains.kotlin.ir.expressions.IrBody
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
import org.jetbrains.kotlin.ir.types.impl.ReturnTypeIsNotInitializedException
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
class IrFunctionWithLateBindingImpl @IrImplementationDetail constructor(
override val startOffset: Int,
override val endOffset: Int,
override var origin: IrDeclarationOrigin,
override var name: Name,
override var visibility: DescriptorVisibility,
override var modality: Modality,
returnType: IrType,
override var isInline: Boolean,
override var isExternal: Boolean,
override var isTailrec: Boolean,
override var isSuspend: Boolean,
override var isOperator: Boolean,
override var isInfix: Boolean,
override var isExpect: Boolean,
override var isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override val factory: IrFactory = IrFactoryImpl
) : IrFunctionWithLateBinding() {
private var _symbol: IrSimpleFunctionSymbol? = null
override val symbol: IrSimpleFunctionSymbol
get() = _symbol ?: error("$this has not acquired a symbol yet")
@ObsoleteDescriptorBasedAPI
override val descriptor
get() = _symbol?.descriptor ?: this.toIrBasedDescriptor()
override fun acquireSymbol(symbol: IrSimpleFunctionSymbol): IrFunctionWithLateBinding {
assert(_symbol == null) { "$this already has symbol _symbol" }
_symbol = symbol
symbol.bind(this)
return this
}
override val isBound: Boolean
get() = _symbol != null
override val containerSource: DeserializedContainerSource?
get() = null
override lateinit var parent: IrDeclarationParent
override var annotations: List<IrConstructorCall> = emptyList()
override var returnType: IrType = returnType
get() = if (field === IrUninitializedType) {
throw ReturnTypeIsNotInitializedException(this)
} else {
field
}
override var typeParameters: List<IrTypeParameter> = emptyList()
override var dispatchReceiverParameter: IrValueParameter? = null
override var extensionReceiverParameter: IrValueParameter? = null
override var valueParameters: List<IrValueParameter> = emptyList()
override var contextReceiverParametersCount: Int = 0
override var body: IrBody? = null
override var metadata: MetadataSource? = null
override var overriddenSymbols: List<IrSimpleFunctionSymbol> = emptyList()
override var attributeOwnerId: IrAttributeContainer = this
override var originalBeforeInline: IrAttributeContainer? = null
override var correspondingPropertySymbol: IrPropertySymbol? = null
}
@@ -16,13 +16,8 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
import org.jetbrains.kotlin.ir.types.IrType
class IrBlockImpl(
@@ -53,51 +48,3 @@ fun IrBlockImpl.inlineStatement(statement: IrStatement) {
statements.add(statement)
}
}
class IrReturnableBlockImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val symbol: IrReturnableBlockSymbol,
override var origin: IrStatementOrigin? = null,
) : IrReturnableBlock() {
@ObsoleteDescriptorBasedAPI
override val descriptor: FunctionDescriptor
get() = symbol.descriptor
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrReturnableBlockSymbol,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) : this(startOffset, endOffset, type, symbol, origin) {
this.statements.addAll(statements)
}
init {
symbol.bind(this)
}
}
class IrInlinedFunctionBlockImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var inlineCall: IrFunctionAccessExpression,
override var inlinedElement: IrElement,
override var origin: IrStatementOrigin? = null,
) : IrInlinedFunctionBlock() {
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
inlineCall: IrFunctionAccessExpression,
inlinedElement: IrElement,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) : this(startOffset, endOffset, type, inlineCall, inlinedElement, origin) {
this.statements.addAll(statements)
}
}
@@ -0,0 +1,19 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrBranch
import org.jetbrains.kotlin.ir.expressions.IrExpression
open class IrBranchImpl(
override val startOffset: Int,
override val endOffset: Int,
override var condition: IrExpression,
override var result: IrExpression
) : IrBranch() {
constructor(condition: IrExpression, result: IrExpression) :
this(condition.startOffset, result.endOffset, condition, result)
}
@@ -0,0 +1,27 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrCatch
import org.jetbrains.kotlin.ir.expressions.IrExpression
class IrCatchImpl(
override val startOffset: Int,
override val endOffset: Int,
override var catchParameter: IrVariable,
) : IrCatch() {
constructor(
startOffset: Int,
endOffset: Int,
catchParameter: IrVariable,
result: IrExpression
) : this(startOffset, endOffset, catchParameter) {
this.result = result
}
override lateinit var result: IrExpression
}
@@ -0,0 +1,34 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrConstantArray
import org.jetbrains.kotlin.ir.expressions.IrConstantValue
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.utils.SmartList
class IrConstantArrayImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
initElements: List<IrConstantValue>,
) : IrConstantArray() {
override val elements = SmartList(initElements)
override fun contentEquals(other: IrConstantValue): Boolean =
other is IrConstantArray &&
other.type == type &&
elements.size == other.elements.size &&
elements.indices.all { elements[it].contentEquals(other.elements[it]) }
override fun contentHashCode(): Int {
var res = type.hashCode()
for (value in elements) {
res = res * 31 + value.contentHashCode()
}
return res
}
}
@@ -11,29 +11,6 @@ import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.constructedClassType
import org.jetbrains.kotlin.utils.SmartList
class IrConstantPrimitiveImpl(
override val startOffset: Int,
override val endOffset: Int,
override var value: IrConst<*>,
) : IrConstantPrimitive() {
override fun contentEquals(other: IrConstantValue) =
other is IrConstantPrimitive &&
type == other.type &&
value.type == other.value.type &&
value.kind == other.value.kind &&
value.value == other.value.value
override fun contentHashCode(): Int {
var result = type.hashCode()
result = result * 31 + value.type.hashCode()
result = result * 31 + value.kind.hashCode()
result = result * 31 + value.value.hashCode()
return result
}
override var type = value.type
}
class IrConstantObjectImpl constructor(
override val startOffset: Int,
override val endOffset: Int,
@@ -66,26 +43,3 @@ class IrConstantObjectImpl constructor(
return res
}
}
class IrConstantArrayImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
initElements: List<IrConstantValue>,
) : IrConstantArray() {
override val elements = SmartList(initElements)
override fun contentEquals(other: IrConstantValue): Boolean =
other is IrConstantArray &&
other.type == type &&
elements.size == other.elements.size &&
elements.indices.all { elements[it].contentEquals(other.elements[it]) }
override fun contentHashCode(): Int {
var res = type.hashCode()
for (value in elements) {
res = res * 31 + value.contentHashCode()
}
return res
}
}
@@ -0,0 +1,33 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrConstantPrimitive
import org.jetbrains.kotlin.ir.expressions.IrConstantValue
class IrConstantPrimitiveImpl(
override val startOffset: Int,
override val endOffset: Int,
override var value: IrConst<*>,
) : IrConstantPrimitive() {
override fun contentEquals(other: IrConstantValue) =
other is IrConstantPrimitive &&
type == other.type &&
value.type == other.value.type &&
value.kind == other.value.kind &&
value.value == other.value.value
override fun contentHashCode(): Int {
var result = type.hashCode()
result = result * 31 + value.type.hashCode()
result = result * 31 + value.kind.hashCode()
result = result * 31 + value.value.hashCode()
return result
}
override var type = value.type
}
@@ -0,0 +1,19 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrElseBranch
import org.jetbrains.kotlin.ir.expressions.IrExpression
class IrElseBranchImpl(
override val startOffset: Int,
override val endOffset: Int,
override var condition: IrExpression,
override var result: IrExpression
) : IrElseBranch() {
constructor(condition: IrExpression, result: IrExpression) :
this(condition.startOffset, result.endOffset, condition, result)
}
@@ -0,0 +1,34 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.IrInlinedFunctionBlock
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.types.IrType
class IrInlinedFunctionBlockImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var inlineCall: IrFunctionAccessExpression,
override var inlinedElement: IrElement,
override var origin: IrStatementOrigin? = null,
) : IrInlinedFunctionBlock() {
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
inlineCall: IrFunctionAccessExpression,
inlinedElement: IrElement,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) : this(startOffset, endOffset, type, inlineCall, inlinedElement, origin) {
this.statements.addAll(statements)
}
}
@@ -0,0 +1,41 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
import org.jetbrains.kotlin.ir.types.IrType
class IrReturnableBlockImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val symbol: IrReturnableBlockSymbol,
override var origin: IrStatementOrigin? = null,
) : IrReturnableBlock() {
@ObsoleteDescriptorBasedAPI
override val descriptor: FunctionDescriptor
get() = symbol.descriptor
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
symbol: IrReturnableBlockSymbol,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
) : this(startOffset, endOffset, type, symbol, origin) {
this.statements.addAll(statements)
}
init {
symbol.bind(this)
}
}
@@ -0,0 +1,18 @@
/*
* 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.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSuspendableExpression
import org.jetbrains.kotlin.ir.types.IrType
class IrSuspendableExpressionImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var suspensionPointId: IrExpression,
override var result: IrExpression
) : IrSuspendableExpression()
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSuspendableExpression
import org.jetbrains.kotlin.ir.expressions.IrSuspensionPoint
import org.jetbrains.kotlin.ir.types.IrType
@@ -20,10 +19,3 @@ class IrSuspensionPointImpl(
override var resumeResult: IrExpression
) : IrSuspensionPoint()
class IrSuspendableExpressionImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override var suspensionPointId: IrExpression,
override var result: IrExpression
) : IrSuspendableExpression()
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrCatch
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrTry
@@ -47,20 +46,3 @@ class IrTryImpl(
override var finallyExpression: IrExpression? = null
}
class IrCatchImpl(
override val startOffset: Int,
override val endOffset: Int,
override var catchParameter: IrVariable,
) : IrCatch() {
constructor(
startOffset: Int,
endOffset: Int,
catchParameter: IrVariable,
result: IrExpression
) : this(startOffset, endOffset, catchParameter) {
this.result = result
}
override lateinit var result: IrExpression
}
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.utils.SmartList
class IrWhenImpl(
override val startOffset: Int,
@@ -38,23 +37,3 @@ class IrWhenImpl(
override val branches: MutableList<IrBranch> = ArrayList(2)
}
open class IrBranchImpl(
override val startOffset: Int,
override val endOffset: Int,
override var condition: IrExpression,
override var result: IrExpression
) : IrBranch() {
constructor(condition: IrExpression, result: IrExpression) :
this(condition.startOffset, result.endOffset, condition, result)
}
class IrElseBranchImpl(
override val startOffset: Int,
override val endOffset: Int,
override var condition: IrExpression,
override var result: IrExpression
) : IrElseBranch() {
constructor(condition: IrExpression, result: IrExpression) :
this(condition.startOffset, result.endOffset, condition, result)
}