IR: create IrExpressionBody via IrFactory
This commit is contained in:
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.ir.descriptors.WrappedEnumEntryDescriptor
|
|||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeAliasDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeAliasDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
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.IrTypeAliasSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol
|
||||||
@@ -408,7 +407,7 @@ class Fir2IrClassifierStorage(
|
|||||||
// which will be translated via visitor later.
|
// which will be translated via visitor later.
|
||||||
} else if (irParent != null && origin == IrDeclarationOrigin.DEFINED) {
|
} else if (irParent != null && origin == IrDeclarationOrigin.DEFINED) {
|
||||||
val constructor = irParent.constructors.first()
|
val constructor = irParent.constructors.first()
|
||||||
this.initializerExpression = IrExpressionBodyImpl(
|
this.initializerExpression = factory.createExpressionBody(
|
||||||
IrEnumConstructorCallImpl(
|
IrEnumConstructorCallImpl(
|
||||||
startOffset, endOffset, irType, constructor.symbol,
|
startOffset, endOffset, irType, constructor.symbol,
|
||||||
valueArgumentsCount = constructor.valueParameters.size,
|
valueArgumentsCount = constructor.valueParameters.size,
|
||||||
|
|||||||
+2
-3
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.ir.descriptors.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
|
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.types.IrErrorType
|
import org.jetbrains.kotlin.ir.types.IrErrorType
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
@@ -670,7 +669,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
if (initializer is FirConstExpression<*>) {
|
if (initializer is FirConstExpression<*>) {
|
||||||
// TODO: Normally we shouldn't have error type here
|
// TODO: Normally we shouldn't have error type here
|
||||||
val constType = initializer.typeRef.toIrType().takeIf { it !is IrErrorType } ?: type
|
val constType = initializer.typeRef.toIrType().takeIf { it !is IrErrorType } ?: type
|
||||||
field.initializer = IrExpressionBodyImpl(initializer.toIrConst(constType))
|
field.initializer = factory.createExpressionBody(initializer.toIrConst(constType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (delegate != null) {
|
} else if (delegate != null) {
|
||||||
@@ -794,7 +793,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
it != null && (useStubForDefaultValueStub || it !is FirExpressionStub)
|
it != null && (useStubForDefaultValueStub || it !is FirExpressionStub)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
this.defaultValue = IrExpressionBodyImpl(
|
this.defaultValue = factory.createExpressionBody(
|
||||||
IrErrorExpressionImpl(
|
IrErrorExpressionImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, type,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, type,
|
||||||
"Stub expression for default value of ${valueParameter.name}"
|
"Stub expression for default value of ${valueParameter.name}"
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Fir2IrVisitor(
|
|||||||
memberGenerator.convertClassContent(correspondingClass, anonymousObject)
|
memberGenerator.convertClassContent(correspondingClass, anonymousObject)
|
||||||
}
|
}
|
||||||
val constructor = correspondingClass.constructors.first()
|
val constructor = correspondingClass.constructors.first()
|
||||||
irEnumEntry.initializerExpression = IrExpressionBodyImpl(
|
irEnumEntry.initializerExpression = irFactory.createExpressionBody(
|
||||||
IrEnumConstructorCallImpl(
|
IrEnumConstructorCallImpl(
|
||||||
startOffset, endOffset, enumEntry.returnTypeRef.toIrType(),
|
startOffset, endOffset, enumEntry.returnTypeRef.toIrType(),
|
||||||
constructor.symbol,
|
constructor.symbol,
|
||||||
@@ -144,7 +144,9 @@ class Fir2IrVisitor(
|
|||||||
val delegatedConstructor = primaryConstructor?.delegatedConstructor
|
val delegatedConstructor = primaryConstructor?.delegatedConstructor
|
||||||
if (delegatedConstructor != null) {
|
if (delegatedConstructor != null) {
|
||||||
with(memberGenerator) {
|
with(memberGenerator) {
|
||||||
irEnumEntry.initializerExpression = IrExpressionBodyImpl(delegatedConstructor.toIrDelegatingConstructorCall())
|
irEnumEntry.initializerExpression = irFactory.createExpressionBody(
|
||||||
|
delegatedConstructor.toIrDelegatingConstructorCall()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-4
@@ -27,7 +27,10 @@ import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.constructedClassType
|
||||||
|
import org.jetbrains.kotlin.ir.util.isAnnotationClass
|
||||||
|
import org.jetbrains.kotlin.ir.util.isSetter
|
||||||
|
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||||
|
|
||||||
internal class ClassMemberGenerator(
|
internal class ClassMemberGenerator(
|
||||||
private val components: Fir2IrComponents,
|
private val components: Fir2IrComponents,
|
||||||
@@ -221,7 +224,7 @@ internal class ClassMemberGenerator(
|
|||||||
declarationStorage.enterScope(this@initializeBackingField)
|
declarationStorage.enterScope(this@initializeBackingField)
|
||||||
// NB: initializer can be already converted
|
// NB: initializer can be already converted
|
||||||
if (initializer == null && initializerExpression != null) {
|
if (initializer == null && initializerExpression != null) {
|
||||||
initializer = IrExpressionBodyImpl(visitor.convertToIrExpression(initializerExpression))
|
initializer = irFactory.createExpressionBody(visitor.convertToIrExpression(initializerExpression))
|
||||||
}
|
}
|
||||||
declarationStorage.leaveScope(this@initializeBackingField)
|
declarationStorage.leaveScope(this@initializeBackingField)
|
||||||
}
|
}
|
||||||
@@ -356,7 +359,7 @@ internal class ClassMemberGenerator(
|
|||||||
private fun IrValueParameter.setDefaultValue(firValueParameter: FirValueParameter) {
|
private fun IrValueParameter.setDefaultValue(firValueParameter: FirValueParameter) {
|
||||||
val firDefaultValue = firValueParameter.defaultValue
|
val firDefaultValue = firValueParameter.defaultValue
|
||||||
if (firDefaultValue != null) {
|
if (firDefaultValue != null) {
|
||||||
this.defaultValue = IrExpressionBodyImpl(visitor.convertToIrExpression(firDefaultValue))
|
this.defaultValue = factory.createExpressionBody(visitor.convertToIrExpression(firDefaultValue))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.fir.symbols.Fir2IrPropertySymbol
|
|||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.types.IrErrorType
|
import org.jetbrains.kotlin.ir.types.IrErrorType
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.isInterface
|
import org.jetbrains.kotlin.ir.util.isInterface
|
||||||
@@ -103,7 +102,7 @@ class Fir2IrLazyProperty(
|
|||||||
if (initializer is FirConstExpression<*>) {
|
if (initializer is FirConstExpression<*>) {
|
||||||
// TODO: Normally we shouldn't have error type here
|
// TODO: Normally we shouldn't have error type here
|
||||||
val constType = with(typeConverter) { initializer.typeRef.toIrType().takeIf { it !is IrErrorType } ?: type }
|
val constType = with(typeConverter) { initializer.typeRef.toIrType().takeIf { it !is IrErrorType } ?: type }
|
||||||
field.initializer = IrExpressionBodyImpl(initializer.toIrConst(constType))
|
field.initializer = factory.createExpressionBody(initializer.toIrConst(constType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildTypeParameter
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.*
|
import org.jetbrains.kotlin.ir.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.IrInstanceInitializerCallImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
@@ -142,7 +145,7 @@ fun IrValueParameter.copyTo(
|
|||||||
}
|
}
|
||||||
val symbol = IrValueParameterSymbolImpl(descriptor)
|
val symbol = IrValueParameterSymbolImpl(descriptor)
|
||||||
val defaultValueCopy = defaultValue?.let { originalDefault ->
|
val defaultValueCopy = defaultValue?.let { originalDefault ->
|
||||||
IrExpressionBodyImpl(originalDefault.startOffset, originalDefault.endOffset) {
|
factory.createExpressionBody(originalDefault.startOffset, originalDefault.endOffset) {
|
||||||
expression = originalDefault.expression.deepCopyWithVariables().also {
|
expression = originalDefault.expression.deepCopyWithVariables().also {
|
||||||
it.patchDeclarationParents(irFunction)
|
it.patchDeclarationParents(irFunction)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -435,8 +435,9 @@ class DefaultParameterCleaner(
|
|||||||
if (declaration is IrValueParameter && declaration.defaultValue != null) {
|
if (declaration is IrValueParameter && declaration.defaultValue != null) {
|
||||||
if (replaceDefaultValuesWithStubs) {
|
if (replaceDefaultValuesWithStubs) {
|
||||||
if (context.mapping.defaultArgumentsOriginalFunction[declaration.parent as IrFunction] == null) {
|
if (context.mapping.defaultArgumentsOriginalFunction[declaration.parent as IrFunction] == null) {
|
||||||
declaration.defaultValue =
|
declaration.defaultValue = context.irFactory.createExpressionBody(
|
||||||
IrExpressionBodyImpl(IrErrorExpressionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, declaration.type, "Default Stub"))
|
IrErrorExpressionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, declaration.type, "Default Stub")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
declaration.defaultValue = null
|
declaration.defaultValue = null
|
||||||
@@ -562,10 +563,9 @@ private fun IrFunction.generateDefaultsFunctionImpl(
|
|||||||
newFunction,
|
newFunction,
|
||||||
type = if (makeNullable) newType.makeNullable() else newType,
|
type = if (makeNullable) newType.makeNullable() else newType,
|
||||||
defaultValue = if (it.defaultValue != null) {
|
defaultValue = if (it.defaultValue != null) {
|
||||||
IrExpressionBodyImpl(IrErrorExpressionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, it.type, "Default Stub"))
|
factory.createExpressionBody(IrErrorExpressionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, it.type, "Default Stub"))
|
||||||
} else null
|
} else null
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in 0 until (valueParameters.size + 31) / 32) {
|
for (i in 0 until (valueParameters.size + 31) / 32) {
|
||||||
|
|||||||
+4
-3
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
||||||
import org.jetbrains.kotlin.ir.util.constructedClass
|
import org.jetbrains.kotlin.ir.util.constructedClass
|
||||||
@@ -112,11 +111,13 @@ class InitializersCleanupLowering(
|
|||||||
} else {
|
} else {
|
||||||
declaration.initializer?.let {
|
declaration.initializer?.let {
|
||||||
declaration.initializer =
|
declaration.initializer =
|
||||||
IrExpressionBodyImpl(it.startOffset, it.endOffset) { expression = it.expression.deepCopyWithSymbols() }
|
context.irFactory.createExpressionBody(it.startOffset, it.endOffset) {
|
||||||
|
expression = it.expression.deepCopyWithSymbols()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ class InnerClassesLowering(val context: BackendContext, private val innerClasses
|
|||||||
val oldConstructorParameterToNew = innerClassesSupport.primaryConstructorParameterMap(declaration)
|
val oldConstructorParameterToNew = innerClassesSupport.primaryConstructorParameterMap(declaration)
|
||||||
for ((oldParam, newParam) in oldConstructorParameterToNew.entries) {
|
for ((oldParam, newParam) in oldConstructorParameterToNew.entries) {
|
||||||
newParam.defaultValue = oldParam.defaultValue?.let { oldDefault ->
|
newParam.defaultValue = oldParam.defaultValue?.let { oldDefault ->
|
||||||
IrExpressionBodyImpl(oldDefault.startOffset, oldDefault.endOffset) {
|
context.irFactory.createExpressionBody(oldDefault.startOffset, oldDefault.endOffset) {
|
||||||
expression = oldDefault.expression.patchDeclarationParents(newConstructor)
|
expression = oldDefault.expression.patchDeclarationParents(newConstructor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.types.makeNullable
|
import org.jetbrains.kotlin.ir.types.makeNullable
|
||||||
@@ -150,7 +149,7 @@ class EnumClassConstructorLowering(val context: JsCommonBackendContext) : Declar
|
|||||||
old.valueParameter = new
|
old.valueParameter = new
|
||||||
|
|
||||||
old.defaultValue?.let { default ->
|
old.defaultValue?.let { default ->
|
||||||
new.defaultValue = IrExpressionBodyImpl(default.startOffset, default.endOffset) {
|
new.defaultValue = context.irFactory.createExpressionBody(default.startOffset, default.endOffset) {
|
||||||
expression = default.expression
|
expression = default.expression
|
||||||
expression.patchDeclarationParents(newConstructor)
|
expression.patchDeclarationParents(newConstructor)
|
||||||
context.fixReferencesToConstructorParameters(enumClass, this)
|
context.fixReferencesToConstructorParameters(enumClass, this)
|
||||||
|
|||||||
+2
-2
@@ -96,7 +96,7 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : DeclarationTrans
|
|||||||
|
|
||||||
parameterMapping[it]?.apply {
|
parameterMapping[it]?.apply {
|
||||||
it.defaultValue?.let { originalDefault ->
|
it.defaultValue?.let { originalDefault ->
|
||||||
defaultValue = IrExpressionBodyImpl(it.startOffset, it.endOffset) {
|
defaultValue = context.irFactory.createExpressionBody(it.startOffset, it.endOffset) {
|
||||||
expression = (originalDefault.copyWithParameters() as IrExpressionBody).expression
|
expression = (originalDefault.copyWithParameters() as IrExpressionBody).expression
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : DeclarationTrans
|
|||||||
is IrBlockBody -> IrBlockBodyImpl(it.startOffset, it.endOffset) {
|
is IrBlockBody -> IrBlockBodyImpl(it.startOffset, it.endOffset) {
|
||||||
statements += (it.copyWithParameters() as IrBlockBody).statements
|
statements += (it.copyWithParameters() as IrBlockBody).statements
|
||||||
}
|
}
|
||||||
is IrExpressionBody -> IrExpressionBodyImpl(it.startOffset, it.endOffset) {
|
is IrExpressionBody -> context.irFactory.createExpressionBody(it.startOffset, it.endOffset) {
|
||||||
expression = (it.copyWithParameters() as IrExpressionBody).expression
|
expression = (it.copyWithParameters() as IrExpressionBody).expression
|
||||||
}
|
}
|
||||||
is IrSyntheticBody -> it
|
is IrSyntheticBody -> it
|
||||||
|
|||||||
+5
-6
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.backend.js.lower.inline
|
package org.jetbrains.kotlin.ir.backend.js.lower.inline
|
||||||
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.DeclarationTransformer
|
import org.jetbrains.kotlin.backend.common.DeclarationTransformer
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||||
@@ -13,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrFunction
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
||||||
|
|
||||||
class RemoveInlineFunctionsWithReifiedTypeParametersLowering: DeclarationTransformer {
|
class RemoveInlineFunctionsWithReifiedTypeParametersLowering: DeclarationTransformer {
|
||||||
@@ -40,12 +38,13 @@ class CopyInlineFunctionBodyLowering(val context: JsIrBackendContext) : Declarat
|
|||||||
|
|
||||||
if (declaration is IrValueParameter && declaration.parent.let { it is IrFunction && it.isInline }) {
|
if (declaration is IrValueParameter && declaration.parent.let { it is IrFunction && it.isInline }) {
|
||||||
declaration.defaultValue?.let { originalDefault ->
|
declaration.defaultValue?.let { originalDefault ->
|
||||||
declaration.defaultValue = IrExpressionBodyImpl(originalDefault.startOffset, originalDefault.endOffset) {
|
declaration.defaultValue =
|
||||||
expression = originalDefault.expression.deepCopyWithSymbols(declaration.parent)
|
context.irFactory.createExpressionBody(originalDefault.startOffset, originalDefault.endOffset) {
|
||||||
}
|
expression = originalDefault.expression.deepCopyWithSymbols(declaration.parent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class BodyGenerator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun generateExpressionBody(ktExpression: KtExpression): IrExpressionBody =
|
fun generateExpressionBody(ktExpression: KtExpression): IrExpressionBody =
|
||||||
IrExpressionBodyImpl(createStatementGenerator().generateExpression(ktExpression))
|
context.irFactory.createExpressionBody(createStatementGenerator().generateExpression(ktExpression))
|
||||||
|
|
||||||
fun generateLambdaBody(ktFun: KtFunctionLiteral): IrBody {
|
fun generateLambdaBody(ktFun: KtFunctionLiteral): IrBody {
|
||||||
val statementGenerator = createStatementGenerator()
|
val statementGenerator = createStatementGenerator()
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ class ClassGenerator(
|
|||||||
|
|
||||||
if (!enumEntryDescriptor.isExpect) {
|
if (!enumEntryDescriptor.isExpect) {
|
||||||
irEnumEntry.initializerExpression =
|
irEnumEntry.initializerExpression =
|
||||||
IrExpressionBodyImpl(createBodyGenerator(irEnumEntry.symbol)
|
context.irFactory.createExpressionBody(createBodyGenerator(irEnumEntry.symbol)
|
||||||
.generateEnumEntryInitializer(ktEnumEntry, enumEntryDescriptor))
|
.generateEnumEntryInitializer(ktEnumEntry, enumEntryDescriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.ir.descriptors.IrLocalDelegatedPropertyDelegateDescr
|
|||||||
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptorImpl
|
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptorImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
@@ -166,7 +165,7 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D
|
|||||||
val irProvideDelegate = CallGenerator(statementGenerator).generateCall(
|
val irProvideDelegate = CallGenerator(statementGenerator).generateCall(
|
||||||
ktDelegate.startOffsetSkippingComments, ktDelegate.endOffset, provideDelegateCall
|
ktDelegate.startOffsetSkippingComments, ktDelegate.endOffset, provideDelegateCall
|
||||||
)
|
)
|
||||||
return IrExpressionBodyImpl(irProvideDelegate)
|
return context.irFactory.createExpressionBody(irProvideDelegate)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createBackingFieldValueForDelegate(
|
private fun createBackingFieldValueForDelegate(
|
||||||
|
|||||||
+2
-2
@@ -344,11 +344,11 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
val constantDefaultValue =
|
val constantDefaultValue =
|
||||||
ConstantExpressionEvaluator.getConstant(valueExpression, context.bindingContext)?.toConstantValue(valueParameterDescriptor.type)
|
ConstantExpressionEvaluator.getConstant(valueExpression, context.bindingContext)?.toConstantValue(valueParameterDescriptor.type)
|
||||||
?: error("Constant value expected for default parameter value in annotation, got $valueExpression")
|
?: error("Constant value expected for default parameter value in annotation, got $valueExpression")
|
||||||
return IrExpressionBodyImpl(
|
return context.irFactory.createExpressionBody(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
context.constantValueGenerator.generateConstantValueAsExpression(
|
context.constantValueGenerator.generateConstantValueAsExpression(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, constantDefaultValue, valueParameterDescriptor.varargElementType
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, constantDefaultValue, valueParameterDescriptor.varargElementType
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.NotFoundClasses
|
import org.jetbrains.kotlin.descriptors.NotFoundClasses
|
||||||
import org.jetbrains.kotlin.ir.builders.IrGeneratorContext
|
import org.jetbrains.kotlin.ir.builders.IrGeneratorContext
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
|
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
|
||||||
import org.jetbrains.kotlin.ir.util.ConstantValueGenerator
|
import org.jetbrains.kotlin.ir.util.ConstantValueGenerator
|
||||||
@@ -33,8 +32,6 @@ class GeneratorContext(
|
|||||||
val constantValueGenerator: ConstantValueGenerator,
|
val constantValueGenerator: ConstantValueGenerator,
|
||||||
override val irBuiltIns: IrBuiltIns
|
override val irBuiltIns: IrBuiltIns
|
||||||
) : IrGeneratorContext {
|
) : IrGeneratorContext {
|
||||||
val irFactory: IrFactory get() = symbolTable.irFactory
|
|
||||||
|
|
||||||
val callToSubstitutedDescriptorMap = mutableMapOf<IrDeclarationReference, CallableDescriptor>()
|
val callToSubstitutedDescriptorMap = mutableMapOf<IrDeclarationReference, CallableDescriptor>()
|
||||||
|
|
||||||
val sourceManager = PsiSourceManager()
|
val sourceManager = PsiSourceManager()
|
||||||
|
|||||||
+2
-3
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
@@ -54,7 +53,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
).also { irProperty ->
|
).also { irProperty ->
|
||||||
irProperty.backingField =
|
irProperty.backingField =
|
||||||
generatePropertyBackingField(ktParameter, propertyDescriptor) {
|
generatePropertyBackingField(ktParameter, propertyDescriptor) {
|
||||||
IrExpressionBodyImpl(
|
context.irFactory.createExpressionBody(
|
||||||
IrGetValueImpl(
|
IrGetValueImpl(
|
||||||
ktParameter.startOffsetSkippingComments, ktParameter.endOffset,
|
ktParameter.startOffsetSkippingComments, ktParameter.endOffset,
|
||||||
irPropertyType,
|
irPropertyType,
|
||||||
@@ -119,7 +118,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
ktProperty.initializer?.let { ktInitializer ->
|
ktProperty.initializer?.let { ktInitializer ->
|
||||||
val compileTimeConst = propertyDescriptor.compileTimeInitializer
|
val compileTimeConst = propertyDescriptor.compileTimeInitializer
|
||||||
if (propertyDescriptor.isConst && compileTimeConst != null)
|
if (propertyDescriptor.isConst && compileTimeConst != null)
|
||||||
IrExpressionBodyImpl(
|
context.irFactory.createExpressionBody(
|
||||||
context.constantValueGenerator.generateConstantValueAsExpression(
|
context.constantValueGenerator.generateConstantValueAsExpression(
|
||||||
ktInitializer.startOffsetSkippingComments, ktInitializer.endOffset,
|
ktInitializer.startOffsetSkippingComments, ktInitializer.endOffset,
|
||||||
compileTimeConst
|
compileTimeConst
|
||||||
|
|||||||
+1
-4
@@ -9,12 +9,9 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
|
||||||
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
|
|
||||||
class SyntheticDeclarationsGenerator(context: GeneratorContext) : DeclarationDescriptorVisitor<Unit, IrDeclarationContainer?> {
|
class SyntheticDeclarationsGenerator(context: GeneratorContext) : DeclarationDescriptorVisitor<Unit, IrDeclarationContainer?> {
|
||||||
|
|
||||||
@@ -36,7 +33,7 @@ class SyntheticDeclarationsGenerator(context: GeneratorContext) : DeclarationDes
|
|||||||
if (!descriptor.declaresDefaultValue()) return null
|
if (!descriptor.declaresDefaultValue()) return null
|
||||||
|
|
||||||
val description = "Default Argument Value stub for ${descriptor.name}|${descriptor.index}"
|
val description = "Default Argument Value stub for ${descriptor.name}|${descriptor.index}"
|
||||||
return IrExpressionBodyImpl(IrErrorExpressionImpl(startOffset, endOffset, parameter.type, description))
|
return factory.createExpressionBody(IrErrorExpressionImpl(startOffset, endOffset, parameter.type, description))
|
||||||
}
|
}
|
||||||
|
|
||||||
private val defaultFactoryReference: IrFunction.(IrValueParameter) -> IrExpressionBody? = { defaultArgumentFactory(it) }
|
private val defaultFactoryReference: IrFunction.(IrValueParameter) -> IrExpressionBody? = { defaultArgumentFactory(it) }
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.builders
|
package org.jetbrains.kotlin.ir.builders
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
@@ -68,7 +67,7 @@ fun <T : IrElement> IrStatementsBuilder<T>.irTemporaryVar(
|
|||||||
|
|
||||||
|
|
||||||
fun IrBuilderWithScope.irExprBody(value: IrExpression) =
|
fun IrBuilderWithScope.irExprBody(value: IrExpression) =
|
||||||
IrExpressionBodyImpl(startOffset, endOffset, value)
|
context.irFactory.createExpressionBody(startOffset, endOffset, value)
|
||||||
|
|
||||||
fun IrBuilderWithScope.irWhen(type: IrType, branches: List<IrBranch>) =
|
fun IrBuilderWithScope.irWhen(type: IrType, branches: List<IrBranch>) =
|
||||||
IrWhenImpl(startOffset, endOffset, type, null, branches)
|
IrWhenImpl(startOffset, endOffset, type, null, branches)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.ir.builders
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
|
|
||||||
interface IrGenerator {
|
interface IrGenerator {
|
||||||
@@ -35,6 +36,8 @@ interface IrGeneratorContextInterface {
|
|||||||
interface IrGeneratorContext : IrGeneratorContextInterface {
|
interface IrGeneratorContext : IrGeneratorContextInterface {
|
||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
val builtIns: KotlinBuiltIns get() = irBuiltIns.builtIns
|
val builtIns: KotlinBuiltIns get() = irBuiltIns.builtIns
|
||||||
|
|
||||||
|
val irFactory: IrFactory get() = irBuiltIns.irFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
open class IrGeneratorContextBase(override val irBuiltIns: IrBuiltIns) : IrGeneratorContext
|
open class IrGeneratorContextBase(override val irBuiltIns: IrBuiltIns) : IrGeneratorContext
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations
|
package org.jetbrains.kotlin.ir.declarations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -192,4 +194,22 @@ interface IrFactory {
|
|||||||
isCrossinline: Boolean,
|
isCrossinline: Boolean,
|
||||||
isNoinline: Boolean,
|
isNoinline: Boolean,
|
||||||
): IrValueParameter
|
): IrValueParameter
|
||||||
|
|
||||||
|
// Bodies
|
||||||
|
|
||||||
|
fun createExpressionBody(
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
initializer: IrExpressionBody.() -> Unit,
|
||||||
|
): IrExpressionBody
|
||||||
|
|
||||||
|
fun createExpressionBody(
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
expression: IrExpression,
|
||||||
|
): IrExpressionBody
|
||||||
|
|
||||||
|
fun createExpressionBody(
|
||||||
|
expression: IrExpression,
|
||||||
|
): IrExpressionBody
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ package org.jetbrains.kotlin.ir.declarations.impl
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -222,4 +225,23 @@ object IrFactoryImpl : IrFactory {
|
|||||||
isNoinline: Boolean,
|
isNoinline: Boolean,
|
||||||
): IrValueParameter =
|
): IrValueParameter =
|
||||||
IrValueParameterImpl(startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline)
|
IrValueParameterImpl(startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline)
|
||||||
|
|
||||||
|
override fun createExpressionBody(
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
initializer: IrExpressionBody.() -> Unit,
|
||||||
|
): IrExpressionBody =
|
||||||
|
IrExpressionBodyImpl(startOffset, endOffset, initializer)
|
||||||
|
|
||||||
|
override fun createExpressionBody(
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
expression: IrExpression,
|
||||||
|
): IrExpressionBody =
|
||||||
|
IrExpressionBodyImpl(startOffset, endOffset, expression)
|
||||||
|
|
||||||
|
override fun createExpressionBody(
|
||||||
|
expression: IrExpression,
|
||||||
|
): IrExpressionBody =
|
||||||
|
IrExpressionBodyImpl(expression)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.ir.declarations.IrField
|
|||||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
@@ -57,7 +56,7 @@ class IrLazyField(
|
|||||||
|
|
||||||
override var initializer: IrExpressionBody? by lazyVar {
|
override var initializer: IrExpressionBody? by lazyVar {
|
||||||
descriptor.compileTimeInitializer?.let {
|
descriptor.compileTimeInitializer?.let {
|
||||||
IrExpressionBodyImpl(
|
factory.createExpressionBody(
|
||||||
typeTranslator.constantValueGenerator.generateConstantValueAsExpression(UNDEFINED_OFFSET, UNDEFINED_OFFSET, it)
|
typeTranslator.constantValueGenerator.generateConstantValueAsExpression(UNDEFINED_OFFSET, UNDEFINED_OFFSET, it)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
|||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOriginImpl
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOriginImpl
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
@@ -42,7 +43,7 @@ class IrBuiltIns(
|
|||||||
val languageVersionSettings = typeTranslator.languageVersionSettings
|
val languageVersionSettings = typeTranslator.languageVersionSettings
|
||||||
|
|
||||||
lateinit var functionFactory: IrAbstractFunctionFactory
|
lateinit var functionFactory: IrAbstractFunctionFactory
|
||||||
private val irFactory = symbolTable.irFactory
|
val irFactory: IrFactory = symbolTable.irFactory
|
||||||
|
|
||||||
private val builtInsModule = builtIns.builtInsModule
|
private val builtInsModule = builtIns.builtInsModule
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
|
|
||||||
interface IrBody : IrElement {
|
interface IrBody : IrElement {
|
||||||
@@ -25,6 +26,8 @@ interface IrBody : IrElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IrExpressionBody : IrBody {
|
interface IrExpressionBody : IrBody {
|
||||||
|
val factory: IrFactory
|
||||||
|
|
||||||
var expression: IrExpression
|
var expression: IrExpression
|
||||||
|
|
||||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpressionBody =
|
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpressionBody =
|
||||||
@@ -41,4 +44,3 @@ enum class IrSyntheticBodyKind {
|
|||||||
ENUM_VALUES,
|
ENUM_VALUES,
|
||||||
ENUM_VALUEOF
|
ENUM_VALUEOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrBodyBase
|
import org.jetbrains.kotlin.ir.declarations.impl.IrBodyBase
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
@@ -44,6 +46,9 @@ class IrExpressionBodyImpl private constructor(
|
|||||||
checkEnabled { expressionField = e }
|
checkEnabled { expressionField = e }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val factory: IrFactory
|
||||||
|
get() = IrFactoryImpl
|
||||||
|
|
||||||
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.visitExpressionBody(this, data)
|
visitor.visitExpressionBody(this, data)
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.lazy.*
|
import org.jetbrains.kotlin.ir.declarations.lazy.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.*
|
import org.jetbrains.kotlin.ir.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.linkage.IrProvider
|
import org.jetbrains.kotlin.ir.linkage.IrProvider
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
@@ -255,7 +254,7 @@ class DeclarationStubGenerator(
|
|||||||
).also { irValueParameter ->
|
).also { irValueParameter ->
|
||||||
if (descriptor.declaresDefaultValue()) {
|
if (descriptor.declaresDefaultValue()) {
|
||||||
irValueParameter.defaultValue =
|
irValueParameter.defaultValue =
|
||||||
IrExpressionBodyImpl(
|
irValueParameter.factory.createExpressionBody(
|
||||||
IrErrorExpressionImpl(
|
IrErrorExpressionImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, descriptor.type.toIrType(),
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, descriptor.type.toIrType(),
|
||||||
"Stub expression for default value of ${descriptor.name}"
|
"Stub expression for default value of ${descriptor.name}"
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ open class DeepCopyIrTreeWithSymbols(
|
|||||||
throw IllegalArgumentException("Unsupported body type: $body")
|
throw IllegalArgumentException("Unsupported body type: $body")
|
||||||
|
|
||||||
override fun visitExpressionBody(body: IrExpressionBody): IrExpressionBody =
|
override fun visitExpressionBody(body: IrExpressionBody): IrExpressionBody =
|
||||||
IrExpressionBodyImpl(body.expression.transform())
|
body.factory.createExpressionBody(body.expression.transform())
|
||||||
|
|
||||||
override fun visitBlockBody(body: IrBlockBody): IrBlockBody =
|
override fun visitBlockBody(body: IrBlockBody): IrBlockBody =
|
||||||
IrBlockBodyImpl(
|
IrBlockBodyImpl(
|
||||||
|
|||||||
@@ -6,12 +6,11 @@
|
|||||||
package org.jetbrains.kotlin.ir.util
|
package org.jetbrains.kotlin.ir.util
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
||||||
@@ -95,7 +94,7 @@ class ExpectDeclarationRemover(val symbolTable: ReferenceSymbolTable, private va
|
|||||||
val defaultValue = expectParameter.defaultValue ?: return
|
val defaultValue = expectParameter.defaultValue ?: return
|
||||||
|
|
||||||
defaultValue.let { originalDefault ->
|
defaultValue.let { originalDefault ->
|
||||||
declaration.defaultValue = IrExpressionBodyImpl(originalDefault.startOffset, originalDefault.endOffset) {
|
declaration.defaultValue = declaration.factory.createExpressionBody(originalDefault.startOffset, originalDefault.endOffset) {
|
||||||
expression = originalDefault.expression.deepCopyWithSymbols(function).remapExpectValueSymbols()
|
expression = originalDefault.expression.deepCopyWithSymbols(function).remapExpectValueSymbols()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1014,7 +1014,7 @@ abstract class IrFileDeserializer(
|
|||||||
flags.isNoInline
|
flags.isNoInline
|
||||||
).apply {
|
).apply {
|
||||||
if (proto.hasDefaultValue())
|
if (proto.hasDefaultValue())
|
||||||
defaultValue = IrExpressionBodyImpl(deserializeExpressionBody(proto.defaultValue))
|
defaultValue = irFactory.createExpressionBody(deserializeExpressionBody(proto.defaultValue))
|
||||||
|
|
||||||
(descriptor as? WrappedValueParameterDescriptor)?.bind(this)
|
(descriptor as? WrappedValueParameterDescriptor)?.bind(this)
|
||||||
(descriptor as? WrappedReceiverParameterDescriptor)?.bind(this)
|
(descriptor as? WrappedReceiverParameterDescriptor)?.bind(this)
|
||||||
@@ -1239,7 +1239,7 @@ abstract class IrFileDeserializer(
|
|||||||
if (proto.hasCorrespondingClass())
|
if (proto.hasCorrespondingClass())
|
||||||
correspondingClass = deserializeIrClass(proto.correspondingClass)
|
correspondingClass = deserializeIrClass(proto.correspondingClass)
|
||||||
if (proto.hasInitializer())
|
if (proto.hasInitializer())
|
||||||
initializerExpression = IrExpressionBodyImpl(deserializeExpressionBody(proto.initializer))
|
initializerExpression = irFactory.createExpressionBody(deserializeExpressionBody(proto.initializer))
|
||||||
|
|
||||||
(descriptor as? WrappedEnumEntryDescriptor)?.bind(this)
|
(descriptor as? WrappedEnumEntryDescriptor)?.bind(this)
|
||||||
}
|
}
|
||||||
@@ -1297,7 +1297,7 @@ abstract class IrFileDeserializer(
|
|||||||
}.usingParent {
|
}.usingParent {
|
||||||
if (proto.hasInitializer()) {
|
if (proto.hasInitializer()) {
|
||||||
withInitializerGuard(isPrivateProperty) {
|
withInitializerGuard(isPrivateProperty) {
|
||||||
initializer = IrExpressionBodyImpl(deserializeExpressionBody(proto.initializer))
|
initializer = irFactory.createExpressionBody(deserializeExpressionBody(proto.initializer))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user