[FIR/IR generator] Inherit TypeRef from Importable
This is the first step to replace the usages of `Importable` in the FIR generator with `TypeRef`. This is a step towards commonizing the code generator between FIR and IR: KT-61970
This commit is contained in:
committed by
Space Team
parent
d86161bccb
commit
3a5e69d651
+17
@@ -10,6 +10,7 @@ import com.squareup.kotlinpoet.PropertySpec
|
||||
import com.squareup.kotlinpoet.TypeSpec
|
||||
import org.jetbrains.kotlin.generators.tree.*
|
||||
import org.jetbrains.kotlin.ir.generator.BASE_PACKAGE
|
||||
import org.jetbrains.kotlin.ir.generator.model.Element
|
||||
import org.jetbrains.kotlin.ir.generator.util.*
|
||||
|
||||
class Config(
|
||||
@@ -71,6 +72,14 @@ class ElementConfig(
|
||||
|
||||
override fun toString() = element.name
|
||||
|
||||
override val packageName: String
|
||||
get() = category.packageName
|
||||
|
||||
override val type: String
|
||||
get() = Element.elementName2typeName(name)
|
||||
|
||||
override fun getTypeWithArguments(notNull: Boolean): String = type
|
||||
|
||||
enum class Category(private val packageDir: String, val defaultVisitorParam: String) {
|
||||
Expression("expressions", "expression"),
|
||||
Declaration("declarations", "declaration"),
|
||||
@@ -93,6 +102,14 @@ class ElementConfigRef(
|
||||
override fun copy(nullable: Boolean) = ElementConfigRef(element, args, nullable)
|
||||
|
||||
override fun toString() = element.name
|
||||
|
||||
override val type: String
|
||||
get() = element.type
|
||||
|
||||
override val packageName: String
|
||||
get() = element.packageName
|
||||
|
||||
override fun getTypeWithArguments(notNull: Boolean): String = type + generics
|
||||
}
|
||||
|
||||
sealed class UseFieldAsParameterInIrFactoryStrategy {
|
||||
|
||||
+8
@@ -87,6 +87,14 @@ data class ElementRef(
|
||||
override fun copy(args: Map<NamedTypeParameterRef, TypeRef>) = ElementRef(element, args, nullable)
|
||||
override fun copy(nullable: Boolean) = ElementRef(element, args, nullable)
|
||||
override fun toString() = "${element.name}<${args}>"
|
||||
|
||||
override val type: String
|
||||
get() = element.typeName
|
||||
|
||||
override val packageName: String
|
||||
get() = element.packageName
|
||||
|
||||
override fun getTypeWithArguments(notNull: Boolean): String = type + generics
|
||||
}
|
||||
|
||||
sealed class Field(
|
||||
|
||||
+10
-1
@@ -12,7 +12,16 @@ import org.jetbrains.kotlin.utils.addToStdlib.UnsafeCastFunction
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.castAll
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.partitionIsInstance
|
||||
|
||||
private object InferredOverriddenType : TypeRef
|
||||
private object InferredOverriddenType : TypeRef {
|
||||
override val type: String
|
||||
get() = error("not supported")
|
||||
override val packageName: String?
|
||||
get() = null
|
||||
|
||||
override fun getTypeWithArguments(notNull: Boolean): String {
|
||||
error("not supported")
|
||||
}
|
||||
}
|
||||
|
||||
data class Model(val elements: List<Element>, val rootElement: Element)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user