JVM_IR. support big arity
This commit is contained in:
@@ -124,6 +124,8 @@ class IrBuiltIns(
|
||||
val stringType = string.toIrType()
|
||||
val stringClass = builtIns.string.toIrSymbol()
|
||||
|
||||
val arrayClass = builtIns.array.toIrSymbol()
|
||||
|
||||
val throwableType = builtIns.throwable.defaultType.toIrType()
|
||||
val throwableClass = builtIns.throwable.toIrSymbol()
|
||||
|
||||
@@ -152,6 +154,7 @@ class IrBuiltIns(
|
||||
val throwIseFun = defineOperator("THROW_ISE", nothing, listOf())
|
||||
val booleanNotFun = defineOperator("NOT", bool, listOf(bool))
|
||||
val noWhenBranchMatchedExceptionFun = defineOperator("noWhenBranchMatchedException", nothing, listOf())
|
||||
val illegalArgumentExceptionFun = defineOperator("illegalArgumentException", nothing, listOf(string))
|
||||
|
||||
val eqeqeq = eqeqeqFun.descriptor
|
||||
val eqeq = eqeqFun.descriptor
|
||||
@@ -159,6 +162,7 @@ class IrBuiltIns(
|
||||
val throwCce = throwCceFun.descriptor
|
||||
val booleanNot = booleanNotFun.descriptor
|
||||
val noWhenBranchMatchedException = noWhenBranchMatchedExceptionFun.descriptor
|
||||
val illegalArgumentException = illegalArgumentExceptionFun.descriptor
|
||||
|
||||
val eqeqeqSymbol = eqeqeqFun.symbol
|
||||
val eqeqSymbol = eqeqFun.symbol
|
||||
@@ -167,6 +171,7 @@ class IrBuiltIns(
|
||||
val throwIseSymbol = throwIseFun.symbol
|
||||
val booleanNotSymbol = booleanNotFun.symbol
|
||||
val noWhenBranchMatchedExceptionSymbol = noWhenBranchMatchedExceptionFun.symbol
|
||||
val illegalArgumentExceptionSymbol = illegalArgumentExceptionFun.symbol
|
||||
|
||||
val enumValueOfFun = createEnumValueOfFun()
|
||||
val enumValueOf = enumValueOfFun.descriptor
|
||||
|
||||
@@ -266,6 +266,26 @@ val IrClass.defaultType: IrType
|
||||
|
||||
val IrSimpleFunction.isReal: Boolean get() = descriptor.kind.isReal
|
||||
|
||||
fun IrClass.isImmediateSubClassOf(ancestor: IrClass) = ancestor.symbol in superTypes.mapNotNull {
|
||||
(it as? IrSimpleType)?.classifier
|
||||
}
|
||||
|
||||
fun IrClass.isSubclassOf(ancestor: IrClass): Boolean {
|
||||
|
||||
val alreadyVisited = mutableSetOf<IrClass>()
|
||||
|
||||
fun IrClass.hasAncestorInSuperTypes(): Boolean = when {
|
||||
this === ancestor -> true
|
||||
this in alreadyVisited -> false
|
||||
else -> {
|
||||
alreadyVisited.add(this)
|
||||
superTypes.mapNotNull { ((it as? IrSimpleType)?.classifier as? IrClassSymbol)?.owner }.any { it.hasAncestorInSuperTypes() }
|
||||
}
|
||||
}
|
||||
|
||||
return this.hasAncestorInSuperTypes()
|
||||
}
|
||||
|
||||
// This implementation is from kotlin-native
|
||||
// TODO: use this implementation instead of any other
|
||||
fun IrSimpleFunction.resolveFakeOverride(): IrSimpleFunction? {
|
||||
@@ -339,6 +359,12 @@ fun IrDeclaration.isEffectivelyExternal(): Boolean {
|
||||
|
||||
fun IrDeclaration.isDynamic() = this is IrFunction && dispatchReceiverParameter?.type is IrDynamicType
|
||||
|
||||
inline fun <reified T : IrDeclaration> IrDeclarationContainer.findDeclaration(predicate: (T) -> Boolean): T? =
|
||||
declarations.find { it is T && predicate(it) } as? T
|
||||
|
||||
inline fun <reified T : IrDeclaration> IrDeclarationContainer.filterDeclarations(predicate: (T) -> Boolean): List<T> =
|
||||
declarations.filter { it is T && predicate(it) } as List<T>
|
||||
|
||||
fun IrValueParameter.copy(newDescriptor: ParameterDescriptor): IrValueParameter {
|
||||
assert(this.descriptor.type == newDescriptor.type)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user