Hide stageController into the IrFactory
This commit is contained in:
@@ -88,7 +88,7 @@ fun buildKLib(
|
||||
configuration = configuration,
|
||||
allDependencies = allDependencies,
|
||||
friendDependencies = emptyList(),
|
||||
irFactory = PersistentIrFactory,
|
||||
irFactory = PersistentIrFactory(), // TODO: IrFactoryImpl?
|
||||
outputKlibPath = outputPath,
|
||||
nopack = true
|
||||
)
|
||||
|
||||
@@ -199,7 +199,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
configuration = config.configuration,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
irFactory = PersistentIrFactory,
|
||||
irFactory = PersistentIrFactory(), // TODO IrFactoryImpl?
|
||||
outputKlibPath = outputFile.path,
|
||||
nopack = arguments.irProduceKlibDir
|
||||
)
|
||||
|
||||
@@ -19,8 +19,10 @@ package org.jetbrains.kotlin.backend.common
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementContainer
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.util.transformFlat
|
||||
import org.jetbrains.kotlin.ir.util.transformSubsetFlat
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
@@ -151,8 +153,8 @@ private class BodyLoweringVisitor(
|
||||
if (allowDeclarationModification) {
|
||||
loweringPass.lower(body, data!!)
|
||||
} else {
|
||||
stageController.bodyLowering {
|
||||
loweringPass.lower(body, data!!)
|
||||
data!!.factory.stageController.bodyLowering {
|
||||
loweringPass.lower(body, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +180,7 @@ interface DeclarationTransformer : FileLoweringPass {
|
||||
}
|
||||
|
||||
private fun transformFlatRestricted(declaration: IrDeclaration): List<IrDeclaration>? {
|
||||
return stageController.restrictTo(declaration) {
|
||||
return declaration.factory.stageController.restrictTo(declaration) {
|
||||
transformFlat(declaration)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ fun IrType.remapTypeParameters(
|
||||
|
||||
/* Copied from K/N */
|
||||
fun IrDeclarationContainer.addChild(declaration: IrDeclaration) {
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
declaration.factory.stageController.unrestrictDeclarationListsAccess {
|
||||
this.declarations += declaration
|
||||
}
|
||||
declaration.setDeclarationsParent(this)
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class InnerClassesLowering(val context: BackendContext, private val innerClasses
|
||||
|
||||
override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
|
||||
if (declaration is IrClass && declaration.isInner) {
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
declaration.declarations += innerClassesSupport.getOuterThisField(declaration)
|
||||
}
|
||||
} else if (declaration is IrConstructor) {
|
||||
|
||||
@@ -29,11 +29,11 @@ fun eliminateDeadDeclarations(
|
||||
context: JsIrBackendContext
|
||||
) {
|
||||
|
||||
val allRoots = stageController.withInitialIr { buildRoots(modules, context) }
|
||||
val allRoots = context.irFactory.stageController.withInitialIr { buildRoots(modules, context) }
|
||||
|
||||
val usefulDeclarations = usefulDeclarations(allRoots, context)
|
||||
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
removeUselessDeclarations(modules, usefulDeclarations)
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
||||
}
|
||||
|
||||
// use withInitialIr to avoid ConcurrentModificationException in dce-driven lowering when adding roots' nested declarations (members)
|
||||
stageController.withInitialIr {
|
||||
context.irFactory.stageController.withInitialIr {
|
||||
// Add roots
|
||||
roots.forEach {
|
||||
it.enqueue(null, null, altFromFqn = "<ROOT>")
|
||||
|
||||
@@ -204,12 +204,12 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
val anyConstructorSymbol = anyClassSymbol.constructors.single()
|
||||
|
||||
val jsObjectClassSymbol = getInternalClassWithoutPackage("kotlin.js.JsObject")
|
||||
val jsObjectConstructorSymbol by lazy2 { jsObjectClassSymbol.constructors.single() }
|
||||
val jsObjectConstructorSymbol by context.lazy2 { jsObjectClassSymbol.constructors.single() }
|
||||
|
||||
val uByteClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.UByte") }
|
||||
val uShortClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.UShort") }
|
||||
val uIntClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.UInt") }
|
||||
val uLongClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.ULong") }
|
||||
val uByteClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.UByte") }
|
||||
val uShortClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.UShort") }
|
||||
val uIntClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.UInt") }
|
||||
val uLongClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.ULong") }
|
||||
|
||||
val unreachable = defineUnreachableIntrinsic()
|
||||
|
||||
@@ -285,16 +285,16 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
|
||||
// TODO move CharSequence-related stiff to IntrinsifyCallsLowering
|
||||
val charSequenceClassSymbol = context.symbolTable.referenceClass(context.getClass(FqName("kotlin.CharSequence")))
|
||||
val charSequenceLengthPropertyGetterSymbol by lazy2 {
|
||||
val charSequenceLengthPropertyGetterSymbol by context.lazy2 {
|
||||
with(charSequenceClassSymbol.owner.declarations) {
|
||||
filterIsInstance<IrProperty>().firstOrNull { it.name.asString() == "length" }?.getter ?:
|
||||
filterIsInstance<IrFunction>().first { it.name.asString() == "<get-length>" }
|
||||
}.symbol
|
||||
}
|
||||
val charSequenceGetFunctionSymbol by lazy2 {
|
||||
val charSequenceGetFunctionSymbol by context.lazy2 {
|
||||
charSequenceClassSymbol.owner.declarations.filterIsInstance<IrFunction>().single { it.name.asString() == "get" }.symbol
|
||||
}
|
||||
val charSequenceSubSequenceFunctionSymbol by lazy2 {
|
||||
val charSequenceSubSequenceFunctionSymbol by context.lazy2 {
|
||||
charSequenceClassSymbol.owner.declarations.filterIsInstance<IrFunction>().single { it.name.asString() == "subSequence" }.symbol
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ class JsIrBackendContext(
|
||||
val testRoots: Map<IrModuleFragment, IrSimpleFunction>
|
||||
get() = testContainerFuns
|
||||
|
||||
override val mapping = JsMapping()
|
||||
override val mapping = JsMapping(irFactory)
|
||||
|
||||
override val inlineClassesUtils = JsInlineClassesUtils(this)
|
||||
|
||||
@@ -362,7 +362,7 @@ class JsIrBackendContext(
|
||||
/*TODO*/
|
||||
print(message)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: investigate if it could be removed
|
||||
fun <T> lazy2(fn: () -> T) = lazy { stageController.withInitialIr(fn) }
|
||||
// TODO: investigate if it could be removed
|
||||
fun <T> lazy2(fn: () -> T) = lazy { irFactory.stageController.withInitialIr(fn) }
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.backend.common.DefaultMapping
|
||||
import org.jetbrains.kotlin.backend.common.Mapping
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
|
||||
class JsMapping : DefaultMapping() {
|
||||
class JsMapping(private val irFactory: IrFactory) : DefaultMapping() {
|
||||
val outerThisFieldSymbols = newMapping<IrClass, IrField>()
|
||||
val innerClassConstructors = newMapping<IrConstructor, IrConstructor>()
|
||||
val originalInnerClassPrimaryConstructorByClass = newMapping<IrClass, IrConstructor>()
|
||||
@@ -35,12 +35,12 @@ class JsMapping : DefaultMapping() {
|
||||
private val map: MutableMap<K, V> = mutableMapOf()
|
||||
|
||||
override operator fun get(key: K): V? {
|
||||
stageController.lazyLower(key)
|
||||
irFactory.stageController.lazyLower(key)
|
||||
return map[key]
|
||||
}
|
||||
|
||||
override operator fun set(key: K, value: V?) {
|
||||
stageController.lazyLower(key)
|
||||
irFactory.stageController.lazyLower(key)
|
||||
if (value == null) {
|
||||
map.remove(key)
|
||||
} else {
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.StageController
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.noUnboundLeft
|
||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||
@@ -51,9 +50,7 @@ fun compile(
|
||||
relativeRequirePath: Boolean = false,
|
||||
propertyLazyInitialization: Boolean,
|
||||
): CompilerResult {
|
||||
stageController = StageController()
|
||||
|
||||
val irFactory = if (dceDriven) PersistentIrFactory else IrFactoryImpl
|
||||
val irFactory = if (dceDriven) PersistentIrFactory() else IrFactoryImpl
|
||||
|
||||
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
||||
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, irFactory)
|
||||
@@ -93,14 +90,15 @@ fun compile(
|
||||
|
||||
if (dceDriven) {
|
||||
val controller = MutableController(context, pirLowerings)
|
||||
stageController = controller
|
||||
|
||||
check(irFactory is PersistentIrFactory)
|
||||
irFactory.stageController = controller
|
||||
|
||||
controller.currentStage = controller.lowerings.size + 1
|
||||
|
||||
eliminateDeadDeclarations(allModules, context)
|
||||
|
||||
// TODO investigate whether this is needed anymore
|
||||
stageController = StageController(controller.currentStage)
|
||||
irFactory.stageController = StageController(controller.currentStage)
|
||||
|
||||
val transformer = IrModuleToJsTransformer(
|
||||
context,
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ abstract class AbstractBlockDecomposerLowering(
|
||||
val lastStatement = newBody.statements.last()
|
||||
val actualParent = if (newBody.statements.size > 1 || lastStatement !is IrReturn || lastStatement.value != expression) {
|
||||
expression = JsIrBuilder.buildCall(initFunction.symbol, expression.type)
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
(container.parent as IrDeclarationContainer).declarations += initFunction
|
||||
}
|
||||
initFunction
|
||||
|
||||
+2
-2
@@ -353,7 +353,7 @@ class EnumClassCreateInitializerLowering(val context: JsCommonBackendContext) :
|
||||
|
||||
// TODO Why not move to upper level?
|
||||
// TODO Also doesn't fit the transformFlat-ish API
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
declaration.declarations += entryInstancesInitializedVar
|
||||
declaration.declarations += initEntryInstancesFun
|
||||
}
|
||||
@@ -414,7 +414,7 @@ class EnumEntryCreateGetInstancesFunsLowering(val context: JsCommonBackendContex
|
||||
|
||||
// TODO prettify
|
||||
entryGetInstanceFun.parent = irClass.parent
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
(irClass.parent as IrDeclarationContainer).declarations += entryGetInstanceFun
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ class ExternalEnumUsagesLowering(val context: JsIrBackendContext) : BodyLowering
|
||||
it.parent = irClass
|
||||
|
||||
// TODO need a way to emerge local declarations from BodyLoweringPass
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
irClass.declarations += it
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ class JsSingleAbstractMethodLowering(context: JsIrBackendContext) : SingleAbstra
|
||||
|
||||
for (wrapper in cachedImplementations.values + inlineCachedImplementations.values) {
|
||||
val parentClass = wrapper.parent as IrDeclarationContainer
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
parentClass.declarations += wrapper
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
|
||||
// Create primary constructor if it doesn't exist
|
||||
class PrimaryConstructorLowering(context: JsCommonBackendContext) : DeclarationTransformer {
|
||||
class PrimaryConstructorLowering(val context: JsCommonBackendContext) : DeclarationTransformer {
|
||||
|
||||
private var IrClass.syntheticPrimaryConstructor by context.mapping.classToSyntheticPrimaryConstructor
|
||||
|
||||
@@ -44,7 +44,7 @@ class PrimaryConstructorLowering(context: JsCommonBackendContext) : DeclarationT
|
||||
|
||||
private fun createPrimaryConstructor(irClass: IrClass): IrConstructor {
|
||||
// TODO better API for declaration creation. This case doesn't fit the usual transformFlat-like API.
|
||||
val declaration = stageController.unrestrictDeclarationListsAccess {
|
||||
val declaration = context.irFactory.stageController.unrestrictDeclarationListsAccess {
|
||||
irClass.addConstructor {
|
||||
origin = SYNTHETIC_PRIMARY_CONSTRUCTOR
|
||||
isPrimary = true
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ private val IrDeclaration.correspondingProperty: IrProperty?
|
||||
}
|
||||
|
||||
private fun IrDeclaration.propertyWithPersistentSafe(transform: IrDeclaration.() -> IrProperty?): IrProperty? =
|
||||
if (((this as? PersistentIrElementBase<*>)?.createdOn ?: 0) <= stageController.currentStage) {
|
||||
if (this !is PersistentIrElementBase<*> || this.createdOn <= this.factory.stageController.currentStage) {
|
||||
transform()
|
||||
} else null
|
||||
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ class WasmBackendContext(
|
||||
@Suppress("UNUSED_PARAMETER") symbolTable: SymbolTable,
|
||||
@Suppress("UNUSED_PARAMETER") irModuleFragment: IrModuleFragment,
|
||||
val additionalExportedDeclarations: Set<FqName>,
|
||||
override val configuration: CompilerConfiguration
|
||||
override val configuration: CompilerConfiguration,
|
||||
) : JsCommonBackendContext {
|
||||
override val builtIns = module.builtIns
|
||||
override var inVerbosePhase: Boolean = false
|
||||
@@ -55,7 +55,7 @@ class WasmBackendContext(
|
||||
)
|
||||
}
|
||||
|
||||
override val mapping = JsMapping()
|
||||
override val mapping = JsMapping(irFactory)
|
||||
|
||||
val innerClassesSupport = JsInnerClassesSupport(mapping, irFactory)
|
||||
|
||||
|
||||
+2
@@ -20,6 +20,8 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
object IrFactoryImpl : IrFactory {
|
||||
override val stageController: StageController = StageController()
|
||||
|
||||
override fun createAnonymousInitializer(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
|
||||
+5
-5
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.AnonymousInitializerCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrAnonymousInitializerSymbol
|
||||
@@ -24,7 +23,8 @@ internal class PersistentIrAnonymousInitializer(
|
||||
override val endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrAnonymousInitializerSymbol,
|
||||
override val isStatic: Boolean = false
|
||||
override val isStatic: Boolean = false,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrAnonymousInitializer(),
|
||||
PersistentIrDeclarationBase<AnonymousInitializerCarrier>,
|
||||
AnonymousInitializerCarrier {
|
||||
@@ -33,10 +33,10 @@ internal class PersistentIrAnonymousInitializer(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+7
-7
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ClassCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -47,7 +46,8 @@ internal class PersistentIrClass(
|
||||
override val isInline: Boolean = false,
|
||||
override val isExpect: Boolean = false,
|
||||
override val isFun: Boolean = false,
|
||||
override val source: SourceElement = SourceElement.NO_SOURCE
|
||||
override val source: SourceElement = SourceElement.NO_SOURCE,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrClass(),
|
||||
PersistentIrDeclarationBase<ClassCarrier>,
|
||||
ClassCarrier {
|
||||
@@ -56,10 +56,10 @@ internal class PersistentIrClass(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
@@ -94,11 +94,11 @@ internal class PersistentIrClass(
|
||||
|
||||
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
||||
get() {
|
||||
if (createdOn < stageController.currentStage && initialDeclarations == null) {
|
||||
if (createdOn < factory.stageController.currentStage && initialDeclarations == null) {
|
||||
initialDeclarations = Collections.unmodifiableList(ArrayList(field))
|
||||
}
|
||||
|
||||
return if (stageController.canAccessDeclarationsOf(this)) {
|
||||
return if (factory.stageController.canAccessDeclarationsOf(this)) {
|
||||
ensureLowered()
|
||||
field
|
||||
} else {
|
||||
|
||||
+5
-5
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ConstructorCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
@@ -40,7 +39,8 @@ internal class PersistentIrConstructor(
|
||||
isExternal: Boolean,
|
||||
override val isPrimary: Boolean,
|
||||
override val isExpect: Boolean,
|
||||
override val containerSource: DeserializedContainerSource?
|
||||
override val containerSource: DeserializedContainerSource?,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrConstructor(),
|
||||
PersistentIrDeclarationBase<ConstructorCarrier>,
|
||||
ConstructorCarrier {
|
||||
@@ -49,10 +49,10 @@ internal class PersistentIrConstructor(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.EnumEntryCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
||||
@@ -26,7 +25,8 @@ internal class PersistentIrEnumEntry(
|
||||
override val endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrEnumEntrySymbol,
|
||||
override val name: Name
|
||||
override val name: Name,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrEnumEntry(),
|
||||
PersistentIrDeclarationBase<EnumEntryCarrier>,
|
||||
EnumEntryCarrier {
|
||||
@@ -35,10 +35,10 @@ internal class PersistentIrEnumEntry(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ErrorDeclarationCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
@@ -22,17 +21,18 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
internal class PersistentIrErrorDeclaration(
|
||||
override val startOffset: Int,
|
||||
override val endOffset: Int,
|
||||
private val _descriptor: DeclarationDescriptor?
|
||||
private val _descriptor: DeclarationDescriptor?,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrErrorDeclaration(),
|
||||
PersistentIrDeclarationBase<ErrorDeclarationCarrier>,
|
||||
ErrorDeclarationCarrier {
|
||||
override val descriptor: DeclarationDescriptor
|
||||
get() = _descriptor ?: this.toIrBasedDescriptor()
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED
|
||||
|
||||
+5
-5
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FieldCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
@@ -34,7 +33,8 @@ internal class PersistentIrField(
|
||||
override var visibility: DescriptorVisibility,
|
||||
override val isFinal: Boolean,
|
||||
isExternal: Boolean,
|
||||
override val isStatic: Boolean
|
||||
override val isStatic: Boolean,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrField(),
|
||||
PersistentIrDeclarationBase<FieldCarrier>,
|
||||
FieldCarrier {
|
||||
@@ -43,10 +43,10 @@ internal class PersistentIrField(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
@@ -42,15 +41,16 @@ internal abstract class PersistentIrFunctionCommon(
|
||||
override val isOperator: Boolean,
|
||||
override val isInfix: Boolean,
|
||||
override val isExpect: Boolean,
|
||||
override val containerSource: DeserializedContainerSource? = null
|
||||
override val containerSource: DeserializedContainerSource? = null,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrSimpleFunction(),
|
||||
PersistentIrDeclarationBase<FunctionCarrier>,
|
||||
FunctionCarrier {
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.LocalDelegatedPropertyCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -31,7 +30,8 @@ internal class PersistentIrLocalDelegatedProperty(
|
||||
override val symbol: IrLocalDelegatedPropertySymbol,
|
||||
override val name: Name,
|
||||
type: IrType,
|
||||
override val isVar: Boolean
|
||||
override val isVar: Boolean,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrLocalDelegatedProperty(),
|
||||
PersistentIrDeclarationBase<LocalDelegatedPropertyCarrier>,
|
||||
LocalDelegatedPropertyCarrier {
|
||||
@@ -40,10 +40,10 @@ internal class PersistentIrLocalDelegatedProperty(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.PropertyCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
@@ -34,15 +33,16 @@ internal abstract class PersistentIrPropertyCommon(
|
||||
override val isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
override val isExpect: Boolean,
|
||||
override val containerSource: DeserializedContainerSource?
|
||||
override val containerSource: DeserializedContainerSource?,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrProperty(),
|
||||
PersistentIrDeclarationBase<PropertyCarrier>,
|
||||
PropertyCarrier {
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.ir.declarations.IrTypeAlias
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.TypeAliasCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -30,7 +29,8 @@ internal class PersistentIrTypeAlias(
|
||||
override var visibility: DescriptorVisibility,
|
||||
expandedType: IrType,
|
||||
override val isActual: Boolean,
|
||||
origin: IrDeclarationOrigin
|
||||
origin: IrDeclarationOrigin,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrTypeAlias(),
|
||||
PersistentIrDeclarationBase<TypeAliasCarrier>,
|
||||
TypeAliasCarrier {
|
||||
@@ -39,10 +39,10 @@ internal class PersistentIrTypeAlias(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.TypeParameterCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -29,7 +28,8 @@ internal class PersistentIrTypeParameter(
|
||||
override val name: Name,
|
||||
override val index: Int,
|
||||
override val isReified: Boolean,
|
||||
override val variance: Variance
|
||||
override val variance: Variance,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrTypeParameter(),
|
||||
PersistentIrDeclarationBase<TypeParameterCarrier>,
|
||||
TypeParameterCarrier {
|
||||
@@ -38,10 +38,10 @@ internal class PersistentIrTypeParameter(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+5
-5
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ValueParameterCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
||||
@@ -33,7 +32,8 @@ internal class PersistentIrValueParameter(
|
||||
override val isCrossinline: Boolean,
|
||||
override val isNoinline: Boolean,
|
||||
override val isHidden: Boolean,
|
||||
override val isAssignable: Boolean
|
||||
override val isAssignable: Boolean,
|
||||
override val factory: PersistentIrFactory
|
||||
) : IrValueParameter(),
|
||||
PersistentIrDeclarationBase<ValueParameterCarrier>,
|
||||
ValueParameterCarrier {
|
||||
@@ -46,10 +46,10 @@ internal class PersistentIrValueParameter(
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ internal fun PersistentIrGenerator.generateAnonymousInitializer() {
|
||||
origin,
|
||||
+"override val symbol: " + IrAnonymousInitializerSymbol,
|
||||
isStatic + " = false",
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("AnonymousInitializer") + " " + blockSpaced(
|
||||
initBlock,
|
||||
|
||||
+3
-2
@@ -36,6 +36,7 @@ internal fun PersistentIrGenerator.generateClass() {
|
||||
isExpect + " = false",
|
||||
isFun,
|
||||
source,
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("Class") + " " + blockSpaced(
|
||||
initBlock,
|
||||
@@ -49,12 +50,12 @@ internal fun PersistentIrGenerator.generateClass() {
|
||||
+"override val declarations: MutableList<IrDeclaration> = " + import("ArrayList", "java.util") + "()",
|
||||
lines(
|
||||
+"get() " + block(
|
||||
+"if (createdOn < stageController.currentStage && initialDeclarations == null) " + block(
|
||||
+"if (createdOn < factory.stageController.currentStage && initialDeclarations == null) " + block(
|
||||
+"initialDeclarations = " + import("Collections", "java.util") + ".unmodifiableList(ArrayList(field))"
|
||||
),
|
||||
id,
|
||||
+"""
|
||||
return if (stageController.canAccessDeclarationsOf(this)) {
|
||||
return if (factory.stageController.canAccessDeclarationsOf(this)) {
|
||||
ensureLowered()
|
||||
field
|
||||
} else {
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ internal fun PersistentIrGenerator.generateConstructor() {
|
||||
isPrimary,
|
||||
isExpect,
|
||||
containerSource,
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("Constructor") + " " + blockSpaced(
|
||||
initBlock,
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ internal fun PersistentIrGenerator.generateEnumEntry() {
|
||||
origin,
|
||||
+"override val symbol: " + irSymbol("IrEnumEntrySymbol"),
|
||||
name,
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("EnumEntry") + " " + blockSpaced(
|
||||
initBlock,
|
||||
|
||||
+2
-1
@@ -15,7 +15,8 @@ internal fun PersistentIrGenerator.generateErrorDeclaration() {
|
||||
arrayOf(
|
||||
startOffset,
|
||||
endOffset,
|
||||
+"private val _descriptor: " + DeclarationDescriptor + "?"
|
||||
+"private val _descriptor: " + DeclarationDescriptor + "?",
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("ErrorDeclaration") + " " + block(
|
||||
lines(
|
||||
|
||||
+1
@@ -27,6 +27,7 @@ internal fun PersistentIrGenerator.generateField() {
|
||||
isFinal,
|
||||
isExternal,
|
||||
isStatic,
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("Field") + " " + blockSpaced(
|
||||
initBlock,
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ internal fun PersistentIrGenerator.generateFunction() {
|
||||
+"override val isInfix: Boolean",
|
||||
isExpect,
|
||||
containerSource + " = null",
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("Function", baseClass = "IrSimpleFunction") + " " + blockSpaced(
|
||||
commonFields,
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ internal fun PersistentIrGenerator.generateLocalDelegatedProperty() {
|
||||
name,
|
||||
+"type: " + IrType,
|
||||
+"override val isVar: Boolean",
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("LocalDelegatedProperty") + " " + blockSpaced(
|
||||
initBlock,
|
||||
|
||||
+5
-5
@@ -53,8 +53,6 @@ internal object PersistentIrGenerator {
|
||||
|
||||
val ObsoleteDescriptorBasedAPI = import("ObsoleteDescriptorBasedAPI", "org.jetbrains.kotlin.ir")
|
||||
|
||||
val stageController = import("stageController", "org.jetbrains.kotlin.ir.declarations")
|
||||
|
||||
val IrType = import("IrType", "org.jetbrains.kotlin.ir.types")
|
||||
|
||||
val IrPropertySymbol = irSymbol("IrPropertySymbol")
|
||||
@@ -82,15 +80,17 @@ internal object PersistentIrGenerator {
|
||||
val isPrimary = +"override val isPrimary: Boolean"
|
||||
val containerSource = +"override val containerSource: " + import("DeserializedContainerSource", "org.jetbrains.kotlin.serialization.deserialization.descriptors") + "?"
|
||||
|
||||
val irFactory = +"override val factory: PersistentIrFactory"
|
||||
|
||||
val initBlock = +"init " + block(
|
||||
+"symbol.bind(this)"
|
||||
)
|
||||
|
||||
// Fields
|
||||
val lastModified = +"override var lastModified: Int = " + stageController + ".currentStage"
|
||||
val loweredUpTo = +"override var loweredUpTo: Int = " + stageController + ".currentStage"
|
||||
val lastModified = +"override var lastModified: Int = factory.stageController.currentStage"
|
||||
val loweredUpTo = +"override var loweredUpTo: Int = factory.stageController.currentStage"
|
||||
val values = +"override var values: Array<" + Carrier + ">? = null"
|
||||
val createdOn = +"override val createdOn: Int = " + stageController + ".currentStage"
|
||||
val createdOn = +"override val createdOn: Int = factory.stageController.currentStage"
|
||||
|
||||
val parentField = +"override var parentField: " + IrDeclarationParent + "? = null"
|
||||
val originField = +"override var originField: " + IrDeclarationOrigin + " = origin"
|
||||
|
||||
+2
-1
@@ -29,7 +29,8 @@ internal fun PersistentIrGenerator.generateProperty() {
|
||||
+"override val isDelegated: Boolean",
|
||||
isExternal,
|
||||
isExpect,
|
||||
containerSource
|
||||
containerSource,
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("Property") + " " + blockSpaced(
|
||||
commonFields,
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ internal fun PersistentIrGenerator.generateTypeAlias() {
|
||||
+"expandedType: " + IrType,
|
||||
+"override val isActual: Boolean",
|
||||
origin,
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("TypeAlias") + " " + blockSpaced(
|
||||
initBlock,
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ internal fun PersistentIrGenerator.generateTypeParameter() {
|
||||
name,
|
||||
+"override val index: Int",
|
||||
+"override val isReified: Boolean",
|
||||
+"override val variance: " + import("Variance", "org.jetbrains.kotlin.types")
|
||||
+"override val variance: " + import("Variance", "org.jetbrains.kotlin.types"),
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("TypeParameter") + " " + blockSpaced(
|
||||
initBlock,
|
||||
|
||||
+2
-1
@@ -27,7 +27,8 @@ internal fun PersistentIrGenerator.generateValueParameter() {
|
||||
+"override val isCrossinline: Boolean",
|
||||
+"override val isNoinline: Boolean",
|
||||
+"override val isHidden: Boolean",
|
||||
+"override val isAssignable: Boolean"
|
||||
+"override val isAssignable: Boolean",
|
||||
irFactory,
|
||||
).join(separator = ",\n").indent(),
|
||||
+") : " + baseClasses("ValueParameter") + " " + blockSpaced(
|
||||
descriptor(descriptorType("ParameterDescriptor")),
|
||||
|
||||
+13
-13
@@ -17,9 +17,6 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
interface PersistentIrDeclarationBase<T : DeclarationCarrier> : PersistentIrElementBase<T>, IrDeclaration, DeclarationCarrier {
|
||||
var removedOn: Int
|
||||
|
||||
override val factory: IrFactory
|
||||
get() = PersistentIrFactory
|
||||
|
||||
// TODO reduce boilerplate
|
||||
override var parent: IrDeclarationParent
|
||||
get() = getCarrier().parentField ?: throw UninitializedPropertyAccessException("Parent not initialized: $this")
|
||||
@@ -46,13 +43,16 @@ interface PersistentIrDeclarationBase<T : DeclarationCarrier> : PersistentIrElem
|
||||
}
|
||||
|
||||
override fun ensureLowered() {
|
||||
if (stageController.currentStage > loweredUpTo) {
|
||||
stageController.lazyLower(this)
|
||||
if (factory.stageController.currentStage > loweredUpTo) {
|
||||
factory.stageController.lazyLower(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface PersistentIrElementBase<T : Carrier> : IrElement, Carrier {
|
||||
|
||||
val factory: PersistentIrFactory
|
||||
|
||||
override var lastModified: Int
|
||||
|
||||
var loweredUpTo: Int
|
||||
@@ -66,7 +66,7 @@ interface PersistentIrElementBase<T : Carrier> : IrElement, Carrier {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getCarrier(): T {
|
||||
stageController.currentStage.let { stage ->
|
||||
factory.stageController.currentStage.let { stage ->
|
||||
ensureLowered()
|
||||
|
||||
if (stage >= lastModified) return this as T
|
||||
@@ -97,11 +97,11 @@ interface PersistentIrElementBase<T : Carrier> : IrElement, Carrier {
|
||||
// TODO naming? e.g. `mutableCarrier`
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun setCarrier(): T {
|
||||
val stage = stageController.currentStage
|
||||
val stage = factory.stageController.currentStage
|
||||
|
||||
ensureLowered()
|
||||
|
||||
if (!stageController.canModify(this)) {
|
||||
if (!factory.stageController.canModify(this)) {
|
||||
error("Cannot modify this element!")
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ interface PersistentIrBodyBase<B : PersistentIrBodyBase<B>> : PersistentIrElemen
|
||||
}
|
||||
|
||||
fun <T> checkEnabled(fn: () -> T): T {
|
||||
if (!stageController.bodiesEnabled) error("Bodies disabled!")
|
||||
if (!factory.stageController.bodiesEnabled) error("Bodies disabled!")
|
||||
ensureLowered()
|
||||
return fn()
|
||||
}
|
||||
@@ -145,14 +145,14 @@ interface PersistentIrBodyBase<B : PersistentIrBodyBase<B>> : PersistentIrElemen
|
||||
override fun ensureLowered() {
|
||||
initializer?.let { initFn ->
|
||||
initializer = null
|
||||
stageController.withStage(createdOn) {
|
||||
stageController.bodyLowering {
|
||||
factory.stageController.withStage(createdOn) {
|
||||
factory.stageController.bodyLowering {
|
||||
initFn.invoke(this as B)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (loweredUpTo + 1 < stageController.currentStage) {
|
||||
stageController.lazyLower(this as IrBody)
|
||||
if (loweredUpTo + 1 < factory.stageController.currentStage) {
|
||||
factory.stageController.lazyLower(this as IrBody)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-19
@@ -19,7 +19,10 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
object PersistentIrFactory : IrFactory {
|
||||
class PersistentIrFactory : IrFactory {
|
||||
|
||||
override var stageController = StageController()
|
||||
|
||||
override fun createAnonymousInitializer(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
@@ -27,7 +30,7 @@ object PersistentIrFactory : IrFactory {
|
||||
symbol: IrAnonymousInitializerSymbol,
|
||||
isStatic: Boolean,
|
||||
): IrAnonymousInitializer =
|
||||
PersistentIrAnonymousInitializer(startOffset, endOffset, origin, symbol, isStatic)
|
||||
PersistentIrAnonymousInitializer(startOffset, endOffset, origin, symbol, isStatic, this)
|
||||
|
||||
override fun createClass(
|
||||
startOffset: Int,
|
||||
@@ -50,6 +53,7 @@ object PersistentIrFactory : IrFactory {
|
||||
PersistentIrClass(
|
||||
startOffset, endOffset, origin, symbol, name, kind, visibility, modality,
|
||||
isCompanion, isInner, isData, isExternal, isInline, isExpect, isFun, source,
|
||||
this
|
||||
)
|
||||
|
||||
override fun createConstructor(
|
||||
@@ -68,7 +72,7 @@ object PersistentIrFactory : IrFactory {
|
||||
): IrConstructor =
|
||||
PersistentIrConstructor(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, returnType, isInline, isExternal, isPrimary, isExpect,
|
||||
containerSource,
|
||||
containerSource, this
|
||||
)
|
||||
|
||||
override fun createEnumEntry(
|
||||
@@ -78,14 +82,14 @@ object PersistentIrFactory : IrFactory {
|
||||
symbol: IrEnumEntrySymbol,
|
||||
name: Name,
|
||||
): IrEnumEntry =
|
||||
PersistentIrEnumEntry(startOffset, endOffset, origin, symbol, name)
|
||||
PersistentIrEnumEntry(startOffset, endOffset, origin, symbol, name, this)
|
||||
|
||||
override fun createErrorDeclaration(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
descriptor: DeclarationDescriptor?,
|
||||
): IrErrorDeclaration =
|
||||
PersistentIrErrorDeclaration(startOffset, endOffset, descriptor)
|
||||
PersistentIrErrorDeclaration(startOffset, endOffset, descriptor, this)
|
||||
|
||||
override fun createField(
|
||||
startOffset: Int,
|
||||
@@ -99,7 +103,7 @@ object PersistentIrFactory : IrFactory {
|
||||
isExternal: Boolean,
|
||||
isStatic: Boolean,
|
||||
): IrField =
|
||||
PersistentIrField(startOffset, endOffset, origin, symbol, name, type, visibility, isFinal, isExternal, isStatic)
|
||||
PersistentIrField(startOffset, endOffset, origin, symbol, name, type, visibility, isFinal, isExternal, isStatic, this)
|
||||
|
||||
override fun createFunction(
|
||||
startOffset: Int,
|
||||
@@ -123,7 +127,7 @@ object PersistentIrFactory : IrFactory {
|
||||
PersistentIrFunction(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, modality, returnType,
|
||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, isFakeOverride,
|
||||
containerSource
|
||||
containerSource, this
|
||||
)
|
||||
|
||||
override fun createFakeOverrideFunction(
|
||||
@@ -144,7 +148,7 @@ object PersistentIrFactory : IrFactory {
|
||||
): IrSimpleFunction =
|
||||
PersistentIrFakeOverrideFunction(
|
||||
startOffset, endOffset, origin, name, visibility, modality, returnType,
|
||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, this
|
||||
)
|
||||
|
||||
override fun createLocalDelegatedProperty(
|
||||
@@ -157,7 +161,7 @@ object PersistentIrFactory : IrFactory {
|
||||
isVar: Boolean,
|
||||
): IrLocalDelegatedProperty =
|
||||
PersistentIrLocalDelegatedProperty(
|
||||
startOffset, endOffset, origin, symbol, name, type, isVar
|
||||
startOffset, endOffset, origin, symbol, name, type, isVar, this
|
||||
)
|
||||
|
||||
override fun createProperty(
|
||||
@@ -180,7 +184,7 @@ object PersistentIrFactory : IrFactory {
|
||||
PersistentIrProperty(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, modality,
|
||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, isFakeOverride,
|
||||
containerSource
|
||||
containerSource, this
|
||||
)
|
||||
|
||||
override fun createFakeOverrideProperty(
|
||||
@@ -200,6 +204,7 @@ object PersistentIrFactory : IrFactory {
|
||||
PersistentIrFakeOverrideProperty(
|
||||
startOffset, endOffset, origin, name, visibility, modality,
|
||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
this
|
||||
)
|
||||
|
||||
override fun createTypeAlias(
|
||||
@@ -212,7 +217,7 @@ object PersistentIrFactory : IrFactory {
|
||||
isActual: Boolean,
|
||||
origin: IrDeclarationOrigin,
|
||||
): IrTypeAlias =
|
||||
PersistentIrTypeAlias(startOffset, endOffset, symbol, name, visibility, expandedType, isActual, origin)
|
||||
PersistentIrTypeAlias(startOffset, endOffset, symbol, name, visibility, expandedType, isActual, origin, this)
|
||||
|
||||
override fun createTypeParameter(
|
||||
startOffset: Int,
|
||||
@@ -224,7 +229,7 @@ object PersistentIrFactory : IrFactory {
|
||||
isReified: Boolean,
|
||||
variance: Variance,
|
||||
): IrTypeParameter =
|
||||
PersistentIrTypeParameter(startOffset, endOffset, origin, symbol, name, index, isReified, variance)
|
||||
PersistentIrTypeParameter(startOffset, endOffset, origin, symbol, name, index, isReified, variance, this)
|
||||
|
||||
override fun createValueParameter(
|
||||
startOffset: Int,
|
||||
@@ -241,7 +246,7 @@ object PersistentIrFactory : IrFactory {
|
||||
isAssignable: Boolean
|
||||
): IrValueParameter =
|
||||
PersistentIrValueParameter(
|
||||
startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline, isHidden, isAssignable
|
||||
startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline, isHidden, isAssignable, this
|
||||
)
|
||||
|
||||
override fun createExpressionBody(
|
||||
@@ -249,37 +254,37 @@ object PersistentIrFactory : IrFactory {
|
||||
endOffset: Int,
|
||||
initializer: IrExpressionBody.() -> Unit,
|
||||
): IrExpressionBody =
|
||||
PersistentIrExpressionBody(startOffset, endOffset, initializer)
|
||||
PersistentIrExpressionBody(startOffset, endOffset, this, initializer)
|
||||
|
||||
override fun createExpressionBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
expression: IrExpression,
|
||||
): IrExpressionBody =
|
||||
PersistentIrExpressionBody(startOffset, endOffset, expression)
|
||||
PersistentIrExpressionBody(startOffset, endOffset, expression, this)
|
||||
|
||||
override fun createExpressionBody(
|
||||
expression: IrExpression,
|
||||
): IrExpressionBody =
|
||||
PersistentIrExpressionBody(expression)
|
||||
PersistentIrExpressionBody(expression, this)
|
||||
|
||||
override fun createBlockBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
): IrBlockBody =
|
||||
PersistentIrBlockBody(startOffset, endOffset)
|
||||
PersistentIrBlockBody(startOffset, endOffset, this)
|
||||
|
||||
override fun createBlockBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
statements: List<IrStatement>,
|
||||
): IrBlockBody =
|
||||
PersistentIrBlockBody(startOffset, endOffset, statements)
|
||||
PersistentIrBlockBody(startOffset, endOffset, statements, this)
|
||||
|
||||
override fun createBlockBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
initializer: IrBlockBody.() -> Unit,
|
||||
): IrBlockBody =
|
||||
PersistentIrBlockBody(startOffset, endOffset, initializer)
|
||||
PersistentIrBlockBody(startOffset, endOffset, this, initializer)
|
||||
}
|
||||
|
||||
+5
-3
@@ -33,11 +33,12 @@ internal class PersistentIrFunction(
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
containerSource: DeserializedContainerSource?
|
||||
containerSource: DeserializedContainerSource?,
|
||||
factory: PersistentIrFactory,
|
||||
) : PersistentIrFunctionCommon(
|
||||
startOffset, endOffset, origin, name, visibility, returnType, isInline,
|
||||
isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
containerSource
|
||||
containerSource, factory
|
||||
) {
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: FunctionDescriptor
|
||||
@@ -63,9 +64,10 @@ internal class PersistentIrFakeOverrideFunction(
|
||||
isOperator: Boolean,
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
factory: PersistentIrFactory,
|
||||
) : PersistentIrFunctionCommon(
|
||||
startOffset, endOffset, origin, name, visibility, returnType, isInline,
|
||||
isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, factory = factory
|
||||
), IrFakeOverrideFunction {
|
||||
override val isFakeOverride: Boolean
|
||||
get() = true
|
||||
|
||||
+4
-2
@@ -35,9 +35,10 @@ internal class PersistentIrProperty(
|
||||
isExpect: Boolean = false,
|
||||
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
containerSource: DeserializedContainerSource?,
|
||||
factory: PersistentIrFactory,
|
||||
) : PersistentIrPropertyCommon(
|
||||
startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
containerSource,
|
||||
containerSource, factory
|
||||
) {
|
||||
init {
|
||||
symbol.bind(this)
|
||||
@@ -61,10 +62,11 @@ internal class PersistentIrFakeOverrideProperty(
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
factory: PersistentIrFactory,
|
||||
) : PersistentIrPropertyCommon(
|
||||
startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit,
|
||||
isDelegated, isExternal, isExpect,
|
||||
containerSource = null,
|
||||
containerSource = null, factory
|
||||
), IrFakeOverrideProperty {
|
||||
override val isFakeOverride: Boolean
|
||||
get() = true
|
||||
|
||||
+5
-9
@@ -18,26 +18,25 @@ package org.jetbrains.kotlin.ir.expressions.persistent
|
||||
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
|
||||
internal class PersistentIrBlockBody(
|
||||
override val startOffset: Int,
|
||||
override val endOffset: Int,
|
||||
override val factory: PersistentIrFactory,
|
||||
override var initializer: (PersistentIrBlockBody.() -> Unit)? = null
|
||||
) : IrBlockBody(), PersistentIrBodyBase<PersistentIrBlockBody> {
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var containerField: IrDeclaration? = null
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, statements: List<IrStatement>) : this(startOffset, endOffset) {
|
||||
constructor(startOffset: Int, endOffset: Int, statements: List<IrStatement>, factory: PersistentIrFactory) : this(startOffset, endOffset, factory) {
|
||||
statementsField.addAll(statements)
|
||||
}
|
||||
|
||||
@@ -45,7 +44,4 @@ internal class PersistentIrBlockBody(
|
||||
|
||||
override val statements: MutableList<IrStatement>
|
||||
get() = checkEnabled { statementsField }
|
||||
|
||||
override val factory: IrFactory
|
||||
get() = PersistentIrFactory
|
||||
}
|
||||
|
||||
+9
-13
@@ -17,40 +17,36 @@
|
||||
package org.jetbrains.kotlin.ir.expressions.persistent
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
|
||||
internal class PersistentIrExpressionBody private constructor(
|
||||
override val startOffset: Int,
|
||||
override val endOffset: Int,
|
||||
override val factory: PersistentIrFactory,
|
||||
private var expressionField: IrExpression? = null,
|
||||
override var initializer: (PersistentIrExpressionBody.() -> Unit)? = null
|
||||
override var initializer: (PersistentIrExpressionBody.() -> Unit)? = null,
|
||||
) : IrExpressionBody(), PersistentIrBodyBase<PersistentIrExpressionBody> {
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
override var loweredUpTo: Int = stageController.currentStage
|
||||
override var lastModified: Int = factory.stageController.currentStage
|
||||
override var loweredUpTo: Int = factory.stageController.currentStage
|
||||
override var values: Array<Carrier>? = null
|
||||
override val createdOn: Int = stageController.currentStage
|
||||
override val createdOn: Int = factory.stageController.currentStage
|
||||
|
||||
override var containerField: IrDeclaration? = null
|
||||
|
||||
constructor(expression: IrExpression) : this(expression.startOffset, expression.endOffset, expression, null)
|
||||
constructor(expression: IrExpression, factory: PersistentIrFactory) : this(expression.startOffset, expression.endOffset, factory, expression, null)
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset, expression, null)
|
||||
constructor(startOffset: Int, endOffset: Int, expression: IrExpression,factory: PersistentIrFactory) : this(startOffset, endOffset, factory, expression, null)
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, initializer: IrExpressionBody.() -> Unit) :
|
||||
this(startOffset, endOffset, null, initializer)
|
||||
constructor(startOffset: Int, endOffset: Int, factory: PersistentIrFactory, initializer: IrExpressionBody.() -> Unit) :
|
||||
this(startOffset, endOffset, factory, null, initializer)
|
||||
|
||||
override var expression: IrExpression
|
||||
get() = checkEnabled { expressionField!! }
|
||||
set(e) {
|
||||
checkEnabled { expressionField = e }
|
||||
}
|
||||
|
||||
override val factory: IrFactory
|
||||
get() = PersistentIrFactory
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
interface IrFactory {
|
||||
val stageController: StageController
|
||||
|
||||
fun createAnonymousInitializer(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
|
||||
@@ -8,11 +8,6 @@ package org.jetbrains.kotlin.ir.declarations
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
|
||||
// TODO threadlocal
|
||||
// TODO make a IrDeclarationBase field? (requires IR factory)
|
||||
var stageController: StageController = StageController()
|
||||
|
||||
// TODO make a class
|
||||
open class StageController(open val currentStage: Int = 0) {
|
||||
open fun lazyLower(declaration: IrDeclaration) {}
|
||||
|
||||
@@ -33,9 +28,4 @@ open class StageController(open val currentStage: Int = 0) {
|
||||
open fun <T> unrestrictDeclarationListsAccess(fn: () -> T): T = fn()
|
||||
|
||||
open fun canAccessDeclarationsOf(irClass: IrClass): Boolean = true
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun <T> withInitialIr(noinline fn: () -> T): T {
|
||||
return stageController.withInitialIr(fn)
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,8 @@ private val SCRIPT_ORIGIN = object : IrDeclarationOriginImpl("SCRIPT") {}
|
||||
|
||||
class IrScriptImpl(
|
||||
override val symbol: IrScriptSymbol,
|
||||
override val name: Name
|
||||
override val name: Name,
|
||||
override val factory: IrFactory,
|
||||
) : IrScript() {
|
||||
override val startOffset: Int get() = UNDEFINED_OFFSET
|
||||
override val endOffset: Int get() = UNDEFINED_OFFSET
|
||||
@@ -55,9 +56,6 @@ class IrScriptImpl(
|
||||
override val descriptor: ScriptDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
override val factory: IrFactory
|
||||
get() = error("Create IrScriptImpl directly")
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
+2
-4
@@ -44,10 +44,8 @@ class IrLazyTypeAlias(
|
||||
}
|
||||
|
||||
override var expandedType: IrType by lazyVar {
|
||||
withInitialIr {
|
||||
typeTranslator.buildWithScope(this) {
|
||||
descriptor.expandedType.toIrType()
|
||||
}
|
||||
typeTranslator.buildWithScope(this) {
|
||||
descriptor.expandedType.toIrType()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -39,11 +39,9 @@ class IrLazyTypeParameter(
|
||||
override var annotations: List<IrConstructorCall> by createLazyAnnotations()
|
||||
|
||||
override var superTypes: List<IrType> by lazyVar {
|
||||
withInitialIr {
|
||||
typeTranslator.buildWithScope(this.parent as IrTypeParametersContainer) {
|
||||
val descriptor = symbol.descriptor
|
||||
descriptor.upperBounds.mapTo(arrayListOf()) { it.toIrType() }
|
||||
}
|
||||
typeTranslator.buildWithScope(this.parent as IrTypeParametersContainer) {
|
||||
val descriptor = symbol.descriptor
|
||||
descriptor.upperBounds.mapTo(arrayListOf()) { it.toIrType() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.lazy
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.withInitialIr
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@@ -19,7 +18,7 @@ private class UnsafeLazyVar<T>(initializer: () -> T) : ReadWriteProperty<Any?, T
|
||||
private val value: T
|
||||
get() {
|
||||
if (!isInitialized) {
|
||||
withInitialIr { _value = initializer!!() }
|
||||
_value = initializer!!()
|
||||
isInitialized = true
|
||||
initializer = null
|
||||
}
|
||||
|
||||
@@ -113,7 +113,8 @@ open class DeepCopyIrTreeWithSymbols(
|
||||
override fun visitScript(declaration: IrScript): IrStatement {
|
||||
return IrScriptImpl(
|
||||
symbolRemapper.getDeclaredScript(declaration.symbol),
|
||||
declaration.name
|
||||
declaration.name,
|
||||
declaration.factory,
|
||||
).also { scriptCopy ->
|
||||
scriptCopy.thisReceiver = declaration.thisReceiver.transform()
|
||||
declaration.statements.mapTo(scriptCopy.statements) { it.transform() }
|
||||
|
||||
@@ -362,7 +362,7 @@ class SymbolTable(
|
||||
fun declareScript(
|
||||
descriptor: ScriptDescriptor,
|
||||
scriptFactory: (IrScriptSymbol) -> IrScript = { symbol: IrScriptSymbol ->
|
||||
IrScriptImpl(symbol, nameProvider.nameForDeclaration(descriptor))
|
||||
IrScriptImpl(symbol, nameProvider.nameForDeclaration(descriptor), irFactory)
|
||||
}
|
||||
): IrScript {
|
||||
return scriptSymbolTable.declare(
|
||||
|
||||
@@ -447,7 +447,7 @@ class GenerateIrRuntime {
|
||||
|
||||
private fun doPsi2Ir(files: List<KtFile>, analysisResult: AnalysisResult): IrModuleFragment {
|
||||
val psi2Ir = Psi2IrTranslator(languageVersionSettings, Psi2IrConfiguration())
|
||||
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), PersistentIrFactory)
|
||||
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), PersistentIrFactory())
|
||||
val psi2IrContext = psi2Ir.createGeneratorContext(analysisResult.moduleDescriptor, analysisResult.bindingContext, symbolTable)
|
||||
|
||||
val irBuiltIns = psi2IrContext.irBuiltIns
|
||||
@@ -510,7 +510,7 @@ class GenerateIrRuntime {
|
||||
private fun doDeserializeIrModule(moduleDescriptor: ModuleDescriptorImpl): DeserializedModuleInfo {
|
||||
val mangler = JsManglerDesc
|
||||
val signaturer = IdSignatureDescriptor(mangler)
|
||||
val symbolTable = SymbolTable(signaturer, PersistentIrFactory)
|
||||
val symbolTable = SymbolTable(signaturer, PersistentIrFactory())
|
||||
val typeTranslator = TypeTranslator(symbolTable, languageVersionSettings, moduleDescriptor.builtIns).also {
|
||||
it.constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable)
|
||||
}
|
||||
@@ -539,7 +539,7 @@ class GenerateIrRuntime {
|
||||
val moduleDescriptor = doDeserializeModuleMetadata(moduleRef)
|
||||
val mangler = JsManglerDesc
|
||||
val signaturer = IdSignatureDescriptor(mangler)
|
||||
val symbolTable = SymbolTable(signaturer, PersistentIrFactory)
|
||||
val symbolTable = SymbolTable(signaturer, PersistentIrFactory())
|
||||
val typeTranslator = TypeTranslator(symbolTable, languageVersionSettings, moduleDescriptor.builtIns).also {
|
||||
it.constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable)
|
||||
}
|
||||
@@ -567,7 +567,7 @@ class GenerateIrRuntime {
|
||||
|
||||
|
||||
private fun doBackEnd(module: IrModuleFragment, symbolTable: SymbolTable, irBuiltIns: IrBuiltIns, jsLinker: JsIrLinker): CompilerResult {
|
||||
val context = JsIrBackendContext(module.descriptor, irBuiltIns, symbolTable, module, emptySet(), configuration)
|
||||
val context = JsIrBackendContext(module.descriptor, irBuiltIns, symbolTable, module, emptySet(), configuration, irFactory = PersistentIrFactory())
|
||||
|
||||
ExternalDependenciesGenerator(symbolTable, listOf(jsLinker)).generateUnboundSymbolsAsDependencies()
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.js.messageCollectorLogger
|
||||
import org.jetbrains.kotlin.ir.backend.js.*
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
import org.jetbrains.kotlin.js.facade.MainCallParameters
|
||||
@@ -183,7 +183,7 @@ abstract class BasicIrBoxTest(
|
||||
configuration = config.configuration,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = emptyList(),
|
||||
irFactory = PersistentIrFactory,
|
||||
irFactory = IrFactoryImpl,
|
||||
outputKlibPath = actualOutputFile,
|
||||
nopack = true
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user