IR: make IrExpression and subtypes classes

This commit is contained in:
Alexander Udalov
2020-07-22 21:46:03 +02:00
parent ba7ff36274
commit 4351f5235b
47 changed files with 164 additions and 255 deletions
@@ -42,7 +42,7 @@ data class LoopBounds(val headState: SuspendState, val exitState: SuspendState)
data class TryState(val tryState: SuspendState, val catchState: SuspendState)
class IrDispatchPoint(val target: SuspendState) : IrExpressionBase() {
class IrDispatchPoint(val target: SuspendState) : IrExpression() {
override val startOffset: Int get() = UNDEFINED_OFFSET
override val endOffset: Int get() = UNDEFINED_OFFSET
@@ -16,31 +16,46 @@
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.file
import org.jetbrains.kotlin.ir.util.transform
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
interface IrContainerExpression : IrExpression, IrStatementContainer {
val origin: IrStatementOrigin?
val isTransparentScope: Boolean
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.transform { it.transform(transformer, data) }
}
}
interface IrBlock : IrContainerExpression {
abstract class IrBlock : IrContainerExpression() {
override val isTransparentScope: Boolean
get() = false
}
interface IrComposite : IrContainerExpression {
abstract class IrComposite : IrContainerExpression() {
override val isTransparentScope: Boolean
get() = true
}
interface IrReturnableBlock : IrBlock, IrSymbolOwner, IrReturnTarget {
override val symbol: IrReturnableBlockSymbol
val inlineFunctionSymbol: IrFunctionSymbol?
abstract class IrReturnableBlock : IrBlock(), IrSymbolOwner, IrReturnTarget {
abstract override val symbol: IrReturnableBlockSymbol
abstract val inlineFunctionSymbol: IrFunctionSymbol?
}
val IrReturnableBlock.sourceFileSymbol: IrFileSymbol?
@@ -16,11 +16,12 @@
package org.jetbrains.kotlin.ir.expressions
interface IrBreakContinue : IrExpression {
var loop: IrLoop
val label: String?
abstract class IrBreakContinue : IrExpression() {
abstract var loop: IrLoop
var label: String? = null
}
interface IrBreak : IrBreakContinue
abstract class IrBreak : IrBreakContinue()
interface IrContinue : IrBreakContinue
abstract class IrContinue : IrBreakContinue()
@@ -16,11 +16,11 @@
package org.jetbrains.kotlin.ir.expressions
interface IrConst<T> : IrExpression, IrExpressionWithCopy {
val kind: IrConstKind<T>
val value: T
abstract class IrConst<T> : IrExpression(), IrExpressionWithCopy {
abstract val kind: IrConstKind<T>
abstract val value: T
override fun copy(): IrConst<T>
abstract override fun copy(): IrConst<T>
}
sealed class IrConstKind<T>(val asString: kotlin.String) {
@@ -41,4 +41,3 @@ sealed class IrConstKind<T>(val asString: kotlin.String) {
override fun toString() = asString
}
@@ -16,13 +16,12 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase
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 : IrExpressionBase() {
abstract class IrDeclarationReference : IrExpression() {
abstract val symbol: IrSymbol
}
@@ -5,14 +5,14 @@
package org.jetbrains.kotlin.ir.expressions
interface IrDynamicExpression : IrExpression
abstract class IrDynamicExpression : IrExpression()
interface IrDynamicOperatorExpression : IrDynamicExpression {
val operator: IrDynamicOperator
abstract class IrDynamicOperatorExpression : IrDynamicExpression() {
abstract val operator: IrDynamicOperator
var receiver: IrExpression
abstract var receiver: IrExpression
val arguments: MutableList<IrExpression>
abstract val arguments: MutableList<IrExpression>
}
var IrDynamicOperatorExpression.left: IrExpression
@@ -30,9 +30,10 @@ var IrDynamicOperatorExpression.right: IrExpression
arguments[0] = value
}
interface IrDynamicMemberExpression : IrDynamicExpression {
val memberName: String
var receiver: IrExpression
abstract class IrDynamicMemberExpression : IrDynamicExpression() {
abstract val memberName: String
abstract var receiver: IrExpression
}
enum class IrDynamicOperator(val image: String, val isAssignmentOperator: Boolean = false) {
@@ -69,4 +70,4 @@ enum class IrDynamicOperator(val image: String, val isAssignmentOperator: Boolea
ARRAY_ACCESS("[]"),
INVOKE("()")
}
}
@@ -16,12 +16,11 @@
package org.jetbrains.kotlin.ir.expressions
interface IrErrorExpression : IrExpression {
val description: String
abstract class IrErrorExpression : IrExpression() {
abstract val description: String
}
interface IrErrorCallExpression : IrErrorExpression {
var explicitReceiver: IrExpression?
val arguments: MutableList<IrExpression>
abstract class IrErrorCallExpression : IrErrorExpression() {
abstract var explicitReceiver: IrExpression?
abstract val arguments: MutableList<IrExpression>
}
@@ -16,16 +16,29 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
interface IrExpression : IrStatement, IrVarargElement, IrAttributeContainer {
val type: IrType
abstract class IrExpression : IrElementBase(), IrStatement, IrVarargElement, IrAttributeContainer {
@Suppress("LeakingThis")
override var attributeOwnerId: IrAttributeContainer = this
abstract val type: IrType
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpression =
accept(transformer, data) as IrExpression
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
// No children by default
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
// No children by default
}
}
interface IrExpressionWithCopy {
@@ -7,7 +7,8 @@ package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
interface IrFunctionExpression : IrExpression {
val origin: IrStatementOrigin
var function: IrSimpleFunction
}
abstract class IrFunctionExpression : IrExpression() {
abstract val origin: IrStatementOrigin
abstract var function: IrSimpleFunction
}
@@ -16,8 +16,6 @@
package org.jetbrains.kotlin.ir.expressions
interface IrGetClass : IrExpression {
var argument: IrExpression
abstract class IrGetClass : IrExpression() {
abstract var argument: IrExpression
}
@@ -18,6 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
interface IrInstanceInitializerCall : IrExpression {
val classSymbol: IrClassSymbol
abstract class IrInstanceInitializerCall : IrExpression() {
abstract val classSymbol: IrClassSymbol
}
@@ -16,13 +16,14 @@
package org.jetbrains.kotlin.ir.expressions
interface IrLoop : IrExpression {
val origin: IrStatementOrigin?
var body: IrExpression?
var condition: IrExpression
var label: String?
abstract class IrLoop : IrExpression() {
abstract val origin: IrStatementOrigin?
var body: IrExpression? = null
lateinit var condition: IrExpression
var label: String? = null
}
interface IrWhileLoop : IrLoop
abstract class IrWhileLoop : IrLoop()
interface IrDoWhileLoop : IrLoop
abstract class IrDoWhileLoop : IrLoop()
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
interface IrReturn : IrExpression {
var value: IrExpression
val returnTargetSymbol: IrReturnTargetSymbol
abstract class IrReturn : IrExpression() {
abstract var value: IrExpression
abstract val returnTargetSymbol: IrReturnTargetSymbol
}
@@ -16,8 +16,8 @@
package org.jetbrains.kotlin.ir.expressions
interface IrStringConcatenation : IrExpression {
val arguments: List<IrExpression>
fun addArgument(argument: IrExpression)
}
abstract class IrStringConcatenation : IrExpression() {
abstract val arguments: List<IrExpression>
abstract fun addArgument(argument: IrExpression)
}
@@ -7,14 +7,13 @@ package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.declarations.IrVariable
interface IrSuspensionPoint : IrExpression {
var suspensionPointIdParameter: IrVariable
var result: IrExpression
var resumeResult: IrExpression
abstract class IrSuspensionPoint : IrExpression() {
abstract var suspensionPointIdParameter: IrVariable
abstract var result: IrExpression
abstract var resumeResult: IrExpression
}
interface IrSuspendableExpression : IrExpression {
var suspensionPointId: IrExpression
var result: IrExpression
abstract class IrSuspendableExpression : IrExpression() {
abstract var suspensionPointId: IrExpression
abstract var result: IrExpression
}
@@ -16,8 +16,6 @@
package org.jetbrains.kotlin.ir.expressions
interface IrThrow : IrExpression {
var value: IrExpression
abstract class IrThrow : IrExpression() {
abstract var value: IrExpression
}
@@ -20,12 +20,12 @@ import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
interface IrTry : IrExpression {
var tryResult: IrExpression
abstract class IrTry : IrExpression() {
abstract var tryResult: IrExpression
val catches: List<IrCatch>
abstract val catches: List<IrCatch>
var finallyExpression: IrExpression?
abstract var finallyExpression: IrExpression?
}
interface IrCatch : IrElement {
@@ -22,43 +22,53 @@ import org.jetbrains.kotlin.ir.types.IrType
enum class IrTypeOperator {
/** Explicit cast: `e as Type` */
CAST,
/** Implicit cast: value of type `A` is used where a value of type `B` is expected */
IMPLICIT_CAST,
/** Implicit cast from a value of nullability flexible type `A!` to non-null type `B`, `B :> A` */
IMPLICIT_NOTNULL,
/** Implicit coercion to Unit: expression of type `A, !(A <: kotlin.Unit)` is used where `kotlin.Unit` is expected */
IMPLICIT_COERCION_TO_UNIT,
/**
* Implicit integer coercion: expression of integer type `A` (`kotlin.Int`, `kotlin.Byte`, ...)
* is used where another integer type `B` (`kotlin.Int`, `kotlin.Byte`, ...) is expected.
* This mostly happens for constant expressions.
*/
IMPLICIT_INTEGER_COERCION,
/** Safe cast: `e as? Type` */
SAFE_CAST,
/** Instance-of check: `a is Type` */
INSTANCEOF,
/** Instance-of check: `a !is Type` */
NOT_INSTANCEOF, // TODO drop and replace with `INSTANCEOF<T>(x).not()`?
/**
* SAM conversion: value of functional type F is used where Single Abstract Method interface value is expected.
* Currently this is possible in Kotlin/JVM only, however, there's a big demand for SAM conversion for Kotlin interfaces.
*/
SAM_CONVERSION,
/**
* Implicit dynamic cast: implicit cast from `dynamic` to `T`.
* This currently can happen in Kotlin/JS only.
*/
IMPLICIT_DYNAMIC_CAST,
/**
* C-like reinterpret_cast<T> using as primitive type operation in JS
*/
REINTERPRET_CAST;
}
interface IrTypeOperatorCall : IrExpression {
val operator: IrTypeOperator
var argument: IrExpression
val typeOperand: IrType
val typeOperandClassifier: IrClassifierSymbol
abstract class IrTypeOperatorCall : IrExpression() {
abstract val operator: IrTypeOperator
abstract var argument: IrExpression
abstract val typeOperand: IrType
abstract val typeOperandClassifier: IrClassifierSymbol
}
@@ -22,12 +22,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
interface IrVarargElement : IrElement
interface IrVararg : IrExpression {
val varargElementType: IrType
abstract class IrVararg : IrExpression() {
abstract val varargElementType: IrType
val elements: List<IrVarargElement>
abstract val elements: List<IrVarargElement>
fun putElement(i: Int, element: IrVarargElement)
abstract fun putElement(i: Int, element: IrVarargElement)
}
interface IrSpreadElement : IrVarargElement {
@@ -36,4 +36,3 @@ interface IrSpreadElement : IrVarargElement {
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrElement =
accept(transformer, data) as IrSpreadElement
}
@@ -18,11 +18,25 @@ package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
interface IrWhen : IrExpression {
val origin: IrStatementOrigin?
abstract class IrWhen : IrExpression() {
abstract val origin: IrStatementOrigin?
val branches: MutableList<IrBranch>
abstract val branches: MutableList<IrBranch>
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitWhen(this, data)
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
branches.forEach { it.accept(visitor, data) }
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
branches.forEachIndexed { i, irBranch ->
branches[i] = irBranch.transform(transformer, data)
}
}
}
interface IrBranch : IrElement {
@@ -33,7 +33,7 @@ class IrBlockImpl(
override val endOffset: Int,
override val type: IrType,
override val origin: IrStatementOrigin? = null,
) : IrContainerExpressionBase(), IrBlock {
) : IrBlock() {
constructor(
startOffset: Int,
endOffset: Int,
@@ -67,7 +67,7 @@ class IrReturnableBlockImpl(
override val symbol: IrReturnableBlockSymbol,
override val origin: IrStatementOrigin? = null,
override val inlineFunctionSymbol: IrFunctionSymbol? = null
) : IrContainerExpressionBase(), IrReturnableBlock {
) : IrReturnableBlock() {
@ObsoleteDescriptorBasedAPI
override val descriptor: FunctionDescriptor
get() = symbol.descriptor
@@ -1,23 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* 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
import org.jetbrains.kotlin.ir.expressions.IrBreakContinue
abstract class IrBreakContinueBase : IrExpressionBase(), IrBreakContinue {
override var label: String? = null
}
@@ -26,7 +26,7 @@ class IrBreakImpl(
override val endOffset: Int,
override val type: IrType,
override var loop: IrLoop,
) : IrBreakContinueBase(), IrBreak {
) : IrBreak() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitBreak(this, data)
}
@@ -27,7 +27,7 @@ class IrCompositeImpl(
override val endOffset: Int,
override val type: IrType,
override val origin: IrStatementOrigin? = null,
) : IrContainerExpressionBase(), IrComposite {
) : IrComposite() {
constructor(
startOffset: Int,
endOffset: Int,
@@ -27,7 +27,7 @@ class IrConstImpl<T>(
override val type: IrType,
override val kind: IrConstKind<T>,
override val value: T
) : IrExpressionBase(), IrConst<T> {
) : IrConst<T>() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitConst(this, data)
@@ -1,36 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* 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
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.expressions.IrContainerExpression
import org.jetbrains.kotlin.ir.util.transform
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
import java.util.*
abstract class IrContainerExpressionBase : IrExpressionBase(), IrContainerExpression {
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.transform { it.transform(transformer, data) }
}
}
@@ -26,7 +26,7 @@ class IrContinueImpl(
override val endOffset: Int,
override val type: IrType,
override var loop: IrLoop,
) : IrBreakContinueBase(), IrContinue {
) : IrContinue() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitContinue(this, data)
}
@@ -27,7 +27,7 @@ class IrDoWhileLoopImpl(
override val endOffset: Int,
override val type: IrType,
override val origin: IrStatementOrigin?,
) : IrLoopBase(), IrDoWhileLoop {
) : IrDoWhileLoop() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitDoWhileLoop(this, data)
}
@@ -17,7 +17,7 @@ class IrDynamicMemberExpressionImpl(
override val type: IrType,
override val memberName: String,
override var receiver: IrExpression
) : IrExpressionBase(), IrDynamicMemberExpression {
) : IrDynamicMemberExpression() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitDynamicMemberExpression(this, data)
@@ -18,7 +18,7 @@ class IrDynamicOperatorExpressionImpl(
override val endOffset: Int,
override val type: IrType,
override val operator: IrDynamicOperator
) : IrExpressionBase(), IrDynamicOperatorExpression {
) : IrDynamicOperatorExpression() {
override lateinit var receiver: IrExpression
override val arguments: MutableList<IrExpression> = SmartList()
@@ -28,7 +28,7 @@ class IrErrorCallExpressionImpl(
override val endOffset: Int,
override val type: IrType,
override val description: String
) : IrExpressionBase(), IrErrorCallExpression {
) : IrErrorCallExpression() {
override var explicitReceiver: IrExpression? = null
override val arguments: MutableList<IrExpression> = SmartList()
@@ -26,7 +26,7 @@ class IrErrorExpressionImpl(
override val endOffset: Int,
override val type: IrType,
override val description: String
) : IrExpressionBase(), IrExpressionWithCopy, IrErrorExpression {
) : IrErrorExpression(), IrExpressionWithCopy {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitErrorExpression(this, data)
@@ -1,36 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* 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
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrExpressionBase : IrElementBase(), IrExpression {
@Suppress("LeakingThis")
override var attributeOwnerId: IrAttributeContainer = this
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
// No children by default
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
// No children by default
}
}
@@ -18,7 +18,7 @@ class IrFunctionExpressionImpl(
override val type: IrType,
override var function: IrSimpleFunction,
override val origin: IrStatementOrigin
) : IrExpressionBase(), IrFunctionExpression {
) : IrFunctionExpression() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitFunctionExpression(this, data)
}
@@ -27,7 +27,7 @@ class IrGetClassImpl(
override val endOffset: Int,
override val type: IrType,
override var argument: IrExpression,
) : IrExpressionBase(), IrGetClass {
) : IrGetClass() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitGetClass(this, data)
}
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrBranch
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.IrWhen
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.utils.SmartList
@@ -26,6 +27,6 @@ class IrIfThenElseImpl(
override val endOffset: Int,
override val type: IrType,
override val origin: IrStatementOrigin? = null
) : IrWhenBase() {
) : IrWhen() {
override val branches: MutableList<IrBranch> = SmartList()
}
@@ -26,7 +26,7 @@ class IrInstanceInitializerCallImpl(
override val endOffset: Int,
override val classSymbol: IrClassSymbol,
override val type: IrType,
) : IrExpressionBase(), IrInstanceInitializerCall {
) : IrInstanceInitializerCall() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitInstanceInitializerCall(this, data)
}
@@ -1,28 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* 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
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrLoop
abstract class IrLoopBase : IrExpressionBase(), IrLoop {
override var label: String? = null
override lateinit var condition: IrExpression
override var body: IrExpression? = null
}
@@ -29,7 +29,7 @@ class IrReturnImpl(
override val type: IrType,
override val returnTargetSymbol: IrReturnTargetSymbol,
override var value: IrExpression
) : IrExpressionBase(), IrReturn {
) : IrReturn() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitReturn(this, data)
@@ -27,7 +27,7 @@ class IrStringConcatenationImpl(
override val startOffset: Int,
override val endOffset: Int,
override val type: IrType
) : IrExpressionBase(), IrStringConcatenation {
) : IrStringConcatenation() {
constructor(
startOffset: Int,
endOffset: Int,
@@ -20,7 +20,7 @@ class IrSuspensionPointImpl(
override var suspensionPointIdParameter: IrVariable,
override var result: IrExpression,
override var resumeResult: IrExpression
) : IrExpressionBase(), IrSuspensionPoint {
) : IrSuspensionPoint() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitSuspensionPoint(this, data)
@@ -43,8 +43,7 @@ class IrSuspendableExpressionImpl(
override val type: IrType,
override var suspensionPointId: IrExpression,
override var result: IrExpression
) : IrExpressionBase(), IrSuspendableExpression {
) : IrSuspendableExpression() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitSuspendableExpression(this, data)
@@ -27,7 +27,7 @@ class IrThrowImpl(
override val endOffset: Int,
override val type: IrType,
override var value: IrExpression,
) : IrExpressionBase(), IrThrow {
) : IrThrow() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitThrow(this, data)
@@ -30,7 +30,7 @@ class IrTryImpl(
override val startOffset: Int,
override val endOffset: Int,
override val type: IrType,
) : IrExpressionBase(), IrTry {
) : IrTry() {
constructor(
startOffset: Int,
endOffset: Int,
@@ -32,7 +32,7 @@ class IrTypeOperatorCallImpl(
override val operator: IrTypeOperator,
override val typeOperand: IrType,
override var argument: IrExpression,
) : IrExpressionBase(), IrTypeOperatorCall {
) : IrTypeOperatorCall() {
override val typeOperandClassifier: IrClassifierSymbol
get() = typeOperand.classifierOrFail
@@ -28,7 +28,7 @@ class IrVarargImpl(
override val endOffset: Int,
override val type: IrType,
override val varargElementType: IrType
) : IrExpressionBase(), IrVararg {
) : IrVararg() {
constructor(
startOffset: Int,
endOffset: Int,
@@ -23,27 +23,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
import java.util.*
abstract class IrWhenBase : IrExpressionBase(), IrWhen {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitWhen(this, data)
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
branches.forEach { it.accept(visitor, data) }
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
branches.forEachIndexed { i, irBranch ->
branches[i] = irBranch.transform(transformer, data)
}
}
}
class IrWhenImpl(
override val startOffset: Int,
override val endOffset: Int,
override val type: IrType,
override val origin: IrStatementOrigin? = null
) : IrWhenBase() {
) : IrWhen() {
constructor(
startOffset: Int,
endOffset: Int,
@@ -27,7 +27,7 @@ class IrWhileLoopImpl(
override val endOffset: Int,
override val type: IrType,
override val origin: IrStatementOrigin?,
) : IrLoopBase(), IrWhileLoop {
) : IrWhileLoop() {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitWhileLoop(this, data)
}