[FIR/IR generator] Rename field's needAcceptAndTransform to isChild

This better describes the semantics.
This commit is contained in:
Sergej Jaskiewicz
2023-11-29 13:08:00 +01:00
committed by Space Team
parent 02052421e6
commit d0f87f9aba
8 changed files with 37 additions and 35 deletions
@@ -104,8 +104,7 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("DeclarationDescriptor")
+field("origin", type(Packages.declarations, "IrDeclarationOrigin"))
+field("parent", declarationParent) {
needAcceptAndTransform = false
+field("parent", declarationParent, isChild = false) {
skipInIrFactory()
}
+factory
@@ -316,13 +315,11 @@ object IrTree : AbstractTreeBuilder() {
idempotence invariant and can contain a chain of declarations.
""".trimIndent()
+field("attributeOwnerId", attributeContainer) {
needAcceptAndTransform = false
+field("attributeOwnerId", attributeContainer, isChild = false) {
skipInIrFactory()
}
// null <=> this element wasn't inlined
+field("originalBeforeInline", attributeContainer, nullable = true) {
needAcceptAndTransform = false
+field("originalBeforeInline", attributeContainer, nullable = true, isChild = false) {
skipInIrFactory()
}
}
@@ -552,9 +549,7 @@ object IrTree : AbstractTreeBuilder() {
+listField("importedScripts", scriptSymbolType, mutability = Var, nullable = true)
+listField("earlierScripts", scriptSymbolType, mutability = Var, nullable = true)
+field("targetClass", classSymbolType, nullable = true)
+field("constructor", constructor, nullable = true) { // K1
needAcceptAndTransform = false
}
+field("constructor", constructor, nullable = true, isChild = false) // K1
}
val simpleFunction: Element by element(Declaration) {
isLeaf = true
@@ -645,9 +640,7 @@ object IrTree : AbstractTreeBuilder() {
parent(metadataSourceOwner)
+symbol(fileSymbolType)
+field("module", moduleFragment) {
needAcceptAndTransform = false
}
+field("module", moduleFragment, isChild = false)
+field("fileEntry", type(Packages.tree, "IrFileEntry"))
}
@@ -659,13 +652,11 @@ object IrTree : AbstractTreeBuilder() {
parent(varargElement)
parent(attributeContainer)
+field("attributeOwnerId", attributeContainer) {
needAcceptAndTransform = false
+field("attributeOwnerId", attributeContainer, isChild = false) {
baseDefaultValue = "this"
skipInIrFactory()
}
+field("originalBeforeInline", attributeContainer, nullable = true) {
needAcceptAndTransform = false
+field("originalBeforeInline", attributeContainer, nullable = true, isChild = false) {
baseDefaultValue = "null"
skipInIrFactory()
}
@@ -884,9 +875,7 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("loop", loop) {
needAcceptAndTransform = false
}
+field("loop", loop, isChild = false)
+field("label", string, nullable = true) {
baseDefaultValue = "null"
}
@@ -75,9 +75,13 @@ abstract class AbstractTreeBuilder {
type: TypeRefWithNullability,
nullable: Boolean = false,
mutable: Boolean = true,
isChild: Boolean = true,
initializer: SingleField.() -> Unit = {}
): SingleField {
return SingleField(name, type.copy(nullable), mutable).apply(initializer)
return SingleField(name, type.copy(nullable), mutable).apply {
this.isChild = isChild
initializer()
}
}
protected fun listField(
@@ -85,6 +89,7 @@ abstract class AbstractTreeBuilder {
baseType: TypeRef,
nullable: Boolean = false,
mutability: ListField.Mutability,
isChild: Boolean = true,
initializer: ListField.() -> Unit = {}
): ListField {
val listType = when (mutability) {
@@ -98,7 +103,10 @@ abstract class AbstractTreeBuilder {
listType = listType,
isNullable = nullable,
mutable = mutability == ListField.Mutability.Var,
).apply(initializer)
).apply(initializer).apply {
this.isChild = isChild
initializer()
}
}
fun build(): Model {
@@ -158,7 +158,7 @@ sealed class Field(
val useInIrFactoryStrategy: UseFieldAsParameterInIrFactoryStrategy
get() = customUseInIrFactoryStrategy
?: if (needAcceptAndTransform && containsElement) {
?: if (isChild && containsElement) {
UseFieldAsParameterInIrFactoryStrategy.No
} else {
UseFieldAsParameterInIrFactoryStrategy.Yes(null)