[IR] Autogenerate IrErrorDeclarationImpl
This commit is contained in:
committed by
Space Team
parent
2b26163030
commit
f92670024e
+11
-5
@@ -3,6 +3,11 @@
|
|||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// This file was generated automatically. See compiler/ir/ir.tree/tree-generator/ReadMe.md.
|
||||||
|
// DO NOT MODIFY IT MANUALLY.
|
||||||
|
|
||||||
|
@file:Suppress("DuplicatedCode")
|
||||||
|
|
||||||
package org.jetbrains.kotlin.ir.declarations.impl
|
package org.jetbrains.kotlin.ir.declarations.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
@@ -15,18 +20,19 @@ import org.jetbrains.kotlin.ir.declarations.IrFactory
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
|
||||||
class IrErrorDeclarationImpl @IrImplementationDetail constructor(
|
class IrErrorDeclarationImpl @IrImplementationDetail constructor(
|
||||||
override val startOffset: Int,
|
override val startOffset: Int,
|
||||||
override val endOffset: Int,
|
override val endOffset: Int,
|
||||||
override val factory: IrFactory,
|
|
||||||
override var origin: IrDeclarationOrigin,
|
override var origin: IrDeclarationOrigin,
|
||||||
|
override val factory: IrFactory,
|
||||||
) : IrErrorDeclaration() {
|
) : IrErrorDeclaration() {
|
||||||
override val symbol: IrSymbol
|
override var annotations: List<IrConstructorCall> = emptyList()
|
||||||
get() = error("Should never be called")
|
|
||||||
|
|
||||||
|
@ObsoleteDescriptorBasedAPI
|
||||||
override lateinit var descriptor: DeclarationDescriptor
|
override lateinit var descriptor: DeclarationDescriptor
|
||||||
|
|
||||||
override lateinit var parent: IrDeclarationParent
|
override lateinit var parent: IrDeclarationParent
|
||||||
override var annotations: List<IrConstructorCall> = emptyList()
|
|
||||||
|
override val symbol: IrSymbol
|
||||||
|
get() = error("Should never be called")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.ir.declarations.impl
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.IrImplementationDetail
|
import org.jetbrains.kotlin.ir.IrImplementationDetail
|
||||||
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||||
@@ -134,6 +135,7 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
factory = this
|
factory = this
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
override fun createErrorDeclaration(
|
override fun createErrorDeclaration(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
|
|||||||
+14
-11
@@ -1,25 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.ir.generator
|
package org.jetbrains.kotlin.ir.generator
|
||||||
|
|
||||||
import org.jetbrains.kotlin.generators.tree.ArbitraryImportable
|
import org.jetbrains.kotlin.generators.tree.*
|
||||||
import org.jetbrains.kotlin.generators.tree.ImplementationKind
|
|
||||||
import org.jetbrains.kotlin.generators.tree.ClassRef
|
|
||||||
import org.jetbrains.kotlin.generators.tree.ImportCollector
|
|
||||||
import org.jetbrains.kotlin.generators.tree.StandardTypes
|
|
||||||
import org.jetbrains.kotlin.generators.tree.Visibility
|
|
||||||
import org.jetbrains.kotlin.generators.tree.printer.FunctionParameter
|
import org.jetbrains.kotlin.generators.tree.printer.FunctionParameter
|
||||||
import org.jetbrains.kotlin.generators.tree.printer.VariableKind
|
import org.jetbrains.kotlin.generators.tree.printer.VariableKind
|
||||||
import org.jetbrains.kotlin.generators.tree.printer.printFunctionWithBlockBody
|
import org.jetbrains.kotlin.generators.tree.printer.printFunctionWithBlockBody
|
||||||
import org.jetbrains.kotlin.generators.tree.printer.printPropertyDeclaration
|
import org.jetbrains.kotlin.generators.tree.printer.printPropertyDeclaration
|
||||||
import org.jetbrains.kotlin.ir.generator.config.AbstractIrTreeImplementationConfigurator
|
import org.jetbrains.kotlin.ir.generator.config.AbstractIrTreeImplementationConfigurator
|
||||||
import org.jetbrains.kotlin.ir.generator.model.Element
|
import org.jetbrains.kotlin.ir.generator.model.Element
|
||||||
import org.jetbrains.kotlin.ir.generator.model.Implementation
|
|
||||||
import org.jetbrains.kotlin.ir.generator.model.ListField
|
import org.jetbrains.kotlin.ir.generator.model.ListField
|
||||||
import org.jetbrains.kotlin.utils.SmartPrinter
|
|
||||||
|
|
||||||
object ImplementationConfigurator : AbstractIrTreeImplementationConfigurator() {
|
object ImplementationConfigurator : AbstractIrTreeImplementationConfigurator() {
|
||||||
override fun configure(model: Model): Unit = with(IrTree) {
|
override fun configure(model: Model): Unit = with(IrTree) {
|
||||||
@@ -117,7 +110,13 @@ object ImplementationConfigurator : AbstractIrTreeImplementationConfigurator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl(errorDeclaration) {
|
impl(errorDeclaration) {
|
||||||
implementation.doPrint = false
|
implementation.bindOwnedSymbol = false
|
||||||
|
default("symbol") {
|
||||||
|
value = "error(\"Should never be called\")"
|
||||||
|
withGetter = true
|
||||||
|
}
|
||||||
|
isMutable("descriptor")
|
||||||
|
isLateinit("descriptor")
|
||||||
}
|
}
|
||||||
|
|
||||||
impl(externalPackageFragment) {
|
impl(externalPackageFragment) {
|
||||||
@@ -130,6 +129,7 @@ object ImplementationConfigurator : AbstractIrTreeImplementationConfigurator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ImplementationContext.configureDeclarationWithLateBindinig(symbolType: ClassRef<*>) {
|
private fun ImplementationContext.configureDeclarationWithLateBindinig(symbolType: ClassRef<*>) {
|
||||||
|
implementation.bindOwnedSymbol = false
|
||||||
default("isBound") {
|
default("isBound") {
|
||||||
value = "_symbol != null"
|
value = "_symbol != null"
|
||||||
withGetter = true
|
withGetter = true
|
||||||
@@ -201,7 +201,10 @@ object ImplementationConfigurator : AbstractIrTreeImplementationConfigurator() {
|
|||||||
default(it, "ArrayList(2)")
|
default(it, "ArrayList(2)")
|
||||||
}
|
}
|
||||||
|
|
||||||
configureFieldInAllImplementations("descriptor", { impl -> impl.allFields.any { it.name == "symbol" } }) {
|
configureFieldInAllImplementations(
|
||||||
|
"descriptor",
|
||||||
|
{ impl -> impl.allFields.any { it.name == "symbol" } && impl.element != IrTree.errorDeclaration }
|
||||||
|
) {
|
||||||
default(it, "symbol.descriptor", withGetter = true)
|
default(it, "symbol.descriptor", withGetter = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -17,6 +17,7 @@ class Implementation(element: Element, name: String?) : AbstractImplementation<I
|
|||||||
|
|
||||||
var generationCallback: (context(ImportCollector) SmartPrinter.() -> Unit)? = null
|
var generationCallback: (context(ImportCollector) SmartPrinter.() -> Unit)? = null
|
||||||
|
|
||||||
|
var bindOwnedSymbol = true
|
||||||
override var doPrint = true
|
override var doPrint = true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
+4
-4
@@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.generator.print
|
package org.jetbrains.kotlin.ir.generator.print
|
||||||
|
|
||||||
import com.intellij.psi.util.PsiExpressionTrimRenderer.render
|
|
||||||
import org.jetbrains.kotlin.generators.tree.*
|
import org.jetbrains.kotlin.generators.tree.*
|
||||||
import org.jetbrains.kotlin.generators.tree.printer.printBlock
|
import org.jetbrains.kotlin.generators.tree.printer.printBlock
|
||||||
import org.jetbrains.kotlin.ir.generator.IrTree
|
import org.jetbrains.kotlin.ir.generator.IrTree
|
||||||
import org.jetbrains.kotlin.ir.generator.IrTree.parent
|
|
||||||
import org.jetbrains.kotlin.ir.generator.irImplementationDetailType
|
import org.jetbrains.kotlin.ir.generator.irImplementationDetailType
|
||||||
import org.jetbrains.kotlin.ir.generator.model.*
|
import org.jetbrains.kotlin.ir.generator.model.Element
|
||||||
|
import org.jetbrains.kotlin.ir.generator.model.Field
|
||||||
|
import org.jetbrains.kotlin.ir.generator.model.Implementation
|
||||||
import org.jetbrains.kotlin.utils.SmartPrinter
|
import org.jetbrains.kotlin.utils.SmartPrinter
|
||||||
|
|
||||||
internal class ImplementationPrinter(printer: SmartPrinter) : AbstractImplementationPrinter<Implementation, Element, Field>(printer) {
|
internal class ImplementationPrinter(printer: SmartPrinter) : AbstractImplementationPrinter<Implementation, Element, Field>(printer) {
|
||||||
@@ -34,7 +34,7 @@ internal class ImplementationPrinter(printer: SmartPrinter) : AbstractImplementa
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
implementation.element.traverseParentsUntil { it == IrTree.symbolOwner } &&
|
implementation.element.traverseParentsUntil { it == IrTree.symbolOwner } &&
|
||||||
!implementation.element.let { it == IrTree.propertyWithLateBinding || it == IrTree.functionWithLateBinding }
|
implementation.bindOwnedSymbol
|
||||||
) {
|
) {
|
||||||
val symbolField = implementation["symbol"]
|
val symbolField = implementation["symbol"]
|
||||||
if (symbolField != null) {
|
if (symbolField != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user