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