[IR] Remove DeclarationDescriptor from IrExpression* tree API
This commit is contained in:
+1
-1
@@ -98,7 +98,7 @@ abstract class AbstractClosureAnnotator : IrElementVisitorVoid {
|
|||||||
override fun visitVariableAccess(expression: IrValueAccessExpression) {
|
override fun visitVariableAccess(expression: IrValueAccessExpression) {
|
||||||
val closureBuilder = closuresStack.peek() ?: return
|
val closureBuilder = closuresStack.peek() ?: return
|
||||||
|
|
||||||
val variableDescriptor = expression.descriptor
|
val variableDescriptor = expression.symbol.descriptor
|
||||||
if (variableDescriptor.containingDeclaration != closureBuilder.owner) {
|
if (variableDescriptor.containingDeclaration != closureBuilder.owner) {
|
||||||
closureBuilder.capturedValues.add(variableDescriptor)
|
closureBuilder.capturedValues.add(variableDescriptor)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -294,7 +294,7 @@ class CheckIrElementVisitor(
|
|||||||
super.visitDeclarationReference(expression)
|
super.visitDeclarationReference(expression)
|
||||||
|
|
||||||
// TODO: Fix unbound external declarations
|
// TODO: Fix unbound external declarations
|
||||||
if (expression.descriptor.isEffectivelyExternal())
|
if (expression.symbol.descriptor.isEffectivelyExternal())
|
||||||
return
|
return
|
||||||
|
|
||||||
// TODO: Fix unbound dynamic filed declarations
|
// TODO: Fix unbound dynamic filed declarations
|
||||||
|
|||||||
+16
-13
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.common
|
package org.jetbrains.kotlin.backend.common
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
@@ -87,38 +88,38 @@ class RenderIrElementWithDescriptorsVisitor : IrElementVisitor<String, Nothing?>
|
|||||||
"RETURN type=${expression.type.render()} from='${expression.returnTarget}'"
|
"RETURN type=${expression.type.render()} from='${expression.returnTarget}'"
|
||||||
|
|
||||||
override fun visitCall(expression: IrCall, data: Nothing?): String =
|
override fun visitCall(expression: IrCall, data: Nothing?): String =
|
||||||
"CALL '${expression.descriptor}' ${expression.renderSuperQualifier()}" +
|
"CALL '${expression.symbol.descriptor}' ${expression.renderSuperQualifier()}" +
|
||||||
"type=${expression.type.render()} origin=${expression.origin}"
|
"type=${expression.type.render()} origin=${expression.origin}"
|
||||||
|
|
||||||
private fun IrCall.renderSuperQualifier(): String =
|
private fun IrCall.renderSuperQualifier(): String =
|
||||||
superQualifierSymbol?.let { "superQualifier=${it.owner.name} " } ?: ""
|
superQualifierSymbol?.let { "superQualifier=${it.owner.name} " } ?: ""
|
||||||
|
|
||||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?): String =
|
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?): String =
|
||||||
"DELEGATING_CONSTRUCTOR_CALL '${expression.descriptor}'"
|
"DELEGATING_CONSTRUCTOR_CALL '${expression.symbol.descriptor}'"
|
||||||
|
|
||||||
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall, data: Nothing?): String =
|
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall, data: Nothing?): String =
|
||||||
"ENUM_CONSTRUCTOR_CALL '${expression.descriptor}'"
|
"ENUM_CONSTRUCTOR_CALL '${expression.symbol.descriptor}'"
|
||||||
|
|
||||||
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?): String =
|
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?): String =
|
||||||
"INSTANCE_INITIALIZER_CALL classDescriptor='${expression.classDescriptor}'"
|
"INSTANCE_INITIALIZER_CALL classDescriptor='${expression.classDescriptor}'"
|
||||||
|
|
||||||
override fun visitGetValue(expression: IrGetValue, data: Nothing?): String =
|
override fun visitGetValue(expression: IrGetValue, data: Nothing?): String =
|
||||||
"GET_VAR '${expression.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
"GET_VAR '${expression.symbol.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
||||||
|
|
||||||
override fun visitSetVariable(expression: IrSetVariable, data: Nothing?): String =
|
override fun visitSetVariable(expression: IrSetVariable, data: Nothing?): String =
|
||||||
"SET_VAR '${expression.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
"SET_VAR '${expression.symbol.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
||||||
|
|
||||||
override fun visitGetField(expression: IrGetField, data: Nothing?): String =
|
override fun visitGetField(expression: IrGetField, data: Nothing?): String =
|
||||||
"GET_FIELD '${expression.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
"GET_FIELD '${expression.symbol.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
||||||
|
|
||||||
override fun visitSetField(expression: IrSetField, data: Nothing?): String =
|
override fun visitSetField(expression: IrSetField, data: Nothing?): String =
|
||||||
"SET_FIELD '${expression.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
"SET_FIELD '${expression.symbol.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
||||||
|
|
||||||
override fun visitGetObjectValue(expression: IrGetObjectValue, data: Nothing?): String =
|
override fun visitGetObjectValue(expression: IrGetObjectValue, data: Nothing?): String =
|
||||||
"GET_OBJECT '${expression.descriptor}' type=${expression.type.render()}"
|
"GET_OBJECT '${expression.symbol.descriptor}' type=${expression.type.render()}"
|
||||||
|
|
||||||
override fun visitGetEnumValue(expression: IrGetEnumValue, data: Nothing?): String =
|
override fun visitGetEnumValue(expression: IrGetEnumValue, data: Nothing?): String =
|
||||||
"GET_ENUM '${expression.descriptor}' type=${expression.type.render()}"
|
"GET_ENUM '${expression.symbol.descriptor}' type=${expression.type.render()}"
|
||||||
|
|
||||||
override fun visitStringConcatenation(expression: IrStringConcatenation, data: Nothing?): String =
|
override fun visitStringConcatenation(expression: IrStringConcatenation, data: Nothing?): String =
|
||||||
"STRING_CONCATENATION type=${expression.type.render()}"
|
"STRING_CONCATENATION type=${expression.type.render()}"
|
||||||
@@ -148,10 +149,10 @@ class RenderIrElementWithDescriptorsVisitor : IrElementVisitor<String, Nothing?>
|
|||||||
"THROW type=${expression.type.render()}"
|
"THROW type=${expression.type.render()}"
|
||||||
|
|
||||||
override fun visitCallableReference(expression: IrCallableReference, data: Nothing?): String =
|
override fun visitCallableReference(expression: IrCallableReference, data: Nothing?): String =
|
||||||
"CALLABLE_REFERENCE '${expression.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
"CALLABLE_REFERENCE '${expression.symbol.descriptor}' type=${expression.type.render()} origin=${expression.origin}"
|
||||||
|
|
||||||
override fun visitClassReference(expression: IrClassReference, data: Nothing?): String =
|
override fun visitClassReference(expression: IrClassReference, data: Nothing?): String =
|
||||||
"CLASS_REFERENCE '${expression.descriptor}' type=${expression.type.render()}"
|
"CLASS_REFERENCE '${expression.symbol.descriptor}' type=${expression.type.render()}"
|
||||||
|
|
||||||
override fun visitGetClass(expression: IrGetClass, data: Nothing?): String =
|
override fun visitGetClass(expression: IrGetClass, data: Nothing?): String =
|
||||||
"GET_CLASS type=${expression.type.render()}"
|
"GET_CLASS type=${expression.type.render()}"
|
||||||
@@ -271,16 +272,18 @@ class DumpIrTreeWithDescriptorsVisitor(out: Appendable) : IrElementVisitor<Unit,
|
|||||||
expression.dumpLabeledElementWith(data) {
|
expression.dumpLabeledElementWith(data) {
|
||||||
dumpTypeArguments(expression)
|
dumpTypeArguments(expression)
|
||||||
|
|
||||||
|
val descriptor = expression.symbol.descriptor as CallableDescriptor
|
||||||
expression.dispatchReceiver?.accept(this, "\$this")
|
expression.dispatchReceiver?.accept(this, "\$this")
|
||||||
expression.extensionReceiver?.accept(this, "\$receiver")
|
expression.extensionReceiver?.accept(this, "\$receiver")
|
||||||
for (valueParameter in expression.descriptor.valueParameters) {
|
for (valueParameter in descriptor.valueParameters) {
|
||||||
expression.getValueArgument(valueParameter.index)?.accept(this, valueParameter.name.asString())
|
expression.getValueArgument(valueParameter.index)?.accept(this, valueParameter.name.asString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dumpTypeArguments(expression: IrMemberAccessExpression) {
|
private fun dumpTypeArguments(expression: IrMemberAccessExpression) {
|
||||||
for (typeParameter in expression.descriptor.original.typeParameters) {
|
val descriptor = expression.symbol.descriptor as CallableDescriptor
|
||||||
|
for (typeParameter in descriptor.original.typeParameters) {
|
||||||
val typeArgument = expression.getTypeArgument(typeParameter) ?: continue
|
val typeArgument = expression.getTypeArgument(typeParameter) ?: continue
|
||||||
val renderedParameter = DescriptorRenderer.ONLY_NAMES_WITH_SHORT_TYPES.render(typeParameter)
|
val renderedParameter = DescriptorRenderer.ONLY_NAMES_WITH_SHORT_TYPES.render(typeParameter)
|
||||||
val renderedType = typeArgument.render()
|
val renderedType = typeArgument.render()
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ abstract class AbstractValueUsageTransformer(
|
|||||||
with(expression) {
|
with(expression) {
|
||||||
dispatchReceiver = dispatchReceiver?.useAsDispatchReceiver(expression)
|
dispatchReceiver = dispatchReceiver?.useAsDispatchReceiver(expression)
|
||||||
extensionReceiver = extensionReceiver?.useAsExtensionReceiver(expression)
|
extensionReceiver = extensionReceiver?.useAsExtensionReceiver(expression)
|
||||||
for (index in descriptor.valueParameters.indices) {
|
for (index in 0 until valueArgumentsCount) {
|
||||||
val argument = getValueArgument(index) ?: continue
|
val argument = getValueArgument(index) ?: continue
|
||||||
val parameter = symbol.owner.valueParameters[index]
|
val parameter = symbol.owner.valueParameters[index]
|
||||||
putValueArgument(index, argument.useAsValueArgument(expression, parameter))
|
putValueArgument(index, argument.useAsValueArgument(expression, parameter))
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ private class KCallableNamePropertyTransformer(val lower: KCallableNamePropertyL
|
|||||||
expression.startOffset,
|
expression.startOffset,
|
||||||
expression.endOffset,
|
expression.endOffset,
|
||||||
lower.context.irBuiltIns.stringType,
|
lower.context.irBuiltIns.stringType,
|
||||||
callableReference.descriptor.name.asString()
|
callableReference.symbol.descriptor.name.asString()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-7
@@ -136,7 +136,7 @@ class FunctionInlining(val context: CommonBackendContext) : IrElementTransformer
|
|||||||
statements.transform { it.transform(transformer, data = null) }
|
statements.transform { it.transform(transformer, data = null) }
|
||||||
statements.addAll(0, evaluationStatements)
|
statements.addAll(0, evaluationStatements)
|
||||||
|
|
||||||
val isCoroutineIntrinsicCall = callSite.descriptor.isBuiltInSuspendCoroutineUninterceptedOrReturn(
|
val isCoroutineIntrinsicCall = callSite.symbol.descriptor.isBuiltInSuspendCoroutineUninterceptedOrReturn(
|
||||||
context.configuration.languageVersionSettings
|
context.configuration.languageVersionSettings
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -434,10 +434,12 @@ class FunctionInlining(val context: CommonBackendContext) : IrElementTransformer
|
|||||||
val variableInitializer = it.argumentExpression.transform(substitutor, data = null) // Arguments may reference the previous ones - substitute them.
|
val variableInitializer = it.argumentExpression.transform(substitutor, data = null) // Arguments may reference the previous ones - substitute them.
|
||||||
val newVariable =
|
val newVariable =
|
||||||
currentScope.scope.createTemporaryVariableWithWrappedDescriptor(
|
currentScope.scope.createTemporaryVariableWithWrappedDescriptor(
|
||||||
irExpression = IrBlockImpl (variableInitializer.startOffset,
|
irExpression = IrBlockImpl(
|
||||||
variableInitializer.endOffset,
|
variableInitializer.startOffset,
|
||||||
variableInitializer.type,
|
variableInitializer.endOffset,
|
||||||
InlinerExpressionLocationHint((currentScope.irElement as IrSymbolOwner).symbol)).apply {
|
variableInitializer.type,
|
||||||
|
InlinerExpressionLocationHint((currentScope.irElement as IrSymbolOwner).symbol)
|
||||||
|
).apply {
|
||||||
statements.add(variableInitializer)
|
statements.add(variableInitializer)
|
||||||
},
|
},
|
||||||
nameHint = callee.symbol.owner.name.toString(),
|
nameHint = callee.symbol.owner.name.toString(),
|
||||||
@@ -454,10 +456,10 @@ class FunctionInlining(val context: CommonBackendContext) : IrElementTransformer
|
|||||||
private class IrGetValueWithoutLocation(
|
private class IrGetValueWithoutLocation(
|
||||||
symbol: IrValueSymbol,
|
symbol: IrValueSymbol,
|
||||||
override val origin: IrStatementOrigin? = null
|
override val origin: IrStatementOrigin? = null
|
||||||
) : IrTerminalDeclarationReferenceBase<IrValueSymbol, ValueDescriptor>(
|
) : IrTerminalDeclarationReferenceBase<IrValueSymbol>(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
symbol.owner.type,
|
symbol.owner.type,
|
||||||
symbol, symbol.descriptor
|
symbol
|
||||||
), IrGetValue {
|
), IrGetValue {
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D) =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D) =
|
||||||
visitor.visitGetValue(this, data)
|
visitor.visitGetValue(this, data)
|
||||||
|
|||||||
+1
-1
@@ -361,7 +361,7 @@ class ExpressionCodegen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expression.descriptor is ConstructorDescriptor ->
|
expression.symbol.descriptor is ConstructorDescriptor ->
|
||||||
throw AssertionError("IrCall with ConstructorDescriptor: ${expression.javaClass.simpleName}")
|
throw AssertionError("IrCall with ConstructorDescriptor: ${expression.javaClass.simpleName}")
|
||||||
callee.isSuspend && !irFunction.shouldNotContainSuspendMarkers(classCodegen.context) ->
|
callee.isSuspend && !irFunction.shouldNotContainSuspendMarkers(classCodegen.context) ->
|
||||||
addInlineMarker(mv, isStartNotEnd = true)
|
addInlineMarker(mv, isStartNotEnd = true)
|
||||||
|
|||||||
+4
-4
@@ -54,7 +54,7 @@ class IrSourceCompilerForInline(
|
|||||||
get() = codegen.context.psiSourceManager.getKtFile(codegen.irFunction.fileParent)
|
get() = codegen.context.psiSourceManager.getKtFile(codegen.irFunction.fileParent)
|
||||||
|
|
||||||
override val contextKind: OwnerKind
|
override val contextKind: OwnerKind
|
||||||
get() = OwnerKind.getMemberOwnerKind(callElement.descriptor.containingDeclaration)
|
get() = OwnerKind.getMemberOwnerKind(callElement.symbol.descriptor.containingDeclaration!!)
|
||||||
|
|
||||||
override val inlineCallSiteInfo: InlineCallSiteInfo
|
override val inlineCallSiteInfo: InlineCallSiteInfo
|
||||||
get() {
|
get() {
|
||||||
@@ -94,7 +94,7 @@ class IrSourceCompilerForInline(
|
|||||||
callDefault: Boolean,
|
callDefault: Boolean,
|
||||||
asmMethod: Method
|
asmMethod: Method
|
||||||
): SMAPAndMethodNode {
|
): SMAPAndMethodNode {
|
||||||
assert(callableDescriptor == callee.descriptor.original) { "Expected $callableDescriptor got ${callee.descriptor.original}" }
|
assert(callableDescriptor == callee.symbol.descriptor.original) { "Expected $callableDescriptor got ${callee.descriptor.original}" }
|
||||||
val irFunction = getFunctionToInline(jvmSignature, callDefault)
|
val irFunction = getFunctionToInline(jvmSignature, callDefault)
|
||||||
return makeInlineNode(irFunction, FakeClassCodegen(irFunction, codegen.classCodegen), false)
|
return makeInlineNode(irFunction, FakeClassCodegen(irFunction, codegen.classCodegen), false)
|
||||||
}
|
}
|
||||||
@@ -144,10 +144,10 @@ class IrSourceCompilerForInline(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val compilationContextDescriptor: DeclarationDescriptor
|
override val compilationContextDescriptor: DeclarationDescriptor
|
||||||
get() = callElement.descriptor
|
get() = callElement.symbol.descriptor
|
||||||
|
|
||||||
override val compilationContextFunctionDescriptor: FunctionDescriptor
|
override val compilationContextFunctionDescriptor: FunctionDescriptor
|
||||||
get() = callElement.descriptor as FunctionDescriptor
|
get() = callElement.symbol.descriptor as FunctionDescriptor
|
||||||
|
|
||||||
override fun getContextLabels(): Set<String> {
|
override fun getContextLabels(): Set<String> {
|
||||||
val name = codegen.irFunction.name.asString()
|
val name = codegen.irFunction.name.asString()
|
||||||
|
|||||||
+2
-2
@@ -203,7 +203,7 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
|
|||||||
irCall(referenceKind.wrapper).apply {
|
irCall(referenceKind.wrapper).apply {
|
||||||
putValueArgument(0, irCall(referenceKind.reflectedSymbol.constructors.single()).apply {
|
putValueArgument(0, irCall(referenceKind.reflectedSymbol.constructors.single()).apply {
|
||||||
putValueArgument(0, buildReflectedContainerReference(expression))
|
putValueArgument(0, buildReflectedContainerReference(expression))
|
||||||
putValueArgument(1, irString(expression.descriptor.name.asString()))
|
putValueArgument(1, irString(expression.symbol.descriptor.name.asString()))
|
||||||
putValueArgument(2, irString(expression.signature))
|
putValueArgument(2, irString(expression.signature))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -262,7 +262,7 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
|
|||||||
val invoke = superClass.functions.find { it.name.asString() == "invoke" }
|
val invoke = superClass.functions.find { it.name.asString() == "invoke" }
|
||||||
|
|
||||||
referenceClass.addSimpleDelegatingConstructor(superConstructor, context.irBuiltIns, isPrimary = true)
|
referenceClass.addSimpleDelegatingConstructor(superConstructor, context.irBuiltIns, isPrimary = true)
|
||||||
referenceClass.addOverride(getName) { irString(expression.descriptor.name.asString()) }
|
referenceClass.addOverride(getName) { irString(expression.symbol.descriptor.name.asString()) }
|
||||||
referenceClass.addOverride(getOwner) { buildReflectedContainerReference(expression) }
|
referenceClass.addOverride(getOwner) { buildReflectedContainerReference(expression) }
|
||||||
referenceClass.addOverride(getSignature) { irString(expression.signature) }
|
referenceClass.addOverride(getSignature) { irString(expression.signature) }
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir2cfg.generators
|
package org.jetbrains.kotlin.ir2cfg.generators
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
@@ -176,7 +177,8 @@ class FunctionGenerator(val function: IrFunction) {
|
|||||||
override fun visitMemberAccess(expression: IrMemberAccessExpression, data: Boolean): IrStatement? {
|
override fun visitMemberAccess(expression: IrMemberAccessExpression, data: Boolean): IrStatement? {
|
||||||
expression.dispatchReceiver?.process()
|
expression.dispatchReceiver?.process()
|
||||||
expression.extensionReceiver?.process()
|
expression.extensionReceiver?.process()
|
||||||
for (valueParameter in expression.descriptor.valueParameters) {
|
val descriptor = expression.symbol.descriptor as CallableDescriptor
|
||||||
|
for (valueParameter in descriptor.valueParameters) {
|
||||||
expression.getValueArgument(valueParameter)?.process()
|
expression.getValueArgument(valueParameter)?.process()
|
||||||
}
|
}
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
+2
-2
@@ -130,12 +130,12 @@ open class InsertImplicitCasts(
|
|||||||
|
|
||||||
override fun visitSetVariable(expression: IrSetVariable): IrExpression =
|
override fun visitSetVariable(expression: IrSetVariable): IrExpression =
|
||||||
expression.transformPostfix {
|
expression.transformPostfix {
|
||||||
value = value.cast(expression.descriptor.type)
|
value = value.cast(expression.symbol.descriptor.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitSetField(expression: IrSetField): IrExpression =
|
override fun visitSetField(expression: IrSetField): IrExpression =
|
||||||
expression.transformPostfix {
|
expression.transformPostfix {
|
||||||
value = value.cast(expression.descriptor.type)
|
value = value.cast(expression.symbol.descriptor.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitVariable(declaration: IrVariable): IrVariable =
|
override fun visitVariable(declaration: IrVariable): IrVariable =
|
||||||
|
|||||||
@@ -16,21 +16,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
|
|
||||||
interface IrCallableReference : IrMemberAccessExpression {
|
interface IrCallableReference : IrMemberAccessExpression
|
||||||
}
|
|
||||||
|
|
||||||
interface IrFunctionReference : IrCallableReference {
|
interface IrFunctionReference : IrCallableReference {
|
||||||
override val descriptor: FunctionDescriptor
|
|
||||||
override val symbol: IrFunctionSymbol
|
override val symbol: IrFunctionSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IrPropertyReference : IrCallableReference {
|
interface IrPropertyReference : IrCallableReference {
|
||||||
override val descriptor: PropertyDescriptor
|
|
||||||
override val symbol: IrPropertySymbol
|
override val symbol: IrPropertySymbol
|
||||||
val field: IrFieldSymbol?
|
val field: IrFieldSymbol?
|
||||||
val getter: IrSimpleFunctionSymbol?
|
val getter: IrSimpleFunctionSymbol?
|
||||||
@@ -38,7 +32,6 @@ interface IrPropertyReference : IrCallableReference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IrLocalDelegatedPropertyReference : IrCallableReference {
|
interface IrLocalDelegatedPropertyReference : IrCallableReference {
|
||||||
override val descriptor: VariableDescriptorWithAccessors
|
|
||||||
override val symbol: IrLocalDelegatedPropertySymbol
|
override val symbol: IrLocalDelegatedPropertySymbol
|
||||||
val delegate: IrVariableSymbol
|
val delegate: IrVariableSymbol
|
||||||
val getter: IrSimpleFunctionSymbol
|
val getter: IrSimpleFunctionSymbol
|
||||||
|
|||||||
@@ -16,13 +16,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
|
||||||
|
|
||||||
interface IrClassReference : IrDeclarationReference {
|
interface IrClassReference : IrDeclarationReference {
|
||||||
override val descriptor: ClassifierDescriptor
|
|
||||||
override val symbol: IrClassifierSymbol
|
override val symbol: IrClassifierSymbol
|
||||||
val classType: IrType
|
val classType: IrType
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
|
||||||
interface IrConstructorCall : IrFunctionAccessExpression {
|
interface IrConstructorCall : IrFunctionAccessExpression {
|
||||||
override val descriptor: ClassConstructorDescriptor
|
|
||||||
override val symbol: IrConstructorSymbol
|
override val symbol: IrConstructorSymbol
|
||||||
|
|
||||||
val constructorTypeArgumentsCount: Int
|
val constructorTypeArgumentsCount: Int
|
||||||
|
|||||||
+1
-6
@@ -16,21 +16,16 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
|
|
||||||
|
|
||||||
interface IrDeclarationReference : IrExpression {
|
interface IrDeclarationReference : IrExpression {
|
||||||
val descriptor: DeclarationDescriptor
|
|
||||||
val symbol: IrSymbol
|
val symbol: IrSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IrGetSingletonValue : IrDeclarationReference {
|
interface IrGetSingletonValue : IrDeclarationReference
|
||||||
override val descriptor: ClassDescriptor
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IrGetObjectValue : IrGetSingletonValue {
|
interface IrGetObjectValue : IrGetSingletonValue {
|
||||||
override val symbol: IrClassSymbol
|
override val symbol: IrClassSymbol
|
||||||
|
|||||||
-2
@@ -16,11 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
|
|
||||||
interface IrDelegatingConstructorCall : IrFunctionAccessExpression {
|
interface IrDelegatingConstructorCall : IrFunctionAccessExpression {
|
||||||
override val descriptor: ClassConstructorDescriptor
|
|
||||||
override val symbol: IrConstructorSymbol
|
override val symbol: IrConstructorSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
|
|
||||||
|
|
||||||
interface IrEnumConstructorCall : IrFunctionAccessExpression {
|
interface IrEnumConstructorCall : IrFunctionAccessExpression {
|
||||||
override val descriptor: ClassConstructorDescriptor
|
|
||||||
override val symbol: IrConstructorSymbol
|
override val symbol: IrConstructorSymbol
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||||
|
|
||||||
interface IrFieldAccessExpression : IrDeclarationReference {
|
interface IrFieldAccessExpression : IrDeclarationReference {
|
||||||
override val descriptor: PropertyDescriptor
|
|
||||||
override val symbol: IrFieldSymbol
|
override val symbol: IrFieldSymbol
|
||||||
|
|
||||||
val superQualifier: ClassDescriptor?
|
|
||||||
val superQualifierSymbol: IrClassSymbol?
|
val superQualifierSymbol: IrClassSymbol?
|
||||||
|
|
||||||
var receiver: IrExpression?
|
var receiver: IrExpression?
|
||||||
|
|||||||
+3
-2
@@ -19,7 +19,6 @@ interface IrMemberAccessExpression : IrExpression, IrDeclarationReference {
|
|||||||
var dispatchReceiver: IrExpression?
|
var dispatchReceiver: IrExpression?
|
||||||
var extensionReceiver: IrExpression?
|
var extensionReceiver: IrExpression?
|
||||||
|
|
||||||
override val descriptor: CallableDescriptor
|
|
||||||
override val symbol: IrSymbol
|
override val symbol: IrSymbol
|
||||||
|
|
||||||
val origin: IrStatementOrigin?
|
val origin: IrStatementOrigin?
|
||||||
@@ -67,7 +66,6 @@ fun IrMemberAccessExpression.getTypeArgumentOrDefault(irTypeParameter: IrTypePar
|
|||||||
getTypeArgument(irTypeParameter.index) ?: irTypeParameter.defaultType
|
getTypeArgument(irTypeParameter.index) ?: irTypeParameter.defaultType
|
||||||
|
|
||||||
interface IrFunctionAccessExpression : IrMemberAccessExpression {
|
interface IrFunctionAccessExpression : IrMemberAccessExpression {
|
||||||
override val descriptor: FunctionDescriptor
|
|
||||||
override val symbol: IrFunctionSymbol
|
override val symbol: IrFunctionSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +82,7 @@ fun IrMemberAccessExpression.removeValueArgument(valueParameterDescriptor: Value
|
|||||||
|
|
||||||
inline fun <T : IrMemberAccessExpression> T.mapTypeParameters(transform: (TypeParameterDescriptor) -> IrType) : T =
|
inline fun <T : IrMemberAccessExpression> T.mapTypeParameters(transform: (TypeParameterDescriptor) -> IrType) : T =
|
||||||
apply {
|
apply {
|
||||||
|
val descriptor = symbol.descriptor as CallableDescriptor
|
||||||
descriptor.typeParameters.forEach {
|
descriptor.typeParameters.forEach {
|
||||||
putTypeArgument(it.index, transform(it))
|
putTypeArgument(it.index, transform(it))
|
||||||
}
|
}
|
||||||
@@ -91,6 +90,7 @@ inline fun <T : IrMemberAccessExpression> T.mapTypeParameters(transform: (TypePa
|
|||||||
|
|
||||||
inline fun <T : IrMemberAccessExpression> T.mapValueParameters(transform: (ValueParameterDescriptor) -> IrExpression?): T =
|
inline fun <T : IrMemberAccessExpression> T.mapValueParameters(transform: (ValueParameterDescriptor) -> IrExpression?): T =
|
||||||
apply {
|
apply {
|
||||||
|
val descriptor = symbol.descriptor as CallableDescriptor
|
||||||
descriptor.valueParameters.forEach {
|
descriptor.valueParameters.forEach {
|
||||||
putValueArgument(it.index, transform(it))
|
putValueArgument(it.index, transform(it))
|
||||||
}
|
}
|
||||||
@@ -98,6 +98,7 @@ inline fun <T : IrMemberAccessExpression> T.mapValueParameters(transform: (Value
|
|||||||
|
|
||||||
inline fun <T : IrMemberAccessExpression> T.mapValueParametersIndexed(transform: (Int, ValueParameterDescriptor) -> IrExpression?): T =
|
inline fun <T : IrMemberAccessExpression> T.mapValueParametersIndexed(transform: (Int, ValueParameterDescriptor) -> IrExpression?): T =
|
||||||
apply {
|
apply {
|
||||||
|
val descriptor = symbol.descriptor as CallableDescriptor
|
||||||
descriptor.valueParameters.forEach {
|
descriptor.valueParameters.forEach {
|
||||||
putValueArgument(it.index, transform(it.index, it))
|
putValueArgument(it.index, transform(it.index, it))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ValueDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||||
|
|
||||||
interface IrValueAccessExpression : IrDeclarationReference {
|
interface IrValueAccessExpression : IrDeclarationReference {
|
||||||
override val descriptor: ValueDescriptor
|
|
||||||
override val symbol: IrValueSymbol
|
override val symbol: IrValueSymbol
|
||||||
val origin: IrStatementOrigin?
|
val origin: IrStatementOrigin?
|
||||||
}
|
}
|
||||||
@@ -32,7 +29,6 @@ interface IrGetValue : IrValueAccessExpression, IrExpressionWithCopy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IrSetVariable : IrValueAccessExpression {
|
interface IrSetVariable : IrValueAccessExpression {
|
||||||
override val descriptor: VariableDescriptor
|
|
||||||
override val symbol: IrVariableSymbol
|
override val symbol: IrVariableSymbol
|
||||||
var value: IrExpression
|
var value: IrExpression
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
||||||
@@ -50,8 +49,6 @@ class IrCallImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val descriptor: FunctionDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
|
|||||||
+1
-9
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrClassReference
|
import org.jetbrains.kotlin.ir.expressions.IrClassReference
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
@@ -28,14 +27,7 @@ class IrClassReferenceImpl(
|
|||||||
type: IrType,
|
type: IrType,
|
||||||
symbol: IrClassifierSymbol,
|
symbol: IrClassifierSymbol,
|
||||||
override val classType: IrType
|
override val classType: IrType
|
||||||
) :
|
) : IrTerminalDeclarationReferenceBase<IrClassifierSymbol>(startOffset, endOffset, type, symbol), IrClassReference {
|
||||||
IrTerminalDeclarationReferenceBase<IrClassifierSymbol, ClassifierDescriptor>(
|
|
||||||
startOffset, endOffset, type,
|
|
||||||
symbol, symbol.descriptor
|
|
||||||
),
|
|
||||||
IrClassReference {
|
|
||||||
|
|
||||||
override val descriptor: ClassifierDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitClassReference(this, data)
|
visitor.visitClassReference(this, data)
|
||||||
|
|||||||
-2
@@ -30,8 +30,6 @@ class IrConstructorCallImpl(
|
|||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitConstructorCall(this, data)
|
visitor.visitConstructorCall(this, data)
|
||||||
|
|
||||||
override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun fromSymbolDescriptor(
|
fun fromSymbolDescriptor(
|
||||||
|
|||||||
+2
-4
@@ -16,17 +16,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
|
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
|
||||||
abstract class IrDeclarationReferenceBase<out S : IrSymbol, out D : DeclarationDescriptor>(
|
abstract class IrDeclarationReferenceBase<out S : IrSymbol>(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
override val symbol: S,
|
override val symbol: S
|
||||||
override val descriptor: D
|
|
||||||
) :
|
) :
|
||||||
IrExpressionBase(startOffset, endOffset, type),
|
IrExpressionBase(startOffset, endOffset, type),
|
||||||
IrDeclarationReference
|
IrDeclarationReference
|
||||||
-2
@@ -55,8 +55,6 @@ class IrDelegatingConstructorCallImpl(
|
|||||||
typeArgumentsCount: Int
|
typeArgumentsCount: Int
|
||||||
) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size)
|
) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size)
|
||||||
|
|
||||||
override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitDelegatingConstructorCall(this, data)
|
return visitor.visitDelegatingConstructorCall(this, data)
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
@@ -55,8 +54,6 @@ class IrEnumConstructorCallImpl(
|
|||||||
typeArgumentsCount: Int
|
typeArgumentsCount: Int
|
||||||
) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size)
|
) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size)
|
||||||
|
|
||||||
override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitEnumConstructorCall(this, data)
|
return visitor.visitEnumConstructorCall(this, data)
|
||||||
}
|
}
|
||||||
|
|||||||
-5
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrFieldAccessExpression
|
import org.jetbrains.kotlin.ir.expressions.IrFieldAccessExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
@@ -35,8 +33,5 @@ abstract class IrFieldExpressionBase(
|
|||||||
IrExpressionBase(startOffset, endOffset, type),
|
IrExpressionBase(startOffset, endOffset, type),
|
||||||
IrFieldAccessExpression {
|
IrFieldAccessExpression {
|
||||||
|
|
||||||
override val descriptor: PropertyDescriptor get() = symbol.descriptor
|
|
||||||
override val superQualifier: ClassDescriptor? get() = superQualifierSymbol?.descriptor
|
|
||||||
|
|
||||||
final override var receiver: IrExpression? = null
|
final override var receiver: IrExpression? = null
|
||||||
}
|
}
|
||||||
-3
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
@@ -51,8 +50,6 @@ class IrFunctionReferenceImpl(
|
|||||||
origin: IrStatementOrigin? = null
|
origin: IrStatementOrigin? = null
|
||||||
) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size, origin)
|
) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size, origin)
|
||||||
|
|
||||||
override val descriptor: FunctionDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitFunctionReference(this, data)
|
visitor.visitFunctionReference(this, data)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
@@ -27,9 +26,7 @@ class IrGetEnumValueImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
symbol: IrEnumEntrySymbol
|
symbol: IrEnumEntrySymbol
|
||||||
) :
|
) : IrTerminalDeclarationReferenceBase<IrEnumEntrySymbol>(startOffset, endOffset, type, symbol), IrGetEnumValue {
|
||||||
IrTerminalDeclarationReferenceBase<IrEnumEntrySymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor),
|
|
||||||
IrGetEnumValue {
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitGetEnumValue(this, data)
|
return visitor.visitGetEnumValue(this, data)
|
||||||
|
|||||||
+1
-4
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetObjectValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetObjectValue
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
@@ -27,9 +26,7 @@ class IrGetObjectValueImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
symbol: IrClassSymbol
|
symbol: IrClassSymbol
|
||||||
) :
|
) : IrTerminalDeclarationReferenceBase<IrClassSymbol>(startOffset, endOffset, type, symbol), IrGetObjectValue {
|
||||||
IrTerminalDeclarationReferenceBase<IrClassSymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor),
|
|
||||||
IrGetObjectValue {
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitGetObjectValue(this, data)
|
visitor.visitGetObjectValue(this, data)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ValueDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
||||||
@@ -19,12 +18,11 @@ class IrGetValueImpl(
|
|||||||
symbol: IrValueSymbol,
|
symbol: IrValueSymbol,
|
||||||
override val origin: IrStatementOrigin? = null
|
override val origin: IrStatementOrigin? = null
|
||||||
) :
|
) :
|
||||||
IrTerminalDeclarationReferenceBase<IrValueSymbol, ValueDescriptor>(
|
IrTerminalDeclarationReferenceBase<IrValueSymbol>(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
type,
|
type,
|
||||||
symbol,
|
symbol
|
||||||
symbol.descriptor
|
|
||||||
),
|
),
|
||||||
IrGetValue {
|
IrGetValue {
|
||||||
|
|
||||||
|
|||||||
-3
@@ -38,9 +38,6 @@ class IrLocalDelegatedPropertyReferenceImpl(
|
|||||||
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, 0, origin),
|
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, 0, origin),
|
||||||
IrLocalDelegatedPropertyReference {
|
IrLocalDelegatedPropertyReference {
|
||||||
|
|
||||||
override val descriptor: VariableDescriptorWithAccessors
|
|
||||||
get() = symbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitLocalDelegatedPropertyReference(this, data)
|
visitor.visitLocalDelegatedPropertyReference(this, data)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -32,7 +32,7 @@ abstract class IrNoArgumentsCallableReferenceBase(
|
|||||||
IrCallableReference {
|
IrCallableReference {
|
||||||
|
|
||||||
private fun throwNoValueArguments(): Nothing {
|
private fun throwNoValueArguments(): Nothing {
|
||||||
throw UnsupportedOperationException("Property reference $descriptor has no value arguments")
|
throw UnsupportedOperationException("Property reference ${symbol.descriptor} has no value arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getValueArgument(index: Int): IrExpression? = throwNoValueArguments()
|
override fun getValueArgument(index: Int): IrExpression? = throwNoValueArguments()
|
||||||
|
|||||||
-2
@@ -57,8 +57,6 @@ class IrPropertyReferenceImpl(
|
|||||||
typeArgumentsCount, field, getter, setter, origin
|
typeArgumentsCount, field, getter, setter, origin
|
||||||
)
|
)
|
||||||
|
|
||||||
override val descriptor: PropertyDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitPropertyReference(this, data)
|
visitor.visitPropertyReference(this, data)
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,6 @@ class IrSetVariableImpl(
|
|||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
override val descriptor: VariableDescriptor get() = symbol.descriptor
|
|
||||||
|
|
||||||
override lateinit var value: IrExpression
|
override lateinit var value: IrExpression
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
|
|||||||
+3
-5
@@ -16,21 +16,19 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
|
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
|
|
||||||
abstract class IrTerminalDeclarationReferenceBase<out S : IrSymbol, out D : DeclarationDescriptor>(
|
abstract class IrTerminalDeclarationReferenceBase<out S : IrSymbol>(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
symbol: S,
|
symbol: S
|
||||||
descriptor: D
|
|
||||||
) :
|
) :
|
||||||
IrDeclarationReferenceBase<S, D>(startOffset, endOffset, type, symbol, descriptor),
|
IrDeclarationReferenceBase<S>(startOffset, endOffset, type, symbol),
|
||||||
IrDeclarationReference {
|
IrDeclarationReference {
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.utils.DFS
|
|||||||
*/
|
*/
|
||||||
fun IrMemberAccessExpression.getArguments(): List<Pair<ParameterDescriptor, IrExpression>> {
|
fun IrMemberAccessExpression.getArguments(): List<Pair<ParameterDescriptor, IrExpression>> {
|
||||||
val res = mutableListOf<Pair<ParameterDescriptor, IrExpression>>()
|
val res = mutableListOf<Pair<ParameterDescriptor, IrExpression>>()
|
||||||
val descriptor = descriptor
|
val descriptor = symbol.descriptor as CallableDescriptor
|
||||||
|
|
||||||
// TODO: ensure the order below corresponds to the one defined in Kotlin specs.
|
// TODO: ensure the order below corresponds to the one defined in Kotlin specs.
|
||||||
|
|
||||||
@@ -119,6 +119,7 @@ fun IrMemberAccessExpression.getArgumentsWithIr(): List<Pair<IrValueParameter, I
|
|||||||
* Sets arguments that are specified by given mapping of parameters.
|
* Sets arguments that are specified by given mapping of parameters.
|
||||||
*/
|
*/
|
||||||
fun IrMemberAccessExpression.addArguments(args: Map<ParameterDescriptor, IrExpression>) {
|
fun IrMemberAccessExpression.addArguments(args: Map<ParameterDescriptor, IrExpression>) {
|
||||||
|
val descriptor = symbol.descriptor as CallableDescriptor
|
||||||
descriptor.dispatchReceiverParameter?.let {
|
descriptor.dispatchReceiverParameter?.let {
|
||||||
val arg = args[it]
|
val arg = args[it]
|
||||||
if (arg != null) {
|
if (arg != null) {
|
||||||
@@ -177,7 +178,7 @@ fun IrExpression.coerceToUnitIfNeeded(valueType: IrType, irBuiltIns: IrBuiltIns)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun IrMemberAccessExpression.usesDefaultArguments(): Boolean =
|
fun IrMemberAccessExpression.usesDefaultArguments(): Boolean =
|
||||||
this.descriptor.valueParameters.any { this.getValueArgument(it) == null }
|
(symbol.descriptor as CallableDescriptor).valueParameters.any { this.getValueArgument(it) == null }
|
||||||
|
|
||||||
val DeclarationDescriptorWithSource.startOffset: Int? get() = (this.source as? PsiSourceElement)?.psi?.startOffset
|
val DeclarationDescriptorWithSource.startOffset: Int? get() = (this.source as? PsiSourceElement)?.psi?.startOffset
|
||||||
val DeclarationDescriptorWithSource.endOffset: Int? get() = (this.source as? PsiSourceElement)?.psi?.endOffset
|
val DeclarationDescriptorWithSource.endOffset: Int? get() = (this.source as? PsiSourceElement)?.psi?.endOffset
|
||||||
@@ -383,7 +384,7 @@ fun IrDeclaration.isEffectivelyExternal(): Boolean {
|
|||||||
|
|
||||||
fun IrFunction.effectiveParentDeclaration(): IrDeclaration? =
|
fun IrFunction.effectiveParentDeclaration(): IrDeclaration? =
|
||||||
when (this) {
|
when (this) {
|
||||||
is IrSimpleFunction -> correspondingProperty ?: parent as? IrDeclaration
|
is IrSimpleFunction -> correspondingPropertySymbol?.owner ?: parent as? IrDeclaration
|
||||||
else -> parent as? IrDeclaration
|
else -> parent as? IrDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -424,7 +424,7 @@ interface IrBuilderExtension {
|
|||||||
val irExpression =
|
val irExpression =
|
||||||
if (i is IrGetValueImpl && i.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER) {
|
if (i is IrGetValueImpl && i.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER) {
|
||||||
// this is a primary constructor property, use corresponding default of value parameter
|
// this is a primary constructor property, use corresponding default of value parameter
|
||||||
defaultsMap.getValue(i.descriptor as ParameterDescriptor)
|
defaultsMap.getValue(i.symbol.descriptor as ParameterDescriptor)
|
||||||
} else {
|
} else {
|
||||||
i
|
i
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -149,7 +149,7 @@ open class SerializerIrGenerator(val irClass: IrClass, final override val compil
|
|||||||
method: IrFunctionSymbol
|
method: IrFunctionSymbol
|
||||||
) {
|
) {
|
||||||
annotations.forEach { annotationCall ->
|
annotations.forEach { annotationCall ->
|
||||||
if ((annotationCall.descriptor as? ClassConstructorDescriptor)?.constructedClass?.isSerialInfoAnnotation == true)
|
if ((annotationCall.symbol.descriptor as? ClassConstructorDescriptor)?.constructedClass?.isSerialInfoAnnotation == true)
|
||||||
+irInvoke(irGet(receiver), method, annotationCall.deepCopyWithVariables())
|
+irInvoke(irGet(receiver), method, annotationCall.deepCopyWithVariables())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -394,7 +394,7 @@ open class SerializerIrGenerator(val irClass: IrClass, final override val compil
|
|||||||
}
|
}
|
||||||
val typeArgs =
|
val typeArgs =
|
||||||
if (decodeFuncToCall.owner.typeParameters.isNotEmpty()) listOf(property.type.toIrType()) else listOf()
|
if (decodeFuncToCall.owner.typeParameters.isNotEmpty()) listOf(property.type.toIrType()) else listOf()
|
||||||
val args = mutableListOf(localSerialDesc.get(), irInt(index))
|
val args = mutableListOf<IrExpression>(localSerialDesc.get(), irInt(index))
|
||||||
if (innerSerial != null)
|
if (innerSerial != null)
|
||||||
args.add(innerSerial)
|
args.add(innerSerial)
|
||||||
// local$i = localInput.decode...(...)
|
// local$i = localInput.decode...(...)
|
||||||
@@ -457,7 +457,7 @@ open class SerializerIrGenerator(val irClass: IrClass, final override val compil
|
|||||||
context: BackendContext,
|
context: BackendContext,
|
||||||
bindingContext: BindingContext
|
bindingContext: BindingContext
|
||||||
) {
|
) {
|
||||||
val serializableDesc = getSerializableClassDescriptorBySerializer(irClass.descriptor) ?: return
|
val serializableDesc = getSerializableClassDescriptorBySerializer(irClass.symbol.descriptor) ?: return
|
||||||
if (serializableDesc.isSerializableEnum()) {
|
if (serializableDesc.isSerializableEnum()) {
|
||||||
SerializerForEnumsGenerator(irClass, context, bindingContext).generate()
|
SerializerForEnumsGenerator(irClass, context, bindingContext).generate()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user