IR: split files containing multiple classes/functions

This change only moves code around, no behavior is changed.
Specifically, ir.tree sources containing several declarations are split
into several files: one file per class, and one file for all extension
functions per package (IrDeclarations.kt, IrExpressions.kt,
IrVisitors.kt, IrConstructorCallTypeArguments.kt).

This is useful because after introducing IR tree generator, we can
easily see how generated sources are different from those which were
written manually, since Git will recognize file moves. Also, it will
keep Git history for sources which consisted of one big class + a couple
of extension functions (e.g. IrElementVisitorVoid.kt).
This commit is contained in:
Alexander Udalov
2022-01-12 02:04:56 +01:00
parent e4b63d4a2b
commit f17fc67683
80 changed files with 848 additions and 483 deletions
@@ -17,9 +17,3 @@ interface IrAttributeContainer : IrElement {
*/
var attributeOwnerId: IrAttributeContainer
}
fun <D : IrAttributeContainer> D.copyAttributes(other: IrAttributeContainer?): D = apply {
if (other != null) {
attributeOwnerId = other.attributeOwnerId
}
}
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.primaryConstructor
import org.jetbrains.kotlin.ir.util.transformIfNeeded
import org.jetbrains.kotlin.ir.util.transformInPlace
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
@@ -69,17 +68,3 @@ abstract class IrClass :
declarations.transformInPlace(transformer, data)
}
}
val IrClass.isSingleFieldValueClass
get() = this.isValue && (this.inlineClassRepresentation != null || this.primaryConstructor?.valueParameters?.size == 1)
val IrClass.isMultiFieldValueClass
get() = this.isValue && !isSingleFieldValueClass
fun IrClass.addMember(member: IrDeclaration) {
declarations.add(member)
}
fun IrClass.addAll(members: List<IrDeclaration>) {
declarations.addAll(members)
}
@@ -17,23 +17,8 @@
package org.jetbrains.kotlin.ir.declarations
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
interface IrSymbolOwner : IrElement {
val symbol: IrSymbol
}
interface IrMetadataSourceOwner : IrElement {
var metadata: MetadataSource?
}
interface IrDeclaration : IrStatement, IrSymbolOwner, IrMutableAnnotationContainer {
@ObsoleteDescriptorBasedAPI
@@ -45,31 +30,3 @@ interface IrDeclaration : IrStatement, IrSymbolOwner, IrMutableAnnotationContain
val factory: IrFactory
}
abstract class IrDeclarationBase : IrElementBase(), IrDeclaration
interface IrOverridableDeclaration<S : IrSymbol> : IrOverridableMember {
override val symbol: S
val isFakeOverride: Boolean
var overriddenSymbols: List<S>
}
interface IrDeclarationWithVisibility : IrDeclaration {
var visibility: DescriptorVisibility
}
interface IrDeclarationWithName : IrDeclaration {
val name: Name
}
interface IrPossiblyExternalDeclaration : IrDeclarationWithName {
val isExternal: Boolean
}
interface IrOverridableMember : IrDeclarationWithVisibility, IrDeclarationWithName, IrSymbolOwner {
val modality: Modality
}
interface IrMemberWithContainerSource : IrDeclarationWithName {
val containerSource: DeserializedContainerSource?
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.ir.IrElementBase
abstract class IrDeclarationBase : IrElementBase(), IrDeclaration
@@ -16,10 +16,6 @@
package org.jetbrains.kotlin.ir.declarations
import org.jetbrains.kotlin.ir.IrElement
interface IrDeclarationParent : IrElement
interface IrDeclarationContainer : IrDeclarationParent {
val declarations: MutableList<IrDeclaration>
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.ir.IrElement
interface IrDeclarationParent : IrElement
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.name.Name
interface IrDeclarationWithName : IrDeclaration {
val name: Name
}
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
interface IrDeclarationWithVisibility : IrDeclaration {
var visibility: DescriptorVisibility
}
@@ -0,0 +1,56 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.util.primaryConstructor
import java.io.File
fun <D : IrAttributeContainer> D.copyAttributes(other: IrAttributeContainer?): D = apply {
if (other != null) {
attributeOwnerId = other.attributeOwnerId
}
}
val IrClass.isSingleFieldValueClass: Boolean
get() = this.isValue && (this.inlineClassRepresentation != null || this.primaryConstructor?.valueParameters?.size == 1)
val IrClass.isMultiFieldValueClass: Boolean
get() = this.isValue && !isSingleFieldValueClass
fun IrClass.addMember(member: IrDeclaration) {
declarations.add(member)
}
fun IrClass.addAll(members: List<IrDeclaration>) {
declarations.addAll(members)
}
val IrFile.path: String get() = fileEntry.name
val IrFile.name: String get() = File(path).name
@ObsoleteDescriptorBasedAPI
fun IrFunction.getIrValueParameter(parameter: ValueParameterDescriptor): IrValueParameter =
valueParameters.getOrElse(parameter.index) {
throw AssertionError("No IrValueParameter for $parameter")
}.also { found ->
assert(found.descriptor == parameter) {
"Parameter indices mismatch at $descriptor: $parameter != ${found.descriptor}"
}
}
@ObsoleteDescriptorBasedAPI
fun IrFunction.putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) {
getIrValueParameter(parameter).defaultValue = expressionBody
}
val IrFunction.isStaticMethodOfClass: Boolean
get() = this is IrSimpleFunction && parent is IrClass && dispatchReceiverParameter == null
val IrFunction.isPropertyAccessor: Boolean
get() = this is IrSimpleFunction && correspondingPropertySymbol != null
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
abstract class IrExternalPackageFragment : IrPackageFragment() {
abstract override val symbol: IrExternalPackageFragmentSymbol
abstract val containerSource: DeserializedContainerSource?
}
@@ -16,30 +16,9 @@
package org.jetbrains.kotlin.ir.declarations
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.IrFileEntry
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
import org.jetbrains.kotlin.ir.symbols.IrPackageFragmentSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
import java.io.File
abstract class IrPackageFragment : IrElementBase(), IrDeclarationContainer, IrSymbolOwner {
@ObsoleteDescriptorBasedAPI
abstract val packageFragmentDescriptor: PackageFragmentDescriptor
abstract override val symbol: IrPackageFragmentSymbol
abstract val fqName: FqName
}
abstract class IrExternalPackageFragment : IrPackageFragment() {
abstract override val symbol: IrExternalPackageFragmentSymbol
abstract val containerSource: DeserializedContainerSource?
}
abstract class IrFile : IrPackageFragment(), IrMutableAnnotationContainer, IrMetadataSourceOwner {
abstract override val symbol: IrFileSymbol
@@ -51,6 +30,3 @@ abstract class IrFile : IrPackageFragment(), IrMutableAnnotationContainer, IrMet
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrFile =
accept(transformer, data) as IrFile
}
val IrFile.path: String get() = fileEntry.name
val IrFile.name: String get() = File(path).name
@@ -17,10 +17,8 @@
package org.jetbrains.kotlin.ir.declarations
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.expressions.IrBody
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.transformIfNeeded
@@ -73,21 +71,3 @@ abstract class IrFunction :
body = body?.transform(transformer, data)
}
}
@ObsoleteDescriptorBasedAPI
fun IrFunction.getIrValueParameter(parameter: ValueParameterDescriptor): IrValueParameter =
valueParameters.getOrElse(parameter.index) {
throw AssertionError("No IrValueParameter for $parameter")
}.also { found ->
assert(found.descriptor == parameter) {
"Parameter indices mismatch at $descriptor: $parameter != ${found.descriptor}"
}
}
@ObsoleteDescriptorBasedAPI
fun IrFunction.putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) {
getIrValueParameter(parameter).defaultValue = expressionBody
}
val IrFunction.isStaticMethodOfClass: Boolean
get() = this is IrSimpleFunction && parent is IrClass && dispatchReceiverParameter == null
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
interface IrMemberWithContainerSource : IrDeclarationWithName {
val containerSource: DeserializedContainerSource?
}
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.ir.IrElement
interface IrMetadataSourceOwner : IrElement {
var metadata: MetadataSource?
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.ir.symbols.IrSymbol
interface IrOverridableDeclaration<S : IrSymbol> : IrOverridableMember {
override val symbol: S
val isFakeOverride: Boolean
var overriddenSymbols: List<S>
}
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.descriptors.Modality
interface IrOverridableMember : IrDeclarationWithVisibility, IrDeclarationWithName, IrSymbolOwner {
val modality: Modality
}
@@ -0,0 +1,20 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.symbols.IrPackageFragmentSymbol
import org.jetbrains.kotlin.name.FqName
abstract class IrPackageFragment : IrElementBase(), IrDeclarationContainer, IrSymbolOwner {
@ObsoleteDescriptorBasedAPI
abstract val packageFragmentDescriptor: PackageFragmentDescriptor
abstract override val symbol: IrPackageFragmentSymbol
abstract val fqName: FqName
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2022 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
interface IrPossiblyExternalDeclaration : IrDeclarationWithName {
val isExternal: Boolean
}
@@ -27,6 +27,3 @@ abstract class IrSimpleFunction :
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitSimpleFunction(this, data)
}
val IrFunction.isPropertyAccessor: Boolean
get() = this is IrSimpleFunction && correspondingPropertySymbol != null
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.symbols.IrSymbol
interface IrSymbolOwner : IrElement {
val symbol: IrSymbol
}
@@ -16,47 +16,7 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrReturnTarget
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
import org.jetbrains.kotlin.ir.util.fileOrNull
import org.jetbrains.kotlin.ir.util.transformInPlace
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrContainerExpression : IrExpression(), IrStatementContainer {
abstract val origin: IrStatementOrigin?
abstract val isTransparentScope: Boolean
override val statements: MutableList<IrStatement> = ArrayList(2)
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
statements.forEach { it.accept(visitor, data) }
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
statements.transformInPlace(transformer, data)
}
}
abstract class IrBlock : IrContainerExpression() {
override val isTransparentScope: Boolean
get() = false
}
abstract class IrComposite : IrContainerExpression() {
override val isTransparentScope: Boolean
get() = true
}
abstract class IrReturnableBlock : IrBlock(), IrSymbolOwner, IrReturnTarget {
abstract override val symbol: IrReturnableBlockSymbol
abstract val inlineFunctionSymbol: IrFunctionSymbol?
}
val IrReturnableBlock.sourceFileSymbol: IrFileSymbol?
get() = inlineFunctionSymbol?.owner?.fileOrNull?.symbol
@@ -0,0 +1,28 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrBlockBody : IrBody(), IrStatementContainer {
abstract val factory: IrFactory
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitBlockBody(this, data)
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
statements.forEach { it.accept(visitor, data) }
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
statements.forEachIndexed { i, irStatement ->
statements[i] = irStatement.transform(transformer, data) as IrStatement
}
}
}
@@ -17,58 +17,9 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrBody : IrElementBase() {
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrBody =
accept(transformer, data) as IrBody
}
abstract class IrExpressionBody : IrBody() {
abstract val factory: IrFactory
abstract var expression: IrExpression
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitExpressionBody(this, data)
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpressionBody =
accept(transformer, data) as IrExpressionBody
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
expression.accept(visitor, data)
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
expression = expression.transform(transformer, data)
}
}
abstract class IrBlockBody : IrBody(), IrStatementContainer {
abstract val factory: IrFactory
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitBlockBody(this, data)
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
statements.forEach { it.accept(visitor, data) }
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
statements.forEachIndexed { i, irStatement ->
statements[i] = irStatement.transform(transformer, data) as IrStatement
}
}
}
abstract class IrSyntheticBody : IrBody() {
abstract val kind: IrSyntheticBodyKind
}
enum class IrSyntheticBodyKind {
ENUM_VALUES,
ENUM_VALUEOF
}
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrBranch : IrElementBase() {
abstract var condition: IrExpression
abstract var result: IrExpression
abstract override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrBranch
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
condition.accept(visitor, data)
result.accept(visitor, data)
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
condition = condition.transform(transformer, data)
result = result.transform(transformer, data)
}
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrBreak : IrBreakContinue()
@@ -21,7 +21,3 @@ abstract class IrBreakContinue : IrExpression() {
var label: String? = null
}
abstract class IrBreak : IrBreakContinue()
abstract class IrContinue : IrBreakContinue()
@@ -16,37 +16,9 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.name.Name
abstract class IrCallableReference<S : IrSymbol>(typeArgumentsCount: Int) : IrMemberAccessExpression<S>(typeArgumentsCount) {
abstract val referencedName: Name
}
abstract class IrFunctionReference(typeArgumentsCount: Int) : IrCallableReference<IrFunctionSymbol>(typeArgumentsCount) {
abstract val reflectionTarget: IrFunctionSymbol?
}
val IrFunctionReference.isWithReflection: Boolean
get() = reflectionTarget != null
val IrFunctionReference.isAdapterWithReflection: Boolean
get() = reflectionTarget != null && reflectionTarget != symbol
abstract class IrPropertyReference(typeArgumentsCount: Int) : IrCallableReference<IrPropertySymbol>(typeArgumentsCount) {
abstract val field: IrFieldSymbol?
abstract val getter: IrSimpleFunctionSymbol?
abstract val setter: IrSimpleFunctionSymbol?
override val valueArgumentsCount: Int
get() = 0
}
abstract class IrLocalDelegatedPropertyReference : IrCallableReference<IrLocalDelegatedPropertySymbol>(0) {
abstract val delegate: IrVariableSymbol
abstract val getter: IrSimpleFunctionSymbol
abstract val setter: IrSimpleFunctionSymbol?
override val valueArgumentsCount: Int
get() = 0
}
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
abstract class IrCatch : IrElementBase() {
abstract var catchParameter: IrVariable
abstract var result: IrExpression
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrCatch =
super.transform(transformer, data) as IrCatch
}
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2021 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
abstract class IrComposite : IrContainerExpression() {
override val isTransparentScope: Boolean
get() = true
}
@@ -22,22 +22,3 @@ abstract class IrConst<T> : IrExpression() {
abstract fun copyWithOffsets(startOffset: Int, endOffset: Int): IrConst<T>
}
sealed class IrConstKind<T>(val asString: kotlin.String) {
@Suppress("UNCHECKED_CAST")
fun valueOf(aConst: IrConst<*>) =
(aConst as IrConst<T>).value
object Null : IrConstKind<Nothing?>("Null")
object Boolean : IrConstKind<kotlin.Boolean>("Boolean")
object Char : IrConstKind<kotlin.Char>("Char")
object Byte : IrConstKind<kotlin.Byte>("Byte")
object Short : IrConstKind<kotlin.Short>("Short")
object Int : IrConstKind<kotlin.Int>("Int")
object Long : IrConstKind<kotlin.Long>("Long")
object String : IrConstKind<kotlin.String>("String")
object Float : IrConstKind<kotlin.Float>("Float")
object Double : IrConstKind<kotlin.Double>("Double")
override fun toString() = asString
}
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2021 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
sealed class IrConstKind<T>(val asString: kotlin.String) {
@Suppress("UNCHECKED_CAST")
fun valueOf(aConst: IrConst<*>) =
(aConst as IrConst<T>).value
object Null : IrConstKind<Nothing?>("Null")
object Boolean : IrConstKind<kotlin.Boolean>("Boolean")
object Char : IrConstKind<kotlin.Char>("Char")
object Byte : IrConstKind<kotlin.Byte>("Byte")
object Short : IrConstKind<kotlin.Short>("Short")
object Int : IrConstKind<kotlin.Int>("Int")
object Long : IrConstKind<kotlin.Long>("Long")
object String : IrConstKind<kotlin.String>("String")
object Float : IrConstKind<kotlin.Float>("Float")
object Double : IrConstKind<kotlin.Double>("Double")
override fun toString() = asString
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 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
abstract class IrConstantArray : IrConstantValue() {
abstract val elements: MutableList<IrConstantValue>
}
@@ -8,21 +8,8 @@ package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.types.IrType
abstract class IrConstantValue : IrExpression() {
abstract fun contentEquals(other: IrConstantValue) : Boolean
abstract fun contentHashCode(): Int
}
abstract class IrConstantPrimitive : IrConstantValue() {
abstract var value: IrConst<*>
}
abstract class IrConstantObject : IrConstantValue() {
abstract val constructor: IrConstructorSymbol
abstract val valueArguments: MutableList<IrConstantValue>
abstract val typeArguments: List<IrType>
}
abstract class IrConstantArray : IrConstantValue() {
abstract val elements: MutableList<IrConstantValue>
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 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
abstract class IrConstantPrimitive : IrConstantValue() {
abstract var value: IrConst<*>
}
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2021 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
abstract class IrConstantValue : IrExpression() {
abstract fun contentEquals(other: IrConstantValue): Boolean
abstract fun contentHashCode(): Int
}
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.types.IrType
abstract class IrConstructorCall(
typeArgumentsCount: Int,
@@ -15,68 +14,4 @@ abstract class IrConstructorCall(
abstract override val symbol: IrConstructorSymbol
abstract val constructorTypeArgumentsCount: Int
class ConstructorTypeArguments(internal val irConstructorCall: IrConstructorCall) : AbstractList<IrType?>() {
override val size: Int
get() = irConstructorCall.constructorTypeArgumentsCount
override fun get(index: Int): IrType? =
if (index >= size)
throw IndexOutOfBoundsException("index: $index, size: $size")
else
irConstructorCall.getConstructorTypeArgument(index)
}
class ClassTypeArguments(internal val irConstructorCall: IrConstructorCall) : AbstractList<IrType?>() {
override val size: Int
get() = irConstructorCall.classTypeArgumentsCount
override fun get(index: Int): IrType? =
if (index >= size)
throw IndexOutOfBoundsException("index: $index, size: $size")
else
irConstructorCall.getTypeArgument(index)
}
}
fun IrConstructorCall.getConstructorTypeArgumentIndex(constructorTypeArgumentIndex: Int) =
typeArgumentsCount - constructorTypeArgumentsCount + constructorTypeArgumentIndex
fun IrConstructorCall.getConstructorTypeArgument(index: Int): IrType? =
getTypeArgument(getConstructorTypeArgumentIndex(index))
fun IrConstructorCall.putConstructorTypeArgument(index: Int, type: IrType?) {
putTypeArgument(getConstructorTypeArgumentIndex(index), type)
}
operator fun IrConstructorCall.ConstructorTypeArguments.set(index: Int, type: IrType?) {
if (index >= size) throw IndexOutOfBoundsException("index: $index, size: $size")
irConstructorCall.putConstructorTypeArgument(index, type)
}
val IrConstructorCall.classTypeArgumentsCount: Int
get() = typeArgumentsCount - constructorTypeArgumentsCount
fun IrConstructorCall.getClassTypeArgument(index: Int): IrType? =
getTypeArgument(index)
fun IrConstructorCall.putClassTypeArgument(index: Int, type: IrType?) {
putTypeArgument(index, type)
}
operator fun IrConstructorCall.ClassTypeArguments.set(index: Int, type: IrType?) {
if (index >= size) throw IndexOutOfBoundsException("index: $index, size: $size")
irConstructorCall.putClassTypeArgument(index, type)
}
fun IrConstructorCall.getConstructorTypeArguments() =
IrConstructorCall.ConstructorTypeArguments(this)
fun IrConstructorCall.getClassTypeArguments() =
IrConstructorCall.ClassTypeArguments(this)
var IrConstructorCall.outerClassReceiver: IrExpression?
get() = dispatchReceiver
set(value) {
dispatchReceiver = value
}
@@ -0,0 +1,72 @@
/*
* Copyright 2010-2022 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
import org.jetbrains.kotlin.ir.types.IrType
class ConstructorTypeArguments(internal val irConstructorCall: IrConstructorCall) : AbstractList<IrType?>() {
override val size: Int
get() = irConstructorCall.constructorTypeArgumentsCount
override fun get(index: Int): IrType? =
if (index >= size)
throw IndexOutOfBoundsException("index: $index, size: $size")
else
irConstructorCall.getConstructorTypeArgument(index)
}
class ClassTypeArguments(internal val irConstructorCall: IrConstructorCall) : AbstractList<IrType?>() {
override val size: Int
get() = irConstructorCall.classTypeArgumentsCount
override fun get(index: Int): IrType? =
if (index >= size)
throw IndexOutOfBoundsException("index: $index, size: $size")
else
irConstructorCall.getTypeArgument(index)
}
fun IrConstructorCall.getConstructorTypeArgumentIndex(constructorTypeArgumentIndex: Int) =
typeArgumentsCount - constructorTypeArgumentsCount + constructorTypeArgumentIndex
fun IrConstructorCall.getConstructorTypeArgument(index: Int): IrType? =
getTypeArgument(getConstructorTypeArgumentIndex(index))
fun IrConstructorCall.putConstructorTypeArgument(index: Int, type: IrType?) {
putTypeArgument(getConstructorTypeArgumentIndex(index), type)
}
operator fun ConstructorTypeArguments.set(index: Int, type: IrType?) {
if (index >= size) throw IndexOutOfBoundsException("index: $index, size: $size")
irConstructorCall.putConstructorTypeArgument(index, type)
}
val IrConstructorCall.classTypeArgumentsCount: Int
get() = typeArgumentsCount - constructorTypeArgumentsCount
fun IrConstructorCall.getClassTypeArgument(index: Int): IrType? =
getTypeArgument(index)
fun IrConstructorCall.putClassTypeArgument(index: Int, type: IrType?) {
putTypeArgument(index, type)
}
operator fun ClassTypeArguments.set(index: Int, type: IrType?) {
if (index >= size) throw IndexOutOfBoundsException("index: $index, size: $size")
irConstructorCall.putClassTypeArgument(index, type)
}
fun IrConstructorCall.getConstructorTypeArguments() =
ConstructorTypeArguments(this)
fun IrConstructorCall.getClassTypeArguments() =
ClassTypeArguments(this)
var IrConstructorCall.outerClassReceiver: IrExpression?
get() = dispatchReceiver
set(value) {
dispatchReceiver = value
}
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.util.transformInPlace
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrContainerExpression : IrExpression(), IrStatementContainer {
abstract val origin: IrStatementOrigin?
abstract val isTransparentScope: Boolean
override val statements: MutableList<IrStatement> = ArrayList(2)
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
statements.forEach { it.accept(visitor, data) }
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
statements.transformInPlace(transformer, data)
}
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrContinue : IrBreakContinue()
@@ -16,31 +16,8 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol
abstract class IrDeclarationReference : IrExpression() {
abstract val symbol: IrSymbol
}
abstract class IrGetSingletonValue : IrDeclarationReference()
abstract class IrGetObjectValue : IrGetSingletonValue() {
abstract override val symbol: IrClassSymbol
}
abstract class IrGetEnumValue : IrGetSingletonValue() {
abstract override val symbol: IrEnumEntrySymbol
}
/**
* Platform-specific low-level reference to function.
*
* On JS platform it represents a plain reference to JavaScript function.
* On JVM platform it represents a MethodHandle constant.
*/
abstract class IrRawFunctionReference : IrDeclarationReference() {
abstract override val symbol: IrFunctionSymbol
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrDoWhileLoop : IrLoop()
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrDynamicExpression : IrExpression()
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2021 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
abstract class IrDynamicMemberExpression : IrDynamicExpression() {
abstract val memberName: String
abstract var receiver: IrExpression
}
@@ -5,37 +5,6 @@
package org.jetbrains.kotlin.ir.expressions
abstract class IrDynamicExpression : IrExpression()
abstract class IrDynamicOperatorExpression : IrDynamicExpression() {
abstract val operator: IrDynamicOperator
abstract var receiver: IrExpression
abstract val arguments: MutableList<IrExpression>
}
var IrDynamicOperatorExpression.left: IrExpression
get() = receiver
set(value) {
receiver = value
}
var IrDynamicOperatorExpression.right: IrExpression
get() = arguments[0]
set(value) {
if (arguments.isEmpty())
arguments.add(value)
else
arguments[0] = value
}
abstract class IrDynamicMemberExpression : IrDynamicExpression() {
abstract val memberName: String
abstract var receiver: IrExpression
}
enum class IrDynamicOperator(val image: String, val isAssignmentOperator: Boolean = false) {
UNARY_PLUS("+"),
UNARY_MINUS("-"),
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 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
abstract class IrDynamicOperatorExpression : IrDynamicExpression() {
abstract val operator: IrDynamicOperator
abstract var receiver: IrExpression
abstract val arguments: MutableList<IrExpression>
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrElseBranch : IrBranch()
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2021 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
abstract class IrErrorCallExpression : IrErrorExpression() {
abstract var explicitReceiver: IrExpression?
abstract val arguments: MutableList<IrExpression>
}
@@ -19,8 +19,3 @@ package org.jetbrains.kotlin.ir.expressions
abstract class IrErrorExpression : IrExpression() {
abstract val description: String
}
abstract class IrErrorCallExpression : IrErrorExpression() {
abstract var explicitReceiver: IrExpression?
abstract val arguments: MutableList<IrExpression>
}
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrExpressionBody : IrBody() {
abstract val factory: IrFactory
abstract var expression: IrExpression
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitExpressionBody(this, data)
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpressionBody =
accept(transformer, data) as IrExpressionBody
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
expression.accept(visitor, data)
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
expression = expression.transform(transformer, data)
}
}
@@ -0,0 +1,38 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
import org.jetbrains.kotlin.ir.util.fileOrNull
@Suppress("unused") // Used in kotlin-native
val IrReturnableBlock.sourceFileSymbol: IrFileSymbol?
get() = inlineFunctionSymbol?.owner?.fileOrNull?.symbol
val IrFunctionReference.isWithReflection: Boolean
get() = reflectionTarget != null
val IrFunctionReference.isAdapterWithReflection: Boolean
get() = reflectionTarget != null && reflectionTarget != symbol
var IrDynamicOperatorExpression.left: IrExpression
get() = receiver
set(value) {
receiver = value
}
var IrDynamicOperatorExpression.right: IrExpression
get() = arguments[0]
set(value) {
if (arguments.isEmpty())
arguments.add(value)
else
arguments[0] = value
}
fun IrFunctionAccessExpression.putArgument(parameter: IrValueParameter, argument: IrExpression): Unit =
putArgument(symbol.owner, parameter, argument)
@@ -27,9 +27,3 @@ abstract class IrFieldAccessExpression : IrDeclarationReference() {
var receiver: IrExpression? = null
abstract val origin: IrStatementOrigin?
}
abstract class IrGetField : IrFieldAccessExpression()
abstract class IrSetField : IrFieldAccessExpression() {
abstract var value: IrExpression
}
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -51,6 +50,3 @@ abstract class IrFunctionAccessExpression(
}
}
}
fun IrFunctionAccessExpression.putArgument(parameter: IrValueParameter, argument: IrExpression) =
putArgument(symbol.owner, parameter, argument)
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
abstract class IrFunctionReference(typeArgumentsCount: Int) : IrCallableReference<IrFunctionSymbol>(typeArgumentsCount) {
abstract val reflectionTarget: IrFunctionSymbol?
}
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
abstract class IrGetEnumValue : IrGetSingletonValue() {
abstract override val symbol: IrEnumEntrySymbol
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrGetField : IrFieldAccessExpression()
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
abstract class IrGetObjectValue : IrGetSingletonValue() {
abstract override val symbol: IrClassSymbol
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrGetSingletonValue : IrDeclarationReference()
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 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
abstract class IrGetValue : IrValueAccessExpression() {
abstract fun copyWithOffsets(newStartOffset: Int, newEndOffset: Int): IrGetValue
}
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
abstract class IrLocalDelegatedPropertyReference : IrCallableReference<IrLocalDelegatedPropertySymbol>(0) {
abstract val delegate: IrVariableSymbol
abstract val getter: IrSimpleFunctionSymbol
abstract val setter: IrSimpleFunctionSymbol?
override val valueArgumentsCount: Int
get() = 0
}
@@ -23,7 +23,3 @@ abstract class IrLoop : IrExpression() {
lateinit var condition: IrExpression
var label: String? = null
}
abstract class IrWhileLoop : IrLoop()
abstract class IrDoWhileLoop : IrLoop()
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
abstract class IrPropertyReference(typeArgumentsCount: Int) : IrCallableReference<IrPropertySymbol>(typeArgumentsCount) {
abstract val field: IrFieldSymbol?
abstract val getter: IrSimpleFunctionSymbol?
abstract val setter: IrSimpleFunctionSymbol?
override val valueArgumentsCount: Int
get() = 0
}
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
/**
* Platform-specific low-level reference to function.
*
* On JS platform it represents a plain reference to JavaScript function.
* On JVM platform it represents a MethodHandle constant.
*/
abstract class IrRawFunctionReference : IrDeclarationReference() {
abstract override val symbol: IrFunctionSymbol
}
@@ -0,0 +1,17 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.declarations.IrReturnTarget
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
abstract class IrReturnableBlock : IrBlock(), IrSymbolOwner, IrReturnTarget {
abstract override val symbol: IrReturnableBlockSymbol
abstract val inlineFunctionSymbol: IrFunctionSymbol?
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 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
abstract class IrSetField : IrFieldAccessExpression() {
abstract var value: IrExpression
}
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
abstract class IrSetValue : IrValueAccessExpression() {
abstract override val symbol: IrValueSymbol
abstract var value: IrExpression
}
@@ -0,0 +1,17 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
abstract class IrSpreadElement : IrElementBase(), IrVarargElement {
abstract var expression: IrExpression
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrElement =
accept(transformer, data) as IrSpreadElement
}
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2021 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
abstract class IrSuspendableExpression : IrExpression() {
abstract var suspensionPointId: IrExpression
abstract var result: IrExpression
}
@@ -12,8 +12,3 @@ abstract class IrSuspensionPoint : IrExpression() {
abstract var result: IrExpression
abstract var resumeResult: IrExpression
}
abstract class IrSuspendableExpression : IrExpression() {
abstract var suspensionPointId: IrExpression
abstract var result: IrExpression
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 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
abstract class IrSyntheticBody : IrBody() {
abstract val kind: IrSyntheticBodyKind
}
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2021 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
enum class IrSyntheticBodyKind {
ENUM_VALUES,
ENUM_VALUEOF
}
@@ -16,10 +16,6 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
abstract class IrTry : IrExpression() {
abstract var tryResult: IrExpression
@@ -27,11 +23,3 @@ abstract class IrTry : IrExpression() {
abstract var finallyExpression: IrExpression?
}
abstract class IrCatch : IrElementBase() {
abstract var catchParameter: IrVariable
abstract var result: IrExpression
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrCatch =
super.transform(transformer, data) as IrCatch
}
@@ -16,9 +16,6 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.types.IrType
enum class IrTypeOperator {
/** Explicit cast: `e as Type` */
CAST,
@@ -65,10 +62,3 @@ enum class IrTypeOperator {
*/
REINTERPRET_CAST;
}
abstract class IrTypeOperatorCall : IrExpression() {
abstract val operator: IrTypeOperator
abstract var argument: IrExpression
abstract var typeOperand: IrType
abstract val typeOperandClassifier: IrClassifierSymbol
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.types.IrType
abstract class IrTypeOperatorCall : IrExpression() {
abstract val operator: IrTypeOperator
abstract var argument: IrExpression
abstract var typeOperand: IrType
abstract val typeOperandClassifier: IrClassifierSymbol
}
@@ -22,12 +22,3 @@ abstract class IrValueAccessExpression : IrDeclarationReference() {
abstract override val symbol: IrValueSymbol
abstract val origin: IrStatementOrigin?
}
abstract class IrGetValue : IrValueAccessExpression() {
abstract fun copyWithOffsets(newStartOffset: Int, newEndOffset: Int): IrGetValue
}
abstract class IrSetValue : IrValueAccessExpression() {
abstract override val symbol: IrValueSymbol
abstract var value: IrExpression
}
@@ -16,12 +16,7 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
interface IrVarargElement : IrElement
abstract class IrVararg : IrExpression() {
abstract var varargElementType: IrType
@@ -30,10 +25,3 @@ abstract class IrVararg : IrExpression() {
abstract fun putElement(i: Int, element: IrVarargElement)
}
abstract class IrSpreadElement : IrElementBase(), IrVarargElement {
abstract var expression: IrExpression
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrElement =
accept(transformer, data) as IrSpreadElement
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2021 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
import org.jetbrains.kotlin.ir.IrElement
interface IrVarargElement : IrElement
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -38,22 +37,3 @@ abstract class IrWhen : IrExpression() {
}
}
}
abstract class IrBranch : IrElementBase() {
abstract var condition: IrExpression
abstract var result: IrExpression
abstract override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrBranch
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
condition.accept(visitor, data)
result.accept(visitor, data)
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
condition = condition.transform(transformer, data)
result = result.transform(transformer, data)
}
}
abstract class IrElseBranch : IrBranch()
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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
abstract class IrWhileLoop : IrLoop()
@@ -278,11 +278,3 @@ interface IrElementVisitorVoid : IrElementVisitor<Unit, Nothing?> {
fun visitErrorCallExpression(expression: IrErrorCallExpression) = visitErrorExpression(expression)
override fun visitErrorCallExpression(expression: IrErrorCallExpression, data: Nothing?) = visitErrorCallExpression(expression)
}
fun IrElement.acceptVoid(visitor: IrElementVisitorVoid) {
accept(visitor, null)
}
fun IrElement.acceptChildrenVoid(visitor: IrElementVisitorVoid) {
acceptChildren(visitor, null)
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2022 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.visitors
import org.jetbrains.kotlin.ir.IrElement
fun IrElement.acceptVoid(visitor: IrElementVisitorVoid) {
accept(visitor, null)
}
fun IrElement.acceptChildrenVoid(visitor: IrElementVisitorVoid) {
acceptChildren(visitor, null)
}