Formatting: ir.tree and some common code
This commit is contained in:
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.resolve.calls.components.isVararg
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
|
||||
@@ -29,15 +29,15 @@ interface IrElement {
|
||||
fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D): Unit
|
||||
|
||||
fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrElement =
|
||||
accept(transformer, data)
|
||||
accept(transformer, data)
|
||||
|
||||
fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D): Unit
|
||||
}
|
||||
|
||||
interface IrStatement : IrElement {
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrStatement =
|
||||
super.transform(transformer, data) as IrStatement
|
||||
super.transform(transformer, data) as IrStatement
|
||||
}
|
||||
|
||||
inline fun <reified T : IrElement> IrElement.assertCast(): T =
|
||||
if (this is T) this else throw AssertionError("Expected ${T::class.simpleName}: $this")
|
||||
if (this is T) this else throw AssertionError("Expected ${T::class.simpleName}: $this")
|
||||
|
||||
@@ -21,13 +21,13 @@ import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
const val UNDEFINED_OFFSET: Int = -1
|
||||
|
||||
data class SourceRangeInfo(
|
||||
val filePath: String,
|
||||
val startOffset: Int,
|
||||
val startLineNumber: Int,
|
||||
val startColumnNumber: Int,
|
||||
val endOffset: Int,
|
||||
val endLineNumber: Int,
|
||||
val endColumnNumber: Int
|
||||
val filePath: String,
|
||||
val startOffset: Int,
|
||||
val startLineNumber: Int,
|
||||
val startColumnNumber: Int,
|
||||
val endOffset: Int,
|
||||
val endLineNumber: Int,
|
||||
val endColumnNumber: Int
|
||||
)
|
||||
|
||||
interface SourceManager {
|
||||
|
||||
@@ -29,10 +29,10 @@ import org.jetbrains.kotlin.utils.addToStdlib.assertedCast
|
||||
|
||||
|
||||
inline fun IrBuilderWithScope.irLet(
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
nameHint: String? = null,
|
||||
body: (VariableDescriptor) -> IrExpression
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
nameHint: String? = null,
|
||||
body: (VariableDescriptor) -> IrExpression
|
||||
): IrExpression {
|
||||
val irTemporary = scope.createTemporaryVariable(value, nameHint)
|
||||
val irResult = body(irTemporary.descriptor)
|
||||
@@ -43,10 +43,10 @@ inline fun IrBuilderWithScope.irLet(
|
||||
}
|
||||
|
||||
inline fun IrBuilderWithScope.irLetS(
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
nameHint: String? = null,
|
||||
body: (IrValueSymbol) -> IrExpression
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
nameHint: String? = null,
|
||||
body: (IrValueSymbol) -> IrExpression
|
||||
): IrExpression {
|
||||
val irTemporary = scope.createTemporaryVariable(value, nameHint)
|
||||
val irResult = body(irTemporary.symbol)
|
||||
@@ -83,95 +83,108 @@ fun <T : IrElement> IrStatementsBuilder<T>.defineTemporaryVar(value: IrExpressio
|
||||
}
|
||||
|
||||
fun IrBuilderWithScope.irExprBody(value: IrExpression) =
|
||||
IrExpressionBodyImpl(startOffset, endOffset, value)
|
||||
IrExpressionBodyImpl(startOffset, endOffset, value)
|
||||
|
||||
fun IrBuilderWithScope.irReturn(value: IrExpression) =
|
||||
IrReturnImpl(startOffset, endOffset, context.builtIns.nothingType,
|
||||
scope.scopeOwnerSymbol.assertedCast<IrFunctionSymbol> {
|
||||
"Function scope expected: ${scope.scopeOwner}"
|
||||
},
|
||||
value)
|
||||
IrReturnImpl(
|
||||
startOffset, endOffset, context.builtIns.nothingType,
|
||||
scope.scopeOwnerSymbol.assertedCast<IrFunctionSymbol> {
|
||||
"Function scope expected: ${scope.scopeOwner}"
|
||||
},
|
||||
value
|
||||
)
|
||||
|
||||
fun IrBuilderWithScope.irReturnTrue() =
|
||||
irReturn(IrConstImpl(startOffset, endOffset, context.builtIns.booleanType, IrConstKind.Boolean, true))
|
||||
irReturn(IrConstImpl(startOffset, endOffset, context.builtIns.booleanType, IrConstKind.Boolean, true))
|
||||
|
||||
fun IrBuilderWithScope.irReturnFalse() =
|
||||
irReturn(IrConstImpl(startOffset, endOffset, context.builtIns.booleanType, IrConstKind.Boolean, false))
|
||||
irReturn(IrConstImpl(startOffset, endOffset, context.builtIns.booleanType, IrConstKind.Boolean, false))
|
||||
|
||||
fun IrBuilderWithScope.irIfThenElse(type: KotlinType, condition: IrExpression, thenPart: IrExpression, elsePart: IrExpression) =
|
||||
IrIfThenElseImpl(startOffset, endOffset, type, condition, thenPart, elsePart)
|
||||
IrIfThenElseImpl(startOffset, endOffset, type, condition, thenPart, elsePart)
|
||||
|
||||
fun IrBuilderWithScope.irIfNull(type: KotlinType, subject: IrExpression, thenPart: IrExpression, elsePart: IrExpression) =
|
||||
irIfThenElse(type, irEqualsNull(subject), thenPart, elsePart)
|
||||
irIfThenElse(type, irEqualsNull(subject), thenPart, elsePart)
|
||||
|
||||
fun IrBuilderWithScope.irThrowNpe(origin: IrStatementOrigin) =
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, origin, context.irBuiltIns.throwNpeSymbol)
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, origin, context.irBuiltIns.throwNpeSymbol)
|
||||
|
||||
fun IrBuilderWithScope.irIfThenReturnTrue(condition: IrExpression) =
|
||||
IrIfThenElseImpl(startOffset, endOffset, context.builtIns.unitType, condition, irReturnTrue())
|
||||
IrIfThenElseImpl(startOffset, endOffset, context.builtIns.unitType, condition, irReturnTrue())
|
||||
|
||||
fun IrBuilderWithScope.irIfThenReturnFalse(condition: IrExpression) =
|
||||
IrIfThenElseImpl(startOffset, endOffset, context.builtIns.unitType, condition, irReturnFalse())
|
||||
IrIfThenElseImpl(startOffset, endOffset, context.builtIns.unitType, condition, irReturnFalse())
|
||||
|
||||
fun IrBuilderWithScope.irGet(variable: IrValueSymbol) =
|
||||
IrGetValueImpl(startOffset, endOffset, variable)
|
||||
IrGetValueImpl(startOffset, endOffset, variable)
|
||||
|
||||
fun IrBuilderWithScope.irSetVar(variable: IrVariableSymbol, value: IrExpression) =
|
||||
IrSetVariableImpl(startOffset, endOffset, variable, value, IrStatementOrigin.EQ)
|
||||
IrSetVariableImpl(startOffset, endOffset, variable, value, IrStatementOrigin.EQ)
|
||||
|
||||
fun IrBuilderWithScope.irEqeqeq(arg1: IrExpression, arg2: IrExpression) =
|
||||
context.eqeqeq(startOffset, endOffset, arg1, arg2)
|
||||
context.eqeqeq(startOffset, endOffset, arg1, arg2)
|
||||
|
||||
fun IrBuilderWithScope.irNull() =
|
||||
IrConstImpl.constNull(startOffset, endOffset, context.builtIns.nullableNothingType)
|
||||
IrConstImpl.constNull(startOffset, endOffset, context.builtIns.nullableNothingType)
|
||||
|
||||
fun IrBuilderWithScope.irEqualsNull(argument: IrExpression) =
|
||||
primitiveOp2(startOffset, endOffset, context.irBuiltIns.eqeqSymbol, IrStatementOrigin.EQEQ,
|
||||
argument, irNull())
|
||||
primitiveOp2(
|
||||
startOffset, endOffset, context.irBuiltIns.eqeqSymbol, IrStatementOrigin.EQEQ,
|
||||
argument, irNull()
|
||||
)
|
||||
|
||||
fun IrBuilderWithScope.irNotEquals(arg1: IrExpression, arg2: IrExpression) =
|
||||
primitiveOp1(startOffset, endOffset, context.irBuiltIns.booleanNotSymbol, IrStatementOrigin.EXCLEQ,
|
||||
primitiveOp2(startOffset, endOffset, context.irBuiltIns.eqeqSymbol, IrStatementOrigin.EXCLEQ,
|
||||
arg1, arg2))
|
||||
primitiveOp1(
|
||||
startOffset, endOffset, context.irBuiltIns.booleanNotSymbol, IrStatementOrigin.EXCLEQ,
|
||||
primitiveOp2(
|
||||
startOffset, endOffset, context.irBuiltIns.eqeqSymbol, IrStatementOrigin.EXCLEQ,
|
||||
arg1, arg2
|
||||
)
|
||||
)
|
||||
|
||||
fun IrBuilderWithScope.irGet(receiver: IrExpression, getterSymbol: IrFunctionSymbol): IrCall =
|
||||
IrGetterCallImpl(startOffset, endOffset, getterSymbol, getterSymbol.descriptor, null, receiver, null, IrStatementOrigin.GET_PROPERTY)
|
||||
IrGetterCallImpl(startOffset, endOffset, getterSymbol, getterSymbol.descriptor, null, receiver, null, IrStatementOrigin.GET_PROPERTY)
|
||||
|
||||
fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol, type: KotlinType): IrCall =
|
||||
IrCallImpl(startOffset, endOffset, type, callee, callee.descriptor, null)
|
||||
IrCallImpl(startOffset, endOffset, type, callee, callee.descriptor, null)
|
||||
|
||||
fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol): IrCall =
|
||||
irCall(callee, callee.descriptor.returnType!!)
|
||||
irCall(callee, callee.descriptor.returnType!!)
|
||||
|
||||
fun IrBuilderWithScope.irCallOp(callee: IrFunctionSymbol, dispatchReceiver: IrExpression, argument: IrExpression): IrCall =
|
||||
irCall(callee, callee.descriptor.returnType!!).apply {
|
||||
this.dispatchReceiver = dispatchReceiver
|
||||
putValueArgument(0, argument)
|
||||
}
|
||||
irCall(callee, callee.descriptor.returnType!!).apply {
|
||||
this.dispatchReceiver = dispatchReceiver
|
||||
putValueArgument(0, argument)
|
||||
}
|
||||
|
||||
fun IrBuilderWithScope.irCallOp(callee: IrFunctionSymbol, type: KotlinType, dispatchReceiver: IrExpression, argument: IrExpression): IrCall =
|
||||
irCall(callee, type).apply {
|
||||
this.dispatchReceiver = dispatchReceiver
|
||||
putValueArgument(0, argument)
|
||||
}
|
||||
fun IrBuilderWithScope.irCallOp(
|
||||
callee: IrFunctionSymbol,
|
||||
type: KotlinType,
|
||||
dispatchReceiver: IrExpression,
|
||||
argument: IrExpression
|
||||
): IrCall =
|
||||
irCall(callee, type).apply {
|
||||
this.dispatchReceiver = dispatchReceiver
|
||||
putValueArgument(0, argument)
|
||||
}
|
||||
|
||||
fun IrBuilderWithScope.irIs(argument: IrExpression, type: KotlinType) =
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, context.builtIns.booleanType, IrTypeOperator.INSTANCEOF, type, argument)
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, context.builtIns.booleanType, IrTypeOperator.INSTANCEOF, type, argument)
|
||||
|
||||
fun IrBuilderWithScope.irNotIs(argument: IrExpression, type: KotlinType) =
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, context.builtIns.booleanType, IrTypeOperator.NOT_INSTANCEOF, type, argument)
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, context.builtIns.booleanType, IrTypeOperator.NOT_INSTANCEOF, type, argument)
|
||||
|
||||
fun IrBuilderWithScope.irAs(argument: IrExpression, type: KotlinType) =
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.CAST, type, argument)
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.CAST, type, argument)
|
||||
|
||||
fun IrBuilderWithScope.irImplicitCast(argument: IrExpression, type: KotlinType) =
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.IMPLICIT_CAST, type, argument)
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.IMPLICIT_CAST, type, argument)
|
||||
|
||||
fun IrBuilderWithScope.irInt(value: Int) =
|
||||
IrConstImpl.int(startOffset, endOffset, context.builtIns.intType, value)
|
||||
IrConstImpl.int(startOffset, endOffset, context.builtIns.intType, value)
|
||||
|
||||
fun IrBuilderWithScope.irString(value: String) =
|
||||
IrConstImpl.string(startOffset, endOffset, context.builtIns.stringType, value)
|
||||
IrConstImpl.string(startOffset, endOffset, context.builtIns.stringType, value)
|
||||
|
||||
fun IrBuilderWithScope.irConcat() =
|
||||
IrStringConcatenationImpl(startOffset, endOffset, context.builtIns.stringType)
|
||||
IrStringConcatenationImpl(startOffset, endOffset, context.builtIns.stringType)
|
||||
|
||||
@@ -29,23 +29,23 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.util.*
|
||||
|
||||
abstract class IrBuilder(
|
||||
override val context: IrGeneratorContext,
|
||||
var startOffset: Int,
|
||||
var endOffset: Int
|
||||
override val context: IrGeneratorContext,
|
||||
var startOffset: Int,
|
||||
var endOffset: Int
|
||||
) : IrGenerator
|
||||
|
||||
abstract class IrBuilderWithScope(
|
||||
context: IrGeneratorContext,
|
||||
override val scope: Scope,
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
context: IrGeneratorContext,
|
||||
override val scope: Scope,
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
) : IrBuilder(context, startOffset, endOffset), IrGeneratorWithScope
|
||||
|
||||
abstract class IrStatementsBuilder<out T : IrElement>(
|
||||
context: IrGeneratorContext,
|
||||
scope: Scope,
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
context: IrGeneratorContext,
|
||||
scope: Scope,
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
) : IrBuilderWithScope(context, scope, startOffset, endOffset), IrGeneratorWithScope {
|
||||
operator fun IrStatement.unaryPlus() {
|
||||
addStatement(this)
|
||||
@@ -56,10 +56,10 @@ abstract class IrStatementsBuilder<out T : IrElement>(
|
||||
}
|
||||
|
||||
open class IrBlockBodyBuilder(
|
||||
context: IrGeneratorContext,
|
||||
scope: Scope,
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
context: IrGeneratorContext,
|
||||
scope: Scope,
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
) : IrStatementsBuilder<IrBlockBody>(context, scope, startOffset, endOffset) {
|
||||
private val irBlockBody = IrBlockBodyImpl(startOffset, endOffset)
|
||||
|
||||
@@ -78,10 +78,10 @@ open class IrBlockBodyBuilder(
|
||||
}
|
||||
|
||||
class IrBlockBuilder(
|
||||
context: IrGeneratorContext, scope: Scope,
|
||||
startOffset: Int, endOffset: Int,
|
||||
val origin: IrStatementOrigin? = null,
|
||||
var resultType: KotlinType? = null
|
||||
context: IrGeneratorContext, scope: Scope,
|
||||
startOffset: Int, endOffset: Int,
|
||||
val origin: IrStatementOrigin? = null,
|
||||
var resultType: KotlinType? = null
|
||||
) : IrStatementsBuilder<IrBlock>(context, scope, startOffset, endOffset) {
|
||||
private val statements = ArrayList<IrStatement>()
|
||||
|
||||
@@ -95,9 +95,7 @@ class IrBlockBuilder(
|
||||
}
|
||||
|
||||
override fun doBuild(): IrBlock {
|
||||
val resultType = this.resultType ?:
|
||||
(statements.lastOrNull() as? IrExpression)?.type ?:
|
||||
context.builtIns.unitType
|
||||
val resultType = this.resultType ?: (statements.lastOrNull() as? IrExpression)?.type ?: context.builtIns.unitType
|
||||
val irBlock = IrBlockImpl(startOffset, endOffset, resultType, origin)
|
||||
irBlock.statements.addAll(statements)
|
||||
return irBlock
|
||||
@@ -110,20 +108,24 @@ fun <T : IrBuilder> T.at(startOffset: Int, endOffset: Int): T {
|
||||
return this
|
||||
}
|
||||
|
||||
inline fun IrGeneratorWithScope.irBlock(startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET,
|
||||
origin: IrStatementOrigin? = null, resultType: KotlinType? = null,
|
||||
body: IrBlockBuilder.() -> Unit
|
||||
inline fun IrGeneratorWithScope.irBlock(
|
||||
startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET,
|
||||
origin: IrStatementOrigin? = null, resultType: KotlinType? = null,
|
||||
body: IrBlockBuilder.() -> Unit
|
||||
): IrExpression =
|
||||
IrBlockBuilder(context, scope,
|
||||
startOffset,
|
||||
endOffset,
|
||||
origin, resultType
|
||||
).block(body)
|
||||
IrBlockBuilder(
|
||||
context, scope,
|
||||
startOffset,
|
||||
endOffset,
|
||||
origin, resultType
|
||||
).block(body)
|
||||
|
||||
inline fun IrGeneratorWithScope.irBlockBody(startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET,
|
||||
body: IrBlockBodyBuilder.() -> Unit
|
||||
) : IrBlockBody =
|
||||
IrBlockBodyBuilder(context, scope,
|
||||
startOffset,
|
||||
endOffset
|
||||
).blockBody(body)
|
||||
inline fun IrGeneratorWithScope.irBlockBody(
|
||||
startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET,
|
||||
body: IrBlockBodyBuilder.() -> Unit
|
||||
): IrBlockBody =
|
||||
IrBlockBodyBuilder(
|
||||
context, scope,
|
||||
startOffset,
|
||||
endOffset
|
||||
).blockBody(body)
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
@Suppress("unused")
|
||||
@Deprecated("Migrate to symbols")
|
||||
class IrMemberFunctionBuilder(
|
||||
context: IrGeneratorContext,
|
||||
val irClass: IrClass,
|
||||
val function: FunctionDescriptor,
|
||||
val origin: IrDeclarationOrigin,
|
||||
startOffset: Int = UNDEFINED_OFFSET,
|
||||
endOffset: Int = UNDEFINED_OFFSET
|
||||
context: IrGeneratorContext,
|
||||
val irClass: IrClass,
|
||||
val function: FunctionDescriptor,
|
||||
val origin: IrDeclarationOrigin,
|
||||
startOffset: Int = UNDEFINED_OFFSET,
|
||||
endOffset: Int = UNDEFINED_OFFSET
|
||||
) : IrBlockBodyBuilder(context, Scope(function), startOffset, endOffset) {
|
||||
lateinit var irFunction: IrFunction
|
||||
|
||||
|
||||
@@ -22,50 +22,70 @@ import org.jetbrains.kotlin.ir.expressions.IrWhen
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
|
||||
fun primitiveOp1(startOffset: Int, endOffset: Int,
|
||||
primitiveOpSymbol: IrSimpleFunctionSymbol,
|
||||
origin: IrStatementOrigin,
|
||||
argument: IrExpression
|
||||
fun primitiveOp1(
|
||||
startOffset: Int, endOffset: Int,
|
||||
primitiveOpSymbol: IrSimpleFunctionSymbol,
|
||||
origin: IrStatementOrigin,
|
||||
argument: IrExpression
|
||||
): IrExpression =
|
||||
IrUnaryPrimitiveImpl(startOffset, endOffset, origin, primitiveOpSymbol, argument)
|
||||
IrUnaryPrimitiveImpl(startOffset, endOffset, origin, primitiveOpSymbol, argument)
|
||||
|
||||
fun primitiveOp2(startOffset: Int, endOffset: Int,
|
||||
primitiveOpSymbol: IrSimpleFunctionSymbol,
|
||||
origin: IrStatementOrigin,
|
||||
argument1: IrExpression, argument2: IrExpression
|
||||
fun primitiveOp2(
|
||||
startOffset: Int, endOffset: Int,
|
||||
primitiveOpSymbol: IrSimpleFunctionSymbol,
|
||||
origin: IrStatementOrigin,
|
||||
argument1: IrExpression, argument2: IrExpression
|
||||
): IrExpression =
|
||||
IrBinaryPrimitiveImpl(startOffset, endOffset, origin, primitiveOpSymbol, argument1, argument2)
|
||||
IrBinaryPrimitiveImpl(startOffset, endOffset, origin, primitiveOpSymbol, argument1, argument2)
|
||||
|
||||
fun IrGeneratorContext.constNull(startOffset: Int, endOffset: Int): IrExpression =
|
||||
IrConstImpl.constNull(startOffset, endOffset, builtIns.nullableNothingType)
|
||||
IrConstImpl.constNull(startOffset, endOffset, builtIns.nullableNothingType)
|
||||
|
||||
fun IrGeneratorContext.equalsNull(startOffset: Int, endOffset: Int, argument: IrExpression): IrExpression =
|
||||
primitiveOp2(startOffset, endOffset, irBuiltIns.eqeqSymbol, IrStatementOrigin.EQEQ,
|
||||
argument, constNull(startOffset, endOffset))
|
||||
primitiveOp2(
|
||||
startOffset, endOffset, irBuiltIns.eqeqSymbol, IrStatementOrigin.EQEQ,
|
||||
argument, constNull(startOffset, endOffset)
|
||||
)
|
||||
|
||||
fun IrGeneratorContext.eqeqeq(startOffset: Int, endOffset: Int, argument1: IrExpression, argument2: IrExpression): IrExpression =
|
||||
primitiveOp2(startOffset, endOffset, irBuiltIns.eqeqeqSymbol, IrStatementOrigin.EQEQEQ, argument1, argument2)
|
||||
primitiveOp2(startOffset, endOffset, irBuiltIns.eqeqeqSymbol, IrStatementOrigin.EQEQEQ, argument1, argument2)
|
||||
|
||||
fun IrGeneratorContext.throwNpe(startOffset: Int, endOffset: Int, origin: IrStatementOrigin): IrExpression =
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, origin, irBuiltIns.throwNpeSymbol)
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, origin, irBuiltIns.throwNpeSymbol)
|
||||
|
||||
// a || b == if (a) true else b
|
||||
fun IrGeneratorContext.oror(startOffset: Int, endOffset: Int, a: IrExpression, b: IrExpression, origin: IrStatementOrigin = IrStatementOrigin.OROR): IrWhen =
|
||||
IrIfThenElseImpl(startOffset, endOffset, builtIns.booleanType,
|
||||
a, IrConstImpl.constTrue(b.startOffset, b.endOffset, builtIns.booleanType), b,
|
||||
origin)
|
||||
fun IrGeneratorContext.oror(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
a: IrExpression,
|
||||
b: IrExpression,
|
||||
origin: IrStatementOrigin = IrStatementOrigin.OROR
|
||||
): IrWhen =
|
||||
IrIfThenElseImpl(
|
||||
startOffset, endOffset, builtIns.booleanType,
|
||||
a, IrConstImpl.constTrue(b.startOffset, b.endOffset, builtIns.booleanType), b,
|
||||
origin
|
||||
)
|
||||
|
||||
fun IrGeneratorContext.oror(a: IrExpression, b: IrExpression, origin: IrStatementOrigin = IrStatementOrigin.OROR): IrWhen =
|
||||
oror(b.startOffset, b.endOffset, a, b, origin)
|
||||
oror(b.startOffset, b.endOffset, a, b, origin)
|
||||
|
||||
fun IrGeneratorContext.whenComma(a: IrExpression, b: IrExpression): IrWhen =
|
||||
oror(a, b, IrStatementOrigin.WHEN_COMMA)
|
||||
oror(a, b, IrStatementOrigin.WHEN_COMMA)
|
||||
|
||||
// a && b == if (a) b else false
|
||||
fun IrGeneratorContext.andand(startOffset: Int, endOffset: Int, a: IrExpression, b: IrExpression, origin: IrStatementOrigin = IrStatementOrigin.ANDAND): IrWhen =
|
||||
IrIfThenElseImpl(startOffset, endOffset, builtIns.booleanType,
|
||||
a, b, IrConstImpl.constFalse(b.startOffset, b.endOffset, builtIns.booleanType),
|
||||
origin)
|
||||
fun IrGeneratorContext.andand(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
a: IrExpression,
|
||||
b: IrExpression,
|
||||
origin: IrStatementOrigin = IrStatementOrigin.ANDAND
|
||||
): IrWhen =
|
||||
IrIfThenElseImpl(
|
||||
startOffset, endOffset, builtIns.booleanType,
|
||||
a, b, IrConstImpl.constFalse(b.startOffset, b.endOffset, builtIns.booleanType),
|
||||
origin
|
||||
)
|
||||
|
||||
fun IrGeneratorContext.andand(a: IrExpression, b: IrExpression, origin: IrStatementOrigin = IrStatementOrigin.ANDAND): IrWhen =
|
||||
andand(b.startOffset, b.endOffset, a, b, origin)
|
||||
andand(b.startOffset, b.endOffset, a, b, origin)
|
||||
@@ -37,13 +37,17 @@ class Scope(val scopeOwnerSymbol: IrSymbol) {
|
||||
val scopeOwner: DeclarationDescriptor get() = scopeOwnerSymbol.descriptor
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(descriptor: DeclarationDescriptor): this(createSymbolForScopeOwner(descriptor))
|
||||
constructor(descriptor: DeclarationDescriptor) : this(createSymbolForScopeOwner(descriptor))
|
||||
|
||||
private var lastTemporaryIndex: Int = 0
|
||||
private fun nextTemporaryIndex(): Int = lastTemporaryIndex++
|
||||
|
||||
fun createDescriptorForTemporaryVariable(type: KotlinType, nameHint: String? = null, isMutable: Boolean = false): IrTemporaryVariableDescriptor =
|
||||
IrTemporaryVariableDescriptorImpl(scopeOwner, Name.identifier(getNameForTemporary(nameHint)), type, isMutable)
|
||||
fun createDescriptorForTemporaryVariable(
|
||||
type: KotlinType,
|
||||
nameHint: String? = null,
|
||||
isMutable: Boolean = false
|
||||
): IrTemporaryVariableDescriptor =
|
||||
IrTemporaryVariableDescriptorImpl(scopeOwner, Name.identifier(getNameForTemporary(nameHint)), type, isMutable)
|
||||
|
||||
private fun getNameForTemporary(nameHint: String?): String {
|
||||
val index = nextTemporaryIndex()
|
||||
@@ -51,24 +55,24 @@ class Scope(val scopeOwnerSymbol: IrSymbol) {
|
||||
}
|
||||
|
||||
fun createTemporaryVariable(
|
||||
irExpression: IrExpression,
|
||||
nameHint: String? = null,
|
||||
isMutable: Boolean = false,
|
||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
|
||||
irExpression: IrExpression,
|
||||
nameHint: String? = null,
|
||||
isMutable: Boolean = false,
|
||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
|
||||
): IrVariable =
|
||||
IrVariableImpl(
|
||||
irExpression.startOffset, irExpression.endOffset, origin,
|
||||
createDescriptorForTemporaryVariable(irExpression.type, nameHint, isMutable),
|
||||
irExpression
|
||||
)
|
||||
IrVariableImpl(
|
||||
irExpression.startOffset, irExpression.endOffset, origin,
|
||||
createDescriptorForTemporaryVariable(irExpression.type, nameHint, isMutable),
|
||||
irExpression
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("Creates unbound symbol")
|
||||
fun createSymbolForScopeOwner(descriptor: DeclarationDescriptor) =
|
||||
when (descriptor) {
|
||||
is ClassDescriptor -> IrClassSymbolImpl(descriptor)
|
||||
is FunctionDescriptor -> createFunctionSymbol(descriptor)
|
||||
is PropertyDescriptor -> IrFieldSymbolImpl(descriptor)
|
||||
else -> throw AssertionError("Unexpected scopeOwner descriptor: $descriptor")
|
||||
}
|
||||
when (descriptor) {
|
||||
is ClassDescriptor -> IrClassSymbolImpl(descriptor)
|
||||
is FunctionDescriptor -> createFunctionSymbol(descriptor)
|
||||
is PropertyDescriptor -> IrFieldSymbolImpl(descriptor)
|
||||
else -> throw AssertionError("Unexpected scopeOwner descriptor: $descriptor")
|
||||
}
|
||||
|
||||
@@ -21,17 +21,16 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||
|
||||
inline fun <reified T> Scope.assertCastOwner() =
|
||||
scopeOwner as? T ?:
|
||||
throw AssertionError("Unexpected scopeOwner: $scopeOwner")
|
||||
scopeOwner as? T ?: throw AssertionError("Unexpected scopeOwner: $scopeOwner")
|
||||
|
||||
fun Scope.functionOwner(): FunctionDescriptor =
|
||||
assertCastOwner()
|
||||
assertCastOwner()
|
||||
|
||||
fun Scope.classOwner(): ClassDescriptor =
|
||||
scopeOwner.let {
|
||||
when (it) {
|
||||
is ClassDescriptor -> it
|
||||
is MemberDescriptor -> it.containingDeclaration as ClassDescriptor
|
||||
else -> throw AssertionError("Unexpected scopeOwner: $scopeOwner")
|
||||
}
|
||||
scopeOwner.let {
|
||||
when (it) {
|
||||
is ClassDescriptor -> it
|
||||
is MemberDescriptor -> it.containingDeclaration as ClassDescriptor
|
||||
else -> throw AssertionError("Unexpected scopeOwner: $scopeOwner")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class IrBuiltIns(val builtIns: KotlinBuiltIns) {
|
||||
val operatorDescriptor = IrSimpleBuiltinOperatorDescriptorImpl(packageFragment, Name.identifier(name), returnType)
|
||||
for ((i, valueParameterType) in valueParameterTypes.withIndex()) {
|
||||
operatorDescriptor.addValueParameter(
|
||||
IrBuiltinValueParameterDescriptorImpl(operatorDescriptor, Name.identifier("arg$i"), i, valueParameterType)
|
||||
IrBuiltinValueParameterDescriptorImpl(operatorDescriptor, Name.identifier("arg$i"), i, valueParameterType)
|
||||
)
|
||||
}
|
||||
return addStubToPackageFragment(operatorDescriptor)
|
||||
@@ -57,7 +57,7 @@ class IrBuiltIns(val builtIns: KotlinBuiltIns) {
|
||||
}
|
||||
|
||||
private fun <T : SimpleFunctionDescriptor> T.addStub(): IrSimpleFunction =
|
||||
addStubToPackageFragment(this)
|
||||
addStubToPackageFragment(this)
|
||||
|
||||
val bool = builtIns.booleanType
|
||||
val any = builtIns.anyType
|
||||
@@ -102,26 +102,26 @@ class IrBuiltIns(val builtIns: KotlinBuiltIns) {
|
||||
val enumValueOfSymbol = enumValueOfFun.symbol
|
||||
|
||||
private fun createEnumValueOfFun(): IrSimpleFunction =
|
||||
SimpleFunctionDescriptorImpl.create(
|
||||
packageFragment,
|
||||
Annotations.EMPTY,
|
||||
Name.identifier("enumValueOf"),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE
|
||||
).apply {
|
||||
val typeParameterT = TypeParameterDescriptorImpl.createWithDefaultBound(
|
||||
this, Annotations.EMPTY, true, Variance.INVARIANT, Name.identifier("T"), 0
|
||||
)
|
||||
SimpleFunctionDescriptorImpl.create(
|
||||
packageFragment,
|
||||
Annotations.EMPTY,
|
||||
Name.identifier("enumValueOf"),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE
|
||||
).apply {
|
||||
val typeParameterT = TypeParameterDescriptorImpl.createWithDefaultBound(
|
||||
this, Annotations.EMPTY, true, Variance.INVARIANT, Name.identifier("T"), 0
|
||||
)
|
||||
|
||||
val valueParameterName = ValueParameterDescriptorImpl(
|
||||
this, null, 0, Annotations.EMPTY, Name.identifier("name"), builtIns.stringType,
|
||||
false, false, false, null, SourceElement.NO_SOURCE
|
||||
)
|
||||
val valueParameterName = ValueParameterDescriptorImpl(
|
||||
this, null, 0, Annotations.EMPTY, Name.identifier("name"), builtIns.stringType,
|
||||
false, false, false, null, SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
val returnType = KotlinTypeFactory.simpleType(Annotations.EMPTY, typeParameterT.typeConstructor, listOf(), false)
|
||||
val returnType = KotlinTypeFactory.simpleType(Annotations.EMPTY, typeParameterT.typeConstructor, listOf(), false)
|
||||
|
||||
initialize(null, null, listOf(typeParameterT), listOf(valueParameterName), returnType, Modality.FINAL, Visibilities.PUBLIC)
|
||||
}.addStub()
|
||||
initialize(null, null, listOf(typeParameterT), listOf(valueParameterName), returnType, Modality.FINAL, Visibilities.PUBLIC)
|
||||
}.addStub()
|
||||
|
||||
val dataClassArrayMemberHashCodeFun = defineOperator("dataClassArrayMemberHashCode", int, listOf(any))
|
||||
val dataClassArrayMemberHashCode = dataClassArrayMemberHashCodeFun.descriptor
|
||||
|
||||
+22
-18
@@ -31,15 +31,16 @@ interface IrBuiltinOperatorDescriptor : SimpleFunctionDescriptor
|
||||
interface IrBuiltinValueParameterDescriptor : ValueParameterDescriptor
|
||||
|
||||
abstract class IrBuiltinOperatorDescriptorBase(containingDeclaration: DeclarationDescriptor, name: Name) :
|
||||
DeclarationDescriptorNonRootImpl(containingDeclaration, Annotations.EMPTY, name, SourceElement.NO_SOURCE),
|
||||
IrBuiltinOperatorDescriptor
|
||||
{
|
||||
DeclarationDescriptorNonRootImpl(containingDeclaration, Annotations.EMPTY, name, SourceElement.NO_SOURCE),
|
||||
IrBuiltinOperatorDescriptor {
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
override fun getOriginal(): SimpleFunctionDescriptor = this
|
||||
override fun substitute(substitutor: TypeSubstitutor): FunctionDescriptor = throw UnsupportedOperationException()
|
||||
override fun getOverriddenDescriptors(): Collection<FunctionDescriptor> = emptyList()
|
||||
override fun setOverriddenDescriptors(overriddenDescriptors: Collection<CallableMemberDescriptor>) = throw UnsupportedOperationException()
|
||||
override fun setOverriddenDescriptors(overriddenDescriptors: Collection<CallableMemberDescriptor>) =
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override fun getTypeParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
override fun getVisibility(): Visibility = Visibilities.PUBLIC
|
||||
override fun getModality(): Modality = Modality.FINAL
|
||||
@@ -59,11 +60,14 @@ abstract class IrBuiltinOperatorDescriptorBase(containingDeclaration: Declaratio
|
||||
override fun hasStableParameterNames(): Boolean = true
|
||||
override fun hasSynthesizedParameterNames(): Boolean = false
|
||||
|
||||
override fun copy(newOwner: DeclarationDescriptor?, modality: Modality?, visibility: Visibility?,
|
||||
kind: CallableMemberDescriptor.Kind?, copyOverrides: Boolean) =
|
||||
throw UnsupportedOperationException()
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?, modality: Modality?, visibility: Visibility?,
|
||||
kind: CallableMemberDescriptor.Kind?, copyOverrides: Boolean
|
||||
) =
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override fun newCopyBuilder() =
|
||||
throw UnsupportedOperationException()
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||
return visitor.visitFunctionDescriptor(this, data)
|
||||
@@ -71,9 +75,9 @@ abstract class IrBuiltinOperatorDescriptorBase(containingDeclaration: Declaratio
|
||||
}
|
||||
|
||||
class IrSimpleBuiltinOperatorDescriptorImpl(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
private val returnType: KotlinType
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
private val returnType: KotlinType
|
||||
) : IrBuiltinOperatorDescriptorBase(containingDeclaration, name), IrBuiltinOperatorDescriptor {
|
||||
private val valueParameters: MutableList<IrBuiltinValueParameterDescriptor> = ArrayList()
|
||||
|
||||
@@ -86,12 +90,12 @@ class IrSimpleBuiltinOperatorDescriptorImpl(
|
||||
}
|
||||
|
||||
class IrBuiltinValueParameterDescriptorImpl(
|
||||
private val containingDeclaration: CallableDescriptor,
|
||||
name: Name,
|
||||
override val index: Int,
|
||||
outType: KotlinType
|
||||
private val containingDeclaration: CallableDescriptor,
|
||||
name: Name,
|
||||
override val index: Int,
|
||||
outType: KotlinType
|
||||
) : VariableDescriptorImpl(containingDeclaration, Annotations.EMPTY, name, outType, SourceElement.NO_SOURCE),
|
||||
IrBuiltinValueParameterDescriptor {
|
||||
IrBuiltinValueParameterDescriptor {
|
||||
|
||||
override fun getContainingDeclaration(): CallableDescriptor = containingDeclaration
|
||||
|
||||
@@ -106,10 +110,10 @@ class IrBuiltinValueParameterDescriptorImpl(
|
||||
override fun getVisibility(): Visibility = Visibilities.LOCAL
|
||||
|
||||
override fun copy(newOwner: CallableDescriptor, newName: Name, newIndex: Int): ValueParameterDescriptor =
|
||||
throw UnsupportedOperationException()
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override fun substitute(substitutor: TypeSubstitutor): ValueParameterDescriptor =
|
||||
throw UnsupportedOperationException()
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||
return visitor.visitValueParameterDescriptor(this, data)
|
||||
|
||||
+3
-7
@@ -16,19 +16,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.IrBuiltinsPackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
|
||||
class IrBuiltinsPackageFragmentDescriptorImpl(
|
||||
val containingModule: ModuleDescriptor,
|
||||
override val fqName: FqName
|
||||
val containingModule: ModuleDescriptor,
|
||||
override val fqName: FqName
|
||||
) : IrBuiltinsPackageFragmentDescriptor {
|
||||
private val shortName = fqName.shortName()
|
||||
|
||||
|
||||
+51
-49
@@ -45,33 +45,33 @@ interface IrImplementingDelegateDescriptor : IrDelegateDescriptor {
|
||||
}
|
||||
|
||||
abstract class IrDelegateDescriptorBase(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
delegateType: KotlinType
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
delegateType: KotlinType
|
||||
) : PropertyDescriptorImpl(
|
||||
containingDeclaration,
|
||||
/* original = */ null,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
Visibilities.PRIVATE,
|
||||
/* isVar = */ false,
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isActual = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ true
|
||||
containingDeclaration,
|
||||
/* original = */ null,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
Visibilities.PRIVATE,
|
||||
/* isVar = */ false,
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isActual = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ true
|
||||
) {
|
||||
init {
|
||||
val typeParameters: List<TypeParameterDescriptor> = emptyList()
|
||||
val extensionReceiverParameter: ReceiverParameterDescriptor? = null
|
||||
val dispatchReceiverParameter =
|
||||
if (containingDeclaration is ClassDescriptor)
|
||||
containingDeclaration.thisAsReceiverParameter
|
||||
else null
|
||||
if (containingDeclaration is ClassDescriptor)
|
||||
containingDeclaration.thisAsReceiverParameter
|
||||
else null
|
||||
setType(delegateType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter)
|
||||
}
|
||||
|
||||
@@ -90,49 +90,51 @@ abstract class IrDelegateDescriptorBase(
|
||||
override fun isVar(): Boolean = false
|
||||
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R =
|
||||
visitor.visitVariableDescriptor(this, data)
|
||||
visitor.visitVariableDescriptor(this, data)
|
||||
}
|
||||
|
||||
class IrPropertyDelegateDescriptorImpl(
|
||||
override val correspondingProperty: PropertyDescriptor,
|
||||
delegateType: KotlinType,
|
||||
override val kPropertyType: KotlinType
|
||||
override val correspondingProperty: PropertyDescriptor,
|
||||
delegateType: KotlinType,
|
||||
override val kPropertyType: KotlinType
|
||||
) : IrDelegateDescriptorBase(
|
||||
correspondingProperty.containingDeclaration,
|
||||
getDelegateName(correspondingProperty.name),
|
||||
delegateType
|
||||
correspondingProperty.containingDeclaration,
|
||||
getDelegateName(correspondingProperty.name),
|
||||
delegateType
|
||||
), IrPropertyDelegateDescriptor
|
||||
|
||||
class IrImplementingDelegateDescriptorImpl(
|
||||
containingDeclaration: ClassDescriptor,
|
||||
delegateType: KotlinType,
|
||||
override val correspondingSuperType: KotlinType
|
||||
containingDeclaration: ClassDescriptor,
|
||||
delegateType: KotlinType,
|
||||
override val correspondingSuperType: KotlinType
|
||||
) : IrDelegateDescriptorBase(
|
||||
containingDeclaration,
|
||||
getDelegateName(containingDeclaration, correspondingSuperType),
|
||||
delegateType
|
||||
containingDeclaration,
|
||||
getDelegateName(containingDeclaration, correspondingSuperType),
|
||||
delegateType
|
||||
), IrImplementingDelegateDescriptor
|
||||
|
||||
internal fun getDelegateName(name: Name): Name =
|
||||
Name.identifier(name.asString() + "\$delegate")
|
||||
Name.identifier(name.asString() + "\$delegate")
|
||||
|
||||
internal fun getDelegateName(classDescriptor: ClassDescriptor, superType: KotlinType): Name =
|
||||
Name.identifier(classDescriptor.name.asString() + "\$" +
|
||||
(superType.constructor.declarationDescriptor?.name ?: "\$") +
|
||||
"\$delegate")
|
||||
Name.identifier(
|
||||
classDescriptor.name.asString() + "\$" +
|
||||
(superType.constructor.declarationDescriptor?.name ?: "\$") +
|
||||
"\$delegate"
|
||||
)
|
||||
|
||||
class IrLocalDelegatedPropertyDelegateDescriptorImpl(
|
||||
override val correspondingLocalProperty: VariableDescriptorWithAccessors,
|
||||
delegateType: KotlinType,
|
||||
override val kPropertyType: KotlinType
|
||||
override val correspondingLocalProperty: VariableDescriptorWithAccessors,
|
||||
delegateType: KotlinType,
|
||||
override val kPropertyType: KotlinType
|
||||
) : IrLocalDelegatedPropertyDelegateDescriptor,
|
||||
VariableDescriptorImpl(
|
||||
correspondingLocalProperty.containingDeclaration,
|
||||
Annotations.EMPTY,
|
||||
getDelegateName(correspondingLocalProperty.name),
|
||||
delegateType,
|
||||
org.jetbrains.kotlin.descriptors.SourceElement.NO_SOURCE
|
||||
) {
|
||||
VariableDescriptorImpl(
|
||||
correspondingLocalProperty.containingDeclaration,
|
||||
Annotations.EMPTY,
|
||||
getDelegateName(correspondingLocalProperty.name),
|
||||
delegateType,
|
||||
org.jetbrains.kotlin.descriptors.SourceElement.NO_SOURCE
|
||||
) {
|
||||
|
||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
||||
override fun isVar(): Boolean = false
|
||||
@@ -141,5 +143,5 @@ class IrLocalDelegatedPropertyDelegateDescriptorImpl(
|
||||
override fun getVisibility(): Visibility = Visibilities.LOCAL
|
||||
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R =
|
||||
visitor.visitVariableDescriptor(this, data)
|
||||
visitor.visitVariableDescriptor(this, data)
|
||||
}
|
||||
|
||||
+24
-24
@@ -39,19 +39,19 @@ interface IrSyntheticPropertyGetterDescriptor : IrSyntheticPropertyAccessorDescr
|
||||
interface IrSyntheticPropertySetterDescriptor : IrSyntheticPropertyAccessorDescriptor
|
||||
|
||||
class IrSyntheticPropertyGetterDescriptorImpl(
|
||||
correspondingProperty: PropertyDescriptor,
|
||||
override val kind: IrSyntheticPropertyAccessorDescriptor.Kind
|
||||
correspondingProperty: PropertyDescriptor,
|
||||
override val kind: IrSyntheticPropertyAccessorDescriptor.Kind
|
||||
) : PropertyGetterDescriptorImpl(
|
||||
correspondingProperty,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
correspondingProperty.visibility,
|
||||
true, // isDefault
|
||||
false, // isExternal
|
||||
false, // isInline
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
null,
|
||||
correspondingProperty.source
|
||||
correspondingProperty,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
correspondingProperty.visibility,
|
||||
true, // isDefault
|
||||
false, // isExternal
|
||||
false, // isInline
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
null,
|
||||
correspondingProperty.source
|
||||
), IrSyntheticPropertyGetterDescriptor {
|
||||
init {
|
||||
initialize(correspondingProperty.type)
|
||||
@@ -59,19 +59,19 @@ class IrSyntheticPropertyGetterDescriptorImpl(
|
||||
}
|
||||
|
||||
class IrSyntheticPropertySetterDescriptorImpl(
|
||||
correspondingProperty: PropertyDescriptor,
|
||||
override val kind: IrSyntheticPropertyAccessorDescriptor.Kind
|
||||
correspondingProperty: PropertyDescriptor,
|
||||
override val kind: IrSyntheticPropertyAccessorDescriptor.Kind
|
||||
) : PropertySetterDescriptorImpl(
|
||||
correspondingProperty,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
correspondingProperty.visibility,
|
||||
true, // isDefault
|
||||
false, // isExternal
|
||||
false, // isInline
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
null,
|
||||
correspondingProperty.source
|
||||
correspondingProperty,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
correspondingProperty.visibility,
|
||||
true, // isDefault
|
||||
false, // isExternal
|
||||
false, // isInline
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
null,
|
||||
correspondingProperty.source
|
||||
), IrSyntheticPropertySetterDescriptor {
|
||||
init {
|
||||
initializeDefault()
|
||||
|
||||
+7
-8
@@ -27,13 +27,12 @@ import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
interface IrTemporaryVariableDescriptor : VariableDescriptor
|
||||
|
||||
class IrTemporaryVariableDescriptorImpl(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
outType: KotlinType,
|
||||
private val isMutable: Boolean = false
|
||||
): VariableDescriptorImpl(containingDeclaration, Annotations.EMPTY, name, outType, SourceElement.NO_SOURCE),
|
||||
IrTemporaryVariableDescriptor
|
||||
{
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
outType: KotlinType,
|
||||
private val isMutable: Boolean = false
|
||||
) : VariableDescriptorImpl(containingDeclaration, Annotations.EMPTY, name, outType, SourceElement.NO_SOURCE),
|
||||
IrTemporaryVariableDescriptor {
|
||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
||||
|
||||
override fun getVisibility(): Visibility = Visibilities.LOCAL
|
||||
@@ -47,5 +46,5 @@ class IrTemporaryVariableDescriptorImpl(
|
||||
override fun isLateInit(): Boolean = false
|
||||
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R =
|
||||
visitor.visitVariableDescriptor(this, data)
|
||||
visitor.visitVariableDescriptor(this, data)
|
||||
}
|
||||
@@ -35,7 +35,7 @@ interface IrComposite : IrContainerExpression {
|
||||
get() = true
|
||||
}
|
||||
|
||||
interface IrReturnableBlock: IrBlock, IrSymbolOwner {
|
||||
interface IrReturnableBlock : IrBlock, IrSymbolOwner {
|
||||
override val symbol: IrReturnableBlockSymbol
|
||||
val descriptor: FunctionDescriptor
|
||||
val sourceFileName: String
|
||||
|
||||
@@ -21,14 +21,14 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
|
||||
interface IrBody : IrElement {
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrBody =
|
||||
accept(transformer, data) as IrBody
|
||||
accept(transformer, data) as IrBody
|
||||
}
|
||||
|
||||
interface IrExpressionBody : IrBody {
|
||||
var expression: IrExpression
|
||||
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpressionBody =
|
||||
accept(transformer, data) as IrExpressionBody
|
||||
accept(transformer, data) as IrExpressionBody
|
||||
}
|
||||
|
||||
interface IrBlockBody : IrBody, IrStatementContainer
|
||||
|
||||
@@ -21,6 +21,6 @@ interface IrBreakContinue : IrExpression {
|
||||
val label: String?
|
||||
}
|
||||
|
||||
interface IrBreak: IrBreakContinue
|
||||
interface IrBreak : IrBreakContinue
|
||||
|
||||
interface IrContinue: IrBreakContinue
|
||||
interface IrContinue : IrBreakContinue
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.expressions
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||
|
||||
@@ -23,10 +23,10 @@ interface IrConst<T> : IrExpression, IrExpressionWithCopy {
|
||||
override fun copy(): IrConst<T>
|
||||
}
|
||||
|
||||
sealed class IrConstKind<T>(val asString: kotlin.String) {
|
||||
sealed class IrConstKind<T>(val asString: kotlin.String) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun valueOf(aConst: IrConst<*>) =
|
||||
(aConst as IrConst<T>).value
|
||||
(aConst as IrConst<T>).value
|
||||
|
||||
object Null : IrConstKind<Nothing?>("Null")
|
||||
object Boolean : IrConstKind<kotlin.Boolean>("Boolean")
|
||||
|
||||
@@ -24,7 +24,7 @@ interface IrExpression : IrStatement, IrVarargElement {
|
||||
val type: KotlinType
|
||||
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpression =
|
||||
accept(transformer, data) as IrExpression
|
||||
accept(transformer, data) as IrExpression
|
||||
}
|
||||
|
||||
interface IrExpressionWithCopy : IrExpression {
|
||||
|
||||
@@ -18,6 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
|
||||
|
||||
|
||||
interface IrGetClass : IrExpression {
|
||||
var argument : IrExpression
|
||||
var argument: IrExpression
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.expressions
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
@@ -36,7 +39,7 @@ interface IrMemberAccessExpression : IrExpression {
|
||||
}
|
||||
|
||||
fun IrMemberAccessExpression.getTypeArgumentOrDefault(typeParameterDescriptor: TypeParameterDescriptor) =
|
||||
getTypeArgument(typeParameterDescriptor) ?: typeParameterDescriptor.defaultType
|
||||
getTypeArgument(typeParameterDescriptor) ?: typeParameterDescriptor.defaultType
|
||||
|
||||
interface IrFunctionAccessExpression : IrMemberAccessExpression, IrDeclarationReference {
|
||||
override val descriptor: FunctionDescriptor
|
||||
@@ -44,7 +47,7 @@ interface IrFunctionAccessExpression : IrMemberAccessExpression, IrDeclarationRe
|
||||
}
|
||||
|
||||
fun IrMemberAccessExpression.getValueArgument(valueParameterDescriptor: ValueParameterDescriptor) =
|
||||
getValueArgument(valueParameterDescriptor.index)
|
||||
getValueArgument(valueParameterDescriptor.index)
|
||||
|
||||
fun IrMemberAccessExpression.putValueArgument(valueParameterDescriptor: ValueParameterDescriptor, valueArgument: IrExpression?) {
|
||||
putValueArgument(valueParameterDescriptor.index, valueArgument)
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.expressions
|
||||
|
||||
abstract class IrStatementOriginImpl(val debugName: String): IrStatementOrigin {
|
||||
abstract class IrStatementOriginImpl(val debugName: String) : IrStatementOrigin {
|
||||
override fun toString(): String = debugName
|
||||
}
|
||||
|
||||
interface IrStatementOrigin {
|
||||
object SAFE_CALL : IrStatementOriginImpl("SAFE_CALL")
|
||||
|
||||
|
||||
object UMINUS : IrStatementOriginImpl("UMINUS")
|
||||
object UPLUS : IrStatementOriginImpl("UPLUS")
|
||||
object EXCL : IrStatementOriginImpl("EXCL")
|
||||
@@ -70,7 +70,7 @@ interface IrStatementOrigin {
|
||||
|
||||
object ARGUMENTS_REORDERING_FOR_CALL : IrStatementOriginImpl("ARGUMENTS_REORDERING_FOR_CALL")
|
||||
object DESTRUCTURING_DECLARATION : IrStatementOriginImpl("DESTRUCTURING_DECLARATION")
|
||||
|
||||
|
||||
object GET_PROPERTY : IrStatementOriginImpl("GET_PROPERTY")
|
||||
object GET_LOCAL_PROPERTY : IrStatementOriginImpl("GET_LOCAL_PROPERTY")
|
||||
|
||||
@@ -98,20 +98,20 @@ interface IrStatementOrigin {
|
||||
private val precreatedComponents = Array(32) { i -> COMPONENT_N(i + 1) }
|
||||
|
||||
fun withIndex(index: Int) =
|
||||
if (index < precreatedComponents.size)
|
||||
precreatedComponents[index - 1]
|
||||
else
|
||||
COMPONENT_N(index)
|
||||
if (index < precreatedComponents.size)
|
||||
precreatedComponents[index - 1]
|
||||
else
|
||||
COMPONENT_N(index)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun IrStatementOrigin.isAssignmentOperatorWithResult() =
|
||||
when (this) {
|
||||
IrStatementOrigin.PREFIX_INCR, IrStatementOrigin.PREFIX_DECR,
|
||||
IrStatementOrigin.POSTFIX_INCR, IrStatementOrigin.POSTFIX_DECR ->
|
||||
true
|
||||
else ->
|
||||
false
|
||||
}
|
||||
when (this) {
|
||||
IrStatementOrigin.PREFIX_INCR, IrStatementOrigin.PREFIX_DECR,
|
||||
IrStatementOrigin.POSTFIX_INCR, IrStatementOrigin.POSTFIX_DECR ->
|
||||
true
|
||||
else ->
|
||||
false
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package org.jetbrains.kotlin.ir.expressions
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
|
||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
|
||||
interface IrTry : IrExpression {
|
||||
@@ -29,7 +26,7 @@ interface IrTry : IrExpression {
|
||||
|
||||
val catches: List<IrCatch>
|
||||
|
||||
var finallyExpression : IrExpression?
|
||||
var finallyExpression: IrExpression?
|
||||
}
|
||||
|
||||
interface IrCatch : IrElement {
|
||||
@@ -38,5 +35,5 @@ interface IrCatch : IrElement {
|
||||
var result: IrExpression
|
||||
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrCatch =
|
||||
super.transform(transformer, data) as IrCatch
|
||||
super.transform(transformer, data) as IrCatch
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
interface IrVarargElement : IrElement
|
||||
|
||||
interface IrVararg : IrExpression {
|
||||
val varargElementType : KotlinType
|
||||
val varargElementType: KotlinType
|
||||
|
||||
val elements: List<IrVarargElement>
|
||||
|
||||
@@ -34,6 +34,6 @@ interface IrSpreadElement : IrVarargElement {
|
||||
var expression: IrExpression
|
||||
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrElement =
|
||||
accept(transformer, data) as IrSpreadElement
|
||||
accept(transformer, data) as IrSpreadElement
|
||||
}
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ interface IrBranch : IrElement {
|
||||
var result: IrExpression
|
||||
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrBranch =
|
||||
transformer.visitBranch(this, data)
|
||||
transformer.visitBranch(this, data)
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitBranch(this, data)
|
||||
visitor.visitBranch(this, data)
|
||||
}
|
||||
|
||||
interface IrElseBranch : IrBranch {
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrElseBranch =
|
||||
transformer.visitElseBranch(this, data)
|
||||
transformer.visitElseBranch(this, data)
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitElseBranch(this, data)
|
||||
visitor.visitElseBranch(this, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,21 +22,20 @@ import org.jetbrains.kotlin.ir.expressions.IrBlock
|
||||
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.symbols.impl.IrBindableSymbolBase
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrReturnableBlockSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin? = null):
|
||||
IrContainerExpressionBase(startOffset, endOffset, type, origin), IrBlock {
|
||||
class IrBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin? = null) :
|
||||
IrContainerExpressionBase(startOffset, endOffset, type, origin), IrBlock {
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?, statements: List<IrStatement>) :
|
||||
this(startOffset, endOffset, type, origin) {
|
||||
this.statements.addAll(statements)
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitBlock(this, data)
|
||||
visitor.visitBlock(this, data)
|
||||
}
|
||||
|
||||
fun IrBlockImpl.addIfNotNull(statement: IrStatement?) {
|
||||
@@ -46,30 +45,41 @@ fun IrBlockImpl.addIfNotNull(statement: IrStatement?) {
|
||||
fun IrBlockImpl.inlineStatement(statement: IrStatement) {
|
||||
if (statement is IrBlock) {
|
||||
statements.addAll(statement.statements)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
statements.add(statement)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class IrReturnableBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
override val symbol: IrReturnableBlockSymbol, origin: IrStatementOrigin? = null, override val sourceFileName: String = "no source file")
|
||||
: IrContainerExpressionBase(startOffset, endOffset, type, origin), IrReturnableBlock {
|
||||
class IrReturnableBlockImpl(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
override val symbol: IrReturnableBlockSymbol, origin: IrStatementOrigin? = null, override val sourceFileName: String = "no source file"
|
||||
) : IrContainerExpressionBase(startOffset, endOffset, type, origin), IrReturnableBlock {
|
||||
override val descriptor = symbol.descriptor
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
symbol: IrReturnableBlockSymbol, origin: IrStatementOrigin?, statements: List<IrStatement>, sourceFileName: String = "no source file") :
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: IrReturnableBlockSymbol,
|
||||
origin: IrStatementOrigin?,
|
||||
statements: List<IrStatement>,
|
||||
sourceFileName: String = "no source file"
|
||||
) :
|
||||
this(startOffset, endOffset, type, symbol, origin, sourceFileName) {
|
||||
this.statements.addAll(statements)
|
||||
}
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
descriptor: FunctionDescriptor, origin: IrStatementOrigin? = null, sourceFileName: String = "no source file") :
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
descriptor: FunctionDescriptor, origin: IrStatementOrigin? = null, sourceFileName: String = "no source file"
|
||||
) :
|
||||
this(startOffset, endOffset, type, IrReturnableBlockSymbolImpl(descriptor), origin, sourceFileName)
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
descriptor: FunctionDescriptor, origin: IrStatementOrigin?, statements: List<IrStatement>, sourceFileName: String = "no source file") :
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
descriptor: FunctionDescriptor, origin: IrStatementOrigin?, statements: List<IrStatement>, sourceFileName: String = "no source file"
|
||||
) :
|
||||
this(startOffset, endOffset, type, descriptor, origin, sourceFileName) {
|
||||
this.statements.addAll(statements)
|
||||
}
|
||||
@@ -79,7 +89,7 @@ class IrReturnableBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitBlock(this, data)
|
||||
visitor.visitBlock(this, data)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
statements.forEach { it.accept(visitor, data) }
|
||||
|
||||
+4
-4
@@ -21,10 +21,10 @@ import org.jetbrains.kotlin.ir.expressions.IrLoop
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrBreakContinueBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override var loop: IrLoop
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override var loop: IrLoop
|
||||
) : IrTerminalExpressionBase(startOffset, endOffset, type), IrBreakContinue {
|
||||
override var label: String? = null
|
||||
}
|
||||
@@ -22,11 +22,11 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrBreakImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
loop: IrLoop
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
loop: IrLoop
|
||||
) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrBreak {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitBreak(this, data)
|
||||
visitor.visitBreak(this, data)
|
||||
}
|
||||
@@ -29,59 +29,58 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrCallImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val symbol: IrFunctionSymbol,
|
||||
override val descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null,
|
||||
override val superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrCall,
|
||||
IrCallWithIndexedArgumentsBase(startOffset, endOffset, type, symbol.descriptor.valueParameters.size, typeArguments) {
|
||||
@Deprecated("Creates unbound symbols")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val symbol: IrFunctionSymbol,
|
||||
override val descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null,
|
||||
override val superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrCall,
|
||||
IrCallWithIndexedArgumentsBase(startOffset, endOffset, type, symbol.descriptor.valueParameters.size, typeArguments)
|
||||
{
|
||||
@Deprecated("Creates unbound symbols")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
calleeDescriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierDescriptor: ClassDescriptor? = null
|
||||
calleeDescriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierDescriptor: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
type,
|
||||
createFunctionSymbol(calleeDescriptor),
|
||||
calleeDescriptor,
|
||||
typeArguments, origin,
|
||||
createClassSymbolOrNull(superQualifierDescriptor)
|
||||
startOffset, endOffset,
|
||||
type,
|
||||
createFunctionSymbol(calleeDescriptor),
|
||||
calleeDescriptor,
|
||||
typeArguments, origin,
|
||||
createClassSymbolOrNull(superQualifierDescriptor)
|
||||
)
|
||||
|
||||
@Deprecated("Creates unbound symbols")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
calleeDescriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierDescriptor: ClassDescriptor? = null
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
calleeDescriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierDescriptor: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
calleeDescriptor.returnType!!,
|
||||
createFunctionSymbol(calleeDescriptor),
|
||||
calleeDescriptor,
|
||||
typeArguments, origin,
|
||||
createClassSymbolOrNull(superQualifierDescriptor)
|
||||
startOffset, endOffset,
|
||||
calleeDescriptor.returnType!!,
|
||||
createFunctionSymbol(calleeDescriptor),
|
||||
calleeDescriptor,
|
||||
typeArguments, origin,
|
||||
createClassSymbolOrNull(superQualifierDescriptor)
|
||||
)
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : this(startOffset, endOffset, descriptor.returnType!!, symbol, descriptor, typeArguments, origin, superQualifierSymbol)
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, symbol: IrFunctionSymbol) :
|
||||
@@ -91,5 +90,5 @@ class IrCallImpl(
|
||||
override val superQualifier: ClassDescriptor? = superQualifierSymbol?.descriptor
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitCall(this, data)
|
||||
visitor.visitCall(this, data)
|
||||
}
|
||||
+6
-7
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.ir.expressions.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
@@ -26,16 +25,16 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.lang.AssertionError
|
||||
|
||||
abstract class IrCallWithIndexedArgumentsBase(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
numArguments: Int,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
numArguments: Int,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
) : IrMemberAccessExpressionBase(startOffset, endOffset, type, typeArguments) {
|
||||
private val argumentsByParameterIndex =
|
||||
arrayOfNulls<IrExpression>(numArguments)
|
||||
arrayOfNulls<IrExpression>(numArguments)
|
||||
|
||||
override fun getValueArgument(index: Int): IrExpression? =
|
||||
argumentsByParameterIndex[index]
|
||||
argumentsByParameterIndex[index]
|
||||
|
||||
override fun putValueArgument(index: Int, valueArgument: IrExpression?) {
|
||||
if (index >= argumentsByParameterIndex.size) {
|
||||
|
||||
+20
-21
@@ -27,35 +27,34 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrClassReferenceImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: IrClassifierSymbol,
|
||||
override val classType: KotlinType
|
||||
) : IrClassReference,
|
||||
IrTerminalDeclarationReferenceBase<IrClassifierSymbol, ClassifierDescriptor>(
|
||||
startOffset, endOffset, type,
|
||||
symbol, symbol.descriptor
|
||||
) {
|
||||
@Deprecated("Creates unbound symbols")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: IrClassifierSymbol,
|
||||
override val classType: KotlinType
|
||||
) : IrClassReference,
|
||||
IrTerminalDeclarationReferenceBase<IrClassifierSymbol, ClassifierDescriptor>(
|
||||
startOffset, endOffset, type,
|
||||
symbol, symbol.descriptor
|
||||
)
|
||||
{
|
||||
@Deprecated("Creates unbound symbols")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
descriptor: ClassifierDescriptor,
|
||||
classType: KotlinType
|
||||
descriptor: ClassifierDescriptor,
|
||||
classType: KotlinType
|
||||
) : this(startOffset, endOffset, type, createClassifierSymbolForClassReference(descriptor), classType)
|
||||
|
||||
override val descriptor: ClassifierDescriptor get() = symbol.descriptor
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitClassReference(this, data)
|
||||
visitor.visitClassReference(this, data)
|
||||
}
|
||||
|
||||
internal fun createClassifierSymbolForClassReference(descriptor: ClassifierDescriptor): IrClassifierSymbol =
|
||||
when (descriptor) {
|
||||
is ClassDescriptor -> IrClassSymbolImpl(descriptor)
|
||||
is TypeParameterDescriptor -> IrTypeParameterSymbolImpl(descriptor)
|
||||
else -> throw IllegalArgumentException("Unexpected referenced classifier: $descriptor")
|
||||
}
|
||||
when (descriptor) {
|
||||
is ClassDescriptor -> IrClassSymbolImpl(descriptor)
|
||||
is TypeParameterDescriptor -> IrTypeParameterSymbolImpl(descriptor)
|
||||
else -> throw IllegalArgumentException("Unexpected referenced classifier: $descriptor")
|
||||
}
|
||||
@@ -24,13 +24,13 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
|
||||
class IrCompositeImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin? = null) :
|
||||
IrContainerExpressionBase(startOffset, endOffset, type, origin), IrComposite {
|
||||
IrContainerExpressionBase(startOffset, endOffset, type, origin), IrComposite {
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?, statements: List<IrStatement>) :
|
||||
this(startOffset, endOffset, type, origin) {
|
||||
this.statements.addAll(statements)
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitComposite(this, data)
|
||||
visitor.visitComposite(this, data)
|
||||
|
||||
}
|
||||
@@ -22,54 +22,54 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrConstImpl<T> (
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val kind: IrConstKind<T>,
|
||||
override val value: T
|
||||
class IrConstImpl<T>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val kind: IrConstKind<T>,
|
||||
override val value: T
|
||||
) : IrTerminalExpressionBase(startOffset, endOffset, type), IrConst<T> {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitConst(this, data)
|
||||
visitor.visitConst(this, data)
|
||||
|
||||
override fun copy(): IrConst<T> =
|
||||
IrConstImpl(startOffset, endOffset, type, kind, value)
|
||||
IrConstImpl(startOffset, endOffset, type, kind, value)
|
||||
|
||||
companion object {
|
||||
fun string(startOffset: Int, endOffset: Int, type: KotlinType, value: String): IrConstImpl<String> =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.String, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.String, value)
|
||||
|
||||
fun int(startOffset: Int, endOffset: Int, type: KotlinType, value: Int): IrConstImpl<Int> =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Int, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Int, value)
|
||||
|
||||
fun constNull(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl<Nothing?> =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Null, null)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Null, null)
|
||||
|
||||
fun boolean(startOffset: Int, endOffset: Int, type: KotlinType, value: Boolean): IrConstImpl<Boolean> =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Boolean, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Boolean, value)
|
||||
|
||||
fun constTrue(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl<Boolean> =
|
||||
boolean(startOffset, endOffset, type, true)
|
||||
boolean(startOffset, endOffset, type, true)
|
||||
|
||||
fun constFalse(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl<Boolean> =
|
||||
boolean(startOffset, endOffset, type, false)
|
||||
boolean(startOffset, endOffset, type, false)
|
||||
|
||||
fun long(startOffset: Int, endOffset: Int, type: KotlinType, value: Long): IrExpression =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Long, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Long, value)
|
||||
|
||||
fun float(startOffset: Int, endOffset: Int, type: KotlinType, value: Float): IrExpression =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Float, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Float, value)
|
||||
|
||||
fun double(startOffset: Int, endOffset: Int, type: KotlinType, value: Double): IrExpression =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Double, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Double, value)
|
||||
|
||||
fun char(startOffset: Int, endOffset: Int, type: KotlinType, value: Char): IrExpression =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Char, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Char, value)
|
||||
|
||||
fun byte(startOffset: Int, endOffset: Int, type: KotlinType, value: Byte): IrExpression =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Byte, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Byte, value)
|
||||
|
||||
fun short(startOffset: Int, endOffset: Int, type: KotlinType, value: Short): IrExpression =
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Short, value)
|
||||
IrConstImpl(startOffset, endOffset, type, IrConstKind.Short, value)
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -25,8 +25,13 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.util.*
|
||||
|
||||
abstract class IrContainerExpressionBase(startOffset: Int, endOffset: Int, type: KotlinType, override val origin: IrStatementOrigin? = null):
|
||||
IrExpressionBase(startOffset, endOffset, type), IrContainerExpression {
|
||||
abstract class IrContainerExpressionBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
) :
|
||||
IrExpressionBase(startOffset, endOffset, type), IrContainerExpression {
|
||||
override val statements: MutableList<IrStatement> = ArrayList(2)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
|
||||
@@ -22,11 +22,11 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrContinueImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
loop: IrLoop
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
loop: IrLoop
|
||||
) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrContinue {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitContinue(this, data)
|
||||
visitor.visitContinue(this, data)
|
||||
}
|
||||
+6
-6
@@ -21,10 +21,10 @@ import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrDeclarationReferenceBase<out S: IrSymbol, out D : DeclarationDescriptor>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val symbol: S,
|
||||
override val descriptor: D
|
||||
abstract class IrDeclarationReferenceBase<out S : IrSymbol, out D : DeclarationDescriptor>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val symbol: S,
|
||||
override val descriptor: D
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrDeclarationReference
|
||||
+21
-20
@@ -26,29 +26,30 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrDelegatingConstructorCallImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val symbol: IrConstructorSymbol,
|
||||
override val descriptor: ClassConstructorDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val symbol: IrConstructorSymbol,
|
||||
override val descriptor: ClassConstructorDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null
|
||||
) : IrDelegatingConstructorCall,
|
||||
IrCallWithIndexedArgumentsBase(
|
||||
startOffset, endOffset,
|
||||
symbol.descriptor.builtIns.unitType,
|
||||
symbol.descriptor.valueParameters.size,
|
||||
typeArguments
|
||||
)
|
||||
{
|
||||
IrCallWithIndexedArgumentsBase(
|
||||
startOffset, endOffset,
|
||||
symbol.descriptor.builtIns.unitType,
|
||||
symbol.descriptor.valueParameters.size,
|
||||
typeArguments
|
||||
) {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
constructorDescriptor: ClassConstructorDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null
|
||||
) : this(startOffset, endOffset,
|
||||
IrConstructorSymbolImpl(constructorDescriptor.original),
|
||||
constructorDescriptor,
|
||||
typeArguments)
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
constructorDescriptor: ClassConstructorDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrConstructorSymbolImpl(constructorDescriptor.original),
|
||||
constructorDescriptor,
|
||||
typeArguments
|
||||
)
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||
return visitor.visitDelegatingConstructorCall(this, data)
|
||||
|
||||
+4
-4
@@ -23,11 +23,11 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrDoWhileLoopImpl(startOffset: Int, endOffset: Int, type : KotlinType, origin: IrStatementOrigin?) :
|
||||
IrLoopBase(startOffset, endOffset, type, origin), IrDoWhileLoop {
|
||||
class IrDoWhileLoopImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?) :
|
||||
IrLoopBase(startOffset, endOffset, type, origin), IrDoWhileLoop {
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?,
|
||||
body: IrExpression, condition: IrExpression
|
||||
startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?,
|
||||
body: IrExpression, condition: IrExpression
|
||||
) : this(startOffset, endOffset, type, origin) {
|
||||
this.condition = condition
|
||||
this.body = body
|
||||
|
||||
+12
-13
@@ -24,22 +24,21 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
|
||||
class IrEnumConstructorCallImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val symbol: IrConstructorSymbol
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val symbol: IrConstructorSymbol
|
||||
) : IrEnumConstructorCall,
|
||||
IrCallWithIndexedArgumentsBase(
|
||||
startOffset, endOffset,
|
||||
symbol.descriptor.builtIns.unitType,
|
||||
symbol.descriptor.valueParameters.size,
|
||||
null
|
||||
)
|
||||
{
|
||||
IrCallWithIndexedArgumentsBase(
|
||||
startOffset, endOffset,
|
||||
symbol.descriptor.builtIns.unitType,
|
||||
symbol.descriptor.valueParameters.size,
|
||||
null
|
||||
) {
|
||||
@Deprecated("Creates unbound symbols")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
descriptor: ClassConstructorDescriptor
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
descriptor: ClassConstructorDescriptor
|
||||
) : this(startOffset, endOffset, IrConstructorSymbolImpl(descriptor))
|
||||
|
||||
override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor
|
||||
|
||||
+4
-4
@@ -24,10 +24,10 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class IrErrorCallExpressionImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val description: String
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val description: String
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrErrorCallExpression {
|
||||
override var explicitReceiver: IrExpression? = null
|
||||
override val arguments: MutableList<IrExpression> = SmartList()
|
||||
|
||||
+6
-6
@@ -22,14 +22,14 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrErrorExpressionImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val description: String
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val description: String
|
||||
) : IrTerminalExpressionBase(startOffset, endOffset, type), IrExpressionWithCopy, IrErrorExpression {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitErrorExpression(this, data)
|
||||
visitor.visitErrorExpression(this, data)
|
||||
|
||||
override fun copy(): IrErrorExpressionImpl =
|
||||
IrErrorExpressionImpl(startOffset, endOffset, type, description)
|
||||
IrErrorExpressionImpl(startOffset, endOffset, type, description)
|
||||
}
|
||||
+3
-3
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrExpressionBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val type: KotlinType
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val type: KotlinType
|
||||
) : IrElementBase(startOffset, endOffset), IrExpression
|
||||
+1
-1
@@ -32,7 +32,7 @@ class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(sta
|
||||
override lateinit var expression: IrExpression
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitExpressionBody(this, data)
|
||||
visitor.visitExpressionBody(this, data)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
expression.accept(visitor, data)
|
||||
|
||||
+5
-6
@@ -23,15 +23,14 @@ import org.jetbrains.kotlin.ir.expressions.IrFieldAccessExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrFieldExpressionBase(
|
||||
startOffset: Int, endOffset: Int,
|
||||
override val symbol: IrFieldSymbol,
|
||||
type: KotlinType,
|
||||
override val origin: IrStatementOrigin? = null,
|
||||
override val superQualifierSymbol: IrClassSymbol?
|
||||
startOffset: Int, endOffset: Int,
|
||||
override val symbol: IrFieldSymbol,
|
||||
type: KotlinType,
|
||||
override val origin: IrStatementOrigin? = null,
|
||||
override val superQualifierSymbol: IrClassSymbol?
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrFieldAccessExpression {
|
||||
override val descriptor: PropertyDescriptor get() = symbol.descriptor
|
||||
override val superQualifier: ClassDescriptor? get() = superQualifierSymbol?.descriptor
|
||||
|
||||
+18
-19
@@ -26,31 +26,30 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrFunctionReferenceImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val symbol: IrFunctionSymbol,
|
||||
override val descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null
|
||||
) : IrFunctionReference,
|
||||
IrCallWithIndexedArgumentsBase(
|
||||
startOffset, endOffset, type,
|
||||
symbol.descriptor.valueParameters.size,
|
||||
typeArguments,
|
||||
origin
|
||||
) {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val symbol: IrFunctionSymbol,
|
||||
override val descriptor: FunctionDescriptor,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null
|
||||
) : IrFunctionReference,
|
||||
IrCallWithIndexedArgumentsBase(
|
||||
startOffset, endOffset, type,
|
||||
symbol.descriptor.valueParameters.size,
|
||||
typeArguments,
|
||||
origin
|
||||
)
|
||||
{
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null
|
||||
) : this(startOffset, endOffset, type, createFunctionSymbol(descriptor.original), descriptor, typeArguments, origin)
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitFunctionReference(this, data)
|
||||
visitor.visitFunctionReference(this, data)
|
||||
}
|
||||
+9
-10
@@ -24,19 +24,18 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrGetEnumValueImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: IrEnumEntrySymbol
|
||||
) : IrGetEnumValue,
|
||||
IrTerminalDeclarationReferenceBase<IrEnumEntrySymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor) {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: IrEnumEntrySymbol
|
||||
) : IrGetEnumValue,
|
||||
IrTerminalDeclarationReferenceBase<IrEnumEntrySymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor)
|
||||
{
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
descriptor: ClassDescriptor
|
||||
descriptor: ClassDescriptor
|
||||
) : this(startOffset, endOffset, type, IrEnumEntrySymbolImpl(descriptor))
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||
|
||||
+36
-37
@@ -29,47 +29,46 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
|
||||
class IrGetFieldImpl(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFieldSymbol,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrGetField,
|
||||
IrFieldExpressionBase(startOffset, endOffset, symbol, symbol.descriptor.type, origin, superQualifierSymbol) {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
receiver: IrExpression?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
receiver, origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFieldSymbol,
|
||||
receiver: IrExpression?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrGetField,
|
||||
IrFieldExpressionBase(startOffset, endOffset, symbol, symbol.descriptor.type, origin, superQualifierSymbol)
|
||||
{
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
receiver: IrExpression?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
receiver, origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFieldSymbol,
|
||||
receiver: IrExpression?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : this(startOffset, endOffset, symbol, origin, superQualifierSymbol) {
|
||||
this.receiver = receiver
|
||||
}
|
||||
|
||||
+10
-11
@@ -24,21 +24,20 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrGetObjectValueImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: IrClassSymbol
|
||||
) : IrGetObjectValue,
|
||||
IrTerminalDeclarationReferenceBase<IrClassSymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor) {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: IrClassSymbol
|
||||
) : IrGetObjectValue,
|
||||
IrTerminalDeclarationReferenceBase<IrClassSymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor)
|
||||
{
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
descriptor: ClassDescriptor
|
||||
descriptor: ClassDescriptor
|
||||
) : this(startOffset, endOffset, type, IrClassSymbolImpl(descriptor))
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitGetObjectValue(this, data)
|
||||
visitor.visitGetObjectValue(this, data)
|
||||
}
|
||||
+15
-10
@@ -24,22 +24,27 @@ import org.jetbrains.kotlin.ir.symbols.impl.createValueSymbol
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
|
||||
class IrGetValueImpl(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrValueSymbol,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrValueSymbol,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
) : IrGetValue,
|
||||
IrTerminalDeclarationReferenceBase<IrValueSymbol, ValueDescriptor>(startOffset, endOffset, symbol.descriptor.type, symbol, symbol.descriptor)
|
||||
{
|
||||
IrTerminalDeclarationReferenceBase<IrValueSymbol, ValueDescriptor>(
|
||||
startOffset,
|
||||
endOffset,
|
||||
symbol.descriptor.type,
|
||||
symbol,
|
||||
symbol.descriptor
|
||||
) {
|
||||
@Deprecated("Creates unbound reference")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
descriptor: ValueDescriptor,
|
||||
origin: IrStatementOrigin? = null
|
||||
startOffset: Int, endOffset: Int,
|
||||
descriptor: ValueDescriptor,
|
||||
origin: IrStatementOrigin? = null
|
||||
) : this(startOffset, endOffset, createValueSymbol(descriptor), origin)
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitGetValue(this, data)
|
||||
visitor.visitGetValue(this, data)
|
||||
|
||||
override fun copy(): IrGetValue =
|
||||
IrGetValueImpl(startOffset, endOffset, symbol, origin)
|
||||
IrGetValueImpl(startOffset, endOffset, symbol, origin)
|
||||
}
|
||||
+7
-7
@@ -23,17 +23,17 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class IrIfThenElseImpl(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
) : IrWhenBase(startOffset, endOffset, type) {
|
||||
override val branches: MutableList<IrBranch> = SmartList()
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
condition: IrExpression,
|
||||
thenBranch: IrExpression,
|
||||
elseBranch: IrExpression? = null,
|
||||
origin: IrStatementOrigin? = null
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
condition: IrExpression,
|
||||
thenBranch: IrExpression,
|
||||
elseBranch: IrExpression? = null,
|
||||
origin: IrStatementOrigin? = null
|
||||
) : this(startOffset, endOffset, type, origin) {
|
||||
branches.add(IrBranchImpl(startOffset, endOffset, condition, thenBranch))
|
||||
if (elseBranch != null) {
|
||||
|
||||
+6
-6
@@ -24,15 +24,15 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
|
||||
class IrInstanceInitializerCallImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val classSymbol: IrClassSymbol
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val classSymbol: IrClassSymbol
|
||||
) : IrTerminalExpressionBase(startOffset, endOffset, classSymbol.descriptor.builtIns.unitType), IrInstanceInitializerCall {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
descriptor: ClassDescriptor
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
descriptor: ClassDescriptor
|
||||
) : this(startOffset, endOffset, IrClassSymbolImpl(descriptor))
|
||||
|
||||
override val classDescriptor: ClassDescriptor get() = classSymbol.descriptor
|
||||
|
||||
+10
-11
@@ -25,17 +25,16 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrLocalDelegatedPropertyReferenceImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val descriptor: VariableDescriptorWithAccessors,
|
||||
override val delegate: IrVariableSymbol,
|
||||
override val getter: IrFunctionSymbol,
|
||||
override val setter: IrFunctionSymbol?,
|
||||
origin: IrStatementOrigin? = null
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val descriptor: VariableDescriptorWithAccessors,
|
||||
override val delegate: IrVariableSymbol,
|
||||
override val getter: IrFunctionSymbol,
|
||||
override val setter: IrFunctionSymbol?,
|
||||
origin: IrStatementOrigin? = null
|
||||
) : IrLocalDelegatedPropertyReference,
|
||||
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, null, origin)
|
||||
{
|
||||
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, null, origin) {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitLocalDelegatedPropertyReference(this, data)
|
||||
visitor.visitLocalDelegatedPropertyReference(this, data)
|
||||
}
|
||||
@@ -22,10 +22,10 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrLoopBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val origin: IrStatementOrigin?
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val origin: IrStatementOrigin?
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrLoop {
|
||||
override var label: String? = null
|
||||
|
||||
|
||||
+5
-5
@@ -24,16 +24,16 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrMemberAccessExpressionBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
val typeArguments: Map<TypeParameterDescriptor, KotlinType>?
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
val typeArguments: Map<TypeParameterDescriptor, KotlinType>?
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrMemberAccessExpression {
|
||||
override var dispatchReceiver: IrExpression? = null
|
||||
override var extensionReceiver: IrExpression? = null
|
||||
|
||||
override fun getTypeArgument(typeParameterDescriptor: TypeParameterDescriptor): KotlinType? =
|
||||
typeArguments?.get(typeParameterDescriptor)
|
||||
typeArguments?.get(typeParameterDescriptor)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
dispatchReceiver?.accept(visitor, data)
|
||||
|
||||
+6
-7
@@ -23,14 +23,13 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrNoArgumentsCallableReferenceBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
) : IrCallableReference,
|
||||
IrMemberAccessExpressionBase(startOffset, endOffset, type, typeArguments)
|
||||
{
|
||||
IrMemberAccessExpressionBase(startOffset, endOffset, type, typeArguments) {
|
||||
private fun throwNoValueArguments(): Nothing {
|
||||
throw UnsupportedOperationException("Property reference $descriptor has no value arguments")
|
||||
}
|
||||
|
||||
+48
-44
@@ -16,7 +16,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.expressions.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCallWithShallowCopy
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
@@ -30,10 +32,10 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.lang.UnsupportedOperationException
|
||||
|
||||
abstract class IrPrimitiveCallBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val origin: IrStatementOrigin?,
|
||||
override val symbol: IrFunctionSymbol
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val origin: IrStatementOrigin?,
|
||||
override val symbol: IrFunctionSymbol
|
||||
) : IrExpressionBase(startOffset, endOffset, symbol.descriptor.returnType!!), IrCall {
|
||||
override val descriptor: FunctionDescriptor get() = symbol.descriptor
|
||||
override val superQualifier: ClassDescriptor? get() = null
|
||||
@@ -54,7 +56,7 @@ abstract class IrPrimitiveCallBase(
|
||||
}
|
||||
|
||||
override fun getTypeArgument(typeParameterDescriptor: TypeParameterDescriptor): KotlinType? =
|
||||
null // IR primitives have no type parameters
|
||||
null // IR primitives have no type parameters
|
||||
|
||||
override fun removeValueArgument(index: Int) {
|
||||
throw AssertionError("Operator call expression can't have a default argument")
|
||||
@@ -71,7 +73,7 @@ abstract class IrPrimitiveCallBase(
|
||||
}
|
||||
|
||||
class IrNullaryPrimitiveImpl(startOffset: Int, endOffset: Int, origin: IrStatementOrigin?, symbol: IrFunctionSymbol) :
|
||||
IrPrimitiveCallBase(startOffset, endOffset, origin, symbol), IrCallWithShallowCopy {
|
||||
IrPrimitiveCallBase(startOffset, endOffset, origin, symbol), IrCallWithShallowCopy {
|
||||
override fun getValueArgument(index: Int): IrExpression? = null
|
||||
|
||||
override fun putValueArgument(index: Int, valueArgument: IrExpression?) {
|
||||
@@ -87,42 +89,42 @@ class IrNullaryPrimitiveImpl(startOffset: Int, endOffset: Int, origin: IrStateme
|
||||
}
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall =
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall =
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, newOrigin, createFunctionSymbol(newCallee))
|
||||
IrNullaryPrimitiveImpl(startOffset, endOffset, newOrigin, createFunctionSymbol(newCallee))
|
||||
}
|
||||
|
||||
class IrUnaryPrimitiveImpl(startOffset: Int, endOffset: Int, origin: IrStatementOrigin?, symbol: IrFunctionSymbol) :
|
||||
IrPrimitiveCallBase(startOffset, endOffset, origin, symbol), IrCallWithShallowCopy {
|
||||
IrPrimitiveCallBase(startOffset, endOffset, origin, symbol), IrCallWithShallowCopy {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
origin: IrStatementOrigin?,
|
||||
functionDescriptor: FunctionDescriptor
|
||||
startOffset: Int, endOffset: Int,
|
||||
origin: IrStatementOrigin?,
|
||||
functionDescriptor: FunctionDescriptor
|
||||
) : this(
|
||||
startOffset, endOffset, origin,
|
||||
createFunctionSymbol(functionDescriptor)
|
||||
startOffset, endOffset, origin,
|
||||
createFunctionSymbol(functionDescriptor)
|
||||
)
|
||||
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
origin: IrStatementOrigin?,
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
argument: IrExpression
|
||||
startOffset: Int, endOffset: Int,
|
||||
origin: IrStatementOrigin?,
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
argument: IrExpression
|
||||
) : this(
|
||||
startOffset, endOffset, origin,
|
||||
createFunctionSymbol(functionDescriptor),
|
||||
argument
|
||||
startOffset, endOffset, origin,
|
||||
createFunctionSymbol(functionDescriptor),
|
||||
argument
|
||||
)
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
origin: IrStatementOrigin?,
|
||||
symbol: IrFunctionSymbol,
|
||||
argument: IrExpression
|
||||
startOffset: Int, endOffset: Int,
|
||||
origin: IrStatementOrigin?,
|
||||
symbol: IrFunctionSymbol,
|
||||
argument: IrExpression
|
||||
) : this(startOffset, endOffset, origin, symbol) {
|
||||
this.argument = argument
|
||||
}
|
||||
@@ -152,36 +154,38 @@ class IrUnaryPrimitiveImpl(startOffset: Int, endOffset: Int, origin: IrStatement
|
||||
}
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall =
|
||||
IrUnaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
IrUnaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall =
|
||||
IrUnaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
IrUnaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
}
|
||||
|
||||
class IrBinaryPrimitiveImpl(startOffset: Int, endOffset: Int, origin: IrStatementOrigin?, symbol: IrFunctionSymbol) :
|
||||
IrPrimitiveCallBase(startOffset, endOffset, origin, symbol), IrCallWithShallowCopy {
|
||||
IrPrimitiveCallBase(startOffset, endOffset, origin, symbol), IrCallWithShallowCopy {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, origin: IrStatementOrigin?,
|
||||
descriptor: FunctionDescriptor
|
||||
) : this(startOffset, endOffset, origin,
|
||||
createFunctionSymbol(descriptor))
|
||||
startOffset: Int, endOffset: Int, origin: IrStatementOrigin?,
|
||||
descriptor: FunctionDescriptor
|
||||
) : this(
|
||||
startOffset, endOffset, origin,
|
||||
createFunctionSymbol(descriptor)
|
||||
)
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, origin: IrStatementOrigin?,
|
||||
descriptor: FunctionDescriptor,
|
||||
argument0: IrExpression, argument1: IrExpression
|
||||
startOffset: Int, endOffset: Int, origin: IrStatementOrigin?,
|
||||
descriptor: FunctionDescriptor,
|
||||
argument0: IrExpression, argument1: IrExpression
|
||||
) : this(
|
||||
startOffset, endOffset, origin,
|
||||
createFunctionSymbol(descriptor),
|
||||
argument0, argument1
|
||||
startOffset, endOffset, origin,
|
||||
createFunctionSymbol(descriptor),
|
||||
argument0, argument1
|
||||
)
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, origin: IrStatementOrigin?,
|
||||
symbol: IrFunctionSymbol,
|
||||
argument0: IrExpression, argument1: IrExpression
|
||||
startOffset: Int, endOffset: Int, origin: IrStatementOrigin?,
|
||||
symbol: IrFunctionSymbol,
|
||||
argument0: IrExpression, argument1: IrExpression
|
||||
) : this(startOffset, endOffset, origin, symbol) {
|
||||
this.argument0 = argument0
|
||||
this.argument1 = argument1
|
||||
@@ -218,8 +222,8 @@ class IrBinaryPrimitiveImpl(startOffset: Int, endOffset: Int, origin: IrStatemen
|
||||
}
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall =
|
||||
IrBinaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
IrBinaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall =
|
||||
IrBinaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
IrBinaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee)
|
||||
}
|
||||
|
||||
+56
-48
@@ -34,12 +34,12 @@ import java.lang.AssertionError
|
||||
import java.lang.UnsupportedOperationException
|
||||
|
||||
abstract class IrPropertyAccessorCallBase(
|
||||
startOffset: Int, endOffset: Int,
|
||||
override val symbol: IrFunctionSymbol,
|
||||
override val descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null,
|
||||
override val superQualifierSymbol: IrClassSymbol? = null
|
||||
startOffset: Int, endOffset: Int,
|
||||
override val symbol: IrFunctionSymbol,
|
||||
override val descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
override val origin: IrStatementOrigin? = null,
|
||||
override val superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrMemberAccessExpressionBase(startOffset, endOffset, descriptor.returnType!!, typeArguments), IrCall {
|
||||
override val superQualifier: ClassDescriptor? get() = superQualifierSymbol?.descriptor
|
||||
|
||||
@@ -53,21 +53,23 @@ abstract class IrPropertyAccessorCallBase(
|
||||
}
|
||||
|
||||
class IrGetterCallImpl(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrPropertyAccessorCallBase(startOffset, endOffset, symbol, descriptor, typeArguments, origin, superQualifierSymbol),
|
||||
IrCallWithShallowCopy {
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
dispatchReceiver: IrExpression?,
|
||||
extensionReceiver: IrExpression?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrPropertyAccessorCallBase(startOffset, endOffset, symbol, descriptor, typeArguments, origin, superQualifierSymbol), IrCallWithShallowCopy {
|
||||
constructor(startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
dispatchReceiver: IrExpression?,
|
||||
extensionReceiver: IrExpression?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : this(startOffset, endOffset, symbol, descriptor, typeArguments, origin, superQualifierSymbol) {
|
||||
this.dispatchReceiver = dispatchReceiver
|
||||
this.extensionReceiver = extensionReceiver
|
||||
@@ -84,38 +86,42 @@ class IrGetterCallImpl(
|
||||
}
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall =
|
||||
IrGetterCallImpl(startOffset, endOffset, newCallee,
|
||||
descriptor, // TODO substitute descriptor for new callee?
|
||||
typeArguments, dispatchReceiver, extensionReceiver, newOrigin, newSuperQualifier)
|
||||
IrGetterCallImpl(
|
||||
startOffset, endOffset, newCallee,
|
||||
descriptor, // TODO substitute descriptor for new callee?
|
||||
typeArguments, dispatchReceiver, extensionReceiver, newOrigin, newSuperQualifier
|
||||
)
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall =
|
||||
IrGetterCallImpl(
|
||||
startOffset, endOffset,
|
||||
createFunctionSymbol(newCallee),
|
||||
newCallee,
|
||||
typeArguments, dispatchReceiver, extensionReceiver,
|
||||
newOrigin,
|
||||
createClassSymbolOrNull(newSuperQualifier)
|
||||
)
|
||||
IrGetterCallImpl(
|
||||
startOffset, endOffset,
|
||||
createFunctionSymbol(newCallee),
|
||||
newCallee,
|
||||
typeArguments, dispatchReceiver, extensionReceiver,
|
||||
newOrigin,
|
||||
createClassSymbolOrNull(newSuperQualifier)
|
||||
)
|
||||
}
|
||||
|
||||
class IrSetterCallImpl(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrPropertyAccessorCallBase(startOffset, endOffset, symbol, descriptor, typeArguments, origin, superQualifierSymbol),
|
||||
IrCallWithShallowCopy {
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
dispatchReceiver: IrExpression?,
|
||||
extensionReceiver: IrExpression?,
|
||||
argument: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrPropertyAccessorCallBase(startOffset, endOffset, symbol, descriptor, typeArguments, origin, superQualifierSymbol), IrCallWithShallowCopy {
|
||||
constructor(startOffset: Int, endOffset: Int,
|
||||
symbol: IrFunctionSymbol,
|
||||
descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
dispatchReceiver: IrExpression?,
|
||||
extensionReceiver: IrExpression?,
|
||||
argument: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : this(startOffset, endOffset, symbol, descriptor, typeArguments, origin, superQualifierSymbol) {
|
||||
this.dispatchReceiver = dispatchReceiver
|
||||
this.extensionReceiver = extensionReceiver
|
||||
@@ -125,7 +131,7 @@ class IrSetterCallImpl(
|
||||
private var argumentImpl: IrExpression? = null
|
||||
|
||||
override fun getValueArgument(index: Int): IrExpression? =
|
||||
if (index == SETTER_ARGUMENT_INDEX) argumentImpl!! else null
|
||||
if (index == SETTER_ARGUMENT_INDEX) argumentImpl!! else null
|
||||
|
||||
override fun putValueArgument(index: Int, valueArgument: IrExpression?) {
|
||||
if (index != SETTER_ARGUMENT_INDEX) throw AssertionError("Property setter call $descriptor has no argument $index")
|
||||
@@ -138,19 +144,21 @@ class IrSetterCallImpl(
|
||||
}
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall =
|
||||
IrSetterCallImpl(startOffset, endOffset, newCallee,
|
||||
descriptor, // TODO substitute newCallee.descriptor?
|
||||
typeArguments, newOrigin, newSuperQualifier)
|
||||
IrSetterCallImpl(
|
||||
startOffset, endOffset, newCallee,
|
||||
descriptor, // TODO substitute newCallee.descriptor?
|
||||
typeArguments, newOrigin, newSuperQualifier
|
||||
)
|
||||
|
||||
override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall =
|
||||
IrSetterCallImpl(
|
||||
startOffset, endOffset,
|
||||
createFunctionSymbol(newCallee),
|
||||
newCallee,
|
||||
typeArguments,
|
||||
newOrigin,
|
||||
createClassSymbolOrNull(newSuperQualifier)
|
||||
)
|
||||
IrSetterCallImpl(
|
||||
startOffset, endOffset,
|
||||
createFunctionSymbol(newCallee),
|
||||
newCallee,
|
||||
typeArguments,
|
||||
newOrigin,
|
||||
createClassSymbolOrNull(newSuperQualifier)
|
||||
)
|
||||
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
super.transformChildren(transformer, data)
|
||||
|
||||
+11
-12
@@ -26,18 +26,17 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrPropertyReferenceImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val descriptor: PropertyDescriptor,
|
||||
override val field: IrFieldSymbol?,
|
||||
override val getter: IrFunctionSymbol?,
|
||||
override val setter: IrFunctionSymbol?,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val descriptor: PropertyDescriptor,
|
||||
override val field: IrFieldSymbol?,
|
||||
override val getter: IrFunctionSymbol?,
|
||||
override val setter: IrFunctionSymbol?,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null
|
||||
) : IrPropertyReference,
|
||||
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, typeArguments, origin)
|
||||
{
|
||||
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, typeArguments, origin) {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitPropertyReference(this, data)
|
||||
visitor.visitPropertyReference(this, data)
|
||||
}
|
||||
@@ -27,31 +27,35 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrReturnImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val returnTargetSymbol: IrFunctionSymbol,
|
||||
override var value: IrExpression
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val returnTargetSymbol: IrFunctionSymbol,
|
||||
override var value: IrExpression
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrReturn {
|
||||
constructor(startOffset: Int, endOffset: Int, returnTargetSymbol: IrFunctionSymbol, value: IrExpression) :
|
||||
this(startOffset, endOffset, returnTargetSymbol.descriptor.builtIns.nothingType, returnTargetSymbol, value)
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType, returnTargetDescriptor: FunctionDescriptor, value: IrExpression) :
|
||||
this(startOffset, endOffset, type,
|
||||
createFunctionSymbol(returnTargetDescriptor),
|
||||
value)
|
||||
this(
|
||||
startOffset, endOffset, type,
|
||||
createFunctionSymbol(returnTargetDescriptor),
|
||||
value
|
||||
)
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(startOffset: Int, endOffset: Int, returnTargetDescriptor: FunctionDescriptor, value: IrExpression) :
|
||||
this(startOffset, endOffset, returnTargetDescriptor.builtIns.nothingType,
|
||||
createFunctionSymbol(returnTargetDescriptor),
|
||||
value)
|
||||
this(
|
||||
startOffset, endOffset, returnTargetDescriptor.builtIns.nothingType,
|
||||
createFunctionSymbol(returnTargetDescriptor),
|
||||
value
|
||||
)
|
||||
|
||||
override val returnTarget: FunctionDescriptor get() = returnTargetSymbol.descriptor
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitReturn(this, data)
|
||||
visitor.visitReturn(this, data)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
value.accept(visitor, data)
|
||||
|
||||
+43
-44
@@ -30,54 +30,53 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
class IrSetFieldImpl(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFieldSymbol,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrSetField,
|
||||
IrFieldExpressionBase(
|
||||
startOffset, endOffset,
|
||||
symbol,
|
||||
symbol.descriptor.type.builtIns.unitType,
|
||||
origin,
|
||||
superQualifierSymbol
|
||||
) {
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
receiver: IrExpression?,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
receiver, value, origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFieldSymbol,
|
||||
receiver: IrExpression?,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : IrSetField,
|
||||
IrFieldExpressionBase(
|
||||
startOffset, endOffset,
|
||||
symbol,
|
||||
symbol.descriptor.type.builtIns.unitType,
|
||||
origin,
|
||||
superQualifierSymbol
|
||||
)
|
||||
{
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
receiver: IrExpression?,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifier: ClassDescriptor? = null
|
||||
) : this(
|
||||
startOffset, endOffset,
|
||||
IrFieldSymbolImpl(propertyDescriptor),
|
||||
receiver, value, origin,
|
||||
createClassSymbolOrNull(superQualifier)
|
||||
)
|
||||
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrFieldSymbol,
|
||||
receiver: IrExpression?,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin? = null,
|
||||
superQualifierSymbol: IrClassSymbol? = null
|
||||
) : this(startOffset, endOffset, symbol, origin, superQualifierSymbol) {
|
||||
this.receiver = receiver
|
||||
this.value = value
|
||||
|
||||
+11
-11
@@ -27,25 +27,25 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
|
||||
class IrSetVariableImpl(
|
||||
startOffset: Int, endOffset: Int,
|
||||
override val symbol: IrVariableSymbol,
|
||||
override val origin: IrStatementOrigin?
|
||||
startOffset: Int, endOffset: Int,
|
||||
override val symbol: IrVariableSymbol,
|
||||
override val origin: IrStatementOrigin?
|
||||
) : IrExpressionBase(startOffset, endOffset, symbol.descriptor.builtIns.unitType), IrSetVariable {
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrVariableSymbol,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin?
|
||||
startOffset: Int, endOffset: Int,
|
||||
symbol: IrVariableSymbol,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin?
|
||||
) : this(startOffset, endOffset, symbol, origin) {
|
||||
this.value = value
|
||||
}
|
||||
|
||||
@Deprecated("Creates unbound symbol")
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int,
|
||||
descriptor: VariableDescriptor,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin?
|
||||
startOffset: Int, endOffset: Int,
|
||||
descriptor: VariableDescriptor,
|
||||
value: IrExpression,
|
||||
origin: IrStatementOrigin?
|
||||
) : this(startOffset, endOffset, IrVariableSymbolImpl(descriptor), value, origin)
|
||||
|
||||
override val descriptor: VariableDescriptor get() = symbol.descriptor
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
|
||||
class IrSpreadElementImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
) : IrElementBase(startOffset, endOffset), IrSpreadElement {
|
||||
constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) {
|
||||
this.expression = expression
|
||||
|
||||
+7
-3
@@ -24,8 +24,12 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.util.*
|
||||
|
||||
class IrStringConcatenationImpl(startOffset: Int, endOffset: Int, type: KotlinType) :
|
||||
IrExpressionBase(startOffset, endOffset, type), IrStringConcatenation {
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType, arguments: Collection<IrExpression>) : this(startOffset, endOffset, type) {
|
||||
IrExpressionBase(startOffset, endOffset, type), IrStringConcatenation {
|
||||
constructor(startOffset: Int, endOffset: Int, type: KotlinType, arguments: Collection<IrExpression>) : this(
|
||||
startOffset,
|
||||
endOffset,
|
||||
type
|
||||
) {
|
||||
this.arguments.addAll(arguments)
|
||||
}
|
||||
|
||||
@@ -36,7 +40,7 @@ class IrStringConcatenationImpl(startOffset: Int, endOffset: Int, type: KotlinTy
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitStringConcatenation(this, data)
|
||||
visitor.visitStringConcatenation(this, data)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
arguments.forEach { it.accept(visitor, data) }
|
||||
|
||||
+3
-2
@@ -22,7 +22,8 @@ import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
|
||||
class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: IrSyntheticBodyKind) : IrElementBase(startOffset, endOffset), IrSyntheticBody {
|
||||
class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: IrSyntheticBodyKind) : IrElementBase(startOffset, endOffset),
|
||||
IrSyntheticBody {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||
return visitor.visitSyntheticBody(this, data)
|
||||
}
|
||||
@@ -36,5 +37,5 @@ class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: I
|
||||
}
|
||||
|
||||
override fun toString(): String =
|
||||
"IrSyntheticBodyImpl($kind)"
|
||||
"IrSyntheticBodyImpl($kind)"
|
||||
}
|
||||
+6
-6
@@ -23,12 +23,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrTerminalDeclarationReferenceBase<out S: IrSymbol, out D : DeclarationDescriptor>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: S,
|
||||
descriptor: D
|
||||
abstract class IrTerminalDeclarationReferenceBase<out S : IrSymbol, out D : DeclarationDescriptor>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
symbol: S,
|
||||
descriptor: D
|
||||
) : IrDeclarationReferenceBase<S, D>(startOffset, endOffset, type, symbol, descriptor), IrDeclarationReference {
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
// No children
|
||||
|
||||
+3
-3
@@ -21,9 +21,9 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrTerminalExpressionBase(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType
|
||||
) : IrExpressionBase(startOffset, endOffset, type) {
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
// No children
|
||||
|
||||
@@ -23,15 +23,15 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrThrowImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrThrow {
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
value: IrExpression
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
value: IrExpression
|
||||
) : this(startOffset, endOffset, type) {
|
||||
this.value = value
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class IrThrowImpl(
|
||||
override lateinit var value: IrExpression
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitThrow(this, data)
|
||||
visitor.visitThrow(this, data)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
value.accept(visitor, data)
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class IrTryImpl(startOffset: Int, endOffset: Int, type: KotlinType) :
|
||||
IrExpressionBase(startOffset, endOffset, type), IrTry {
|
||||
IrExpressionBase(startOffset, endOffset, type), IrTry {
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
tryResult: IrExpression, catches: List<IrCatch>, finallyExpression: IrExpression?
|
||||
startOffset: Int, endOffset: Int, type: KotlinType,
|
||||
tryResult: IrExpression, catches: List<IrCatch>, finallyExpression: IrExpression?
|
||||
) : this(startOffset, endOffset, type) {
|
||||
this.tryResult = tryResult
|
||||
this.catches.addAll(catches)
|
||||
@@ -63,9 +63,7 @@ class IrTryImpl(startOffset: Int, endOffset: Int, type: KotlinType) :
|
||||
}
|
||||
}
|
||||
|
||||
class IrCatchImpl(startOffset: Int, endOffset: Int)
|
||||
: IrCatch, IrElementBase(startOffset, endOffset)
|
||||
{
|
||||
class IrCatchImpl(startOffset: Int, endOffset: Int) : IrCatch, IrElementBase(startOffset, endOffset) {
|
||||
constructor(startOffset: Int, endOffset: Int, catchParameter: IrVariable)
|
||||
: this(startOffset, endOffset) {
|
||||
this.catchParameter = catchParameter
|
||||
|
||||
+11
-11
@@ -24,19 +24,19 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrTypeOperatorCallImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val operator: IrTypeOperator,
|
||||
override val typeOperand: KotlinType
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrTypeOperatorCall {
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val operator: IrTypeOperator,
|
||||
override val typeOperand: KotlinType
|
||||
) : IrExpressionBase(startOffset, endOffset, type), IrTypeOperatorCall {
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
operator: IrTypeOperator,
|
||||
typeOperand: KotlinType,
|
||||
argument: IrExpression
|
||||
operator: IrTypeOperator,
|
||||
typeOperand: KotlinType,
|
||||
argument: IrExpression
|
||||
) : this(startOffset, endOffset, type, operator, typeOperand) {
|
||||
this.argument = argument
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class IrTypeOperatorCallImpl(
|
||||
override lateinit var argument: IrExpression
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitTypeOperator(this, data)
|
||||
visitor.visitTypeOperator(this, data)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
argument.accept(visitor, data)
|
||||
|
||||
@@ -24,14 +24,14 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class IrVarargImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val varargElementType: KotlinType
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val varargElementType: KotlinType
|
||||
) : IrVararg, IrExpressionBase(startOffset, endOffset, type) {
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType, varargElementType: KotlinType,
|
||||
elements: List<IrVarargElement>
|
||||
startOffset: Int, endOffset: Int, type: KotlinType, varargElementType: KotlinType,
|
||||
elements: List<IrVarargElement>
|
||||
) : this(startOffset, endOffset, type, varargElementType) {
|
||||
this.elements.addAll(elements)
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import java.util.*
|
||||
|
||||
abstract class IrWhenBase(startOffset: Int, endOffset: Int, type: KotlinType, override val origin: IrStatementOrigin? = null) :
|
||||
IrExpressionBase(startOffset, endOffset, type), IrWhen {
|
||||
IrExpressionBase(startOffset, endOffset, type), IrWhen {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitWhen(this, data)
|
||||
visitor.visitWhen(this, data)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
branches.forEach { it.accept(visitor, data) }
|
||||
@@ -41,14 +41,14 @@ abstract class IrWhenBase(startOffset: Int, endOffset: Int, type: KotlinType, ov
|
||||
}
|
||||
|
||||
class IrWhenImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
type: KotlinType,
|
||||
override val origin: IrStatementOrigin? = null
|
||||
) : IrWhenBase(startOffset, endOffset, type) {
|
||||
constructor(
|
||||
startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?,
|
||||
branches: List<IrBranch>
|
||||
startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?,
|
||||
branches: List<IrBranch>
|
||||
) : this(startOffset, endOffset, type, origin) {
|
||||
this.branches.addAll(branches)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class IrWhenImpl(
|
||||
}
|
||||
|
||||
open class IrBranchImpl(startOffset: Int, endOffset: Int, override var condition: IrExpression, override var result: IrExpression) :
|
||||
IrElementBase(startOffset, endOffset), IrBranch {
|
||||
IrElementBase(startOffset, endOffset), IrBranch {
|
||||
constructor(condition: IrExpression, result: IrExpression) : this(condition.startOffset, condition.endOffset, condition, result)
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
@@ -72,14 +72,14 @@ open class IrBranchImpl(startOffset: Int, endOffset: Int, override var condition
|
||||
|
||||
companion object {
|
||||
fun elseBranch(result: IrExpression) =
|
||||
IrElseBranchImpl(
|
||||
IrConstImpl.boolean(result.startOffset, result.endOffset, result.type.builtIns.booleanType, true),
|
||||
result
|
||||
)
|
||||
IrElseBranchImpl(
|
||||
IrConstImpl.boolean(result.startOffset, result.endOffset, result.type.builtIns.booleanType, true),
|
||||
result
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class IrElseBranchImpl(startOffset: Int, endOffset: Int, condition: IrExpression, result: IrExpression) :
|
||||
IrBranchImpl(startOffset, endOffset, condition, result), IrElseBranch {
|
||||
IrBranchImpl(startOffset, endOffset, condition, result), IrElseBranch {
|
||||
constructor(condition: IrExpression, result: IrExpression) : this(condition.startOffset, condition.endOffset, condition, result)
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrWhileLoopImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?) :
|
||||
IrLoopBase(startOffset, endOffset, type, origin), IrWhileLoop {
|
||||
IrLoopBase(startOffset, endOffset, type, origin), IrWhileLoop {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||
return visitor.visitWhileLoop(this, data)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
|
||||
|
||||
interface IrSymbol {
|
||||
val owner : IrSymbolOwner
|
||||
val owner: IrSymbolOwner
|
||||
val descriptor: DeclarationDescriptor
|
||||
val isBound: Boolean
|
||||
}
|
||||
@@ -36,6 +36,7 @@ interface IrBindableSymbol<out D : DeclarationDescriptor, B : IrSymbolOwner> : I
|
||||
interface IrPackageFragmentSymbol : IrSymbol {
|
||||
override val descriptor: PackageFragmentDescriptor
|
||||
}
|
||||
|
||||
interface IrFileSymbol : IrPackageFragmentSymbol, IrBindableSymbol<PackageFragmentDescriptor, IrFile>
|
||||
interface IrExternalPackageFragmentSymbol : IrPackageFragmentSymbol, IrBindableSymbol<PackageFragmentDescriptor, IrExternalPackageFragment>
|
||||
|
||||
@@ -47,18 +48,21 @@ interface IrFieldSymbol : IrBindableSymbol<PropertyDescriptor, IrField>
|
||||
interface IrClassifierSymbol : IrSymbol {
|
||||
override val descriptor: ClassifierDescriptor
|
||||
}
|
||||
|
||||
interface IrClassSymbol : IrClassifierSymbol, IrBindableSymbol<ClassDescriptor, IrClass>
|
||||
interface IrTypeParameterSymbol : IrClassifierSymbol, IrBindableSymbol<TypeParameterDescriptor, IrTypeParameter>
|
||||
|
||||
interface IrValueSymbol : IrSymbol {
|
||||
override val descriptor: ValueDescriptor
|
||||
}
|
||||
|
||||
interface IrValueParameterSymbol : IrValueSymbol, IrBindableSymbol<ParameterDescriptor, IrValueParameter>
|
||||
interface IrVariableSymbol : IrValueSymbol, IrBindableSymbol<VariableDescriptor, IrVariable>
|
||||
|
||||
interface IrFunctionSymbol : IrSymbol {
|
||||
override val descriptor: FunctionDescriptor
|
||||
}
|
||||
|
||||
interface IrConstructorSymbol : IrFunctionSymbol, IrBindableSymbol<ClassConstructorDescriptor, IrConstructor>
|
||||
interface IrSimpleFunctionSymbol : IrFunctionSymbol, IrBindableSymbol<FunctionDescriptor, IrSimpleFunction>
|
||||
|
||||
|
||||
@@ -17,20 +17,14 @@
|
||||
package org.jetbrains.kotlin.ir.symbols.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrContainerExpressionBase
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
abstract class IrSymbolBase<out D : DeclarationDescriptor>(override val descriptor: D) : IrSymbol
|
||||
|
||||
abstract class IrBindableSymbolBase<out D : DeclarationDescriptor, B : IrSymbolOwner>(descriptor: D) :
|
||||
IrBindableSymbol<D, B>, IrSymbolBase<D>(descriptor) {
|
||||
IrBindableSymbol<D, B>, IrSymbolBase<D>(descriptor) {
|
||||
init {
|
||||
assert(isOriginalDescriptor(descriptor)) {
|
||||
"Substituted descriptor $descriptor for ${descriptor.original}"
|
||||
@@ -38,10 +32,10 @@ abstract class IrBindableSymbolBase<out D : DeclarationDescriptor, B : IrSymbolO
|
||||
}
|
||||
|
||||
private fun isOriginalDescriptor(descriptor: DeclarationDescriptor): Boolean =
|
||||
if (descriptor is ValueParameterDescriptor)
|
||||
isOriginalDescriptor(descriptor.containingDeclaration)
|
||||
else
|
||||
descriptor == descriptor.original
|
||||
if (descriptor is ValueParameterDescriptor)
|
||||
isOriginalDescriptor(descriptor.containingDeclaration)
|
||||
else
|
||||
descriptor == descriptor.original
|
||||
|
||||
private var _owner: B? = null
|
||||
override val owner: B
|
||||
@@ -59,66 +53,66 @@ abstract class IrBindableSymbolBase<out D : DeclarationDescriptor, B : IrSymbolO
|
||||
}
|
||||
|
||||
class IrFileSymbolImpl(descriptor: PackageFragmentDescriptor) :
|
||||
IrBindableSymbolBase<PackageFragmentDescriptor, IrFile>(descriptor),
|
||||
IrFileSymbol
|
||||
IrBindableSymbolBase<PackageFragmentDescriptor, IrFile>(descriptor),
|
||||
IrFileSymbol
|
||||
|
||||
class IrExternalPackageFragmentSymbolImpl(descriptor: PackageFragmentDescriptor) :
|
||||
IrBindableSymbolBase<PackageFragmentDescriptor, IrExternalPackageFragment>(descriptor),
|
||||
IrExternalPackageFragmentSymbol
|
||||
IrBindableSymbolBase<PackageFragmentDescriptor, IrExternalPackageFragment>(descriptor),
|
||||
IrExternalPackageFragmentSymbol
|
||||
|
||||
class IrAnonymousInitializerSymbolImpl(descriptor: ClassDescriptor) :
|
||||
IrBindableSymbolBase<ClassDescriptor, IrAnonymousInitializer>(descriptor),
|
||||
IrAnonymousInitializerSymbol
|
||||
IrBindableSymbolBase<ClassDescriptor, IrAnonymousInitializer>(descriptor),
|
||||
IrAnonymousInitializerSymbol
|
||||
|
||||
class IrClassSymbolImpl(descriptor: ClassDescriptor) :
|
||||
IrBindableSymbolBase<ClassDescriptor, IrClass>(descriptor),
|
||||
IrClassSymbol
|
||||
IrBindableSymbolBase<ClassDescriptor, IrClass>(descriptor),
|
||||
IrClassSymbol
|
||||
|
||||
fun createClassSymbolOrNull(descriptor: ClassDescriptor?) =
|
||||
descriptor?.let { IrClassSymbolImpl(it) }
|
||||
descriptor?.let { IrClassSymbolImpl(it) }
|
||||
|
||||
class IrEnumEntrySymbolImpl(descriptor: ClassDescriptor) :
|
||||
IrBindableSymbolBase<ClassDescriptor, IrEnumEntry>(descriptor),
|
||||
IrEnumEntrySymbol
|
||||
IrBindableSymbolBase<ClassDescriptor, IrEnumEntry>(descriptor),
|
||||
IrEnumEntrySymbol
|
||||
|
||||
class IrFieldSymbolImpl(descriptor: PropertyDescriptor) :
|
||||
IrBindableSymbolBase<PropertyDescriptor, IrField>(descriptor),
|
||||
IrFieldSymbol
|
||||
IrBindableSymbolBase<PropertyDescriptor, IrField>(descriptor),
|
||||
IrFieldSymbol
|
||||
|
||||
class IrTypeParameterSymbolImpl(descriptor: TypeParameterDescriptor) :
|
||||
IrBindableSymbolBase<TypeParameterDescriptor, IrTypeParameter>(descriptor),
|
||||
IrTypeParameterSymbol
|
||||
IrBindableSymbolBase<TypeParameterDescriptor, IrTypeParameter>(descriptor),
|
||||
IrTypeParameterSymbol
|
||||
|
||||
class IrValueParameterSymbolImpl(descriptor: ParameterDescriptor) :
|
||||
IrBindableSymbolBase<ParameterDescriptor, IrValueParameter>(descriptor),
|
||||
IrValueParameterSymbol
|
||||
IrBindableSymbolBase<ParameterDescriptor, IrValueParameter>(descriptor),
|
||||
IrValueParameterSymbol
|
||||
|
||||
class IrVariableSymbolImpl(descriptor: VariableDescriptor) :
|
||||
IrBindableSymbolBase<VariableDescriptor, IrVariable>(descriptor),
|
||||
IrVariableSymbol
|
||||
IrBindableSymbolBase<VariableDescriptor, IrVariable>(descriptor),
|
||||
IrVariableSymbol
|
||||
|
||||
fun createValueSymbol(descriptor: ValueDescriptor): IrValueSymbol =
|
||||
when (descriptor) {
|
||||
is ParameterDescriptor -> IrValueParameterSymbolImpl(descriptor)
|
||||
is VariableDescriptor -> IrVariableSymbolImpl(descriptor)
|
||||
else -> throw IllegalArgumentException("Unexpected descriptor kind: $descriptor")
|
||||
}
|
||||
when (descriptor) {
|
||||
is ParameterDescriptor -> IrValueParameterSymbolImpl(descriptor)
|
||||
is VariableDescriptor -> IrVariableSymbolImpl(descriptor)
|
||||
else -> throw IllegalArgumentException("Unexpected descriptor kind: $descriptor")
|
||||
}
|
||||
|
||||
class IrSimpleFunctionSymbolImpl(descriptor: FunctionDescriptor) :
|
||||
IrBindableSymbolBase<FunctionDescriptor, IrSimpleFunction>(descriptor),
|
||||
IrSimpleFunctionSymbol
|
||||
IrBindableSymbolBase<FunctionDescriptor, IrSimpleFunction>(descriptor),
|
||||
IrSimpleFunctionSymbol
|
||||
|
||||
class IrConstructorSymbolImpl(descriptor: ClassConstructorDescriptor) :
|
||||
IrBindableSymbolBase<ClassConstructorDescriptor, IrConstructor>(descriptor),
|
||||
IrConstructorSymbol
|
||||
IrBindableSymbolBase<ClassConstructorDescriptor, IrConstructor>(descriptor),
|
||||
IrConstructorSymbol
|
||||
|
||||
fun createFunctionSymbol(descriptor: CallableMemberDescriptor): IrFunctionSymbol =
|
||||
when (descriptor) {
|
||||
is ClassConstructorDescriptor -> IrConstructorSymbolImpl(descriptor.original)
|
||||
is FunctionDescriptor -> IrSimpleFunctionSymbolImpl(descriptor.original)
|
||||
else -> throw IllegalArgumentException("Unexpected descriptor kind: $descriptor")
|
||||
}
|
||||
when (descriptor) {
|
||||
is ClassConstructorDescriptor -> IrConstructorSymbolImpl(descriptor.original)
|
||||
is FunctionDescriptor -> IrSimpleFunctionSymbolImpl(descriptor.original)
|
||||
else -> throw IllegalArgumentException("Unexpected descriptor kind: $descriptor")
|
||||
}
|
||||
|
||||
class IrReturnableBlockSymbolImpl(descriptor: FunctionDescriptor) :
|
||||
IrBindableSymbolBase<FunctionDescriptor, IrReturnableBlock>(descriptor),
|
||||
IrReturnableBlockSymbol
|
||||
IrBindableSymbolBase<FunctionDescriptor, IrReturnableBlock>(descriptor),
|
||||
IrReturnableBlockSymbol
|
||||
@@ -24,97 +24,96 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
|
||||
class DeclarationStubGenerator(
|
||||
val symbolTable: SymbolTable,
|
||||
val origin: IrDeclarationOrigin
|
||||
val symbolTable: SymbolTable,
|
||||
val origin: IrDeclarationOrigin
|
||||
) {
|
||||
fun generateEmptyModuleFragmentStub(descriptor: ModuleDescriptor, irBuiltIns: IrBuiltIns): IrModuleFragment =
|
||||
IrModuleFragmentImpl(descriptor, irBuiltIns)
|
||||
IrModuleFragmentImpl(descriptor, irBuiltIns)
|
||||
|
||||
fun generateEmptyExternalPackageFragmentStub(descriptor: PackageFragmentDescriptor): IrExternalPackageFragment =
|
||||
symbolTable.declareExternalPackageFragment(descriptor)
|
||||
symbolTable.declareExternalPackageFragment(descriptor)
|
||||
|
||||
fun generateMemberStub(descriptor: DeclarationDescriptor): IrDeclaration =
|
||||
when (descriptor) {
|
||||
is ClassDescriptor ->
|
||||
if (DescriptorUtils.isEnumEntry(descriptor))
|
||||
generateEnumEntryStub(descriptor)
|
||||
else
|
||||
generateClassStub(descriptor)
|
||||
is ClassConstructorDescriptor ->
|
||||
generateConstructorStub(descriptor)
|
||||
is FunctionDescriptor ->
|
||||
generateFunctionStub(descriptor)
|
||||
is PropertyDescriptor ->
|
||||
generatePropertyStub(descriptor)
|
||||
else ->
|
||||
throw AssertionError("Unexpected member descriptor: $descriptor")
|
||||
}
|
||||
when (descriptor) {
|
||||
is ClassDescriptor ->
|
||||
if (DescriptorUtils.isEnumEntry(descriptor))
|
||||
generateEnumEntryStub(descriptor)
|
||||
else
|
||||
generateClassStub(descriptor)
|
||||
is ClassConstructorDescriptor ->
|
||||
generateConstructorStub(descriptor)
|
||||
is FunctionDescriptor ->
|
||||
generateFunctionStub(descriptor)
|
||||
is PropertyDescriptor ->
|
||||
generatePropertyStub(descriptor)
|
||||
else ->
|
||||
throw AssertionError("Unexpected member descriptor: $descriptor")
|
||||
}
|
||||
|
||||
fun generatePropertyStub(descriptor: PropertyDescriptor): IrProperty =
|
||||
IrPropertyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irProperty ->
|
||||
val getterDescriptor = descriptor.getter
|
||||
if (getterDescriptor == null) {
|
||||
irProperty.backingField =
|
||||
symbolTable.declareField(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor)
|
||||
}
|
||||
else {
|
||||
irProperty.getter = generateFunctionStub(getterDescriptor)
|
||||
}
|
||||
|
||||
irProperty.setter = descriptor.setter?.let { generateFunctionStub(it) }
|
||||
IrPropertyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irProperty ->
|
||||
val getterDescriptor = descriptor.getter
|
||||
if (getterDescriptor == null) {
|
||||
irProperty.backingField =
|
||||
symbolTable.declareField(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor)
|
||||
} else {
|
||||
irProperty.getter = generateFunctionStub(getterDescriptor)
|
||||
}
|
||||
|
||||
irProperty.setter = descriptor.setter?.let { generateFunctionStub(it) }
|
||||
}
|
||||
|
||||
fun generateFunctionStub(descriptor: FunctionDescriptor): IrSimpleFunction =
|
||||
symbolTable.declareSimpleFunction(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor.original).also { irFunction ->
|
||||
generateTypeParameterStubs(descriptor.typeParameters, irFunction)
|
||||
generateValueParametersStubs(descriptor.valueParameters, irFunction)
|
||||
}
|
||||
symbolTable.declareSimpleFunction(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor.original).also { irFunction ->
|
||||
generateTypeParameterStubs(descriptor.typeParameters, irFunction)
|
||||
generateValueParametersStubs(descriptor.valueParameters, irFunction)
|
||||
}
|
||||
|
||||
fun generateConstructorStub(descriptor: ClassConstructorDescriptor): IrConstructor =
|
||||
symbolTable.declareConstructor(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor.original).also { irConstructor ->
|
||||
generateValueParametersStubs(descriptor.valueParameters, irConstructor)
|
||||
}
|
||||
symbolTable.declareConstructor(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor.original).also { irConstructor ->
|
||||
generateValueParametersStubs(descriptor.valueParameters, irConstructor)
|
||||
}
|
||||
|
||||
fun generateValueParametersStubs(valueParameters: Collection<ValueParameterDescriptor>, function: IrFunction) {
|
||||
valueParameters.mapTo(function.valueParameters) { generateValueParameterStub(it) }
|
||||
}
|
||||
|
||||
fun generateValueParameterStub(descriptor: ValueParameterDescriptor): IrValueParameter =
|
||||
IrValueParameterImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irValueParameter ->
|
||||
if (descriptor.declaresDefaultValue()) {
|
||||
irValueParameter.defaultValue =
|
||||
IrExpressionBodyImpl(IrErrorExpressionImpl(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, descriptor.type,
|
||||
"Stub expression for default value of ${descriptor.name}"
|
||||
))
|
||||
}
|
||||
IrValueParameterImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irValueParameter ->
|
||||
if (descriptor.declaresDefaultValue()) {
|
||||
irValueParameter.defaultValue =
|
||||
IrExpressionBodyImpl(
|
||||
IrErrorExpressionImpl(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, descriptor.type,
|
||||
"Stub expression for default value of ${descriptor.name}"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun generateClassStub(descriptor: ClassDescriptor): IrClass =
|
||||
symbolTable.declareClass(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irClass ->
|
||||
generateTypeParameterStubs(descriptor.declaredTypeParameters, irClass)
|
||||
generateChildStubs(descriptor.constructors, irClass)
|
||||
generateMemberStubs(descriptor.defaultType.memberScope, irClass)
|
||||
generateMemberStubs(descriptor.staticScope, irClass)
|
||||
}
|
||||
symbolTable.declareClass(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor).also { irClass ->
|
||||
generateTypeParameterStubs(descriptor.declaredTypeParameters, irClass)
|
||||
generateChildStubs(descriptor.constructors, irClass)
|
||||
generateMemberStubs(descriptor.defaultType.memberScope, irClass)
|
||||
generateMemberStubs(descriptor.staticScope, irClass)
|
||||
}
|
||||
|
||||
fun generateEnumEntryStub(descriptor: ClassDescriptor): IrEnumEntry =
|
||||
symbolTable.declareEnumEntry(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor)
|
||||
symbolTable.declareEnumEntry(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor)
|
||||
|
||||
fun generateTypeParameterStubs(typeParameters: List<TypeParameterDescriptor>, container: IrTypeParametersContainer) {
|
||||
typeParameters.mapTo(container.typeParameters) { generateTypeParameterStub(it) }
|
||||
}
|
||||
|
||||
fun generateTypeParameterStub(descriptor: TypeParameterDescriptor): IrTypeParameter =
|
||||
IrTypeParameterImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor)
|
||||
IrTypeParameterImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, descriptor)
|
||||
|
||||
fun generateMemberStubs(memberScope: MemberScope, container: IrDeclarationContainer) {
|
||||
generateChildStubs(memberScope.getContributedDescriptors(), container)
|
||||
|
||||
@@ -29,10 +29,10 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.util.HashMap
|
||||
import java.util.*
|
||||
|
||||
inline fun <reified T : IrElement> T.deepCopyOld() =
|
||||
transform(DeepCopyIrTree(), null) as T
|
||||
transform(DeepCopyIrTree(), null) as T
|
||||
|
||||
@Deprecated("Creates unbound symbols")
|
||||
open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
@@ -67,307 +67,313 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
private inline fun <reified T : IrElement> T.transform() = transform(this@DeepCopyIrTree, null) as T
|
||||
|
||||
override fun visitElement(element: IrElement): IrElement =
|
||||
throw IllegalArgumentException("Unsupported element type: $element")
|
||||
throw IllegalArgumentException("Unsupported element type: $element")
|
||||
|
||||
override fun visitModuleFragment(declaration: IrModuleFragment): IrModuleFragment =
|
||||
IrModuleFragmentImpl(
|
||||
mapModuleDescriptor(declaration.descriptor),
|
||||
declaration.irBuiltins,
|
||||
declaration.files.map { it.transform() }
|
||||
)
|
||||
IrModuleFragmentImpl(
|
||||
mapModuleDescriptor(declaration.descriptor),
|
||||
declaration.irBuiltins,
|
||||
declaration.files.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitFile(declaration: IrFile): IrFile =
|
||||
IrFileImpl(
|
||||
mapFileEntry(declaration.fileEntry),
|
||||
mapPackageFragmentDescriptor(declaration.packageFragmentDescriptor),
|
||||
declaration.fileAnnotations.toMutableList(),
|
||||
declaration.declarations.map { it.transform() }
|
||||
)
|
||||
IrFileImpl(
|
||||
mapFileEntry(declaration.fileEntry),
|
||||
mapPackageFragmentDescriptor(declaration.packageFragmentDescriptor),
|
||||
declaration.fileAnnotations.toMutableList(),
|
||||
declaration.declarations.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitDeclaration(declaration: IrDeclaration): IrStatement =
|
||||
throw IllegalArgumentException("Unsupported declaration type: $declaration")
|
||||
throw IllegalArgumentException("Unsupported declaration type: $declaration")
|
||||
|
||||
override fun visitClass(declaration: IrClass): IrClass =
|
||||
IrClassImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapClassDeclaration(declaration.descriptor),
|
||||
declaration.declarations.map { it.transform() }
|
||||
).apply {
|
||||
thisReceiver = declaration.thisReceiver?.withDescriptor(descriptor.thisAsReceiverParameter)
|
||||
transformTypeParameters(declaration, descriptor.declaredTypeParameters)
|
||||
}
|
||||
IrClassImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapClassDeclaration(declaration.descriptor),
|
||||
declaration.declarations.map { it.transform() }
|
||||
).apply {
|
||||
thisReceiver = declaration.thisReceiver?.withDescriptor(descriptor.thisAsReceiverParameter)
|
||||
transformTypeParameters(declaration, descriptor.declaredTypeParameters)
|
||||
}
|
||||
|
||||
private fun IrValueParameter.withDescriptor(newDescriptor: ParameterDescriptor) =
|
||||
IrValueParameterImpl(startOffset, endOffset, origin, newDescriptor, defaultValue?.transform())
|
||||
IrValueParameterImpl(startOffset, endOffset, origin, newDescriptor, defaultValue?.transform())
|
||||
|
||||
override fun visitTypeAlias(declaration: IrTypeAlias): IrTypeAlias =
|
||||
IrTypeAliasImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapTypeAliasDeclaration(declaration.descriptor)
|
||||
)
|
||||
IrTypeAliasImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapTypeAliasDeclaration(declaration.descriptor)
|
||||
)
|
||||
|
||||
override fun visitFunction(declaration: IrFunction): IrFunction =
|
||||
IrFunctionImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapFunctionDeclaration(declaration.descriptor),
|
||||
declaration.body?.transform()
|
||||
).transformParameters(declaration)
|
||||
IrFunctionImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapFunctionDeclaration(declaration.descriptor),
|
||||
declaration.body?.transform()
|
||||
).transformParameters(declaration)
|
||||
|
||||
override fun visitConstructor(declaration: IrConstructor): IrConstructor =
|
||||
IrConstructorImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapConstructorDeclaration(declaration.descriptor),
|
||||
declaration.body!!.transform()
|
||||
).transformParameters(declaration)
|
||||
IrConstructorImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapConstructorDeclaration(declaration.descriptor),
|
||||
declaration.body!!.transform()
|
||||
).transformParameters(declaration)
|
||||
|
||||
protected fun <T : IrTypeParametersContainer> T.transformTypeParameters(original: T, myTypeParameters: List<TypeParameterDescriptor>): T =
|
||||
apply {
|
||||
original.typeParameters.mapTo(typeParameters) { originalTypeParameter ->
|
||||
copyTypeParameter(originalTypeParameter, myTypeParameters[originalTypeParameter.descriptor.index])
|
||||
}
|
||||
protected fun <T : IrTypeParametersContainer> T.transformTypeParameters(
|
||||
original: T,
|
||||
myTypeParameters: List<TypeParameterDescriptor>
|
||||
): T =
|
||||
apply {
|
||||
original.typeParameters.mapTo(typeParameters) { originalTypeParameter ->
|
||||
copyTypeParameter(originalTypeParameter, myTypeParameters[originalTypeParameter.descriptor.index])
|
||||
}
|
||||
}
|
||||
|
||||
protected fun <T : IrFunction> T.transformParameters(original: T): T =
|
||||
apply {
|
||||
transformTypeParameters(original, descriptor.typeParameters)
|
||||
transformValueParameters(original)
|
||||
}
|
||||
apply {
|
||||
transformTypeParameters(original, descriptor.typeParameters)
|
||||
transformValueParameters(original)
|
||||
}
|
||||
|
||||
protected fun <T : IrFunction> T.transformValueParameters(original: T) =
|
||||
apply {
|
||||
dispatchReceiverParameter = original.dispatchReceiverParameter?.let {
|
||||
copyValueParameter(it, descriptor.dispatchReceiverParameter ?: throw AssertionError("No dispatch receiver in $descriptor"))
|
||||
}
|
||||
|
||||
extensionReceiverParameter = original.extensionReceiverParameter?.let {
|
||||
copyValueParameter(it, descriptor.extensionReceiverParameter ?: throw AssertionError("No extension receiver in $descriptor"))
|
||||
}
|
||||
|
||||
original.valueParameters.mapIndexedTo(valueParameters) { i, originalValueParameter ->
|
||||
copyValueParameter(originalValueParameter, descriptor.valueParameters[i])
|
||||
}
|
||||
apply {
|
||||
dispatchReceiverParameter = original.dispatchReceiverParameter?.let {
|
||||
copyValueParameter(it, descriptor.dispatchReceiverParameter ?: throw AssertionError("No dispatch receiver in $descriptor"))
|
||||
}
|
||||
|
||||
extensionReceiverParameter = original.extensionReceiverParameter?.let {
|
||||
copyValueParameter(
|
||||
it,
|
||||
descriptor.extensionReceiverParameter ?: throw AssertionError("No extension receiver in $descriptor")
|
||||
)
|
||||
}
|
||||
|
||||
original.valueParameters.mapIndexedTo(valueParameters) { i, originalValueParameter ->
|
||||
copyValueParameter(originalValueParameter, descriptor.valueParameters[i])
|
||||
}
|
||||
}
|
||||
|
||||
protected fun copyTypeParameter(
|
||||
originalTypeParameter: IrTypeParameter,
|
||||
newTypeParameterDescriptor: TypeParameterDescriptor
|
||||
originalTypeParameter: IrTypeParameter,
|
||||
newTypeParameterDescriptor: TypeParameterDescriptor
|
||||
): IrTypeParameterImpl =
|
||||
IrTypeParameterImpl(
|
||||
originalTypeParameter.startOffset, originalTypeParameter.endOffset,
|
||||
mapDeclarationOrigin(originalTypeParameter.origin),
|
||||
newTypeParameterDescriptor
|
||||
)
|
||||
IrTypeParameterImpl(
|
||||
originalTypeParameter.startOffset, originalTypeParameter.endOffset,
|
||||
mapDeclarationOrigin(originalTypeParameter.origin),
|
||||
newTypeParameterDescriptor
|
||||
)
|
||||
|
||||
protected fun copyValueParameter(
|
||||
originalValueParameter: IrValueParameter,
|
||||
newParameterDescriptor: ParameterDescriptor
|
||||
originalValueParameter: IrValueParameter,
|
||||
newParameterDescriptor: ParameterDescriptor
|
||||
): IrValueParameterImpl =
|
||||
IrValueParameterImpl(
|
||||
originalValueParameter.startOffset, originalValueParameter.endOffset,
|
||||
mapDeclarationOrigin(originalValueParameter.origin),
|
||||
newParameterDescriptor,
|
||||
originalValueParameter.defaultValue?.transform()
|
||||
)
|
||||
IrValueParameterImpl(
|
||||
originalValueParameter.startOffset, originalValueParameter.endOffset,
|
||||
mapDeclarationOrigin(originalValueParameter.origin),
|
||||
newParameterDescriptor,
|
||||
originalValueParameter.defaultValue?.transform()
|
||||
)
|
||||
|
||||
// TODO visitTypeParameter
|
||||
// TODO visitValueParameter
|
||||
|
||||
override fun visitProperty(declaration: IrProperty): IrProperty =
|
||||
IrPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.isDelegated,
|
||||
mapPropertyDeclaration(declaration.descriptor),
|
||||
declaration.backingField?.transform(),
|
||||
declaration.getter?.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
IrPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.isDelegated,
|
||||
mapPropertyDeclaration(declaration.descriptor),
|
||||
declaration.backingField?.transform(),
|
||||
declaration.getter?.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
|
||||
override fun visitField(declaration: IrField): IrField =
|
||||
IrFieldImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapPropertyDeclaration(declaration.descriptor),
|
||||
declaration.initializer?.transform()
|
||||
)
|
||||
IrFieldImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapPropertyDeclaration(declaration.descriptor),
|
||||
declaration.initializer?.transform()
|
||||
)
|
||||
|
||||
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrLocalDelegatedProperty =
|
||||
IrLocalDelegatedPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapLocalPropertyDeclaration(declaration.descriptor),
|
||||
declaration.delegate.transform(),
|
||||
declaration.getter.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
IrLocalDelegatedPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapLocalPropertyDeclaration(declaration.descriptor),
|
||||
declaration.delegate.transform(),
|
||||
declaration.getter.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
|
||||
override fun visitEnumEntry(declaration: IrEnumEntry): IrEnumEntry =
|
||||
IrEnumEntryImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapEnumEntryDeclaration(declaration.descriptor),
|
||||
declaration.correspondingClass?.transform(),
|
||||
declaration.initializerExpression?.transform()
|
||||
)
|
||||
IrEnumEntryImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapEnumEntryDeclaration(declaration.descriptor),
|
||||
declaration.correspondingClass?.transform(),
|
||||
declaration.initializerExpression?.transform()
|
||||
)
|
||||
|
||||
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer): IrAnonymousInitializer =
|
||||
IrAnonymousInitializerImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapClassDeclaration(declaration.descriptor),
|
||||
declaration.body.transform()
|
||||
)
|
||||
IrAnonymousInitializerImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapClassDeclaration(declaration.descriptor),
|
||||
declaration.body.transform()
|
||||
)
|
||||
|
||||
override fun visitVariable(declaration: IrVariable): IrVariable =
|
||||
IrVariableImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapVariableDeclaration(declaration.descriptor),
|
||||
declaration.initializer?.transform()
|
||||
)
|
||||
IrVariableImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
mapVariableDeclaration(declaration.descriptor),
|
||||
declaration.initializer?.transform()
|
||||
)
|
||||
|
||||
override fun visitBody(body: IrBody): IrBody =
|
||||
throw IllegalArgumentException("Unsupported body type: $body")
|
||||
throw IllegalArgumentException("Unsupported body type: $body")
|
||||
|
||||
override fun visitExpressionBody(body: IrExpressionBody): IrExpressionBody =
|
||||
IrExpressionBodyImpl(body.expression.transform())
|
||||
IrExpressionBodyImpl(body.expression.transform())
|
||||
|
||||
override fun visitBlockBody(body: IrBlockBody): IrBlockBody =
|
||||
IrBlockBodyImpl(
|
||||
body.startOffset, body.endOffset,
|
||||
body.statements.map { it.transform() }
|
||||
)
|
||||
IrBlockBodyImpl(
|
||||
body.startOffset, body.endOffset,
|
||||
body.statements.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitSyntheticBody(body: IrSyntheticBody): IrSyntheticBody =
|
||||
IrSyntheticBodyImpl(body.startOffset, body.endOffset, body.kind)
|
||||
IrSyntheticBodyImpl(body.startOffset, body.endOffset, body.kind)
|
||||
|
||||
override fun visitExpression(expression: IrExpression): IrExpression =
|
||||
throw IllegalArgumentException("Unsupported expression type: $expression")
|
||||
throw IllegalArgumentException("Unsupported expression type: $expression")
|
||||
|
||||
override fun <T> visitConst(expression: IrConst<T>): IrConst<T> =
|
||||
expression.copy()
|
||||
expression.copy()
|
||||
|
||||
override fun visitVararg(expression: IrVararg): IrVararg =
|
||||
IrVarargImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type, expression.varargElementType,
|
||||
expression.elements.map { it.transform() }
|
||||
)
|
||||
IrVarargImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type, expression.varargElementType,
|
||||
expression.elements.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitSpreadElement(spread: IrSpreadElement): IrSpreadElement =
|
||||
IrSpreadElementImpl(
|
||||
spread.startOffset, spread.endOffset,
|
||||
spread.expression.transform()
|
||||
)
|
||||
IrSpreadElementImpl(
|
||||
spread.startOffset, spread.endOffset,
|
||||
spread.expression.transform()
|
||||
)
|
||||
|
||||
override fun visitBlock(expression: IrBlock): IrBlock =
|
||||
IrBlockImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
IrBlockImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitComposite(expression: IrComposite): IrComposite =
|
||||
IrCompositeImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
IrCompositeImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitStringConcatenation(expression: IrStringConcatenation): IrStringConcatenation =
|
||||
IrStringConcatenationImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.arguments.map { it.transform() }
|
||||
)
|
||||
IrStringConcatenationImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.arguments.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitGetObjectValue(expression: IrGetObjectValue): IrGetObjectValue =
|
||||
IrGetObjectValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapClassReference(expression.descriptor)
|
||||
)
|
||||
IrGetObjectValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapClassReference(expression.descriptor)
|
||||
)
|
||||
|
||||
override fun visitGetEnumValue(expression: IrGetEnumValue): IrGetEnumValue =
|
||||
IrGetEnumValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapClassReference(expression.descriptor)
|
||||
)
|
||||
IrGetEnumValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapClassReference(expression.descriptor)
|
||||
)
|
||||
|
||||
override fun visitGetValue(expression: IrGetValue): IrGetValue =
|
||||
IrGetValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapValueReference(expression.descriptor),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
IrGetValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapValueReference(expression.descriptor),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
|
||||
override fun visitSetVariable(expression: IrSetVariable): IrSetVariable =
|
||||
IrSetVariableImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapVariableReference(expression.descriptor),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
IrSetVariableImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapVariableReference(expression.descriptor),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
|
||||
override fun visitGetField(expression: IrGetField): IrGetField =
|
||||
IrGetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapPropertyReference(expression.descriptor),
|
||||
expression.receiver?.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
IrGetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapPropertyReference(expression.descriptor),
|
||||
expression.receiver?.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
|
||||
override fun visitSetField(expression: IrSetField): IrSetField =
|
||||
IrSetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapPropertyReference(expression.descriptor),
|
||||
expression.receiver?.transform(),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
IrSetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapPropertyReference(expression.descriptor),
|
||||
expression.receiver?.transform(),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
|
||||
override fun visitCall(expression: IrCall): IrCall =
|
||||
shallowCopyCall(expression).transformValueArguments(expression)
|
||||
shallowCopyCall(expression).transformValueArguments(expression)
|
||||
|
||||
protected fun shallowCopyCall(expression: IrCall) =
|
||||
when (expression) {
|
||||
is IrCallWithShallowCopy ->
|
||||
expression.shallowCopy(
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapCallee(expression.descriptor),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
else -> {
|
||||
val newCallee = mapCallee(expression.descriptor)
|
||||
IrCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
newCallee,
|
||||
expression.transformTypeArguments(newCallee),
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
}
|
||||
when (expression) {
|
||||
is IrCallWithShallowCopy ->
|
||||
expression.shallowCopy(
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapCallee(expression.descriptor),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
else -> {
|
||||
val newCallee = mapCallee(expression.descriptor)
|
||||
IrCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
newCallee,
|
||||
expression.transformTypeArguments(newCallee),
|
||||
mapStatementOrigin(expression.origin),
|
||||
mapSuperQualifier(expression.superQualifier)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun <T : IrMemberAccessExpression> T.transformValueArguments(original: IrMemberAccessExpression): T =
|
||||
apply {
|
||||
dispatchReceiver = original.dispatchReceiver?.transform()
|
||||
extensionReceiver = original.extensionReceiver?.transform()
|
||||
mapValueParameters { valueParameter ->
|
||||
original.getValueArgument(valueParameter)?.transform()
|
||||
}
|
||||
Unit
|
||||
apply {
|
||||
dispatchReceiver = original.dispatchReceiver?.transform()
|
||||
extensionReceiver = original.extensionReceiver?.transform()
|
||||
mapValueParameters { valueParameter ->
|
||||
original.getValueArgument(valueParameter)?.transform()
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
||||
protected fun IrMemberAccessExpression.transformTypeArguments(newCallee: CallableDescriptor): Map<TypeParameterDescriptor, KotlinType>? {
|
||||
if (this is IrMemberAccessExpressionBase) return typeArguments
|
||||
@@ -377,41 +383,41 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
null
|
||||
else
|
||||
typeParameters.associateBy(
|
||||
{ newCallee.typeParameters[it.index] },
|
||||
{ getTypeArgument(it)!! }
|
||||
{ newCallee.typeParameters[it.index] },
|
||||
{ getTypeArgument(it)!! }
|
||||
)
|
||||
}
|
||||
|
||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrDelegatingConstructorCall {
|
||||
val newCallee = mapDelegatedConstructorCallee(expression.descriptor)
|
||||
return IrDelegatingConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
newCallee,
|
||||
expression.transformTypeArguments(newCallee)
|
||||
expression.startOffset, expression.endOffset,
|
||||
newCallee,
|
||||
expression.transformTypeArguments(newCallee)
|
||||
).transformValueArguments(expression)
|
||||
}
|
||||
|
||||
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrEnumConstructorCall =
|
||||
IrEnumConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapEnumConstructorCallee(expression.descriptor)
|
||||
).transformValueArguments(expression)
|
||||
IrEnumConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapEnumConstructorCallee(expression.descriptor)
|
||||
).transformValueArguments(expression)
|
||||
|
||||
override fun visitGetClass(expression: IrGetClass): IrGetClass =
|
||||
IrGetClassImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.argument.transform()
|
||||
)
|
||||
IrGetClassImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.argument.transform()
|
||||
)
|
||||
|
||||
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
|
||||
val newCallee = mapCallee(expression.descriptor)
|
||||
return IrFunctionReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
newCallee.original,
|
||||
expression.transformTypeArguments(newCallee),
|
||||
mapStatementOrigin(expression.origin)
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
newCallee.original,
|
||||
expression.transformTypeArguments(newCallee),
|
||||
mapStatementOrigin(expression.origin)
|
||||
).transformValueArguments(expression)
|
||||
}
|
||||
|
||||
@@ -421,10 +427,10 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
val newGetterSymbol = newProperty.getter?.let { IrSimpleFunctionSymbolImpl(it.original) }
|
||||
val newSetterSymbol = newProperty.setter?.let { IrSimpleFunctionSymbolImpl(it.original) }
|
||||
return IrPropertyReferenceImpl(
|
||||
expression.startOffset, expression.endOffset, expression.type,
|
||||
newProperty, newFieldSymbol, newGetterSymbol, newSetterSymbol,
|
||||
expression.transformTypeArguments(newProperty),
|
||||
mapStatementOrigin(expression.origin)
|
||||
expression.startOffset, expression.endOffset, expression.type,
|
||||
newProperty, newFieldSymbol, newGetterSymbol, newSetterSymbol,
|
||||
expression.transformTypeArguments(newProperty),
|
||||
mapStatementOrigin(expression.origin)
|
||||
).transformValueArguments(expression)
|
||||
}
|
||||
|
||||
@@ -435,65 +441,65 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
val newGetterSymbol = newLocalDelegatedProperty.getter!!.let { IrSimpleFunctionSymbolImpl(it.original) }
|
||||
val newSetterSymbol = newLocalDelegatedProperty.setter?.let { IrSimpleFunctionSymbolImpl(it.original) }
|
||||
return IrLocalDelegatedPropertyReferenceImpl(
|
||||
expression.startOffset, expression.endOffset, expression.type,
|
||||
newLocalDelegatedProperty,
|
||||
newDelegateSymbol, newGetterSymbol, newSetterSymbol,
|
||||
mapStatementOrigin(expression.origin)
|
||||
expression.startOffset, expression.endOffset, expression.type,
|
||||
newLocalDelegatedProperty,
|
||||
newDelegateSymbol, newGetterSymbol, newSetterSymbol,
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
}
|
||||
|
||||
override fun visitClassReference(expression: IrClassReference): IrClassReference =
|
||||
IrClassReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapClassifierReference(expression.descriptor),
|
||||
expression.classType
|
||||
)
|
||||
IrClassReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapClassifierReference(expression.descriptor),
|
||||
expression.classType
|
||||
)
|
||||
|
||||
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall): IrInstanceInitializerCall =
|
||||
IrInstanceInitializerCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapClassReference(expression.classDescriptor)
|
||||
)
|
||||
IrInstanceInitializerCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
mapClassReference(expression.classDescriptor)
|
||||
)
|
||||
|
||||
override fun visitTypeOperator(expression: IrTypeOperatorCall): IrTypeOperatorCall =
|
||||
IrTypeOperatorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.operator,
|
||||
expression.typeOperand,
|
||||
expression.argument.transform()
|
||||
)
|
||||
IrTypeOperatorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.operator,
|
||||
expression.typeOperand,
|
||||
expression.argument.transform()
|
||||
)
|
||||
|
||||
override fun visitWhen(expression: IrWhen): IrWhen =
|
||||
IrWhenImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.branches.map { it.transform() }
|
||||
)
|
||||
IrWhenImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.branches.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitBranch(branch: IrBranch): IrBranch =
|
||||
IrBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
IrBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
|
||||
override fun visitElseBranch(branch: IrElseBranch): IrElseBranch =
|
||||
IrElseBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
IrElseBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
|
||||
private val transformedLoops = HashMap<IrLoop, IrLoop>()
|
||||
|
||||
private fun getTransformedLoop(irLoop: IrLoop): IrLoop =
|
||||
transformedLoops.getOrElse(irLoop) { getNonTransformedLoop(irLoop) }
|
||||
transformedLoops.getOrElse(irLoop) { getNonTransformedLoop(irLoop) }
|
||||
|
||||
protected open fun getNonTransformedLoop(irLoop: IrLoop): IrLoop =
|
||||
throw AssertionError("Outer loop was not transformed: ${irLoop.render()}")
|
||||
throw AssertionError("Outer loop was not transformed: ${irLoop.render()}")
|
||||
|
||||
override fun visitWhileLoop(loop: IrWhileLoop): IrWhileLoop {
|
||||
val newLoop = IrWhileLoopImpl(loop.startOffset, loop.endOffset, loop.type, mapStatementOrigin(loop.origin))
|
||||
@@ -514,70 +520,70 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
}
|
||||
|
||||
override fun visitBreak(jump: IrBreak): IrBreak =
|
||||
IrBreakImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
IrBreakImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
|
||||
override fun visitContinue(jump: IrContinue): IrContinue =
|
||||
IrContinueImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
IrContinueImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
|
||||
override fun visitTry(aTry: IrTry): IrTry =
|
||||
IrTryImpl(
|
||||
aTry.startOffset, aTry.endOffset,
|
||||
aTry.type,
|
||||
aTry.tryResult.transform(),
|
||||
aTry.catches.map { it.transform() },
|
||||
aTry.finallyExpression?.transform()
|
||||
)
|
||||
IrTryImpl(
|
||||
aTry.startOffset, aTry.endOffset,
|
||||
aTry.type,
|
||||
aTry.tryResult.transform(),
|
||||
aTry.catches.map { it.transform() },
|
||||
aTry.finallyExpression?.transform()
|
||||
)
|
||||
|
||||
override fun visitCatch(aCatch: IrCatch): IrCatch =
|
||||
IrCatchImpl(
|
||||
aCatch.startOffset, aCatch.endOffset,
|
||||
aCatch.catchParameter.transform(),
|
||||
aCatch.result.transform()
|
||||
)
|
||||
IrCatchImpl(
|
||||
aCatch.startOffset, aCatch.endOffset,
|
||||
aCatch.catchParameter.transform(),
|
||||
aCatch.result.transform()
|
||||
)
|
||||
|
||||
override fun visitReturn(expression: IrReturn): IrReturn =
|
||||
IrReturnImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapReturnTarget(expression.returnTarget),
|
||||
expression.value.transform()
|
||||
)
|
||||
IrReturnImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapReturnTarget(expression.returnTarget),
|
||||
expression.value.transform()
|
||||
)
|
||||
|
||||
override fun visitThrow(expression: IrThrow): IrThrow =
|
||||
IrThrowImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.value.transform()
|
||||
)
|
||||
IrThrowImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.value.transform()
|
||||
)
|
||||
|
||||
override fun visitErrorDeclaration(declaration: IrErrorDeclaration): IrErrorDeclaration =
|
||||
IrErrorDeclarationImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapErrorDeclaration(declaration.descriptor)
|
||||
)
|
||||
IrErrorDeclarationImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapErrorDeclaration(declaration.descriptor)
|
||||
)
|
||||
|
||||
override fun visitErrorExpression(expression: IrErrorExpression): IrErrorExpression =
|
||||
IrErrorExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
)
|
||||
IrErrorExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
)
|
||||
|
||||
override fun visitErrorCallExpression(expression: IrErrorCallExpression): IrErrorCallExpression =
|
||||
IrErrorCallExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
).apply {
|
||||
explicitReceiver = expression.explicitReceiver?.transform()
|
||||
expression.arguments.mapTo(arguments) { it.transform() }
|
||||
}
|
||||
IrErrorCallExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
).apply {
|
||||
explicitReceiver = expression.explicitReceiver?.transform()
|
||||
expression.arguments.mapTo(arguments) { it.transform() }
|
||||
}
|
||||
}
|
||||
+351
-351
@@ -41,306 +41,306 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper)
|
||||
private fun mapStatementOrigin(origin: IrStatementOrigin?) = origin
|
||||
|
||||
private inline fun <reified T : IrElement> T.transform() =
|
||||
transform(this@DeepCopyIrTreeWithSymbols, null) as T
|
||||
transform(this@DeepCopyIrTreeWithSymbols, null) as T
|
||||
|
||||
private inline fun <reified T : IrElement> List<T>.transform() =
|
||||
map { it.transform() }
|
||||
map { it.transform() }
|
||||
|
||||
private inline fun <reified T : IrElement> List<T>.transformTo(destination: MutableList<T>) =
|
||||
mapTo(destination) { it.transform() }
|
||||
mapTo(destination) { it.transform() }
|
||||
|
||||
private fun <T : IrDeclarationContainer> T.transformDeclarationsTo(destination: T) =
|
||||
declarations.transformTo(destination.declarations)
|
||||
declarations.transformTo(destination.declarations)
|
||||
|
||||
override fun visitElement(element: IrElement): IrElement =
|
||||
throw IllegalArgumentException("Unsupported element type: $element")
|
||||
throw IllegalArgumentException("Unsupported element type: $element")
|
||||
|
||||
override fun visitModuleFragment(declaration: IrModuleFragment): IrModuleFragment =
|
||||
IrModuleFragmentImpl(
|
||||
declaration.descriptor,
|
||||
declaration.irBuiltins,
|
||||
declaration.files.transform()
|
||||
)
|
||||
IrModuleFragmentImpl(
|
||||
declaration.descriptor,
|
||||
declaration.irBuiltins,
|
||||
declaration.files.transform()
|
||||
)
|
||||
|
||||
override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment, data: Nothing?): IrExternalPackageFragment =
|
||||
IrExternalPackageFragmentImpl(
|
||||
symbolRemapper.getDeclaredExternalPackageFragment(declaration.symbol)
|
||||
).apply {
|
||||
declaration.transformDeclarationsTo(this)
|
||||
}
|
||||
IrExternalPackageFragmentImpl(
|
||||
symbolRemapper.getDeclaredExternalPackageFragment(declaration.symbol)
|
||||
).apply {
|
||||
declaration.transformDeclarationsTo(this)
|
||||
}
|
||||
|
||||
override fun visitFile(declaration: IrFile): IrFile =
|
||||
IrFileImpl(
|
||||
declaration.fileEntry,
|
||||
symbolRemapper.getDeclaredFile(declaration.symbol)
|
||||
).apply {
|
||||
fileAnnotations.addAll(declaration.fileAnnotations)
|
||||
declaration.transformDeclarationsTo(this)
|
||||
}
|
||||
IrFileImpl(
|
||||
declaration.fileEntry,
|
||||
symbolRemapper.getDeclaredFile(declaration.symbol)
|
||||
).apply {
|
||||
fileAnnotations.addAll(declaration.fileAnnotations)
|
||||
declaration.transformDeclarationsTo(this)
|
||||
}
|
||||
|
||||
override fun visitDeclaration(declaration: IrDeclaration): IrStatement =
|
||||
throw IllegalArgumentException("Unsupported declaration type: $declaration")
|
||||
throw IllegalArgumentException("Unsupported declaration type: $declaration")
|
||||
|
||||
override fun visitClass(declaration: IrClass): IrClass =
|
||||
IrClassImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredClass(declaration.symbol)
|
||||
).apply {
|
||||
thisReceiver = declaration.thisReceiver?.transform()
|
||||
declaration.typeParameters.transformTo(typeParameters)
|
||||
declaration.transformDeclarationsTo(this)
|
||||
}
|
||||
IrClassImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredClass(declaration.symbol)
|
||||
).apply {
|
||||
thisReceiver = declaration.thisReceiver?.transform()
|
||||
declaration.typeParameters.transformTo(typeParameters)
|
||||
declaration.transformDeclarationsTo(this)
|
||||
}
|
||||
|
||||
override fun visitTypeAlias(declaration: IrTypeAlias): IrTypeAlias =
|
||||
IrTypeAliasImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.descriptor
|
||||
)
|
||||
IrTypeAliasImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.descriptor
|
||||
)
|
||||
|
||||
override fun visitSimpleFunction(declaration: IrSimpleFunction): IrSimpleFunction =
|
||||
IrFunctionImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredFunction(declaration.symbol)
|
||||
).apply {
|
||||
transformFunctionChildren(declaration)
|
||||
}
|
||||
IrFunctionImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredFunction(declaration.symbol)
|
||||
).apply {
|
||||
transformFunctionChildren(declaration)
|
||||
}
|
||||
|
||||
override fun visitConstructor(declaration: IrConstructor): IrConstructor =
|
||||
IrConstructorImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredConstructor(declaration.symbol)
|
||||
).apply {
|
||||
transformFunctionChildren(declaration)
|
||||
}
|
||||
IrConstructorImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredConstructor(declaration.symbol)
|
||||
).apply {
|
||||
transformFunctionChildren(declaration)
|
||||
}
|
||||
|
||||
private fun <T : IrFunction> T.transformFunctionChildren(declaration: T): T =
|
||||
apply {
|
||||
declaration.typeParameters.transformTo(typeParameters)
|
||||
dispatchReceiverParameter = declaration.dispatchReceiverParameter?.transform()
|
||||
extensionReceiverParameter = declaration.extensionReceiverParameter?.transform()
|
||||
declaration.valueParameters.transformTo(valueParameters)
|
||||
body = declaration.body?.transform()
|
||||
}
|
||||
apply {
|
||||
declaration.typeParameters.transformTo(typeParameters)
|
||||
dispatchReceiverParameter = declaration.dispatchReceiverParameter?.transform()
|
||||
extensionReceiverParameter = declaration.extensionReceiverParameter?.transform()
|
||||
declaration.valueParameters.transformTo(valueParameters)
|
||||
body = declaration.body?.transform()
|
||||
}
|
||||
|
||||
override fun visitProperty(declaration: IrProperty): IrProperty =
|
||||
IrPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.isDelegated,
|
||||
declaration.descriptor,
|
||||
declaration.backingField?.transform(),
|
||||
declaration.getter?.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
IrPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.isDelegated,
|
||||
declaration.descriptor,
|
||||
declaration.backingField?.transform(),
|
||||
declaration.getter?.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
|
||||
override fun visitField(declaration: IrField): IrField =
|
||||
IrFieldImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredField(declaration.symbol)
|
||||
).apply {
|
||||
initializer = declaration.initializer?.transform()
|
||||
}
|
||||
IrFieldImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredField(declaration.symbol)
|
||||
).apply {
|
||||
initializer = declaration.initializer?.transform()
|
||||
}
|
||||
|
||||
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrLocalDelegatedProperty =
|
||||
IrLocalDelegatedPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.descriptor,
|
||||
declaration.delegate.transform(),
|
||||
declaration.getter.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
IrLocalDelegatedPropertyImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
declaration.descriptor,
|
||||
declaration.delegate.transform(),
|
||||
declaration.getter.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
|
||||
override fun visitEnumEntry(declaration: IrEnumEntry): IrEnumEntry =
|
||||
IrEnumEntryImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredEnumEntry(declaration.symbol)
|
||||
).apply {
|
||||
correspondingClass = declaration.correspondingClass?.transform()
|
||||
initializerExpression = declaration.initializerExpression?.transform()
|
||||
}
|
||||
IrEnumEntryImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredEnumEntry(declaration.symbol)
|
||||
).apply {
|
||||
correspondingClass = declaration.correspondingClass?.transform()
|
||||
initializerExpression = declaration.initializerExpression?.transform()
|
||||
}
|
||||
|
||||
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer): IrAnonymousInitializer =
|
||||
IrAnonymousInitializerImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
IrAnonymousInitializerSymbolImpl(declaration.descriptor)
|
||||
).apply {
|
||||
body = declaration.body.transform()
|
||||
}
|
||||
IrAnonymousInitializerImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
IrAnonymousInitializerSymbolImpl(declaration.descriptor)
|
||||
).apply {
|
||||
body = declaration.body.transform()
|
||||
}
|
||||
|
||||
override fun visitVariable(declaration: IrVariable): IrVariable =
|
||||
IrVariableImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredVariable(declaration.symbol)
|
||||
).apply {
|
||||
initializer = declaration.initializer?.transform()
|
||||
}
|
||||
IrVariableImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredVariable(declaration.symbol)
|
||||
).apply {
|
||||
initializer = declaration.initializer?.transform()
|
||||
}
|
||||
|
||||
override fun visitTypeParameter(declaration: IrTypeParameter): IrTypeParameter =
|
||||
IrTypeParameterImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredTypeParameter(declaration.symbol)
|
||||
)
|
||||
IrTypeParameterImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredTypeParameter(declaration.symbol)
|
||||
)
|
||||
|
||||
override fun visitValueParameter(declaration: IrValueParameter): IrValueParameter =
|
||||
IrValueParameterImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredValueParameter(declaration.symbol)
|
||||
).apply {
|
||||
defaultValue = declaration.defaultValue?.transform()
|
||||
}
|
||||
IrValueParameterImpl(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredValueParameter(declaration.symbol)
|
||||
).apply {
|
||||
defaultValue = declaration.defaultValue?.transform()
|
||||
}
|
||||
|
||||
override fun visitBody(body: IrBody): IrBody =
|
||||
throw IllegalArgumentException("Unsupported body type: $body")
|
||||
throw IllegalArgumentException("Unsupported body type: $body")
|
||||
|
||||
override fun visitExpressionBody(body: IrExpressionBody): IrExpressionBody =
|
||||
IrExpressionBodyImpl(body.expression.transform())
|
||||
IrExpressionBodyImpl(body.expression.transform())
|
||||
|
||||
override fun visitBlockBody(body: IrBlockBody): IrBlockBody =
|
||||
IrBlockBodyImpl(
|
||||
body.startOffset, body.endOffset,
|
||||
body.statements.map { it.transform() }
|
||||
)
|
||||
IrBlockBodyImpl(
|
||||
body.startOffset, body.endOffset,
|
||||
body.statements.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitSyntheticBody(body: IrSyntheticBody): IrSyntheticBody =
|
||||
IrSyntheticBodyImpl(body.startOffset, body.endOffset, body.kind)
|
||||
IrSyntheticBodyImpl(body.startOffset, body.endOffset, body.kind)
|
||||
|
||||
override fun visitExpression(expression: IrExpression): IrExpression =
|
||||
throw IllegalArgumentException("Unsupported expression type: $expression")
|
||||
throw IllegalArgumentException("Unsupported expression type: $expression")
|
||||
|
||||
override fun <T> visitConst(expression: IrConst<T>): IrConst<T> =
|
||||
expression.copy()
|
||||
expression.copy()
|
||||
|
||||
override fun visitVararg(expression: IrVararg): IrVararg =
|
||||
IrVarargImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type, expression.varargElementType,
|
||||
expression.elements.transform()
|
||||
)
|
||||
IrVarargImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type, expression.varargElementType,
|
||||
expression.elements.transform()
|
||||
)
|
||||
|
||||
override fun visitSpreadElement(spread: IrSpreadElement): IrSpreadElement =
|
||||
IrSpreadElementImpl(
|
||||
spread.startOffset, spread.endOffset,
|
||||
spread.expression.transform()
|
||||
)
|
||||
IrSpreadElementImpl(
|
||||
spread.startOffset, spread.endOffset,
|
||||
spread.expression.transform()
|
||||
)
|
||||
|
||||
override fun visitBlock(expression: IrBlock): IrBlock =
|
||||
IrBlockImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
IrBlockImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitComposite(expression: IrComposite): IrComposite =
|
||||
IrCompositeImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
IrCompositeImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.statements.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitStringConcatenation(expression: IrStringConcatenation): IrStringConcatenation =
|
||||
IrStringConcatenationImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.arguments.map { it.transform() }
|
||||
)
|
||||
IrStringConcatenationImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.arguments.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitGetObjectValue(expression: IrGetObjectValue): IrGetObjectValue =
|
||||
IrGetObjectValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedClass(expression.symbol)
|
||||
)
|
||||
IrGetObjectValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedClass(expression.symbol)
|
||||
)
|
||||
|
||||
override fun visitGetEnumValue(expression: IrGetEnumValue): IrGetEnumValue =
|
||||
IrGetEnumValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedEnumEntry(expression.symbol)
|
||||
)
|
||||
IrGetEnumValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedEnumEntry(expression.symbol)
|
||||
)
|
||||
|
||||
override fun visitGetValue(expression: IrGetValue): IrGetValue =
|
||||
IrGetValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedValue(expression.symbol),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
IrGetValueImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedValue(expression.symbol),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
|
||||
override fun visitSetVariable(expression: IrSetVariable): IrSetVariable =
|
||||
IrSetVariableImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedVariable(expression.symbol),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
IrSetVariableImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedVariable(expression.symbol),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
|
||||
override fun visitGetField(expression: IrGetField): IrGetField =
|
||||
IrGetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedField(expression.symbol),
|
||||
expression.receiver?.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
IrGetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedField(expression.symbol),
|
||||
expression.receiver?.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
|
||||
override fun visitSetField(expression: IrSetField): IrSetField =
|
||||
IrSetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedField(expression.symbol),
|
||||
expression.receiver?.transform(),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
IrSetFieldImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedField(expression.symbol),
|
||||
expression.receiver?.transform(),
|
||||
expression.value.transform(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
|
||||
override fun visitCall(expression: IrCall): IrCall =
|
||||
shallowCopyCall(expression).transformValueArguments(expression)
|
||||
shallowCopyCall(expression).transformValueArguments(expression)
|
||||
|
||||
private fun shallowCopyCall(expression: IrCall) =
|
||||
when (expression) {
|
||||
is IrCallWithShallowCopy ->
|
||||
expression.shallowCopy(
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedFunction(expression.symbol),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
else ->
|
||||
IrCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedFunction(expression.symbol),
|
||||
expression.descriptor, // TODO substitute referenced descriptor
|
||||
expression.getTypeArgumentsMap(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
}
|
||||
when (expression) {
|
||||
is IrCallWithShallowCopy ->
|
||||
expression.shallowCopy(
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedFunction(expression.symbol),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
else ->
|
||||
IrCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedFunction(expression.symbol),
|
||||
expression.descriptor, // TODO substitute referenced descriptor
|
||||
expression.getTypeArgumentsMap(),
|
||||
mapStatementOrigin(expression.origin),
|
||||
symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
|
||||
)
|
||||
}
|
||||
|
||||
private fun <T : IrMemberAccessExpression> T.transformReceiverArguments(original: T): T =
|
||||
apply {
|
||||
dispatchReceiver = original.dispatchReceiver?.transform()
|
||||
extensionReceiver = original.extensionReceiver?.transform()
|
||||
}
|
||||
apply {
|
||||
dispatchReceiver = original.dispatchReceiver?.transform()
|
||||
extensionReceiver = original.extensionReceiver?.transform()
|
||||
}
|
||||
|
||||
private fun <T : IrMemberAccessExpression> T.transformValueArguments(original: T): T =
|
||||
apply {
|
||||
transformReceiverArguments(original)
|
||||
mapValueParameters { valueParameter ->
|
||||
original.getValueArgument(valueParameter)?.transform()
|
||||
}
|
||||
apply {
|
||||
transformReceiverArguments(original)
|
||||
mapValueParameters { valueParameter ->
|
||||
original.getValueArgument(valueParameter)?.transform()
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrMemberAccessExpression.getTypeArgumentsMap(): Map<TypeParameterDescriptor, KotlinType>? {
|
||||
if (this is IrMemberAccessExpressionBase) return typeArguments
|
||||
@@ -353,192 +353,192 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper)
|
||||
}
|
||||
|
||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrDelegatingConstructorCall =
|
||||
IrDelegatingConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedConstructor(expression.symbol),
|
||||
expression.descriptor,
|
||||
expression.getTypeArgumentsMap()
|
||||
).transformValueArguments(expression)
|
||||
IrDelegatingConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedConstructor(expression.symbol),
|
||||
expression.descriptor,
|
||||
expression.getTypeArgumentsMap()
|
||||
).transformValueArguments(expression)
|
||||
|
||||
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrEnumConstructorCall =
|
||||
IrEnumConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedConstructor(expression.symbol)
|
||||
).transformValueArguments(expression)
|
||||
IrEnumConstructorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedConstructor(expression.symbol)
|
||||
).transformValueArguments(expression)
|
||||
|
||||
override fun visitGetClass(expression: IrGetClass): IrGetClass =
|
||||
IrGetClassImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.argument.transform()
|
||||
)
|
||||
IrGetClassImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.argument.transform()
|
||||
)
|
||||
|
||||
override fun visitFunctionReference(expression: IrFunctionReference): IrFunctionReference =
|
||||
IrFunctionReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedFunction(expression.symbol),
|
||||
expression.descriptor, // TODO substitute referenced descriptor
|
||||
expression.getTypeArgumentsMap(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
).transformValueArguments(expression)
|
||||
IrFunctionReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedFunction(expression.symbol),
|
||||
expression.descriptor, // TODO substitute referenced descriptor
|
||||
expression.getTypeArgumentsMap(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
).transformValueArguments(expression)
|
||||
|
||||
override fun visitPropertyReference(expression: IrPropertyReference): IrPropertyReference =
|
||||
IrPropertyReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.descriptor,
|
||||
expression.field?.let { symbolRemapper.getReferencedField(it) },
|
||||
expression.getter?.let { symbolRemapper.getReferencedFunction(it) },
|
||||
expression.setter?.let { symbolRemapper.getReferencedFunction(it) },
|
||||
expression.getTypeArgumentsMap(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
).transformReceiverArguments(expression)
|
||||
IrPropertyReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.descriptor,
|
||||
expression.field?.let { symbolRemapper.getReferencedField(it) },
|
||||
expression.getter?.let { symbolRemapper.getReferencedFunction(it) },
|
||||
expression.setter?.let { symbolRemapper.getReferencedFunction(it) },
|
||||
expression.getTypeArgumentsMap(),
|
||||
mapStatementOrigin(expression.origin)
|
||||
).transformReceiverArguments(expression)
|
||||
|
||||
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrLocalDelegatedPropertyReference =
|
||||
IrLocalDelegatedPropertyReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.descriptor,
|
||||
symbolRemapper.getReferencedVariable(expression.delegate),
|
||||
symbolRemapper.getReferencedFunction(expression.getter),
|
||||
expression.setter?.let { symbolRemapper.getReferencedFunction(it) },
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
IrLocalDelegatedPropertyReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.descriptor,
|
||||
symbolRemapper.getReferencedVariable(expression.delegate),
|
||||
symbolRemapper.getReferencedFunction(expression.getter),
|
||||
expression.setter?.let { symbolRemapper.getReferencedFunction(it) },
|
||||
mapStatementOrigin(expression.origin)
|
||||
)
|
||||
|
||||
override fun visitClassReference(expression: IrClassReference): IrClassReference =
|
||||
IrClassReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedClassifier(expression.symbol),
|
||||
expression.classType
|
||||
)
|
||||
IrClassReferenceImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedClassifier(expression.symbol),
|
||||
expression.classType
|
||||
)
|
||||
|
||||
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall): IrInstanceInitializerCall =
|
||||
IrInstanceInitializerCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedClass(expression.classSymbol)
|
||||
)
|
||||
IrInstanceInitializerCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
symbolRemapper.getReferencedClass(expression.classSymbol)
|
||||
)
|
||||
|
||||
override fun visitTypeOperator(expression: IrTypeOperatorCall): IrTypeOperatorCall =
|
||||
IrTypeOperatorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.operator,
|
||||
expression.typeOperand,
|
||||
expression.argument.transform()
|
||||
)
|
||||
IrTypeOperatorCallImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.operator,
|
||||
expression.typeOperand,
|
||||
expression.argument.transform()
|
||||
)
|
||||
|
||||
override fun visitWhen(expression: IrWhen): IrWhen =
|
||||
IrWhenImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.branches.map { it.transform() }
|
||||
)
|
||||
IrWhenImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
mapStatementOrigin(expression.origin),
|
||||
expression.branches.map { it.transform() }
|
||||
)
|
||||
|
||||
override fun visitBranch(branch: IrBranch): IrBranch =
|
||||
IrBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
IrBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
|
||||
override fun visitElseBranch(branch: IrElseBranch): IrElseBranch =
|
||||
IrElseBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
IrElseBranchImpl(
|
||||
branch.startOffset, branch.endOffset,
|
||||
branch.condition.transform(),
|
||||
branch.result.transform()
|
||||
)
|
||||
|
||||
private val transformedLoops = HashMap<IrLoop, IrLoop>()
|
||||
|
||||
private fun getTransformedLoop(irLoop: IrLoop): IrLoop =
|
||||
transformedLoops.getOrElse(irLoop) { getNonTransformedLoop(irLoop) }
|
||||
transformedLoops.getOrElse(irLoop) { getNonTransformedLoop(irLoop) }
|
||||
|
||||
protected open fun getNonTransformedLoop(irLoop: IrLoop): IrLoop =
|
||||
throw AssertionError("Outer loop was not transformed: ${irLoop.render()}")
|
||||
throw AssertionError("Outer loop was not transformed: ${irLoop.render()}")
|
||||
|
||||
override fun visitWhileLoop(loop: IrWhileLoop): IrWhileLoop =
|
||||
IrWhileLoopImpl(loop.startOffset, loop.endOffset, loop.type, mapStatementOrigin(loop.origin)).also { newLoop ->
|
||||
transformedLoops[loop] = newLoop
|
||||
newLoop.label = loop.label
|
||||
newLoop.condition = loop.condition.transform()
|
||||
newLoop.body = loop.body?.transform()
|
||||
}
|
||||
IrWhileLoopImpl(loop.startOffset, loop.endOffset, loop.type, mapStatementOrigin(loop.origin)).also { newLoop ->
|
||||
transformedLoops[loop] = newLoop
|
||||
newLoop.label = loop.label
|
||||
newLoop.condition = loop.condition.transform()
|
||||
newLoop.body = loop.body?.transform()
|
||||
}
|
||||
|
||||
override fun visitDoWhileLoop(loop: IrDoWhileLoop): IrDoWhileLoop =
|
||||
IrDoWhileLoopImpl(loop.startOffset, loop.endOffset, loop.type, mapStatementOrigin(loop.origin)).also { newLoop ->
|
||||
transformedLoops[loop] = newLoop
|
||||
newLoop.label = loop.label
|
||||
newLoop.condition = loop.condition.transform()
|
||||
newLoop.body = loop.body?.transform()
|
||||
}
|
||||
IrDoWhileLoopImpl(loop.startOffset, loop.endOffset, loop.type, mapStatementOrigin(loop.origin)).also { newLoop ->
|
||||
transformedLoops[loop] = newLoop
|
||||
newLoop.label = loop.label
|
||||
newLoop.condition = loop.condition.transform()
|
||||
newLoop.body = loop.body?.transform()
|
||||
}
|
||||
|
||||
override fun visitBreak(jump: IrBreak): IrBreak =
|
||||
IrBreakImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
IrBreakImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
|
||||
override fun visitContinue(jump: IrContinue): IrContinue =
|
||||
IrContinueImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
IrContinueImpl(
|
||||
jump.startOffset, jump.endOffset,
|
||||
jump.type,
|
||||
getTransformedLoop(jump.loop)
|
||||
).apply { label = jump.label }
|
||||
|
||||
override fun visitTry(aTry: IrTry): IrTry =
|
||||
IrTryImpl(
|
||||
aTry.startOffset, aTry.endOffset,
|
||||
aTry.type,
|
||||
aTry.tryResult.transform(),
|
||||
aTry.catches.map { it.transform() },
|
||||
aTry.finallyExpression?.transform()
|
||||
)
|
||||
IrTryImpl(
|
||||
aTry.startOffset, aTry.endOffset,
|
||||
aTry.type,
|
||||
aTry.tryResult.transform(),
|
||||
aTry.catches.map { it.transform() },
|
||||
aTry.finallyExpression?.transform()
|
||||
)
|
||||
|
||||
override fun visitCatch(aCatch: IrCatch): IrCatch =
|
||||
IrCatchImpl(
|
||||
aCatch.startOffset, aCatch.endOffset,
|
||||
aCatch.catchParameter.transform(),
|
||||
aCatch.result.transform()
|
||||
)
|
||||
IrCatchImpl(
|
||||
aCatch.startOffset, aCatch.endOffset,
|
||||
aCatch.catchParameter.transform(),
|
||||
aCatch.result.transform()
|
||||
)
|
||||
|
||||
override fun visitReturn(expression: IrReturn): IrReturn =
|
||||
IrReturnImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedFunction(expression.returnTargetSymbol),
|
||||
expression.value.transform()
|
||||
)
|
||||
IrReturnImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
symbolRemapper.getReferencedFunction(expression.returnTargetSymbol),
|
||||
expression.value.transform()
|
||||
)
|
||||
|
||||
override fun visitThrow(expression: IrThrow): IrThrow =
|
||||
IrThrowImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.value.transform()
|
||||
)
|
||||
IrThrowImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.value.transform()
|
||||
)
|
||||
|
||||
override fun visitErrorDeclaration(declaration: IrErrorDeclaration): IrErrorDeclaration =
|
||||
IrErrorDeclarationImpl(declaration.startOffset, declaration.endOffset, declaration.descriptor)
|
||||
IrErrorDeclarationImpl(declaration.startOffset, declaration.endOffset, declaration.descriptor)
|
||||
|
||||
override fun visitErrorExpression(expression: IrErrorExpression): IrErrorExpression =
|
||||
IrErrorExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
)
|
||||
IrErrorExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
)
|
||||
|
||||
override fun visitErrorCallExpression(expression: IrErrorCallExpression): IrErrorCallExpression =
|
||||
IrErrorCallExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
).apply {
|
||||
explicitReceiver = expression.explicitReceiver?.transform()
|
||||
expression.arguments.transformTo(arguments)
|
||||
}
|
||||
IrErrorCallExpressionImpl(
|
||||
expression.startOffset, expression.endOffset,
|
||||
expression.type,
|
||||
expression.description
|
||||
).apply {
|
||||
explicitReceiver = expression.explicitReceiver?.transform()
|
||||
expression.arguments.transformTo(arguments)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
|
||||
open class DeepCopySymbolsRemapper(
|
||||
private val descriptorsRemapper: DescriptorsRemapper = DescriptorsRemapper.DEFAULT
|
||||
private val descriptorsRemapper: DescriptorsRemapper = DescriptorsRemapper.DEFAULT
|
||||
) : IrElementVisitorVoid, SymbolRemapper {
|
||||
private val classes = hashMapOf<IrClassSymbol, IrClassSymbol>()
|
||||
private val constructors = hashMapOf<IrConstructorSymbol, IrConstructorSymbol>()
|
||||
@@ -119,12 +119,12 @@ open class DeepCopySymbolsRemapper(
|
||||
}
|
||||
|
||||
private fun <T : IrSymbol> Map<T, T>.getDeclared(symbol: T) =
|
||||
getOrElse(symbol) {
|
||||
throw IllegalArgumentException("Non-remapped symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
getOrElse(symbol) {
|
||||
throw IllegalArgumentException("Non-remapped symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
|
||||
private fun <T : IrSymbol> Map<T, T>.getReferenced(symbol: T) =
|
||||
getOrElse(symbol) { symbol }
|
||||
getOrElse(symbol) { symbol }
|
||||
|
||||
override fun getDeclaredClass(symbol: IrClassSymbol): IrClassSymbol = classes.getDeclared(symbol)
|
||||
override fun getDeclaredFunction(symbol: IrSimpleFunctionSymbol): IrSimpleFunctionSymbol = functions.getDeclared(symbol)
|
||||
@@ -132,7 +132,9 @@ open class DeepCopySymbolsRemapper(
|
||||
override fun getDeclaredFile(symbol: IrFileSymbol): IrFileSymbol = files.getDeclared(symbol)
|
||||
override fun getDeclaredConstructor(symbol: IrConstructorSymbol): IrConstructorSymbol = constructors.getDeclared(symbol)
|
||||
override fun getDeclaredEnumEntry(symbol: IrEnumEntrySymbol): IrEnumEntrySymbol = enumEntries.getDeclared(symbol)
|
||||
override fun getDeclaredExternalPackageFragment(symbol: IrExternalPackageFragmentSymbol): IrExternalPackageFragmentSymbol = externalPackageFragments.getDeclared(symbol)
|
||||
override fun getDeclaredExternalPackageFragment(symbol: IrExternalPackageFragmentSymbol): IrExternalPackageFragmentSymbol =
|
||||
externalPackageFragments.getDeclared(symbol)
|
||||
|
||||
override fun getDeclaredVariable(symbol: IrVariableSymbol): IrVariableSymbol = variables.getDeclared(symbol)
|
||||
override fun getDeclaredTypeParameter(symbol: IrTypeParameterSymbol): IrTypeParameterSymbol = typeParameters.getDeclared(symbol)
|
||||
override fun getDeclaredValueParameter(symbol: IrValueParameterSymbol): IrValueParameterSymbol = valueParameters.getDeclared(symbol)
|
||||
@@ -145,23 +147,23 @@ open class DeepCopySymbolsRemapper(
|
||||
override fun getReferencedConstructor(symbol: IrConstructorSymbol): IrConstructorSymbol = constructors.getReferenced(symbol)
|
||||
|
||||
override fun getReferencedValue(symbol: IrValueSymbol): IrValueSymbol =
|
||||
when (symbol) {
|
||||
is IrValueParameterSymbol -> valueParameters.getReferenced(symbol)
|
||||
is IrVariableSymbol -> variables.getReferenced(symbol)
|
||||
else -> throw IllegalArgumentException("Unexpected symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
when (symbol) {
|
||||
is IrValueParameterSymbol -> valueParameters.getReferenced(symbol)
|
||||
is IrVariableSymbol -> variables.getReferenced(symbol)
|
||||
else -> throw IllegalArgumentException("Unexpected symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
|
||||
override fun getReferencedFunction(symbol: IrFunctionSymbol): IrFunctionSymbol =
|
||||
when (symbol) {
|
||||
is IrSimpleFunctionSymbol -> functions.getReferenced(symbol)
|
||||
is IrConstructorSymbol -> constructors.getReferenced(symbol)
|
||||
else -> throw IllegalArgumentException("Unexpected symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
when (symbol) {
|
||||
is IrSimpleFunctionSymbol -> functions.getReferenced(symbol)
|
||||
is IrConstructorSymbol -> constructors.getReferenced(symbol)
|
||||
else -> throw IllegalArgumentException("Unexpected symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
|
||||
override fun getReferencedClassifier(symbol: IrClassifierSymbol): IrClassifierSymbol =
|
||||
when (symbol) {
|
||||
is IrClassSymbol -> classes.getReferenced(symbol)
|
||||
is IrTypeParameterSymbol -> typeParameters.getReferenced(symbol)
|
||||
else -> throw IllegalArgumentException("Unexpected symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
when (symbol) {
|
||||
is IrClassSymbol -> classes.getReferenced(symbol)
|
||||
is IrTypeParameterSymbol -> typeParameters.getReferenced(symbol)
|
||||
else -> throw IllegalArgumentException("Unexpected symbol $symbol ${symbol.descriptor}")
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,10 @@ class DependenciesCollector {
|
||||
val dependencyModules: Collection<ModuleDescriptor> get() = modulesForDependencyDescriptors
|
||||
|
||||
fun getPackageFragments(moduleDescriptor: ModuleDescriptor): Collection<PackageFragmentDescriptor> =
|
||||
packageFragmentsForDependencyDescriptors[moduleDescriptor] ?: emptyList()
|
||||
packageFragmentsForDependencyDescriptors[moduleDescriptor] ?: emptyList()
|
||||
|
||||
fun getTopLevelDescriptors(packageFragmentDescriptor: PackageFragmentDescriptor): Collection<DeclarationDescriptor> =
|
||||
topLevelDescriptors[packageFragmentDescriptor] ?: emptyList()
|
||||
topLevelDescriptors[packageFragmentDescriptor] ?: emptyList()
|
||||
|
||||
fun collectTopLevelDescriptorsForUnboundSymbols(symbolTable: SymbolTable) {
|
||||
assert(symbolTable.unboundTypeParameters.isEmpty()) { "Unbound type parameters: ${symbolTable.unboundTypeParameters}" }
|
||||
|
||||
@@ -39,7 +39,7 @@ fun IrFile.dumpTreesFromLineNumber(lineNumber: Int): String {
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
class DumpIrTreeVisitor(out: Appendable): IrElementVisitor<Unit, String> {
|
||||
class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor<Unit, String> {
|
||||
private val printer = Printer(out, " ")
|
||||
private val elementRenderer = RenderIrElementVisitor()
|
||||
|
||||
@@ -218,14 +218,14 @@ class DumpIrTreeVisitor(out: Appendable): IrElementVisitor<Unit, String> {
|
||||
}
|
||||
|
||||
private fun String.withLabel(label: String) =
|
||||
if (label.isEmpty()) this else "$label: $this"
|
||||
if (label.isEmpty()) this else "$label: $this"
|
||||
}
|
||||
|
||||
class DumpTreeFromSourceLineVisitor(
|
||||
val fileEntry: SourceManager.FileEntry,
|
||||
private val lineNumber: Int,
|
||||
out: Appendable
|
||||
): IrElementVisitorVoid {
|
||||
val fileEntry: SourceManager.FileEntry,
|
||||
private val lineNumber: Int,
|
||||
out: Appendable
|
||||
) : IrElementVisitorVoid {
|
||||
private val dumper = DumpIrTreeVisitor(out)
|
||||
|
||||
override fun visitElement(element: IrElement) {
|
||||
|
||||
+12
-8
@@ -37,17 +37,21 @@ class ExternalDependenciesGenerator(val symbolTable: SymbolTable, val irBuiltIns
|
||||
}
|
||||
|
||||
private fun generateModuleStub(collector: DependenciesCollector, moduleDescriptor: ModuleDescriptor): IrModuleFragment =
|
||||
stubGenerator.generateEmptyModuleFragmentStub(moduleDescriptor, irBuiltIns).also { irDependencyModule ->
|
||||
collector.getPackageFragments(moduleDescriptor).mapTo(irDependencyModule.externalPackageFragments) { packageFragmentDescriptor ->
|
||||
stubGenerator.generateEmptyModuleFragmentStub(moduleDescriptor, irBuiltIns).also { irDependencyModule ->
|
||||
collector.getPackageFragments(moduleDescriptor)
|
||||
.mapTo(irDependencyModule.externalPackageFragments) { packageFragmentDescriptor ->
|
||||
generatePackageStub(packageFragmentDescriptor, collector.getTopLevelDescriptors(packageFragmentDescriptor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun generatePackageStub(packageFragmentDescriptor: PackageFragmentDescriptor, topLevelDescriptors: Collection<DeclarationDescriptor>): IrExternalPackageFragment =
|
||||
stubGenerator.generateEmptyExternalPackageFragmentStub(packageFragmentDescriptor).also { irExternalPackageFragment ->
|
||||
topLevelDescriptors.mapTo(irExternalPackageFragment.declarations) {
|
||||
stubGenerator.generateMemberStub(it)
|
||||
}
|
||||
private fun generatePackageStub(
|
||||
packageFragmentDescriptor: PackageFragmentDescriptor,
|
||||
topLevelDescriptors: Collection<DeclarationDescriptor>
|
||||
): IrExternalPackageFragment =
|
||||
stubGenerator.generateEmptyExternalPackageFragmentStub(packageFragmentDescriptor).also { irExternalPackageFragment ->
|
||||
topLevelDescriptors.mapTo(irExternalPackageFragment.declarations) {
|
||||
stubGenerator.generateMemberStub(it)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,8 +38,7 @@ class SymbolTable {
|
||||
val new = createSymbol()
|
||||
set(d, new)
|
||||
new
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unboundSymbols.remove(existing)
|
||||
existing
|
||||
}
|
||||
@@ -61,8 +60,7 @@ class SymbolTable {
|
||||
}
|
||||
|
||||
private class FlatSymbolTable<D : DeclarationDescriptor, B : IrSymbolOwner, S : IrBindableSymbol<D, B>>
|
||||
: SymbolTableBase<D, B, S>()
|
||||
{
|
||||
: SymbolTableBase<D, B, S>() {
|
||||
val descriptorToSymbol = linkedMapOf<D, S>()
|
||||
|
||||
override fun get(d: D): S? = descriptorToSymbol[d]
|
||||
@@ -73,13 +71,12 @@ class SymbolTable {
|
||||
}
|
||||
|
||||
private class ScopedSymbolTable<D : DeclarationDescriptor, B : IrSymbolOwner, S : IrBindableSymbol<D, B>>
|
||||
: SymbolTableBase<D, B, S>()
|
||||
{
|
||||
: SymbolTableBase<D, B, S>() {
|
||||
inner class Scope(val owner: DeclarationDescriptor, val parent: Scope?) {
|
||||
private val descriptorToSymbol = linkedMapOf<D, S>()
|
||||
|
||||
operator fun get(d: D): S? =
|
||||
descriptorToSymbol[d] ?: parent?.get(d)
|
||||
descriptorToSymbol[d] ?: parent?.get(d)
|
||||
|
||||
fun getLocal(d: D) = descriptorToSymbol[d]
|
||||
|
||||
@@ -88,14 +85,14 @@ class SymbolTable {
|
||||
}
|
||||
|
||||
fun dumpTo(stringBuilder: StringBuilder): StringBuilder =
|
||||
stringBuilder.also {
|
||||
it.append("owner=")
|
||||
it.append(owner)
|
||||
it.append("; ")
|
||||
descriptorToSymbol.keys.joinTo(prefix = "[", postfix = "]", buffer = it)
|
||||
it.append('\n')
|
||||
parent?.dumpTo(it)
|
||||
}
|
||||
stringBuilder.also {
|
||||
it.append("owner=")
|
||||
it.append(owner)
|
||||
it.append("; ")
|
||||
descriptorToSymbol.keys.joinTo(prefix = "[", postfix = "]", buffer = it)
|
||||
it.append('\n')
|
||||
parent?.dumpTo(it)
|
||||
}
|
||||
|
||||
fun dump(): String = dumpTo(StringBuilder()).toString()
|
||||
}
|
||||
@@ -106,6 +103,7 @@ class SymbolTable {
|
||||
val scope = currentScope ?: throw AssertionError("No active scope")
|
||||
return scope[d]
|
||||
}
|
||||
|
||||
override fun set(d: D, s: S) {
|
||||
val scope = currentScope ?: throw AssertionError("No active scope")
|
||||
scope[d] = s
|
||||
@@ -142,7 +140,7 @@ class SymbolTable {
|
||||
}
|
||||
|
||||
fun dump(): String =
|
||||
currentScope?.dump() ?: "<none>"
|
||||
currentScope?.dump() ?: "<none>"
|
||||
}
|
||||
|
||||
private val classSymbolTable = FlatSymbolTable<ClassDescriptor, IrClass, IrClassSymbol>()
|
||||
@@ -157,132 +155,159 @@ class SymbolTable {
|
||||
private val scopedSymbolTables = listOf(typeParameterSymbolTable, valueParameterSymbolTable, variableSymbolTable)
|
||||
|
||||
fun declareFile(fileEntry: SourceManager.FileEntry, packageFragmentDescriptor: PackageFragmentDescriptor): IrFile =
|
||||
IrFileImpl(fileEntry, IrFileSymbolImpl(packageFragmentDescriptor))
|
||||
IrFileImpl(fileEntry, IrFileSymbolImpl(packageFragmentDescriptor))
|
||||
|
||||
fun declareExternalPackageFragment(packageFragmentDescriptor: PackageFragmentDescriptor): IrExternalPackageFragment =
|
||||
IrExternalPackageFragmentImpl(IrExternalPackageFragmentSymbolImpl(packageFragmentDescriptor))
|
||||
IrExternalPackageFragmentImpl(IrExternalPackageFragmentSymbolImpl(packageFragmentDescriptor))
|
||||
|
||||
fun declareAnonymousInitializer(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassDescriptor): IrAnonymousInitializer =
|
||||
IrAnonymousInitializerImpl(
|
||||
startOffset, endOffset, origin,
|
||||
IrAnonymousInitializerSymbolImpl(descriptor)
|
||||
)
|
||||
fun declareAnonymousInitializer(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: ClassDescriptor
|
||||
): IrAnonymousInitializer =
|
||||
IrAnonymousInitializerImpl(
|
||||
startOffset, endOffset, origin,
|
||||
IrAnonymousInitializerSymbolImpl(descriptor)
|
||||
)
|
||||
|
||||
fun declareClass(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassDescriptor): IrClass =
|
||||
classSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrClassSymbolImpl(descriptor) },
|
||||
{ IrClassImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
classSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrClassSymbolImpl(descriptor) },
|
||||
{ IrClassImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun referenceClass(descriptor: ClassDescriptor) =
|
||||
classSymbolTable.referenced(descriptor) { IrClassSymbolImpl(descriptor) }
|
||||
classSymbolTable.referenced(descriptor) { IrClassSymbolImpl(descriptor) }
|
||||
|
||||
val unboundClasses: Set<IrClassSymbol> get() = classSymbolTable.unboundSymbols
|
||||
|
||||
fun declareConstructor(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassConstructorDescriptor): IrConstructor =
|
||||
constructorSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrConstructorSymbolImpl(descriptor) },
|
||||
{ IrConstructorImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
fun declareConstructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: ClassConstructorDescriptor
|
||||
): IrConstructor =
|
||||
constructorSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrConstructorSymbolImpl(descriptor) },
|
||||
{ IrConstructorImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun referenceConstructor(descriptor: ClassConstructorDescriptor) =
|
||||
constructorSymbolTable.referenced(descriptor) { IrConstructorSymbolImpl(descriptor) }
|
||||
constructorSymbolTable.referenced(descriptor) { IrConstructorSymbolImpl(descriptor) }
|
||||
|
||||
val unboundConstructors: Set<IrConstructorSymbol> get() = constructorSymbolTable.unboundSymbols
|
||||
|
||||
fun declareEnumEntry(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassDescriptor): IrEnumEntry =
|
||||
enumEntrySymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrEnumEntrySymbolImpl(descriptor) },
|
||||
{ IrEnumEntryImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
enumEntrySymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrEnumEntrySymbolImpl(descriptor) },
|
||||
{ IrEnumEntryImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun referenceEnumEntry(descriptor: ClassDescriptor) =
|
||||
enumEntrySymbolTable.referenced(descriptor) { IrEnumEntrySymbolImpl(descriptor) }
|
||||
enumEntrySymbolTable.referenced(descriptor) { IrEnumEntrySymbolImpl(descriptor) }
|
||||
|
||||
val unboundEnumEntries: Set<IrEnumEntrySymbol> get() = enumEntrySymbolTable.unboundSymbols
|
||||
|
||||
fun declareField(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: PropertyDescriptor): IrField =
|
||||
fieldSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrFieldSymbolImpl(descriptor) },
|
||||
{ IrFieldImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
fieldSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrFieldSymbolImpl(descriptor) },
|
||||
{ IrFieldImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun declareField(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: PropertyDescriptor,
|
||||
irInitializer: IrExpressionBody?) : IrField =
|
||||
declareField(startOffset, endOffset, origin, descriptor).apply { initializer = irInitializer }
|
||||
fun declareField(
|
||||
startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: PropertyDescriptor,
|
||||
irInitializer: IrExpressionBody?
|
||||
): IrField =
|
||||
declareField(startOffset, endOffset, origin, descriptor).apply { initializer = irInitializer }
|
||||
|
||||
fun referenceField(descriptor: PropertyDescriptor) =
|
||||
fieldSymbolTable.referenced(descriptor) { IrFieldSymbolImpl(descriptor) }
|
||||
fieldSymbolTable.referenced(descriptor) { IrFieldSymbolImpl(descriptor) }
|
||||
|
||||
val unboundFields: Set<IrFieldSymbol> get() = fieldSymbolTable.unboundSymbols
|
||||
|
||||
fun declareSimpleFunction(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: FunctionDescriptor): IrSimpleFunction =
|
||||
simpleFunctionSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrSimpleFunctionSymbolImpl(descriptor) },
|
||||
{ IrFunctionImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
fun declareSimpleFunction(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: FunctionDescriptor
|
||||
): IrSimpleFunction =
|
||||
simpleFunctionSymbolTable.declare(
|
||||
descriptor,
|
||||
{ IrSimpleFunctionSymbolImpl(descriptor) },
|
||||
{ IrFunctionImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun referenceSimpleFunction(descriptor: FunctionDescriptor) =
|
||||
simpleFunctionSymbolTable.referenced(descriptor) { IrSimpleFunctionSymbolImpl(descriptor) }
|
||||
simpleFunctionSymbolTable.referenced(descriptor) { IrSimpleFunctionSymbolImpl(descriptor) }
|
||||
|
||||
fun referenceDeclaredFunction(descriptor: FunctionDescriptor) =
|
||||
simpleFunctionSymbolTable.referenced(descriptor) { throw AssertionError("Function is not declared: $descriptor") }
|
||||
simpleFunctionSymbolTable.referenced(descriptor) { throw AssertionError("Function is not declared: $descriptor") }
|
||||
|
||||
val unboundSimpleFunctions: Set<IrSimpleFunctionSymbol> get() = simpleFunctionSymbolTable.unboundSymbols
|
||||
|
||||
fun declareTypeParameter(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: TypeParameterDescriptor) : IrTypeParameter =
|
||||
typeParameterSymbolTable.declareLocal(
|
||||
descriptor,
|
||||
{ IrTypeParameterSymbolImpl(descriptor) },
|
||||
{ IrTypeParameterImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
fun declareTypeParameter(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeParameterDescriptor
|
||||
): IrTypeParameter =
|
||||
typeParameterSymbolTable.declareLocal(
|
||||
descriptor,
|
||||
{ IrTypeParameterSymbolImpl(descriptor) },
|
||||
{ IrTypeParameterImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun referenceTypeParameter(descriptor: TypeParameterDescriptor) =
|
||||
typeParameterSymbolTable.referenced(descriptor) { throw AssertionError("Undefined type parameter referenced: $descriptor") }
|
||||
typeParameterSymbolTable.referenced(descriptor) { throw AssertionError("Undefined type parameter referenced: $descriptor") }
|
||||
|
||||
val unboundTypeParameters: Set<IrTypeParameterSymbol> get() = typeParameterSymbolTable.unboundSymbols
|
||||
|
||||
fun declareValueParameter(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ParameterDescriptor): IrValueParameter =
|
||||
valueParameterSymbolTable.declareLocal(
|
||||
descriptor,
|
||||
{ IrValueParameterSymbolImpl(descriptor) },
|
||||
{ IrValueParameterImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
fun declareValueParameter(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: ParameterDescriptor
|
||||
): IrValueParameter =
|
||||
valueParameterSymbolTable.declareLocal(
|
||||
descriptor,
|
||||
{ IrValueParameterSymbolImpl(descriptor) },
|
||||
{ IrValueParameterImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun introduceValueParameter(irValueParameter: IrValueParameter) {
|
||||
valueParameterSymbolTable.introduceLocal(irValueParameter.descriptor, irValueParameter.symbol)
|
||||
}
|
||||
|
||||
fun referenceValueParameter(descriptor: ParameterDescriptor) =
|
||||
valueParameterSymbolTable.referenced(descriptor) {
|
||||
throw AssertionError("Undefined parameter referenced: $descriptor\n${valueParameterSymbolTable.dump()}")
|
||||
}
|
||||
valueParameterSymbolTable.referenced(descriptor) {
|
||||
throw AssertionError("Undefined parameter referenced: $descriptor\n${valueParameterSymbolTable.dump()}")
|
||||
}
|
||||
|
||||
val unboundValueParameters: Set<IrValueParameterSymbol> get() = valueParameterSymbolTable.unboundSymbols
|
||||
|
||||
fun declareVariable(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: VariableDescriptor): IrVariable =
|
||||
variableSymbolTable.declareLocal(
|
||||
descriptor,
|
||||
{ IrVariableSymbolImpl(descriptor) },
|
||||
{ IrVariableImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
variableSymbolTable.declareLocal(
|
||||
descriptor,
|
||||
{ IrVariableSymbolImpl(descriptor) },
|
||||
{ IrVariableImpl(startOffset, endOffset, origin, it) }
|
||||
)
|
||||
|
||||
fun declareVariable(
|
||||
startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin,
|
||||
descriptor: VariableDescriptor,
|
||||
irInitializerExpression: IrExpression?
|
||||
startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin,
|
||||
descriptor: VariableDescriptor,
|
||||
irInitializerExpression: IrExpression?
|
||||
): IrVariable =
|
||||
declareVariable(startOffset, endOffset, origin, descriptor).apply {
|
||||
initializer = irInitializerExpression
|
||||
}
|
||||
declareVariable(startOffset, endOffset, origin, descriptor).apply {
|
||||
initializer = irInitializerExpression
|
||||
}
|
||||
|
||||
fun referenceVariable(descriptor: VariableDescriptor) =
|
||||
variableSymbolTable.referenced(descriptor) { throw AssertionError("Undefined variable referenced: $descriptor") }
|
||||
variableSymbolTable.referenced(descriptor) { throw AssertionError("Undefined variable referenced: $descriptor") }
|
||||
|
||||
val unboundVariables: Set<IrVariableSymbol> get() = variableSymbolTable.unboundSymbols
|
||||
|
||||
@@ -295,34 +320,34 @@ class SymbolTable {
|
||||
}
|
||||
|
||||
fun referenceFunction(callable: CallableDescriptor): IrFunctionSymbol =
|
||||
when (callable) {
|
||||
is ClassConstructorDescriptor ->
|
||||
constructorSymbolTable.referenced(callable) { IrConstructorSymbolImpl(callable) }
|
||||
is FunctionDescriptor ->
|
||||
simpleFunctionSymbolTable.referenced(callable) { IrSimpleFunctionSymbolImpl(callable) }
|
||||
else ->
|
||||
throw IllegalArgumentException("Unexpected callable descriptor: $callable")
|
||||
}
|
||||
when (callable) {
|
||||
is ClassConstructorDescriptor ->
|
||||
constructorSymbolTable.referenced(callable) { IrConstructorSymbolImpl(callable) }
|
||||
is FunctionDescriptor ->
|
||||
simpleFunctionSymbolTable.referenced(callable) { IrSimpleFunctionSymbolImpl(callable) }
|
||||
else ->
|
||||
throw IllegalArgumentException("Unexpected callable descriptor: $callable")
|
||||
}
|
||||
|
||||
fun referenceValue(value: ValueDescriptor): IrValueSymbol =
|
||||
when (value) {
|
||||
is ParameterDescriptor ->
|
||||
valueParameterSymbolTable.referenced(value) { throw AssertionError("Undefined parameter referenced: $value") }
|
||||
is VariableDescriptor ->
|
||||
variableSymbolTable.referenced(value) { throw AssertionError("Undefined variable referenced: $value") }
|
||||
else ->
|
||||
throw IllegalArgumentException("Unexpected value descriptor: $value")
|
||||
}
|
||||
when (value) {
|
||||
is ParameterDescriptor ->
|
||||
valueParameterSymbolTable.referenced(value) { throw AssertionError("Undefined parameter referenced: $value") }
|
||||
is VariableDescriptor ->
|
||||
variableSymbolTable.referenced(value) { throw AssertionError("Undefined variable referenced: $value") }
|
||||
else ->
|
||||
throw IllegalArgumentException("Unexpected value descriptor: $value")
|
||||
}
|
||||
|
||||
fun referenceClassifier(classifier: ClassifierDescriptor): IrClassifierSymbol =
|
||||
when (classifier) {
|
||||
is TypeParameterDescriptor ->
|
||||
typeParameterSymbolTable.referenced(classifier) { throw AssertionError("Undefined type parameter referenced: $classifier") }
|
||||
is ClassDescriptor ->
|
||||
classSymbolTable.referenced(classifier) { IrClassSymbolImpl(classifier) }
|
||||
else ->
|
||||
throw IllegalArgumentException("Unexpected classifier descriptor: $classifier")
|
||||
}
|
||||
when (classifier) {
|
||||
is TypeParameterDescriptor ->
|
||||
typeParameterSymbolTable.referenced(classifier) { throw AssertionError("Undefined type parameter referenced: $classifier") }
|
||||
is ClassDescriptor ->
|
||||
classSymbolTable.referenced(classifier) { IrClassSymbolImpl(classifier) }
|
||||
else ->
|
||||
throw IllegalArgumentException("Unexpected classifier descriptor: $classifier")
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> SymbolTable.withScope(owner: DeclarationDescriptor, block: () -> T): T {
|
||||
|
||||
@@ -23,19 +23,19 @@ import org.jetbrains.kotlin.ir.expressions.*
|
||||
|
||||
interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
|
||||
override fun visitElement(element: IrElement, data: D): IrElement =
|
||||
element.also { it.transformChildren(this, data) }
|
||||
element.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitModuleFragment(declaration: IrModuleFragment, data: D): IrModuleFragment =
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitFile(declaration: IrFile, data: D): IrFile =
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment, data: D): IrExternalPackageFragment =
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitDeclaration(declaration: IrDeclaration, data: D): IrStatement =
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
declaration.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitClass(declaration: IrClass, data: D) = visitDeclaration(declaration, data)
|
||||
override fun visitTypeAlias(declaration: IrTypeAlias, data: D) = visitDeclaration(declaration, data)
|
||||
@@ -52,20 +52,20 @@ interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
|
||||
override fun visitValueParameter(declaration: IrValueParameter, data: D) = visitDeclaration(declaration, data)
|
||||
|
||||
override fun visitBody(body: IrBody, data: D): IrBody =
|
||||
body.also { it.transformChildren(this, data) }
|
||||
body.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitExpressionBody(body: IrExpressionBody, data: D) = visitBody(body, data)
|
||||
override fun visitBlockBody(body: IrBlockBody, data: D) = visitBody(body, data)
|
||||
override fun visitSyntheticBody(body: IrSyntheticBody, data: D) = visitBody(body, data)
|
||||
|
||||
override fun visitExpression(expression: IrExpression, data: D): IrExpression =
|
||||
expression.also { it.transformChildren(this, data) }
|
||||
expression.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun <T> visitConst(expression: IrConst<T>, data: D) = visitExpression(expression, data)
|
||||
override fun visitVararg(expression: IrVararg, data: D) = visitExpression(expression, data)
|
||||
|
||||
override fun visitSpreadElement(spread: IrSpreadElement, data: D): IrSpreadElement =
|
||||
spread.also { it.transformChildren(this, data) }
|
||||
spread.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitContainerExpression(expression: IrContainerExpression, data: D) = visitExpression(expression, data)
|
||||
override fun visitBlock(expression: IrBlock, data: D) = visitContainerExpression(expression, data)
|
||||
@@ -92,7 +92,8 @@ interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
|
||||
override fun visitCallableReference(expression: IrCallableReference, data: D) = visitMemberAccess(expression, data)
|
||||
override fun visitFunctionReference(expression: IrFunctionReference, data: D) = visitCallableReference(expression, data)
|
||||
override fun visitPropertyReference(expression: IrPropertyReference, data: D) = visitCallableReference(expression, data)
|
||||
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: D) = visitCallableReference(expression, data)
|
||||
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: D) =
|
||||
visitCallableReference(expression, data)
|
||||
|
||||
override fun visitClassReference(expression: IrClassReference, data: D) = visitDeclarationReference(expression, data)
|
||||
|
||||
@@ -103,16 +104,16 @@ interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
|
||||
override fun visitWhen(expression: IrWhen, data: D) = visitExpression(expression, data)
|
||||
|
||||
override fun visitBranch(branch: IrBranch, data: D): IrBranch =
|
||||
branch.also {
|
||||
it.condition = it.condition.transform(this, data)
|
||||
it.result = it.result.transform(this, data)
|
||||
}
|
||||
branch.also {
|
||||
it.condition = it.condition.transform(this, data)
|
||||
it.result = it.result.transform(this, data)
|
||||
}
|
||||
|
||||
override fun visitElseBranch(branch: IrElseBranch, data: D): IrElseBranch =
|
||||
branch.also {
|
||||
it.condition = it.condition.transform(this, data)
|
||||
it.result = it.result.transform(this, data)
|
||||
}
|
||||
branch.also {
|
||||
it.condition = it.condition.transform(this, data)
|
||||
it.result = it.result.transform(this, data)
|
||||
}
|
||||
|
||||
override fun visitLoop(loop: IrLoop, data: D) = visitExpression(loop, data)
|
||||
override fun visitWhileLoop(loop: IrWhileLoop, data: D) = visitLoop(loop, data)
|
||||
@@ -120,7 +121,7 @@ interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
|
||||
override fun visitTry(aTry: IrTry, data: D) = visitExpression(aTry, data)
|
||||
|
||||
override fun visitCatch(aCatch: IrCatch, data: D): IrCatch =
|
||||
aCatch.also { it.transformChildren(this, data) }
|
||||
aCatch.also { it.transformChildren(this, data) }
|
||||
|
||||
override fun visitBreakContinue(jump: IrBreakContinue, data: D) = visitExpression(jump, data)
|
||||
override fun visitBreak(jump: IrBreak, data: D) = visitBreakContinue(jump, data)
|
||||
|
||||
+21
-12
@@ -28,7 +28,8 @@ abstract class IrElementTransformerVoid : IrElementTransformer<Nothing?> {
|
||||
override final fun visitElement(element: IrElement, data: Nothing?): IrElement = visitElement(element)
|
||||
|
||||
open fun visitModuleFragment(declaration: IrModuleFragment): IrModuleFragment = declaration.transformChildren()
|
||||
override final fun visitModuleFragment(declaration: IrModuleFragment, data: Nothing?): IrModuleFragment = visitModuleFragment(declaration)
|
||||
override final fun visitModuleFragment(declaration: IrModuleFragment, data: Nothing?): IrModuleFragment =
|
||||
visitModuleFragment(declaration)
|
||||
|
||||
open fun visitPackageFragment(declaration: IrPackageFragment): IrPackageFragment = declaration.transformChildren()
|
||||
override fun visitPackageFragment(declaration: IrPackageFragment, data: Nothing?): IrElement = visitPackageFragment(declaration)
|
||||
@@ -36,9 +37,11 @@ abstract class IrElementTransformerVoid : IrElementTransformer<Nothing?> {
|
||||
open fun visitFile(declaration: IrFile): IrFile = visitPackageFragment(declaration) as IrFile
|
||||
override final fun visitFile(declaration: IrFile, data: Nothing?): IrFile = visitFile(declaration)
|
||||
|
||||
open fun visitExternalPackageFragment(declaration: IrExternalPackageFragment) = visitPackageFragment(declaration) as IrExternalPackageFragment
|
||||
open fun visitExternalPackageFragment(declaration: IrExternalPackageFragment) =
|
||||
visitPackageFragment(declaration) as IrExternalPackageFragment
|
||||
|
||||
override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment, data: Nothing?): IrExternalPackageFragment =
|
||||
visitExternalPackageFragment(declaration)
|
||||
visitExternalPackageFragment(declaration)
|
||||
|
||||
open fun visitDeclaration(declaration: IrDeclaration): IrStatement = declaration.transformChildren()
|
||||
override final fun visitDeclaration(declaration: IrDeclaration, data: Nothing?): IrStatement = visitDeclaration(declaration)
|
||||
@@ -65,13 +68,15 @@ abstract class IrElementTransformerVoid : IrElementTransformer<Nothing?> {
|
||||
override final fun visitField(declaration: IrField, data: Nothing?) = visitField(declaration)
|
||||
|
||||
open fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty) = visitDeclaration(declaration)
|
||||
override final fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty, data: Nothing?) = visitLocalDelegatedProperty(declaration)
|
||||
override final fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty, data: Nothing?) =
|
||||
visitLocalDelegatedProperty(declaration)
|
||||
|
||||
open fun visitEnumEntry(declaration: IrEnumEntry) = visitDeclaration(declaration)
|
||||
override final fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?) = visitEnumEntry(declaration)
|
||||
|
||||
open fun visitAnonymousInitializer(declaration: IrAnonymousInitializer) = visitDeclaration(declaration)
|
||||
override final fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: Nothing?) = visitAnonymousInitializer(declaration)
|
||||
override final fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: Nothing?) =
|
||||
visitAnonymousInitializer(declaration)
|
||||
|
||||
open fun visitTypeParameter(declaration: IrTypeParameter) = visitDeclaration(declaration)
|
||||
override final fun visitTypeParameter(declaration: IrTypeParameter, data: Nothing?): IrStatement = visitTypeParameter(declaration)
|
||||
@@ -83,7 +88,7 @@ abstract class IrElementTransformerVoid : IrElementTransformer<Nothing?> {
|
||||
override final fun visitVariable(declaration: IrVariable, data: Nothing?) = visitVariable(declaration)
|
||||
|
||||
open fun visitBody(body: IrBody): IrBody = body.transformChildren()
|
||||
override final fun visitBody(body: IrBody, data: Nothing?): IrBody = visitBody(body)
|
||||
override final fun visitBody(body: IrBody, data: Nothing?): IrBody = visitBody(body)
|
||||
|
||||
open fun visitExpressionBody(body: IrExpressionBody) = visitBody(body)
|
||||
override final fun visitExpressionBody(body: IrExpressionBody, data: Nothing?) = visitExpressionBody(body)
|
||||
@@ -153,12 +158,13 @@ abstract class IrElementTransformerVoid : IrElementTransformer<Nothing?> {
|
||||
|
||||
open fun visitFunctionAccess(expression: IrFunctionAccessExpression) = visitMemberAccess(expression)
|
||||
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: Nothing?) = visitFunctionAccess(expression)
|
||||
|
||||
|
||||
open fun visitCall(expression: IrCall) = visitFunctionAccess(expression)
|
||||
override final fun visitCall(expression: IrCall, data: Nothing?) = visitCall(expression)
|
||||
|
||||
open fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall) = visitMemberAccess(expression)
|
||||
override final fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?) = visitDelegatingConstructorCall(expression)
|
||||
override final fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?) =
|
||||
visitDelegatingConstructorCall(expression)
|
||||
|
||||
open fun visitEnumConstructorCall(expression: IrEnumConstructorCall) = visitMemberAccess(expression)
|
||||
override final fun visitEnumConstructorCall(expression: IrEnumConstructorCall, data: Nothing?) = visitEnumConstructorCall(expression)
|
||||
@@ -170,20 +176,23 @@ abstract class IrElementTransformerVoid : IrElementTransformer<Nothing?> {
|
||||
override final fun visitCallableReference(expression: IrCallableReference, data: Nothing?) = visitCallableReference(expression)
|
||||
|
||||
open fun visitFunctionReference(expression: IrFunctionReference) = visitCallableReference(expression)
|
||||
override final fun visitFunctionReference(expression: IrFunctionReference, data: Nothing?): IrElement = visitFunctionReference(expression)
|
||||
override final fun visitFunctionReference(expression: IrFunctionReference, data: Nothing?): IrElement =
|
||||
visitFunctionReference(expression)
|
||||
|
||||
open fun visitPropertyReference(expression: IrPropertyReference) = visitCallableReference(expression)
|
||||
override final fun visitPropertyReference(expression: IrPropertyReference, data: Nothing?): IrElement = visitPropertyReference(expression)
|
||||
override final fun visitPropertyReference(expression: IrPropertyReference, data: Nothing?): IrElement =
|
||||
visitPropertyReference(expression)
|
||||
|
||||
open fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference) = visitCallableReference(expression)
|
||||
override final fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: Nothing?) =
|
||||
visitLocalDelegatedPropertyReference(expression)
|
||||
visitLocalDelegatedPropertyReference(expression)
|
||||
|
||||
open fun visitClassReference(expression: IrClassReference) = visitDeclarationReference(expression)
|
||||
override final fun visitClassReference(expression: IrClassReference, data: Nothing?) = visitClassReference(expression)
|
||||
|
||||
open fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall) = visitExpression(expression)
|
||||
override final fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?) = visitInstanceInitializerCall(expression)
|
||||
override final fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?) =
|
||||
visitInstanceInitializerCall(expression)
|
||||
|
||||
open fun visitTypeOperator(expression: IrTypeOperatorCall) = visitExpression(expression)
|
||||
override final fun visitTypeOperator(expression: IrTypeOperatorCall, data: Nothing?) = visitTypeOperator(expression)
|
||||
|
||||
@@ -78,7 +78,8 @@ interface IrElementVisitor<out R, in D> {
|
||||
fun visitCallableReference(expression: IrCallableReference, data: D) = visitMemberAccess(expression, data)
|
||||
fun visitFunctionReference(expression: IrFunctionReference, data: D) = visitCallableReference(expression, data)
|
||||
fun visitPropertyReference(expression: IrPropertyReference, data: D) = visitCallableReference(expression, data)
|
||||
fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: D) = visitCallableReference(expression, data)
|
||||
fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: D) =
|
||||
visitCallableReference(expression, data)
|
||||
|
||||
fun visitClassReference(expression: IrClassReference, data: D) = visitDeclarationReference(expression, data)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.ir.expressions.*
|
||||
interface IrElementVisitorVoid : IrElementVisitor<Unit, Nothing?> {
|
||||
fun visitElement(element: IrElement)
|
||||
override fun visitElement(element: IrElement, data: Nothing?) = visitElement(element)
|
||||
|
||||
|
||||
fun visitModuleFragment(declaration: IrModuleFragment) = visitElement(declaration)
|
||||
override fun visitModuleFragment(declaration: IrModuleFragment, data: Nothing?) = visitModuleFragment(declaration)
|
||||
|
||||
@@ -31,7 +31,8 @@ interface IrElementVisitorVoid : IrElementVisitor<Unit, Nothing?> {
|
||||
override fun visitPackageFragment(declaration: IrPackageFragment, data: Nothing?) = visitPackageFragment(declaration)
|
||||
|
||||
fun visitExternalPackageFragment(declaration: IrExternalPackageFragment) = visitPackageFragment(declaration)
|
||||
override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment, data: Nothing?) = visitExternalPackageFragment(declaration)
|
||||
override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment, data: Nothing?) =
|
||||
visitExternalPackageFragment(declaration)
|
||||
|
||||
fun visitFile(declaration: IrFile) = visitPackageFragment(declaration)
|
||||
override fun visitFile(declaration: IrFile, data: Nothing?) = visitFile(declaration)
|
||||
@@ -61,7 +62,8 @@ interface IrElementVisitorVoid : IrElementVisitor<Unit, Nothing?> {
|
||||
override fun visitField(declaration: IrField, data: Nothing?) = visitField(declaration)
|
||||
|
||||
fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty) = visitDeclaration(declaration)
|
||||
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty, data: Nothing?) = visitLocalDelegatedProperty(declaration)
|
||||
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty, data: Nothing?) =
|
||||
visitLocalDelegatedProperty(declaration)
|
||||
|
||||
fun visitVariable(declaration: IrVariable) = visitDeclaration(declaration)
|
||||
override fun visitVariable(declaration: IrVariable, data: Nothing?) = visitVariable(declaration)
|
||||
@@ -149,12 +151,13 @@ interface IrElementVisitorVoid : IrElementVisitor<Unit, Nothing?> {
|
||||
|
||||
fun visitFunctionAccess(expression: IrFunctionAccessExpression) = visitMemberAccess(expression)
|
||||
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: Nothing?) = visitFunctionAccess(expression)
|
||||
|
||||
|
||||
fun visitCall(expression: IrCall) = visitFunctionAccess(expression)
|
||||
override fun visitCall(expression: IrCall, data: Nothing?) = visitCall(expression)
|
||||
|
||||
fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall) = visitFunctionAccess(expression)
|
||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?) = visitDelegatingConstructorCall(expression)
|
||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?) =
|
||||
visitDelegatingConstructorCall(expression)
|
||||
|
||||
fun visitEnumConstructorCall(expression: IrEnumConstructorCall) = visitFunctionAccess(expression)
|
||||
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall, data: Nothing?) = visitEnumConstructorCall(expression)
|
||||
@@ -172,13 +175,15 @@ interface IrElementVisitorVoid : IrElementVisitor<Unit, Nothing?> {
|
||||
override fun visitPropertyReference(expression: IrPropertyReference, data: Nothing?) = visitPropertyReference(expression)
|
||||
|
||||
fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference) = visitCallableReference(expression)
|
||||
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: Nothing?) = visitLocalDelegatedPropertyReference(expression)
|
||||
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: Nothing?) =
|
||||
visitLocalDelegatedPropertyReference(expression)
|
||||
|
||||
fun visitClassReference(expression: IrClassReference) = visitDeclarationReference(expression)
|
||||
override fun visitClassReference(expression: IrClassReference, data: Nothing?) = visitClassReference(expression)
|
||||
|
||||
fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall) = visitExpression(expression)
|
||||
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?) = visitInstanceInitializerCall(expression)
|
||||
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?) =
|
||||
visitInstanceInitializerCall(expression)
|
||||
|
||||
fun visitTypeOperator(expression: IrTypeOperatorCall) = visitExpression(expression)
|
||||
override fun visitTypeOperator(expression: IrTypeOperatorCall, data: Nothing?) = visitTypeOperator(expression)
|
||||
|
||||
@@ -92,8 +92,7 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
|
||||
try {
|
||||
TestCase.assertEquals(irFileDump, expected.toString(), actual.toString())
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
} catch (e: Throwable) {
|
||||
println(irFileDump)
|
||||
throw rethrow(e)
|
||||
}
|
||||
@@ -145,23 +144,26 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
val expectedDispatchReceiver = functionDescriptor.dispatchReceiverParameter
|
||||
val actualDispatchReceiver = declaration.dispatchReceiverParameter?.descriptor
|
||||
if (expectedDispatchReceiver != actualDispatchReceiver) {
|
||||
error("$functionDescriptor: Dispatch receiver parameter mismatch: " +
|
||||
"expected $expectedDispatchReceiver, actual $actualDispatchReceiver")
|
||||
error(
|
||||
"$functionDescriptor: Dispatch receiver parameter mismatch: " +
|
||||
"expected $expectedDispatchReceiver, actual $actualDispatchReceiver"
|
||||
)
|
||||
}
|
||||
|
||||
val expectedExtensionReceiver = functionDescriptor.extensionReceiverParameter
|
||||
val expectedExtensionReceiver = functionDescriptor.extensionReceiverParameter
|
||||
val actualExtensionReceiver = declaration.extensionReceiverParameter?.descriptor
|
||||
if (expectedExtensionReceiver != actualExtensionReceiver) {
|
||||
error("$functionDescriptor: Extension receiver parameter mismatch: " +
|
||||
"expected $expectedExtensionReceiver, actual $actualExtensionReceiver")
|
||||
error(
|
||||
"$functionDescriptor: Extension receiver parameter mismatch: " +
|
||||
"expected $expectedExtensionReceiver, actual $actualExtensionReceiver"
|
||||
)
|
||||
}
|
||||
|
||||
val declaredValueParameters = declaration.valueParameters.map { it.descriptor }
|
||||
val actualValueParameters = functionDescriptor.valueParameters
|
||||
if (declaredValueParameters.size != actualValueParameters.size) {
|
||||
error("$functionDescriptor: Value parameters mismatch: $declaredValueParameters != $actualValueParameters")
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
declaredValueParameters.zip(actualValueParameters).forEach { (declaredValueParameter, actualValueParameter) ->
|
||||
if (declaredValueParameter != actualValueParameter) {
|
||||
error("$functionDescriptor: Value parameters mismatch: $declaredValueParameter != $actualValueParameter")
|
||||
@@ -207,13 +209,16 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
checkTypeParameters(declaration.descriptor, declaration, declaration.descriptor.declaredTypeParameters)
|
||||
}
|
||||
|
||||
private fun checkTypeParameters(descriptor: DeclarationDescriptor, declaration: IrTypeParametersContainer, expectedTypeParameters: List<TypeParameterDescriptor>) {
|
||||
private fun checkTypeParameters(
|
||||
descriptor: DeclarationDescriptor,
|
||||
declaration: IrTypeParametersContainer,
|
||||
expectedTypeParameters: List<TypeParameterDescriptor>
|
||||
) {
|
||||
val declaredTypeParameters = declaration.typeParameters.map { it.descriptor }
|
||||
|
||||
if (declaredTypeParameters.size != expectedTypeParameters.size) {
|
||||
error("$descriptor: Type parameters mismatch: $declaredTypeParameters != $expectedTypeParameters")
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
declaredTypeParameters.zip(expectedTypeParameters).forEach { (declaredTypeParameter, expectedTypeParameter) ->
|
||||
if (declaredTypeParameter != expectedTypeParameter) {
|
||||
error("$descriptor: Type parameters mismatch: $declaredTypeParameter != $expectedTypeParameter")
|
||||
@@ -240,13 +245,13 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
private val EXTERNAL_FILE_PATTERN = Regex("""// EXTERNAL_FILE""")
|
||||
|
||||
internal fun shouldDumpDependencies(wholeFile: File): Boolean =
|
||||
DUMP_DEPENDENCIES_PATTERN.containsMatchIn(wholeFile.readText())
|
||||
DUMP_DEPENDENCIES_PATTERN.containsMatchIn(wholeFile.readText())
|
||||
|
||||
internal fun TestFile.isExternalFile() =
|
||||
EXTERNAL_FILE_PATTERN.containsMatchIn(content)
|
||||
EXTERNAL_FILE_PATTERN.containsMatchIn(content)
|
||||
|
||||
internal fun KtFile.isExternalFile() =
|
||||
EXTERNAL_FILE_PATTERN.containsMatchIn(text)
|
||||
EXTERNAL_FILE_PATTERN.containsMatchIn(text)
|
||||
|
||||
internal fun parseExpectations(dir: File, testFile: TestFile): Expectations {
|
||||
val regexps = ArrayList<RegexpInText>()
|
||||
@@ -255,8 +260,7 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
for (line in testFile.content.split("\n")) {
|
||||
EXPECTED_OCCURRENCES_PATTERN.matchEntire(line)?.let { matchResult ->
|
||||
regexps.add(RegexpInText(matchResult.groupValues[1], matchResult.groupValues[2].trim()))
|
||||
}
|
||||
?: IR_FILE_TXT_PATTERN.find(line)?.let { matchResult ->
|
||||
} ?: IR_FILE_TXT_PATTERN.find(line)?.let { matchResult ->
|
||||
val fileName = matchResult.groupValues[1].trim()
|
||||
val file = createExpectedTextFile(testFile, dir, fileName)
|
||||
treeFiles.add(IrTreeFileLabel(file, 0))
|
||||
|
||||
Reference in New Issue
Block a user