Adapt to removal of WrappedDescriptors in master
(cherry picked from commit 2fe4105acfa0487f49b31ef90cb01249f8c9a137)
This commit is contained in:
committed by
Nikolay Krasko
parent
39805c72dc
commit
22c4406db1
+8
-18
@@ -14,8 +14,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
@@ -59,11 +57,10 @@ internal val Context.getBoxFunction: (IrClass) -> IrSimpleFunction by Context.la
|
|||||||
val startOffset = inlinedClass.startOffset
|
val startOffset = inlinedClass.startOffset
|
||||||
val endOffset = inlinedClass.endOffset
|
val endOffset = inlinedClass.endOffset
|
||||||
|
|
||||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_INLINE_CLASS_SPECIAL_FUNCTION,
|
DECLARATION_ORIGIN_INLINE_CLASS_SPECIAL_FUNCTION,
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
Name.special("<${inlinedClass.name}-box>"),
|
Name.special("<${inlinedClass.name}-box>"),
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -77,11 +74,11 @@ internal val Context.getBoxFunction: (IrClass) -> IrSimpleFunction by Context.la
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).also { function ->
|
).also { function ->
|
||||||
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
|
function.valueParameters = listOf(
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrValueParameterSymbolImpl(it),
|
IrValueParameterSymbolImpl(),
|
||||||
Name.identifier("value"),
|
Name.identifier("value"),
|
||||||
index = 0,
|
index = 0,
|
||||||
varargElementType = null,
|
varargElementType = null,
|
||||||
@@ -91,11 +88,8 @@ internal val Context.getBoxFunction: (IrClass) -> IrSimpleFunction by Context.la
|
|||||||
isHidden = false,
|
isHidden = false,
|
||||||
isAssignable = false
|
isAssignable = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = function
|
parent = function
|
||||||
}
|
})
|
||||||
})
|
|
||||||
descriptor.bind(function)
|
|
||||||
function.parent = inlinedClass.getContainingFile()!!
|
function.parent = inlinedClass.getContainingFile()!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,11 +110,10 @@ internal val Context.getUnboxFunction: (IrClass) -> IrSimpleFunction by Context.
|
|||||||
val startOffset = inlinedClass.startOffset
|
val startOffset = inlinedClass.startOffset
|
||||||
val endOffset = inlinedClass.endOffset
|
val endOffset = inlinedClass.endOffset
|
||||||
|
|
||||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_INLINE_CLASS_SPECIAL_FUNCTION,
|
DECLARATION_ORIGIN_INLINE_CLASS_SPECIAL_FUNCTION,
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
Name.special("<${inlinedClass.name}-unbox>"),
|
Name.special("<${inlinedClass.name}-unbox>"),
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -134,11 +127,11 @@ internal val Context.getUnboxFunction: (IrClass) -> IrSimpleFunction by Context.
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).also { function ->
|
).also { function ->
|
||||||
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
|
function.valueParameters = listOf(
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrValueParameterSymbolImpl(it),
|
IrValueParameterSymbolImpl(),
|
||||||
Name.identifier("value"),
|
Name.identifier("value"),
|
||||||
index = 0,
|
index = 0,
|
||||||
varargElementType = null,
|
varargElementType = null,
|
||||||
@@ -148,11 +141,8 @@ internal val Context.getUnboxFunction: (IrClass) -> IrSimpleFunction by Context.
|
|||||||
isHidden = false,
|
isHidden = false,
|
||||||
isAssignable = false
|
isAssignable = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = function
|
parent = function
|
||||||
}
|
})
|
||||||
})
|
|
||||||
descriptor.bind(function)
|
|
||||||
function.parent = inlinedClass.getContainingFile()!!
|
function.parent = inlinedClass.getContainingFile()!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-5
@@ -41,7 +41,6 @@ import org.jetbrains.kotlin.backend.common.ir.copyToWithoutSuperTypes
|
|||||||
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExport
|
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExport
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.coverage.CoverageManager
|
import org.jetbrains.kotlin.backend.konan.llvm.coverage.CoverageManager
|
||||||
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass
|
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -138,7 +137,7 @@ internal class SpecialDeclarationsFactory(val context: Context) {
|
|||||||
return bridges.getOrPut(key) { createBridge(key) }
|
return bridges.getOrPut(key) { createBridge(key) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createBridge(key: BridgeKey): IrSimpleFunction = WrappedSimpleFunctionDescriptor().let { descriptor ->
|
private fun createBridge(key: BridgeKey): IrSimpleFunction {
|
||||||
val (function, bridgeDirections) = key
|
val (function, bridgeDirections) = key
|
||||||
val startOffset = function.startOffset
|
val startOffset = function.startOffset
|
||||||
val endOffset = function.endOffset
|
val endOffset = function.endOffset
|
||||||
@@ -148,10 +147,10 @@ internal class SpecialDeclarationsFactory(val context: Context) {
|
|||||||
null
|
null
|
||||||
else this.irClass?.defaultType ?: context.irBuiltIns.anyNType
|
else this.irClass?.defaultType ?: context.irBuiltIns.anyNType
|
||||||
|
|
||||||
IrFunctionImpl(
|
return IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_BRIDGE_METHOD(function),
|
DECLARATION_ORIGIN_BRIDGE_METHOD(function),
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
"<bridge-$bridgeDirections>${function.computeFunctionName()}".synthesizedName,
|
"<bridge-$bridgeDirections>${function.computeFunctionName()}".synthesizedName,
|
||||||
function.visibility,
|
function.visibility,
|
||||||
function.modality,
|
function.modality,
|
||||||
@@ -166,7 +165,6 @@ internal class SpecialDeclarationsFactory(val context: Context) {
|
|||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
).apply {
|
||||||
val bridge = this
|
val bridge = this
|
||||||
descriptor.bind(bridge)
|
|
||||||
parent = function.parent
|
parent = function.parent
|
||||||
|
|
||||||
dispatchReceiverParameter = function.dispatchReceiverParameter?.let {
|
dispatchReceiverParameter = function.dispatchReceiverParameter?.let {
|
||||||
|
|||||||
+4
-10
@@ -15,8 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrTryImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrTryImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
@@ -25,13 +23,12 @@ import org.jetbrains.kotlin.ir.util.irCatch
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
internal fun makeEntryPoint(context: Context): IrFunction {
|
internal fun makeEntryPoint(context: Context): IrFunction {
|
||||||
val entryPointDescriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
val actualMain = context.ir.symbols.entryPoint!!.owner
|
val actualMain = context.ir.symbols.entryPoint!!.owner
|
||||||
val entryPoint = IrFunctionImpl(
|
val entryPoint = IrFunctionImpl(
|
||||||
actualMain.startOffset,
|
actualMain.startOffset,
|
||||||
actualMain.startOffset,
|
actualMain.startOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(entryPointDescriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
Name.identifier("Konan_start"),
|
Name.identifier("Konan_start"),
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -45,11 +42,11 @@ internal fun makeEntryPoint(context: Context): IrFunction {
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).also { function ->
|
).also { function ->
|
||||||
function.valueParameters = listOf(WrappedValueParameterDescriptor().let {
|
function.valueParameters = listOf(
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
actualMain.startOffset, actualMain.startOffset,
|
actualMain.startOffset, actualMain.startOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrValueParameterSymbolImpl(it),
|
IrValueParameterSymbolImpl(),
|
||||||
Name.identifier("args"),
|
Name.identifier("args"),
|
||||||
index = 0,
|
index = 0,
|
||||||
varargElementType = null,
|
varargElementType = null,
|
||||||
@@ -59,12 +56,9 @@ internal fun makeEntryPoint(context: Context): IrFunction {
|
|||||||
isHidden = false,
|
isHidden = false,
|
||||||
isAssignable = false
|
isAssignable = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = function
|
parent = function
|
||||||
}
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
entryPointDescriptor.bind(entryPoint)
|
|
||||||
entryPoint.annotations += buildSimpleAnnotation(context.irBuiltIns,
|
entryPoint.annotations += buildSimpleAnnotation(context.irBuiltIns,
|
||||||
actualMain.startOffset, actualMain.startOffset,
|
actualMain.startOffset, actualMain.startOffset,
|
||||||
context.ir.symbols.exportForCppRuntime.owner, "Konan_start")
|
context.ir.symbols.exportForCppRuntime.owner, "Konan_start")
|
||||||
|
|||||||
+6
-15
@@ -22,9 +22,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
||||||
@@ -135,11 +132,11 @@ internal class EnumSpecialDeclarationsFactory(val context: Context) {
|
|||||||
val startOffset = enumClass.startOffset
|
val startOffset = enumClass.startOffset
|
||||||
val endOffset = enumClass.endOffset
|
val endOffset = enumClass.endOffset
|
||||||
|
|
||||||
val implObject = WrappedClassDescriptor().let {
|
val implObject =
|
||||||
IrClassImpl(
|
IrClassImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_ENUM,
|
DECLARATION_ORIGIN_ENUM,
|
||||||
IrClassSymbolImpl(it),
|
IrClassSymbolImpl(),
|
||||||
"OBJECT".synthesizedName,
|
"OBJECT".synthesizedName,
|
||||||
ClassKind.OBJECT,
|
ClassKind.OBJECT,
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
@@ -152,18 +149,16 @@ internal class EnumSpecialDeclarationsFactory(val context: Context) {
|
|||||||
isExpect = false,
|
isExpect = false,
|
||||||
isFun = false
|
isFun = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = enumClass
|
parent = enumClass
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val valuesType = valuesArrayType(enumClass)
|
val valuesType = valuesArrayType(enumClass)
|
||||||
val valuesField = WrappedFieldDescriptor().let {
|
val valuesField =
|
||||||
IrFieldImpl(
|
IrFieldImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_ENUM,
|
DECLARATION_ORIGIN_ENUM,
|
||||||
IrFieldSymbolImpl(it),
|
IrFieldSymbolImpl(),
|
||||||
"VALUES".synthesizedName,
|
"VALUES".synthesizedName,
|
||||||
valuesType,
|
valuesType,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
@@ -171,16 +166,14 @@ internal class EnumSpecialDeclarationsFactory(val context: Context) {
|
|||||||
isExternal = false,
|
isExternal = false,
|
||||||
isStatic = false,
|
isStatic = false,
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = implObject
|
parent = implObject
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val valuesGetter = WrappedSimpleFunctionDescriptor().let {
|
val valuesGetter =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_ENUM,
|
DECLARATION_ORIGIN_ENUM,
|
||||||
IrSimpleFunctionSymbolImpl(it),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
"get-VALUES".synthesizedName,
|
"get-VALUES".synthesizedName,
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -194,10 +187,8 @@ internal class EnumSpecialDeclarationsFactory(val context: Context) {
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = implObject
|
parent = implObject
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val constructorOfAny = context.irBuiltIns.anyClass.owner.constructors.first()
|
val constructorOfAny = context.irBuiltIns.anyClass.owner.constructors.first()
|
||||||
implObject.addSimpleDelegatingConstructor(
|
implObject.addSimpleDelegatingConstructor(
|
||||||
|
|||||||
+6
-18
@@ -549,12 +549,11 @@ private fun KotlinStubs.createFakeKotlinExternalFunction(
|
|||||||
cFunctionName: String,
|
cFunctionName: String,
|
||||||
isObjCMethod: Boolean
|
isObjCMethod: Boolean
|
||||||
): IrSimpleFunction {
|
): IrSimpleFunction {
|
||||||
val bridgeDescriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
val bridge = IrFunctionImpl(
|
val bridge = IrFunctionImpl(
|
||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(bridgeDescriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
Name.identifier(cFunctionName),
|
Name.identifier(cFunctionName),
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -568,7 +567,6 @@ private fun KotlinStubs.createFakeKotlinExternalFunction(
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
)
|
)
|
||||||
bridgeDescriptor.bind(bridge)
|
|
||||||
|
|
||||||
bridge.annotations += buildSimpleAnnotation(irBuiltIns, UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
bridge.annotations += buildSimpleAnnotation(irBuiltIns, UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
symbols.symbolName.owner, cFunctionName)
|
symbols.symbolName.owner, cFunctionName)
|
||||||
@@ -1098,16 +1096,14 @@ private class ObjCBlockPointerValuePassing(
|
|||||||
private fun IrBuilderWithScope.generateKotlinFunctionClass(): IrConstructor {
|
private fun IrBuilderWithScope.generateKotlinFunctionClass(): IrConstructor {
|
||||||
val symbols = stubs.symbols
|
val symbols = stubs.symbols
|
||||||
|
|
||||||
val classDescriptor = WrappedClassDescriptor()
|
|
||||||
val irClass = IrClassImpl(
|
val irClass = IrClassImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
OBJC_BLOCK_FUNCTION_IMPL, IrClassSymbolImpl(classDescriptor),
|
OBJC_BLOCK_FUNCTION_IMPL, IrClassSymbolImpl(),
|
||||||
Name.identifier(stubs.getUniqueKotlinFunctionReferenceClassName("BlockFunctionImpl")),
|
Name.identifier(stubs.getUniqueKotlinFunctionReferenceClassName("BlockFunctionImpl")),
|
||||||
ClassKind.CLASS, DescriptorVisibilities.PRIVATE, Modality.FINAL,
|
ClassKind.CLASS, DescriptorVisibilities.PRIVATE, Modality.FINAL,
|
||||||
isCompanion = false, isInner = false, isData = false, isExternal = false,
|
isCompanion = false, isInner = false, isData = false, isExternal = false,
|
||||||
isInline = false, isExpect = false, isFun = false
|
isInline = false, isExpect = false, isFun = false
|
||||||
)
|
)
|
||||||
classDescriptor.bind(irClass)
|
|
||||||
irClass.createParameterDeclarations()
|
irClass.createParameterDeclarations()
|
||||||
|
|
||||||
irClass.superTypes += stubs.irBuiltIns.anyType
|
irClass.superTypes += stubs.irBuiltIns.anyType
|
||||||
@@ -1121,24 +1117,21 @@ private class ObjCBlockPointerValuePassing(
|
|||||||
isMutable = false, owner = irClass
|
isMutable = false, owner = irClass
|
||||||
)
|
)
|
||||||
|
|
||||||
val constructorDescriptor = WrappedClassConstructorDescriptor()
|
|
||||||
val constructor = IrConstructorImpl(
|
val constructor = IrConstructorImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
OBJC_BLOCK_FUNCTION_IMPL,
|
OBJC_BLOCK_FUNCTION_IMPL,
|
||||||
IrConstructorSymbolImpl(constructorDescriptor),
|
IrConstructorSymbolImpl(),
|
||||||
Name.special("<init>"),
|
Name.special("<init>"),
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
irClass.defaultType,
|
irClass.defaultType,
|
||||||
isInline = false, isExternal = false, isPrimary = true, isExpect = false
|
isInline = false, isExternal = false, isPrimary = true, isExpect = false
|
||||||
)
|
)
|
||||||
constructorDescriptor.bind(constructor)
|
|
||||||
irClass.addChild(constructor)
|
irClass.addChild(constructor)
|
||||||
|
|
||||||
val constructorParameterDescriptor = WrappedValueParameterDescriptor()
|
|
||||||
val constructorParameter = IrValueParameterImpl(
|
val constructorParameter = IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
OBJC_BLOCK_FUNCTION_IMPL,
|
OBJC_BLOCK_FUNCTION_IMPL,
|
||||||
IrValueParameterSymbolImpl(constructorParameterDescriptor),
|
IrValueParameterSymbolImpl(),
|
||||||
Name.identifier("blockPointer"),
|
Name.identifier("blockPointer"),
|
||||||
0,
|
0,
|
||||||
symbols.nativePtrType,
|
symbols.nativePtrType,
|
||||||
@@ -1148,7 +1141,6 @@ private class ObjCBlockPointerValuePassing(
|
|||||||
isHidden = false,
|
isHidden = false,
|
||||||
isAssignable = false
|
isAssignable = false
|
||||||
)
|
)
|
||||||
constructorParameterDescriptor.bind(constructorParameter)
|
|
||||||
constructor.valueParameters += constructorParameter
|
constructor.valueParameters += constructorParameter
|
||||||
constructorParameter.parent = constructor
|
constructorParameter.parent = constructor
|
||||||
|
|
||||||
@@ -1166,28 +1158,25 @@ private class ObjCBlockPointerValuePassing(
|
|||||||
val overriddenInvokeMethod = (functionType.classifier.owner as IrClass).simpleFunctions()
|
val overriddenInvokeMethod = (functionType.classifier.owner as IrClass).simpleFunctions()
|
||||||
.single { it.name == OperatorNameConventions.INVOKE }
|
.single { it.name == OperatorNameConventions.INVOKE }
|
||||||
|
|
||||||
val invokeMethodDescriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
val invokeMethod = IrFunctionImpl(
|
val invokeMethod = IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
OBJC_BLOCK_FUNCTION_IMPL,
|
OBJC_BLOCK_FUNCTION_IMPL,
|
||||||
IrSimpleFunctionSymbolImpl(invokeMethodDescriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
overriddenInvokeMethod.name,
|
overriddenInvokeMethod.name,
|
||||||
DescriptorVisibilities.PUBLIC, Modality.FINAL,
|
DescriptorVisibilities.PUBLIC, Modality.FINAL,
|
||||||
returnType = functionType.arguments.last().typeOrNull!!,
|
returnType = functionType.arguments.last().typeOrNull!!,
|
||||||
isInline = false, isExternal = false, isTailrec = false, isSuspend = false, isExpect = false,
|
isInline = false, isExternal = false, isTailrec = false, isSuspend = false, isExpect = false,
|
||||||
isFakeOverride = false, isOperator = false, isInfix = false
|
isFakeOverride = false, isOperator = false, isInfix = false
|
||||||
)
|
)
|
||||||
invokeMethodDescriptor.bind(invokeMethod)
|
|
||||||
invokeMethod.overriddenSymbols += overriddenInvokeMethod.symbol
|
invokeMethod.overriddenSymbols += overriddenInvokeMethod.symbol
|
||||||
irClass.addChild(invokeMethod)
|
irClass.addChild(invokeMethod)
|
||||||
invokeMethod.createDispatchReceiverParameter()
|
invokeMethod.createDispatchReceiverParameter()
|
||||||
|
|
||||||
invokeMethod.valueParameters += (0 until parameterCount).map { index ->
|
invokeMethod.valueParameters += (0 until parameterCount).map { index ->
|
||||||
val parameterDescriptor = WrappedValueParameterDescriptor()
|
|
||||||
val parameter = IrValueParameterImpl(
|
val parameter = IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
OBJC_BLOCK_FUNCTION_IMPL,
|
OBJC_BLOCK_FUNCTION_IMPL,
|
||||||
IrValueParameterSymbolImpl(parameterDescriptor),
|
IrValueParameterSymbolImpl(),
|
||||||
Name.identifier("p$index"),
|
Name.identifier("p$index"),
|
||||||
index,
|
index,
|
||||||
functionType.arguments[index].typeOrNull!!,
|
functionType.arguments[index].typeOrNull!!,
|
||||||
@@ -1197,7 +1186,6 @@ private class ObjCBlockPointerValuePassing(
|
|||||||
isHidden = false,
|
isHidden = false,
|
||||||
isAssignable = false
|
isAssignable = false
|
||||||
)
|
)
|
||||||
parameterDescriptor.bind(parameter)
|
|
||||||
parameter.parent = invokeMethod
|
parameter.parent = invokeMethod
|
||||||
parameter
|
parameter
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-8
@@ -15,8 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrTryImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrTryImpl
|
||||||
@@ -81,11 +79,10 @@ internal class KotlinBridgeBuilder(
|
|||||||
|
|
||||||
fun addParameter(type: IrType): IrValueParameter {
|
fun addParameter(type: IrType): IrValueParameter {
|
||||||
val index = counter++
|
val index = counter++
|
||||||
val descriptor = WrappedValueParameterDescriptor()
|
|
||||||
|
|
||||||
return IrValueParameterImpl(
|
return IrValueParameterImpl(
|
||||||
bridge.startOffset, bridge.endOffset, bridge.origin,
|
bridge.startOffset, bridge.endOffset, bridge.origin,
|
||||||
IrValueParameterSymbolImpl(descriptor),
|
IrValueParameterSymbolImpl(),
|
||||||
Name.identifier("p$index"), index, type,
|
Name.identifier("p$index"), index, type,
|
||||||
null,
|
null,
|
||||||
isCrossinline = false,
|
isCrossinline = false,
|
||||||
@@ -93,7 +90,6 @@ internal class KotlinBridgeBuilder(
|
|||||||
isHidden = false,
|
isHidden = false,
|
||||||
isAssignable = false
|
isAssignable = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
parent = bridge
|
parent = bridge
|
||||||
bridge.valueParameters += this
|
bridge.valueParameters += this
|
||||||
}
|
}
|
||||||
@@ -114,12 +110,11 @@ private fun createKotlinBridge(
|
|||||||
isExternal: Boolean,
|
isExternal: Boolean,
|
||||||
foreignExceptionMode: ForeignExceptionMode.Mode
|
foreignExceptionMode: ForeignExceptionMode.Mode
|
||||||
): IrFunction {
|
): IrFunction {
|
||||||
val bridgeDescriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
val bridge = IrFunctionImpl(
|
val bridge = IrFunctionImpl(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(bridgeDescriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
Name.identifier(cBridgeName),
|
Name.identifier(cBridgeName),
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -133,7 +128,6 @@ private fun createKotlinBridge(
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
)
|
)
|
||||||
bridgeDescriptor.bind(bridge)
|
|
||||||
if (isExternal) {
|
if (isExternal) {
|
||||||
bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset,
|
bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset,
|
||||||
stubs.symbols.symbolName.owner, cBridgeName)
|
stubs.symbols.symbolName.owner, cBridgeName)
|
||||||
|
|||||||
+8
-12
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrSetValue
|
import org.jetbrains.kotlin.ir.expressions.IrSetValue
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
@@ -44,17 +43,14 @@ internal class KonanSharedVariablesManager(val context: KonanBackendContext) : S
|
|||||||
}
|
}
|
||||||
|
|
||||||
return with(originalDeclaration) {
|
return with(originalDeclaration) {
|
||||||
WrappedVariableDescriptor().let {
|
IrVariableImpl(
|
||||||
IrVariableImpl(
|
startOffset, endOffset, origin,
|
||||||
startOffset, endOffset, origin,
|
IrVariableSymbolImpl(), name, refConstructorCall.type,
|
||||||
IrVariableSymbolImpl(it), name, refConstructorCall.type,
|
isVar = false,
|
||||||
isVar = false,
|
isConst = false,
|
||||||
isConst = false,
|
isLateinit = false
|
||||||
isLateinit = false
|
).apply {
|
||||||
).apply {
|
initializer = refConstructorCall
|
||||||
it.bind(this)
|
|
||||||
initializer = refConstructorCall
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -60,7 +60,7 @@ internal interface DescriptorToIrTranslationMixin {
|
|||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB, it, descriptor
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB, it, descriptor
|
||||||
)
|
)
|
||||||
}.also { irClass ->
|
}.also { irClass ->
|
||||||
symbolTable.withScope(descriptor) {
|
symbolTable.withScope(irClass) {
|
||||||
irClass.superTypes += descriptor.typeConstructor.supertypes.map {
|
irClass.superTypes += descriptor.typeConstructor.supertypes.map {
|
||||||
it.toIrType()
|
it.toIrType()
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ internal interface DescriptorToIrTranslationMixin {
|
|||||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB
|
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB
|
||||||
): IrSimpleFunction {
|
): IrSimpleFunction {
|
||||||
val irFunction = symbolTable.declareSimpleFunctionWithOverrides(SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, origin, functionDescriptor)
|
val irFunction = symbolTable.declareSimpleFunctionWithOverrides(SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, origin, functionDescriptor)
|
||||||
symbolTable.withScope(functionDescriptor) {
|
symbolTable.withScope(irFunction) {
|
||||||
irFunction.returnType = functionDescriptor.returnType!!.toIrType()
|
irFunction.returnType = functionDescriptor.returnType!!.toIrType()
|
||||||
irFunction.valueParameters += functionDescriptor.valueParameters.map {
|
irFunction.valueParameters += functionDescriptor.valueParameters.map {
|
||||||
symbolTable.declareValueParameter(SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, IrDeclarationOrigin.DEFINED, it, it.type.toIrType())
|
symbolTable.declareValueParameter(SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, IrDeclarationOrigin.DEFINED, it, it.type.toIrType())
|
||||||
|
|||||||
+1
-1
@@ -93,7 +93,7 @@ internal class CEnumClassGenerator(
|
|||||||
.findDeclarationByName<PropertyDescriptor>("value")
|
.findDeclarationByName<PropertyDescriptor>("value")
|
||||||
?: error("No `value` property in ${irClass.name}")
|
?: error("No `value` property in ${irClass.name}")
|
||||||
val irProperty = createProperty(propertyDescriptor)
|
val irProperty = createProperty(propertyDescriptor)
|
||||||
symbolTable.withScope(propertyDescriptor) {
|
symbolTable.withScope(irProperty) {
|
||||||
irProperty.backingField = symbolTable.declareField(
|
irProperty.backingField = symbolTable.declareField(
|
||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, IrDeclarationOrigin.PROPERTY_BACKING_FIELD,
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, IrDeclarationOrigin.PROPERTY_BACKING_FIELD,
|
||||||
propertyDescriptor, propertyDescriptor.type.toIrType(), DescriptorVisibilities.PRIVATE
|
propertyDescriptor, propertyDescriptor.type.toIrType(), DescriptorVisibilities.PRIVATE
|
||||||
|
|||||||
+3
-9
@@ -20,8 +20,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
@@ -414,13 +412,12 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT
|
|||||||
private fun buildBoxField(declaration: IrClass) {
|
private fun buildBoxField(declaration: IrClass) {
|
||||||
val startOffset = declaration.startOffset
|
val startOffset = declaration.startOffset
|
||||||
val endOffset = declaration.endOffset
|
val endOffset = declaration.endOffset
|
||||||
val descriptor = WrappedPropertyDescriptor()
|
|
||||||
|
|
||||||
val irField = IrFieldImpl(
|
val irField = IrFieldImpl(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrFieldSymbolImpl(descriptor),
|
IrFieldSymbolImpl(),
|
||||||
Name.identifier("value"),
|
Name.identifier("value"),
|
||||||
declaration.defaultType,
|
declaration.defaultType,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
@@ -434,7 +431,7 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT
|
|||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrPropertySymbolImpl(descriptor),
|
IrPropertySymbolImpl(),
|
||||||
irField.name,
|
irField.name,
|
||||||
irField.visibility,
|
irField.visibility,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -444,7 +441,6 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT
|
|||||||
isDelegated = false,
|
isDelegated = false,
|
||||||
isExternal = false
|
isExternal = false
|
||||||
)
|
)
|
||||||
descriptor.bind(irProperty)
|
|
||||||
irProperty.backingField = irField
|
irProperty.backingField = irField
|
||||||
|
|
||||||
declaration.addChild(irProperty)
|
declaration.addChild(irProperty)
|
||||||
@@ -553,11 +549,10 @@ private val Context.getLoweredInlineClassConstructor: (IrConstructor) -> IrSimpl
|
|||||||
irConstructor.returnType
|
irConstructor.returnType
|
||||||
}
|
}
|
||||||
|
|
||||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
irConstructor.startOffset, irConstructor.endOffset,
|
irConstructor.startOffset, irConstructor.endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
Name.special("<constructor>"),
|
Name.special("<constructor>"),
|
||||||
irConstructor.visibility,
|
irConstructor.visibility,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -571,7 +566,6 @@ private val Context.getLoweredInlineClassConstructor: (IrConstructor) -> IrSimpl
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
parent = irConstructor.parent
|
parent = irConstructor.parent
|
||||||
|
|
||||||
// Note: technically speaking, this function doesn't have access to class type parameters (since it is "static").
|
// Note: technically speaking, this function doesn't have access to class type parameters (since it is "static").
|
||||||
|
|||||||
+6
-12
@@ -19,8 +19,6 @@ import org.jetbrains.kotlin.ir.builders.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
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.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
@@ -71,11 +69,11 @@ internal class WorkersBridgesBuilding(val context: Context) : DeclarationContain
|
|||||||
val arg = jobFunction.valueParameters[0]
|
val arg = jobFunction.valueParameters[0]
|
||||||
val startOffset = jobFunction.startOffset
|
val startOffset = jobFunction.startOffset
|
||||||
val endOffset = jobFunction.endOffset
|
val endOffset = jobFunction.endOffset
|
||||||
runtimeJobFunction = WrappedSimpleFunctionDescriptor().let {
|
runtimeJobFunction =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(it),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
jobFunction.name,
|
jobFunction.name,
|
||||||
jobFunction.visibility,
|
jobFunction.visibility,
|
||||||
jobFunction.modality,
|
jobFunction.modality,
|
||||||
@@ -88,16 +86,13 @@ internal class WorkersBridgesBuilding(val context: Context) : DeclarationContain
|
|||||||
isFakeOverride = false,
|
isFakeOverride = false,
|
||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
)
|
||||||
it.bind(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
runtimeJobFunction.valueParameters += WrappedValueParameterDescriptor().let {
|
runtimeJobFunction.valueParameters +=
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrValueParameterSymbolImpl(it),
|
IrValueParameterSymbolImpl(),
|
||||||
arg.name,
|
arg.name,
|
||||||
arg.index,
|
arg.index,
|
||||||
type = context.irBuiltIns.anyNType,
|
type = context.irBuiltIns.anyNType,
|
||||||
@@ -106,8 +101,7 @@ internal class WorkersBridgesBuilding(val context: Context) : DeclarationContain
|
|||||||
isNoinline = arg.isNoinline,
|
isNoinline = arg.isNoinline,
|
||||||
isHidden = arg.isHidden,
|
isHidden = arg.isHidden,
|
||||||
isAssignable = arg.isAssignable
|
isAssignable = arg.isAssignable
|
||||||
).apply { it.bind(this) }
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val overriddenJobDescriptor = OverriddenFunctionInfo(jobFunction, runtimeJobFunction)
|
val overriddenJobDescriptor = OverriddenFunctionInfo(jobFunction, runtimeJobFunction)
|
||||||
if (!overriddenJobDescriptor.needBridge) return expression
|
if (!overriddenJobDescriptor.needBridge) return expression
|
||||||
|
|||||||
+2
-5
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrLocalDelegatedPropertyReference
|
import org.jetbrains.kotlin.ir.expressions.IrLocalDelegatedPropertyReference
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
|
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
|
||||||
@@ -84,11 +83,11 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
|
|||||||
|
|
||||||
val kPropertiesFieldType: IrType = context.ir.symbols.array.typeWith(kPropertyImplType)
|
val kPropertiesFieldType: IrType = context.ir.symbols.array.typeWith(kPropertyImplType)
|
||||||
|
|
||||||
val kPropertiesField = WrappedFieldDescriptor().let {
|
val kPropertiesField =
|
||||||
IrFieldImpl(
|
IrFieldImpl(
|
||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
||||||
DECLARATION_ORIGIN_KPROPERTIES_FOR_DELEGATION,
|
DECLARATION_ORIGIN_KPROPERTIES_FOR_DELEGATION,
|
||||||
IrFieldSymbolImpl(it),
|
IrFieldSymbolImpl(),
|
||||||
"KPROPERTIES".synthesizedName,
|
"KPROPERTIES".synthesizedName,
|
||||||
kPropertiesFieldType,
|
kPropertiesFieldType,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
@@ -96,11 +95,9 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
|
|||||||
isExternal = false,
|
isExternal = false,
|
||||||
isStatic = true,
|
isStatic = true,
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = irFile
|
parent = irFile
|
||||||
annotations += buildSimpleAnnotation(context.irBuiltIns, startOffset, endOffset, context.ir.symbols.sharedImmutable.owner)
|
annotations += buildSimpleAnnotation(context.irBuiltIns, startOffset, endOffset, context.ir.symbols.sharedImmutable.owner)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
irFile.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
|
irFile.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
|
||||||
|
|
||||||
|
|||||||
+16
-23
@@ -16,8 +16,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
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.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
@@ -109,11 +107,11 @@ internal class EnumConstructorsLowering(val context: Context) : ClassLoweringPas
|
|||||||
private fun lowerEnumConstructor(constructor: IrConstructor): IrConstructor {
|
private fun lowerEnumConstructor(constructor: IrConstructor): IrConstructor {
|
||||||
val startOffset = constructor.startOffset
|
val startOffset = constructor.startOffset
|
||||||
val endOffset = constructor.endOffset
|
val endOffset = constructor.endOffset
|
||||||
val loweredConstructor = WrappedClassConstructorDescriptor().let {
|
val loweredConstructor =
|
||||||
IrConstructorImpl(
|
IrConstructorImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
constructor.origin,
|
constructor.origin,
|
||||||
IrConstructorSymbolImpl(it),
|
IrConstructorSymbolImpl(),
|
||||||
constructor.name,
|
constructor.name,
|
||||||
DescriptorVisibilities.PROTECTED,
|
DescriptorVisibilities.PROTECTED,
|
||||||
constructor.returnType,
|
constructor.returnType,
|
||||||
@@ -122,32 +120,27 @@ internal class EnumConstructorsLowering(val context: Context) : ClassLoweringPas
|
|||||||
isPrimary = constructor.isPrimary,
|
isPrimary = constructor.isPrimary,
|
||||||
isExpect = false
|
isExpect = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = constructor.parent
|
parent = constructor.parent
|
||||||
val body = constructor.body!!
|
val body = constructor.body!!
|
||||||
this.body = body // Will be transformed later.
|
this.body = body // Will be transformed later.
|
||||||
body.setDeclarationsParent(this)
|
body.setDeclarationsParent(this)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun createSynthesizedValueParameter(index: Int, name: String, type: IrType): IrValueParameter =
|
fun createSynthesizedValueParameter(index: Int, name: String, type: IrType): IrValueParameter =
|
||||||
WrappedValueParameterDescriptor().let {
|
IrValueParameterImpl(
|
||||||
IrValueParameterImpl(
|
startOffset, endOffset,
|
||||||
startOffset, endOffset,
|
DECLARATION_ORIGIN_ENUM,
|
||||||
DECLARATION_ORIGIN_ENUM,
|
IrValueParameterSymbolImpl(),
|
||||||
IrValueParameterSymbolImpl(it),
|
Name.identifier(name),
|
||||||
Name.identifier(name),
|
index,
|
||||||
index,
|
type,
|
||||||
type,
|
varargElementType = null,
|
||||||
varargElementType = null,
|
isCrossinline = false,
|
||||||
isCrossinline = false,
|
isNoinline = false,
|
||||||
isNoinline = false,
|
isHidden = false,
|
||||||
isHidden = false,
|
isAssignable = false
|
||||||
isAssignable = false
|
).apply {
|
||||||
).apply {
|
parent = loweredConstructor
|
||||||
it.bind(this)
|
|
||||||
parent = loweredConstructor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loweredConstructor.valueParameters += createSynthesizedValueParameter(0, "name", context.irBuiltIns.stringType)
|
loweredConstructor.valueParameters += createSynthesizedValueParameter(0, "name", context.irBuiltIns.stringType)
|
||||||
|
|||||||
+5
-30
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.backend.common.lower.*
|
|||||||
import org.jetbrains.kotlin.backend.common.*
|
import org.jetbrains.kotlin.backend.common.*
|
||||||
import org.jetbrains.kotlin.backend.konan.Context
|
import org.jetbrains.kotlin.backend.konan.Context
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||||
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
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.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
@@ -24,8 +24,6 @@ import org.jetbrains.kotlin.ir.types.IrType
|
|||||||
import org.jetbrains.kotlin.ir.builders.irGet
|
import org.jetbrains.kotlin.ir.builders.irGet
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||||
@@ -173,27 +171,6 @@ internal class FinallyBlocksLowering(val context: Context): FileLoweringPass, Ir
|
|||||||
else -> error("Unknown ReturnTarget: $this")
|
else -> error("Unknown ReturnTarget: $this")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createSyntheticFunctionDescriptor(name: String): SimpleFunctionDescriptor {
|
|
||||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
descriptor.bind(IrFunctionImpl(
|
|
||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
|
||||||
IrDeclarationOrigin.DEFINED,
|
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
|
||||||
Name.identifier(name),
|
|
||||||
DescriptorVisibilities.PUBLIC,
|
|
||||||
Modality.FINAL,
|
|
||||||
context.irBuiltIns.unitType,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false)
|
|
||||||
)
|
|
||||||
return descriptor
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun performHighLevelJump(tryScopes: List<TryScope>,
|
private fun performHighLevelJump(tryScopes: List<TryScope>,
|
||||||
index: Int,
|
index: Int,
|
||||||
jump: HighLevelJump,
|
jump: HighLevelJump,
|
||||||
@@ -206,7 +183,7 @@ internal class FinallyBlocksLowering(val context: Context): FileLoweringPass, Ir
|
|||||||
val currentTryScope = tryScopes[index]
|
val currentTryScope = tryScopes[index]
|
||||||
currentTryScope.jumps.getOrPut(jump) {
|
currentTryScope.jumps.getOrPut(jump) {
|
||||||
val type = (jump as? Return)?.target?.owner?.returnType ?: value.type
|
val type = (jump as? Return)?.target?.owner?.returnType ?: value.type
|
||||||
val symbol = IrReturnableBlockSymbolImpl(createSyntheticFunctionDescriptor("\$Finally$index"))
|
val symbol = IrReturnableBlockSymbolImpl()
|
||||||
with(currentTryScope) {
|
with(currentTryScope) {
|
||||||
irBuilder.run {
|
irBuilder.run {
|
||||||
val inlinedFinally = irInlineFinally(symbol, type, expression, finallyExpression)
|
val inlinedFinally = irInlineFinally(symbol, type, expression, finallyExpression)
|
||||||
@@ -245,21 +222,19 @@ internal class FinallyBlocksLowering(val context: Context): FileLoweringPass, Ir
|
|||||||
type = context.irBuiltIns.nothingType
|
type = context.irBuiltIns.nothingType
|
||||||
)
|
)
|
||||||
val transformedFinallyExpression = finallyExpression.transform(transformer, null)
|
val transformedFinallyExpression = finallyExpression.transform(transformer, null)
|
||||||
val catchParameter = WrappedVariableDescriptor().let {
|
val catchParameter =
|
||||||
IrVariableImpl(
|
IrVariableImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
IrDeclarationOrigin.CATCH_PARAMETER,
|
IrDeclarationOrigin.CATCH_PARAMETER,
|
||||||
IrVariableSymbolImpl(it),
|
IrVariableSymbolImpl(),
|
||||||
Name.identifier("t"),
|
Name.identifier("t"),
|
||||||
symbols.throwable.owner.defaultType,
|
symbols.throwable.owner.defaultType,
|
||||||
isVar = false,
|
isVar = false,
|
||||||
isConst = false,
|
isConst = false,
|
||||||
isLateinit = false
|
isLateinit = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = this@run.parent
|
parent = this@run.parent
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val syntheticTry = IrTryImpl(
|
val syntheticTry = IrTryImpl(
|
||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
@@ -276,7 +251,7 @@ internal class FinallyBlocksLowering(val context: Context): FileLoweringPass, Ir
|
|||||||
)
|
)
|
||||||
using(TryScope(syntheticTry, transformedFinallyExpression, this)) {
|
using(TryScope(syntheticTry, transformedFinallyExpression, this)) {
|
||||||
val fallThroughType = aTry.type
|
val fallThroughType = aTry.type
|
||||||
val fallThroughSymbol = IrReturnableBlockSymbolImpl(createSyntheticFunctionDescriptor("\$Fallthrough"))
|
val fallThroughSymbol = IrReturnableBlockSymbolImpl()
|
||||||
val transformedResult = aTry.tryResult.transform(transformer, null)
|
val transformedResult = aTry.tryResult.transform(transformer, null)
|
||||||
transformedTry.tryResult = irReturn(fallThroughSymbol, transformedResult)
|
transformedTry.tryResult = irReturn(fallThroughSymbol, transformedResult)
|
||||||
for (aCatch in aTry.catches) {
|
for (aCatch in aTry.catches) {
|
||||||
|
|||||||
+6
-15
@@ -25,9 +25,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrInstanceInitializerCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrInstanceInitializerCallImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
@@ -224,11 +221,11 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
private val adaptedReferenceOriginalTarget: IrFunction? = adapteeCall?.symbol?.owner
|
private val adaptedReferenceOriginalTarget: IrFunction? = adapteeCall?.symbol?.owner
|
||||||
private val functionReferenceTarget = adaptedReferenceOriginalTarget ?: referencedFunction
|
private val functionReferenceTarget = adaptedReferenceOriginalTarget ?: referencedFunction
|
||||||
|
|
||||||
private val functionReferenceClass: IrClass = WrappedClassDescriptor().let {
|
private val functionReferenceClass: IrClass =
|
||||||
IrClassImpl(
|
IrClassImpl(
|
||||||
startOffset,endOffset,
|
startOffset,endOffset,
|
||||||
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
IrClassSymbolImpl(it),
|
IrClassSymbolImpl(),
|
||||||
"${functionReferenceTarget.name}\$FUNCTION_REFERENCE\$${context.functionReferenceCount++}".synthesizedName,
|
"${functionReferenceTarget.name}\$FUNCTION_REFERENCE\$${context.functionReferenceCount++}".synthesizedName,
|
||||||
ClassKind.CLASS,
|
ClassKind.CLASS,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
@@ -241,11 +238,9 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
isExpect = false,
|
isExpect = false,
|
||||||
isFun = false
|
isFun = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = this@FunctionReferenceBuilder.parent
|
parent = this@FunctionReferenceBuilder.parent
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private val functionReferenceThis = functionReferenceClass.thisReceiver!!
|
private val functionReferenceThis = functionReferenceClass.thisReceiver!!
|
||||||
|
|
||||||
@@ -337,11 +332,11 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
return BuiltFunctionReference(functionReferenceClass, constructor)
|
return BuiltFunctionReference(functionReferenceClass, constructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildConstructor(): IrConstructor = WrappedClassConstructorDescriptor().let {
|
private fun buildConstructor(): IrConstructor =
|
||||||
IrConstructorImpl(
|
IrConstructorImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
IrConstructorSymbolImpl(it),
|
IrConstructorSymbolImpl(),
|
||||||
Name.special("<init>"),
|
Name.special("<init>"),
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
functionReferenceClass.defaultType,
|
functionReferenceClass.defaultType,
|
||||||
@@ -350,7 +345,6 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
isPrimary = true,
|
isPrimary = true,
|
||||||
isExpect = false
|
isExpect = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = functionReferenceClass
|
parent = functionReferenceClass
|
||||||
functionReferenceClass.declarations += this
|
functionReferenceClass.declarations += this
|
||||||
|
|
||||||
@@ -387,7 +381,6 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun getFlags() =
|
private fun getFlags() =
|
||||||
(if (referencedFunction.isSuspend) 1 else 0) + getAdaptedCallableReferenceFlags() shl 1
|
(if (referencedFunction.isSuspend) 1 else 0) + getAdaptedCallableReferenceFlags() shl 1
|
||||||
@@ -418,11 +411,11 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildInvokeMethod(superFunction: IrSimpleFunction): IrSimpleFunction = WrappedSimpleFunctionDescriptor().let {
|
private fun buildInvokeMethod(superFunction: IrSimpleFunction): IrSimpleFunction =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
IrSimpleFunctionSymbolImpl(it),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
superFunction.name,
|
superFunction.name,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -436,7 +429,6 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
val function = this
|
val function = this
|
||||||
parent = functionReferenceClass
|
parent = functionReferenceClass
|
||||||
functionReferenceClass.declarations += function
|
functionReferenceClass.declarations += function
|
||||||
@@ -486,6 +478,5 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
|||||||
import org.jetbrains.kotlin.ir.builders.irDelegatingConstructorCall
|
import org.jetbrains.kotlin.ir.builders.irDelegatingConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
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.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
@@ -108,11 +107,11 @@ internal class InitializersLowering(val context: CommonBackendContext) : ClassLo
|
|||||||
|
|
||||||
val startOffset = irClass.startOffset
|
val startOffset = irClass.startOffset
|
||||||
val endOffset = irClass.endOffset
|
val endOffset = irClass.endOffset
|
||||||
val initializeFun = WrappedSimpleFunctionDescriptor().let {
|
val initializeFun =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_ANONYMOUS_INITIALIZER,
|
DECLARATION_ORIGIN_ANONYMOUS_INITIALIZER,
|
||||||
IrSimpleFunctionSymbolImpl(it),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
"INITIALIZER".synthesizedName,
|
"INITIALIZER".synthesizedName,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -126,7 +125,6 @@ internal class InitializersLowering(val context: CommonBackendContext) : ClassLo
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
parent = irClass
|
parent = irClass
|
||||||
irClass.declarations.add(this)
|
irClass.declarations.add(this)
|
||||||
|
|
||||||
@@ -134,7 +132,6 @@ internal class InitializersLowering(val context: CommonBackendContext) : ClassLo
|
|||||||
|
|
||||||
body = IrBlockBodyImpl(startOffset, endOffset, initializers)
|
body = IrBlockBodyImpl(startOffset, endOffset, initializers)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (initializer in initializers) {
|
for (initializer in initializers) {
|
||||||
initializer.transformChildrenVoid(object : IrElementTransformerVoid() {
|
initializer.transformChildrenVoid(object : IrElementTransformerVoid() {
|
||||||
|
|||||||
+18
-28
@@ -27,8 +27,6 @@ import org.jetbrains.kotlin.ir.builders.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl
|
||||||
@@ -225,11 +223,10 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
|||||||
|
|
||||||
// Generate `override fun init...(...) = this.initBy(...)`:
|
// Generate `override fun init...(...) = this.initBy(...)`:
|
||||||
|
|
||||||
val resultDescriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
return IrFunctionImpl(
|
return IrFunctionImpl(
|
||||||
constructor.startOffset, constructor.endOffset,
|
constructor.startOffset, constructor.endOffset,
|
||||||
OVERRIDING_INITIALIZER_BY_CONSTRUCTOR,
|
OVERRIDING_INITIALIZER_BY_CONSTRUCTOR,
|
||||||
IrSimpleFunctionSymbolImpl(resultDescriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
initMethod.name,
|
initMethod.name,
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
Modality.OPEN,
|
Modality.OPEN,
|
||||||
@@ -243,7 +240,6 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).also { result ->
|
).also { result ->
|
||||||
resultDescriptor.bind(result)
|
|
||||||
result.parent = irClass
|
result.parent = irClass
|
||||||
result.createDispatchReceiverParameter()
|
result.createDispatchReceiverParameter()
|
||||||
result.valueParameters += constructor.valueParameters.map { it.copyTo(result) }
|
result.valueParameters += constructor.valueParameters.map { it.copyTo(result) }
|
||||||
@@ -323,11 +319,11 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
|||||||
|
|
||||||
function.valueParameters.mapTo(parameterTypes) { nativePtrType }
|
function.valueParameters.mapTo(parameterTypes) { nativePtrType }
|
||||||
|
|
||||||
val newFunction = WrappedSimpleFunctionDescriptor().let {
|
val newFunction =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
function.startOffset, function.endOffset,
|
function.startOffset, function.endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(it),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
("imp:$selector").synthesizedName,
|
("imp:$selector").synthesizedName,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -340,29 +336,23 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
|||||||
isFakeOverride = false,
|
isFakeOverride = false,
|
||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
)
|
||||||
it.bind(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newFunction.valueParameters += parameterTypes.mapIndexed { index, type ->
|
newFunction.valueParameters += parameterTypes.mapIndexed { index, type ->
|
||||||
WrappedValueParameterDescriptor().let {
|
IrValueParameterImpl(
|
||||||
IrValueParameterImpl(
|
function.startOffset, function.endOffset,
|
||||||
function.startOffset, function.endOffset,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrValueParameterSymbolImpl(),
|
||||||
IrValueParameterSymbolImpl(it),
|
Name.identifier("p$index"),
|
||||||
Name.identifier("p$index"),
|
index,
|
||||||
index,
|
type,
|
||||||
type,
|
varargElementType = null,
|
||||||
varargElementType = null,
|
isCrossinline = false,
|
||||||
isCrossinline = false,
|
isNoinline = false,
|
||||||
isNoinline = false,
|
isHidden = false,
|
||||||
isHidden = false,
|
isAssignable = false
|
||||||
isAssignable = false
|
).apply {
|
||||||
).apply {
|
parent = newFunction
|
||||||
it.bind(this)
|
|
||||||
parent = newFunction
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-18
@@ -14,8 +14,6 @@ import org.jetbrains.kotlin.ir.builders.irCall
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetValueImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrSetValueImpl
|
||||||
@@ -478,11 +476,11 @@ internal class NativeSuspendFunctionsLowering(ctx: Context): AbstractSuspendFunc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are marker functions to split up the lowering on two parts.
|
// These are marker functions to split up the lowering on two parts.
|
||||||
private val saveState = WrappedSimpleFunctionDescriptor().let {
|
private val saveState =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(it),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
"saveState".synthesizedName,
|
"saveState".synthesizedName,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.ABSTRACT,
|
Modality.ABSTRACT,
|
||||||
@@ -495,16 +493,13 @@ internal class NativeSuspendFunctionsLowering(ctx: Context): AbstractSuspendFunc
|
|||||||
isFakeOverride = false,
|
isFakeOverride = false,
|
||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
)
|
||||||
it.bind(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val restoreState = WrappedSimpleFunctionDescriptor().let {
|
private val restoreState =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
SYNTHETIC_OFFSET, SYNTHETIC_OFFSET,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(it),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
"restoreState".synthesizedName,
|
"restoreState".synthesizedName,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
Modality.ABSTRACT,
|
Modality.ABSTRACT,
|
||||||
@@ -517,29 +512,24 @@ internal class NativeSuspendFunctionsLowering(ctx: Context): AbstractSuspendFunc
|
|||||||
isFakeOverride = false,
|
isFakeOverride = false,
|
||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
)
|
||||||
it.bind(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun IrBuilderWithScope.irVar(name: Name, type: IrType,
|
private fun IrBuilderWithScope.irVar(name: Name, type: IrType,
|
||||||
isMutable: Boolean = false,
|
isMutable: Boolean = false,
|
||||||
initializer: IrExpression? = null) = WrappedVariableDescriptor().let {
|
initializer: IrExpression? = null) =
|
||||||
IrVariableImpl(
|
IrVariableImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||||
IrVariableSymbolImpl(it),
|
IrVariableSymbolImpl(),
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
isMutable,
|
isMutable,
|
||||||
isConst = false,
|
isConst = false,
|
||||||
isLateinit = false
|
isLateinit = false
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
this.initializer = initializer
|
this.initializer = initializer
|
||||||
this.parent = this@irVar.parent
|
this.parent = this@irVar.parent
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun IrBuilderWithScope.irGetOrThrow(result: IrExpression): IrExpression =
|
private fun IrBuilderWithScope.irGetOrThrow(result: IrExpression): IrExpression =
|
||||||
irCall(symbols.kotlinResultGetOrThrow.owner).apply {
|
irCall(symbols.kotlinResultGetOrThrow.owner).apply {
|
||||||
|
|||||||
+1
-1
@@ -150,7 +150,7 @@ internal class RedundantCoercionsCleaner(val context: Context) : FileLoweringPas
|
|||||||
expression
|
expression
|
||||||
else {
|
else {
|
||||||
val oldSymbol = expression.symbol
|
val oldSymbol = expression.symbol
|
||||||
val newSymbol = IrReturnableBlockSymbolImpl(expression.descriptor)
|
val newSymbol = IrReturnableBlockSymbolImpl()
|
||||||
val transformedReturnableBlock = with(expression) {
|
val transformedReturnableBlock = with(expression) {
|
||||||
IrReturnableBlockImpl(
|
IrReturnableBlockImpl(
|
||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
|
|||||||
+8
-19
@@ -22,9 +22,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
||||||
@@ -335,11 +332,11 @@ internal class TestProcessor (val context: Context) {
|
|||||||
*/
|
*/
|
||||||
private fun buildObjectGetter(objectSymbol: IrClassSymbol,
|
private fun buildObjectGetter(objectSymbol: IrClassSymbol,
|
||||||
owner: IrClass,
|
owner: IrClass,
|
||||||
getterName: Name): IrSimpleFunction = WrappedSimpleFunctionDescriptor().let { descriptor ->
|
getterName: Name): IrSimpleFunction =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
owner.startOffset, owner.endOffset,
|
owner.startOffset, owner.endOffset,
|
||||||
TEST_SUITE_GENERATED_MEMBER,
|
TEST_SUITE_GENERATED_MEMBER,
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
getterName,
|
getterName,
|
||||||
DescriptorVisibilities.PROTECTED,
|
DescriptorVisibilities.PROTECTED,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -353,7 +350,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
parent = owner
|
parent = owner
|
||||||
|
|
||||||
val superFunction = baseClassSuite.simpleFunctions()
|
val superFunction = baseClassSuite.simpleFunctions()
|
||||||
@@ -367,7 +363,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a method in `[testSuite]` class with name `[getterName]`
|
* Builds a method in `[testSuite]` class with name `[getterName]`
|
||||||
@@ -375,11 +370,11 @@ internal class TestProcessor (val context: Context) {
|
|||||||
*/
|
*/
|
||||||
private fun buildInstanceGetter(classSymbol: IrClassSymbol,
|
private fun buildInstanceGetter(classSymbol: IrClassSymbol,
|
||||||
owner: IrClass,
|
owner: IrClass,
|
||||||
getterName: Name): IrSimpleFunction = WrappedSimpleFunctionDescriptor().let { descriptor ->
|
getterName: Name): IrSimpleFunction =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
owner.startOffset, owner.endOffset,
|
owner.startOffset, owner.endOffset,
|
||||||
TEST_SUITE_GENERATED_MEMBER,
|
TEST_SUITE_GENERATED_MEMBER,
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
IrSimpleFunctionSymbolImpl(),
|
||||||
getterName,
|
getterName,
|
||||||
DescriptorVisibilities.PROTECTED,
|
DescriptorVisibilities.PROTECTED,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
@@ -393,7 +388,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
isOperator = false,
|
isOperator = false,
|
||||||
isInfix = false
|
isInfix = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
parent = owner
|
parent = owner
|
||||||
|
|
||||||
val superFunction = baseClassSuite.simpleFunctions()
|
val superFunction = baseClassSuite.simpleFunctions()
|
||||||
@@ -407,7 +401,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
+irReturn(irCall(constructor))
|
+irReturn(irCall(constructor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private val baseClassSuiteConstructor = baseClassSuite.constructors.single {
|
private val baseClassSuiteConstructor = baseClassSuite.constructors.single {
|
||||||
it.valueParameters.size == 2
|
it.valueParameters.size == 2
|
||||||
@@ -426,11 +419,11 @@ internal class TestProcessor (val context: Context) {
|
|||||||
testSuite: IrClassSymbol,
|
testSuite: IrClassSymbol,
|
||||||
owner: IrClass,
|
owner: IrClass,
|
||||||
functions: Collection<TestFunction>,
|
functions: Collection<TestFunction>,
|
||||||
ignored: Boolean): IrConstructor = WrappedClassConstructorDescriptor().let { descriptor ->
|
ignored: Boolean): IrConstructor =
|
||||||
IrConstructorImpl(
|
IrConstructorImpl(
|
||||||
testSuite.owner.startOffset, testSuite.owner.endOffset,
|
testSuite.owner.startOffset, testSuite.owner.endOffset,
|
||||||
TEST_SUITE_GENERATED_MEMBER,
|
TEST_SUITE_GENERATED_MEMBER,
|
||||||
IrConstructorSymbolImpl(descriptor),
|
IrConstructorSymbolImpl(),
|
||||||
Name.special("<init>"),
|
Name.special("<init>"),
|
||||||
DescriptorVisibilities.PUBLIC,
|
DescriptorVisibilities.PUBLIC,
|
||||||
testSuite.typeWithStarProjections,
|
testSuite.typeWithStarProjections,
|
||||||
@@ -439,7 +432,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
isPrimary = true,
|
isPrimary = true,
|
||||||
isExpect = false
|
isExpect = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
parent = owner
|
parent = owner
|
||||||
|
|
||||||
fun IrClass.getFunction(name: String, predicate: (IrSimpleFunction) -> Boolean) =
|
fun IrClass.getFunction(name: String, predicate: (IrSimpleFunction) -> Boolean) =
|
||||||
@@ -469,7 +461,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
registerTestCase, registerFunction, functions)
|
registerTestCase, registerFunction, functions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private val IrClass.ignored: Boolean get() = annotations.hasAnnotation(IGNORE_FQ_NAME)
|
private val IrClass.ignored: Boolean get() = annotations.hasAnnotation(IGNORE_FQ_NAME)
|
||||||
|
|
||||||
@@ -479,11 +470,11 @@ internal class TestProcessor (val context: Context) {
|
|||||||
*/
|
*/
|
||||||
private fun buildClassSuite(testClass: IrClass,
|
private fun buildClassSuite(testClass: IrClass,
|
||||||
testCompanion: IrClass?,
|
testCompanion: IrClass?,
|
||||||
functions: Collection<TestFunction>): IrClass = WrappedClassDescriptor().let { descriptor ->
|
functions: Collection<TestFunction>): IrClass =
|
||||||
IrClassImpl(
|
IrClassImpl(
|
||||||
testClass.startOffset, testClass.endOffset,
|
testClass.startOffset, testClass.endOffset,
|
||||||
TEST_SUITE_CLASS,
|
TEST_SUITE_CLASS,
|
||||||
IrClassSymbolImpl(descriptor),
|
IrClassSymbolImpl(),
|
||||||
testClass.name.synthesizeSuiteClassName(),
|
testClass.name.synthesizeSuiteClassName(),
|
||||||
ClassKind.CLASS,
|
ClassKind.CLASS,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
@@ -496,7 +487,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
isExpect = false,
|
isExpect = false,
|
||||||
isFun = false
|
isFun = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
|
|
||||||
val testClassType = testClass.defaultType
|
val testClassType = testClass.defaultType
|
||||||
@@ -531,7 +521,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
superTypes += symbols.baseClassSuite.typeWith(listOf(testClassType, testCompanionType))
|
superTypes += symbols.baseClassSuite.typeWith(listOf(testClassType, testCompanionType))
|
||||||
addFakeOverrides(context.irBuiltIns)
|
addFakeOverrides(context.irBuiltIns)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
// region IR generation methods
|
// region IR generation methods
|
||||||
|
|||||||
+1
-5
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
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.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
@@ -1318,13 +1317,10 @@ internal object Devirtualization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun <T : IrElement> IrStatementsBuilder<T>.irTemporary(value: IrExpression, tempName: String, type: IrType): IrVariable {
|
fun <T : IrElement> IrStatementsBuilder<T>.irTemporary(value: IrExpression, tempName: String, type: IrType): IrVariable {
|
||||||
val descriptor = WrappedVariableDescriptor()
|
|
||||||
|
|
||||||
val temporary = IrVariableImpl(
|
val temporary = IrVariableImpl(
|
||||||
value.startOffset, value.endOffset, IrDeclarationOrigin.IR_TEMPORARY_VARIABLE, IrVariableSymbolImpl(descriptor),
|
value.startOffset, value.endOffset, IrDeclarationOrigin.IR_TEMPORARY_VARIABLE, IrVariableSymbolImpl(),
|
||||||
Name.identifier(tempName), type, isVar = false, isConst = false, isLateinit = false
|
Name.identifier(tempName), type, isVar = false, isConst = false, isLateinit = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
this.initializer = value
|
this.initializer = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -210,7 +210,7 @@ internal class KonanIrLinker(
|
|||||||
if (actualModule !== moduleDescriptor) {
|
if (actualModule !== moduleDescriptor) {
|
||||||
val moduleDeserializer = deserializersForModules[actualModule] ?: error("No module deserializer for $actualModule")
|
val moduleDeserializer = deserializersForModules[actualModule] ?: error("No module deserializer for $actualModule")
|
||||||
moduleDeserializer.addModuleReachableTopLevel(idSig)
|
moduleDeserializer.addModuleReachableTopLevel(idSig)
|
||||||
return symbolTable.referenceClassFromLinker(descriptor, idSig)
|
return symbolTable.referenceClassFromLinker(idSig)
|
||||||
}
|
}
|
||||||
|
|
||||||
return declaredDeclaration.getOrPut(idSig) { buildForwardDeclarationStub(descriptor) }.symbol
|
return declaredDeclaration.getOrPut(idSig) { buildForwardDeclarationStub(descriptor) }.symbol
|
||||||
|
|||||||
+16
-26
@@ -25,8 +25,6 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
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.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
@@ -69,11 +67,10 @@ internal fun IrExpression.isNullConst() = this is IrConst<*> && this.kind == IrC
|
|||||||
private var topLevelInitializersCounter = 0
|
private var topLevelInitializersCounter = 0
|
||||||
|
|
||||||
internal fun IrFile.addTopLevelInitializer(expression: IrExpression, context: KonanBackendContext, threadLocal: Boolean) {
|
internal fun IrFile.addTopLevelInitializer(expression: IrExpression, context: KonanBackendContext, threadLocal: Boolean) {
|
||||||
val descriptor = WrappedFieldDescriptor()
|
|
||||||
val irField = IrFieldImpl(
|
val irField = IrFieldImpl(
|
||||||
expression.startOffset, expression.endOffset,
|
expression.startOffset, expression.endOffset,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrFieldSymbolImpl(descriptor),
|
IrFieldSymbolImpl(),
|
||||||
"topLevelInitializer${topLevelInitializersCounter++}".synthesizedName,
|
"topLevelInitializer${topLevelInitializersCounter++}".synthesizedName,
|
||||||
expression.type,
|
expression.type,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
@@ -81,8 +78,6 @@ internal fun IrFile.addTopLevelInitializer(expression: IrExpression, context: Ko
|
|||||||
isExternal = false,
|
isExternal = false,
|
||||||
isStatic = true,
|
isStatic = true,
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
|
||||||
|
|
||||||
expression.setDeclarationsParent(this)
|
expression.setDeclarationsParent(this)
|
||||||
|
|
||||||
if (threadLocal)
|
if (threadLocal)
|
||||||
@@ -264,21 +259,18 @@ fun IrBuilderWithScope.irSetVar(variable: IrVariable, value: IrExpression) =
|
|||||||
fun IrBuilderWithScope.irCatch(type: IrType) =
|
fun IrBuilderWithScope.irCatch(type: IrType) =
|
||||||
IrCatchImpl(
|
IrCatchImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
WrappedVariableDescriptor().let { descriptor ->
|
IrVariableImpl(
|
||||||
IrVariableImpl(
|
startOffset,
|
||||||
startOffset,
|
endOffset,
|
||||||
endOffset,
|
IrDeclarationOrigin.IR_TEMPORARY_VARIABLE,
|
||||||
IrDeclarationOrigin.IR_TEMPORARY_VARIABLE,
|
IrVariableSymbolImpl(),
|
||||||
IrVariableSymbolImpl(descriptor),
|
Name.identifier("e"),
|
||||||
Name.identifier("e"),
|
type,
|
||||||
type,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false
|
||||||
false
|
).apply {
|
||||||
).apply {
|
parent = this@irCatch.parent
|
||||||
descriptor.bind(this)
|
|
||||||
parent = this@irCatch.parent
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -345,11 +337,11 @@ fun createField(
|
|||||||
name: Name,
|
name: Name,
|
||||||
isMutable: Boolean,
|
isMutable: Boolean,
|
||||||
owner: IrClass
|
owner: IrClass
|
||||||
) = WrappedFieldDescriptor().let {
|
) =
|
||||||
IrFieldImpl(
|
IrFieldImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
origin,
|
origin,
|
||||||
IrFieldSymbolImpl(it),
|
IrFieldSymbolImpl(),
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
DescriptorVisibilities.PRIVATE,
|
DescriptorVisibilities.PRIVATE,
|
||||||
@@ -357,14 +349,12 @@ fun createField(
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
).apply {
|
).apply {
|
||||||
it.bind(this)
|
|
||||||
owner.declarations += this
|
owner.declarations += this
|
||||||
parent = owner
|
parent = owner
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun IrValueParameter.copy(newDescriptor: ParameterDescriptor): IrValueParameter {
|
fun IrValueParameter.copy(newDescriptor: ParameterDescriptor): IrValueParameter {
|
||||||
// Aggressive use of WrappedDescriptors during deserialization
|
// Aggressive use of IrBasedDescriptors during deserialization
|
||||||
// makes these types different.
|
// makes these types different.
|
||||||
// Let's hope they not really used afterwards.
|
// Let's hope they not really used afterwards.
|
||||||
//assert(this.descriptor.type == newDescriptor.type) {
|
//assert(this.descriptor.type == newDescriptor.type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user