[IR generator] Inherit Element from AbstractElement
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
f9d17a2d51
commit
7ab4ca6f51
+2
-10
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.generators.tree.ElementOrRef
|
||||
import org.jetbrains.kotlin.generators.tree.ElementOrRef as GenericElementOrRef
|
||||
import org.jetbrains.kotlin.generators.tree.ElementRef as GenericElementRef
|
||||
|
||||
class Element(override val name: String, kind: Kind) : AbstractElement<Element, Field> {
|
||||
class Element(override val name: String, kind: Kind) : AbstractElement<Element, Field>() {
|
||||
companion object {
|
||||
private val allowedKinds = setOf(
|
||||
ImplementationKind.Interface,
|
||||
@@ -31,10 +31,6 @@ class Element(override val name: String, kind: Kind) : AbstractElement<Element,
|
||||
override val nullable: Boolean
|
||||
get() = false
|
||||
|
||||
override fun copy(nullable: Boolean) = ElementRef(this, args, nullable)
|
||||
|
||||
override fun copy(args: Map<NamedTypeParameterRef, TypeRef>) = ElementRef(this, args, nullable)
|
||||
|
||||
override val fields = mutableSetOf<Field>()
|
||||
override val type: String = "Fir$name"
|
||||
override val packageName: String = BASE_PACKAGE + kind.packageName.let { if (it.isBlank()) it else "." + it }
|
||||
@@ -63,7 +59,7 @@ class Element(override val name: String, kind: Kind) : AbstractElement<Element,
|
||||
var doesNotNeedImplementation: Boolean = false
|
||||
|
||||
val needTransformOtherChildren: Boolean get() = _needTransformOtherChildren || parentRefs.any { it.element.needTransformOtherChildren }
|
||||
override val overridenFields: MutableMap<Field, MutableMap<Field, Boolean>> = mutableMapOf()
|
||||
val overridenFields: MutableMap<Field, MutableMap<Field, Boolean>> = mutableMapOf()
|
||||
val useNullableForReplace: MutableSet<Field> = mutableSetOf()
|
||||
val allImplementations: List<Implementation> by lazy {
|
||||
if (doesNotNeedImplementation) {
|
||||
@@ -149,10 +145,6 @@ class Element(override val name: String, kind: Kind) : AbstractElement<Element,
|
||||
return typeWithArguments
|
||||
}
|
||||
|
||||
override fun get(fieldName: String): Field? {
|
||||
return allFields.firstOrNull { it.name == fieldName }
|
||||
}
|
||||
|
||||
enum class Kind(val packageName: String) {
|
||||
Expression("expressions"),
|
||||
Declaration("declarations"),
|
||||
|
||||
Reference in New Issue
Block a user