[IR] Unbind construction methods of IrValueParameterImpl from symbol.descriptor

This commit is contained in:
Mikhail Glukhikh
2020-05-18 19:15:32 +03:00
parent 03f2c6d38a
commit 784d3a9005
3 changed files with 37 additions and 23 deletions
@@ -35,17 +35,22 @@ class IrValueParameterImpl(
endOffset: Int, endOffset: Int,
origin: IrDeclarationOrigin, origin: IrDeclarationOrigin,
override val symbol: IrValueParameterSymbol, override val symbol: IrValueParameterSymbol,
override val name: Name = symbol.descriptor.name, override val name: Name,
override val index: Int = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.index ?: -1, override val index: Int,
override val type: IrType, override val type: IrType,
override val varargElementType: IrType?, override val varargElementType: IrType?,
override val isCrossinline: Boolean = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isCrossinline ?: false, override val isCrossinline: Boolean,
override val isNoinline: Boolean = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isNoinline ?: false override val isNoinline: Boolean
) : ) :
IrDeclarationBase<ValueParameterCarrier>(startOffset, endOffset, origin), IrDeclarationBase<ValueParameterCarrier>(startOffset, endOffset, origin),
IrValueParameter, IrValueParameter,
ValueParameterCarrier { ValueParameterCarrier {
@Deprecated(
"This constructor is left for native compilation purpose only. " +
"It takes value parameter attributes from symbol.descriptor " +
"Please either provide parameter attributes or its descriptor explicitly"
)
constructor( constructor(
startOffset: Int, startOffset: Int,
endOffset: Int, endOffset: Int,
@@ -53,17 +58,15 @@ class IrValueParameterImpl(
symbol: IrValueParameterSymbol, symbol: IrValueParameterSymbol,
type: IrType, type: IrType,
varargElementType: IrType? varargElementType: IrType?
) : ) : this(
this( startOffset, endOffset, origin, symbol,
startOffset, endOffset, origin, name = symbol.descriptor.name,
symbol, index = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.index ?: -1,
symbol.descriptor.name, type = type,
symbol.descriptor.safeAs<ValueParameterDescriptor>()?.index ?: -1, varargElementType = varargElementType,
type, isCrossinline = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isCrossinline == true,
varargElementType, isNoinline = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isNoinline == true
symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isCrossinline ?: false, )
symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isNoinline ?: false
)
constructor( constructor(
startOffset: Int, startOffset: Int,
@@ -71,9 +74,17 @@ class IrValueParameterImpl(
origin: IrDeclarationOrigin, origin: IrDeclarationOrigin,
descriptor: ParameterDescriptor, descriptor: ParameterDescriptor,
type: IrType, type: IrType,
varargElementType: IrType? varargElementType: IrType?,
) : name: Name = descriptor.name,
this(startOffset, endOffset, origin, IrValueParameterSymbolImpl(descriptor), type, varargElementType) symbol: IrValueParameterSymbol = IrValueParameterSymbolImpl(descriptor)
) : this(
startOffset, endOffset, origin, symbol,
name,
index = descriptor.safeAs<ValueParameterDescriptor>()?.index ?: -1,
type = type, varargElementType = varargElementType,
isCrossinline = descriptor.safeAs<ValueParameterDescriptor>()?.isCrossinline ?: false,
isNoinline = descriptor.safeAs<ValueParameterDescriptor>()?.isNoinline ?: false
)
override val descriptor: ParameterDescriptor = symbol.descriptor override val descriptor: ParameterDescriptor = symbol.descriptor
@@ -357,9 +357,11 @@ class IrFunctionFactory(private val irBuiltIns: IrBuiltIns, private val symbolTa
offset, offset,
offset, offset,
memberOrigin, memberOrigin,
symbol, descriptor,
toIrType(descriptor.type), symbol = symbol,
varargType?.let { toIrType(it) }).also { type = toIrType(descriptor.type),
varargElementType = varargType?.let { toIrType(it) }
).also {
it.parent = this it.parent = this
} }
} }
@@ -800,9 +800,10 @@ open class SymbolTable(
varargElementType: IrType? = null, varargElementType: IrType? = null,
valueParameterFactory: (IrValueParameterSymbol) -> IrValueParameter = { valueParameterFactory: (IrValueParameterSymbol) -> IrValueParameter = {
IrValueParameterImpl( IrValueParameterImpl(
startOffset, endOffset, origin, it, startOffset, endOffset, origin, descriptor,
nameProvider.nameForDeclaration(descriptor), name = nameProvider.nameForDeclaration(descriptor),
type = type, varargElementType = varargElementType, type = type, varargElementType = varargElementType,
symbol = it
) )
} }
): IrValueParameter = ): IrValueParameter =