Fix rebase
This commit is contained in:
@@ -266,18 +266,12 @@ class JsIrBackendContext(
|
||||
primitiveClassesObject.owner.declarations.filterIsInstance<IrProperty>()
|
||||
}
|
||||
|
||||
val primitiveClassProperties by lazy { primitiveClassesObject.declarations.filterIsInstance<IrProperty>() }
|
||||
val primitiveClassFunctionClass by lazy {
|
||||
primitiveClassesObject.declarations
|
||||
primitiveClassesObject.owner.declarations
|
||||
.filterIsInstance<IrSimpleFunction>()
|
||||
.find { it.name == Name.identifier("functionClass") }!!
|
||||
}
|
||||
|
||||
val throwableClass by lazy {
|
||||
symbolTable.referenceClass(
|
||||
getClass(JsIrBackendContext.KOTLIN_PACKAGE_FQN.child(Name.identifier("Throwable")))
|
||||
)
|
||||
}
|
||||
val throwableConstructors by lazy { throwableClass.owner.declarations.filterIsInstance<IrConstructor>().map { it.symbol } }
|
||||
val defaultThrowableCtor by lazy { throwableConstructors.single { it.owner.valueParameters.size == 0 } }
|
||||
|
||||
|
||||
+4
-23
@@ -29,20 +29,9 @@ class ClassReferenceLowering(val context: JsIrBackendContext) : FileLoweringPass
|
||||
|
||||
private val primitiveClassProperties = context.primitiveClassProperties
|
||||
|
||||
private val booleanClass by lazy {
|
||||
primitiveClassProperties.singleOrNull { it.name == Name.identifier("booleanClass") }?.getter
|
||||
?: primitiveClassesObject.owner.declarations.filterIsInstance<IrSimpleFunction>().single { it.name == Name.special("<get-booleanClass>") }
|
||||
}
|
||||
private val intClass by lazy {
|
||||
primitiveClassProperties.singleOrNull { it.name == Name.identifier("intClass") }?.getter
|
||||
?: primitiveClassesObject.owner.declarations.filterIsInstance<IrSimpleFunction>().single { it.name == Name.special("<get-intClass>") }
|
||||
}
|
||||
private val doubleClass by lazy {
|
||||
primitiveClassProperties.singleOrNull { it.name == Name.identifier("doubleClass") }?.getter
|
||||
?: primitiveClassesObject.owner.declarations.filterIsInstance<IrSimpleFunction>().single { it.name == Name.special("<get-doubleClass>") }
|
||||
}
|
||||
private fun primitiveClassProperty(name: String) =
|
||||
primitiveClassProperties.single { it.name == Name.identifier(name) }
|
||||
primitiveClassProperties.singleOrNull { it.name == Name.identifier(name) }?.getter
|
||||
?: primitiveClassesObject.owner.declarations.filterIsInstance<IrSimpleFunction>().single { it.name == Name.special("<get-$name>") }
|
||||
|
||||
private val finalPrimitiveClasses by lazy {
|
||||
mapOf(
|
||||
@@ -64,7 +53,7 @@ class ClassReferenceLowering(val context: JsIrBackendContext) : FileLoweringPass
|
||||
IrType::isFloatArray to "floatArrayClass",
|
||||
IrType::isDoubleArray to "doubleArrayClass"
|
||||
).mapValues {
|
||||
primitiveClassProperty(it.value).getter!!
|
||||
primitiveClassProperty(it.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +63,7 @@ class ClassReferenceLowering(val context: JsIrBackendContext) : FileLoweringPass
|
||||
IrType::isNumber to "numberClass",
|
||||
IrType::isNothing to "nothingClass"
|
||||
).mapValues {
|
||||
primitiveClassProperty(it.value).getter!!
|
||||
primitiveClassProperty(it.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,14 +82,6 @@ class ClassReferenceLowering(val context: JsIrBackendContext) : FileLoweringPass
|
||||
dispatchReceiver = JsIrBuilder.buildGetObjectValue(primitiveClassesObject.owner.defaultType, primitiveClassesObject)
|
||||
}
|
||||
|
||||
private fun callGetKClass(returnType: IrType, typeArgument: IrType) = when {
|
||||
typeArgument.isBoolean() -> getPrimitiveClass(booleanClass, returnType)
|
||||
typeArgument.isByte() -> getPrimitiveClass(intClass, returnType)
|
||||
typeArgument.isShort() -> getPrimitiveClass(intClass, returnType)
|
||||
typeArgument.isInt() -> getPrimitiveClass(intClass, returnType)
|
||||
typeArgument.isFloat() -> getPrimitiveClass(doubleClass, returnType)
|
||||
typeArgument.isDouble() -> getPrimitiveClass(doubleClass, returnType)
|
||||
else -> JsIrBuilder.buildCall(intrinsics.jsGetKClass, returnType, listOf(typeArgument)).apply {
|
||||
private fun getFinalPrimitiveKClass(returnType: IrType, typeArgument: IrType): IrCall? {
|
||||
for ((typePredicate, v) in finalPrimitiveClasses) {
|
||||
if (typePredicate(typeArgument))
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ class SimpleNameGenerator : NameGenerator {
|
||||
if (declaration.kind == ClassKind.OBJECT || declaration.name.isSpecial || declaration.visibility == Visibilities.LOCAL) {
|
||||
val parent = declaration.parent
|
||||
when (parent) {
|
||||
is IrDeclaration -> nameBuilder.append(getNameForDeclaration(parent, context))
|
||||
is IrDeclarationWithName -> nameBuilder.append(getNameForDeclaration(parent, context))
|
||||
is IrPackageFragment -> nameBuilder.append(parent.fqName.asString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ class IrBuiltIns(
|
||||
val stringType by lazy { string.toIrType() }
|
||||
val stringClass by lazy { builtIns.string.toIrSymbol() }
|
||||
|
||||
val collectionClass by lazy { builtIns.collection.toIrSymbol() }
|
||||
val collectionClass = builtIns.collection.toIrSymbol()
|
||||
|
||||
val arrayType by lazy { builtIns.array.toIrType(symbolTable = symbolTable) }
|
||||
val arrayClass by lazy { builtIns.array.toIrSymbol() }
|
||||
|
||||
Reference in New Issue
Block a user