IR: add module ir.tree.persistent, copy PIR implementation there
Use PersistentIrFactory in JS IR compiler entry points.
This commit is contained in:
@@ -229,6 +229,7 @@ extra["compilerModules"] = arrayOf(
|
||||
":compiler:frontend.java",
|
||||
":compiler:cli-common",
|
||||
":compiler:ir.tree",
|
||||
":compiler:ir.tree.persistent",
|
||||
":compiler:ir.psi2ir",
|
||||
":compiler:ir.backend.common",
|
||||
":compiler:backend.jvm",
|
||||
|
||||
@@ -6,6 +6,7 @@ plugins {
|
||||
dependencies {
|
||||
compile(project(":compiler:cli"))
|
||||
compile(project(":compiler:ir.serialization.js"))
|
||||
compileOnly(project(":compiler:ir.tree.persistent"))
|
||||
runtimeOnly(project(":kotlin-reflect"))
|
||||
if (Platform[193].orLower()) {
|
||||
compile(intellijDep()) { includeJars("picocontainer", rootProject = rootProject) }
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.cli.common.messages.*
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -88,7 +88,7 @@ fun buildKLib(
|
||||
configuration = configuration,
|
||||
allDependencies = allDependencies,
|
||||
friendDependencies = emptyList(),
|
||||
irFactory = IrFactoryImpl,
|
||||
irFactory = PersistentIrFactory,
|
||||
outputKlibPath = outputPath,
|
||||
nopack = true
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalNextRoundChecker
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||
import org.jetbrains.kotlin.ir.backend.js.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.js.config.EcmaVersion
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
@@ -197,7 +197,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
configuration = config.configuration,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
irFactory = IrFactoryImpl,
|
||||
irFactory = PersistentIrFactory,
|
||||
outputKlibPath = outputKlibPath,
|
||||
nopack = arguments.irProduceKlibDir
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ dependencies {
|
||||
compile(project(":compiler:ir.backend.common"))
|
||||
compile(project(":compiler:ir.serialization.common"))
|
||||
compile(project(":compiler:ir.serialization.js"))
|
||||
compile(project(":compiler:ir.tree.persistent"))
|
||||
compile(project(":js:js.ast"))
|
||||
compile(project(":js:js.frontend"))
|
||||
|
||||
@@ -22,4 +23,3 @@ sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.jetbrains.kotlin.ir.backend.js.utils.OperatorNames
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
@@ -55,7 +55,7 @@ class JsIrBackendContext(
|
||||
|
||||
override var inVerbosePhase: Boolean = false
|
||||
|
||||
override val irFactory: IrFactory = IrFactoryImpl
|
||||
override val irFactory: IrFactory = PersistentIrFactory
|
||||
|
||||
val devMode = configuration[JSConfigurationKeys.DEVELOPER_MODE] ?: false
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.ir.backend.js
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrDeclarationBase
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.util.isLocal
|
||||
|
||||
@@ -18,7 +18,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
override var currentStage: Int = 0
|
||||
|
||||
override fun lazyLower(declaration: IrDeclaration) {
|
||||
if (declaration is IrDeclarationBase<*>) {
|
||||
if (declaration is PersistentIrDeclarationBase<*>) {
|
||||
while (declaration.loweredUpTo + 1 < currentStage) {
|
||||
val i = declaration.loweredUpTo + 1
|
||||
withStage(i) {
|
||||
@@ -44,7 +44,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
}
|
||||
|
||||
override fun lazyLower(body: IrBody) {
|
||||
if (body is IrBodyBase<*>) {
|
||||
if (body is PersistentIrBodyBase<*>) {
|
||||
for (i in (body.loweredUpTo + 1) until currentStage) {
|
||||
withStage(i) {
|
||||
if (body.container !in context.externalDeclarations) {
|
||||
@@ -63,7 +63,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
}
|
||||
|
||||
// Launches a lowering and applies it's results
|
||||
private fun DeclarationLowering.doApplyLoweringTo(declaration: IrDeclarationBase<*>) {
|
||||
private fun DeclarationLowering.doApplyLoweringTo(declaration: PersistentIrDeclarationBase<*>) {
|
||||
val parentBefore = declaration.parent
|
||||
val result = restrictTo(declaration) { this.declarationTransformer(context).transformFlat(declaration) }
|
||||
if (result != null) {
|
||||
@@ -184,4 +184,4 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
declarationListsRestricted = wereDeclarationListsRestricted
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransf
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.NameTables
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.StageController
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.noUnboundLeft
|
||||
@@ -53,7 +53,7 @@ fun compile(
|
||||
stageController = StageController()
|
||||
|
||||
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
||||
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, IrFactoryImpl)
|
||||
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, PersistentIrFactory)
|
||||
|
||||
val moduleDescriptor = moduleFragment.descriptor
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.ir.backend.js.JsSharedVariablesManager
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.JsInnerClassesSupport
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
|
||||
@@ -42,7 +42,7 @@ class WasmBackendContext(
|
||||
override val transformedFunction = mutableMapOf<IrFunctionSymbol, IrSimpleFunctionSymbol>()
|
||||
override val lateinitNullableFields = mutableMapOf<IrField, IrField>()
|
||||
override val extractedLocalClasses: MutableSet<IrClass> = hashSetOf()
|
||||
override val irFactory: IrFactory = IrFactoryImpl
|
||||
override val irFactory: IrFactory = PersistentIrFactory
|
||||
|
||||
// Place to store declarations excluded from code generation
|
||||
val excludedDeclarations: IrPackageFragment by lazy {
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.ir.backend.js.MainModule
|
||||
import org.jetbrains.kotlin.ir.backend.js.loadIr
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.generateTypicalIrProviderList
|
||||
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
|
||||
@@ -37,7 +37,8 @@ fun compileWasm(
|
||||
): WasmCompilerResult {
|
||||
val (moduleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
||||
loadIr(
|
||||
project, MainModule.SourceFiles(files), analyzer, configuration, allDependencies, friendDependencies, IrFactoryImpl
|
||||
project, MainModule.SourceFiles(files), analyzer, configuration, allDependencies, friendDependencies,
|
||||
PersistentIrFactory
|
||||
)
|
||||
|
||||
val moduleDescriptor = moduleFragment.descriptor
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:ir.tree"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrAnonymousInitializer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.AnonymousInitializerCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrAnonymousInitializerSymbol
|
||||
|
||||
class PersistentIrAnonymousInitializer(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrAnonymousInitializerSymbol,
|
||||
override val isStatic: Boolean = false
|
||||
) : PersistentIrDeclarationBase<AnonymousInitializerCarrier>(startOffset, endOffset, origin),
|
||||
IrAnonymousInitializer,
|
||||
AnonymousInitializerCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ClassDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
override var bodyField: IrBlockBody? = null
|
||||
|
||||
override var body: IrBlockBody
|
||||
get() = getCarrier().bodyField!!
|
||||
set(v) {
|
||||
if (getCarrier().bodyField !== v) {
|
||||
if (v is PersistentIrBodyBase<*>) {
|
||||
v.container = this
|
||||
}
|
||||
setCarrier().bodyField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ClassCarrier
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import java.util.*
|
||||
|
||||
class PersistentIrClass(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrClassSymbol,
|
||||
override val name: Name,
|
||||
override val kind: ClassKind,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
override val isCompanion: Boolean = false,
|
||||
override val isInner: Boolean = false,
|
||||
override val isData: Boolean = false,
|
||||
override val isExternal: Boolean = false,
|
||||
override val isInline: Boolean = false,
|
||||
override val isExpect: Boolean = false,
|
||||
override val isFun: Boolean = false,
|
||||
override val source: SourceElement = SourceElement.NO_SOURCE
|
||||
) :
|
||||
PersistentIrDeclarationBase<ClassCarrier>(startOffset, endOffset, origin),
|
||||
IrClass,
|
||||
ClassCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ClassDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
override var visibilityField: Visibility = visibility
|
||||
|
||||
override var visibility: Visibility
|
||||
get() = getCarrier().visibilityField
|
||||
set(v) {
|
||||
if (visibility !== v) {
|
||||
setCarrier().visibilityField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var thisReceiverField: IrValueParameter? = null
|
||||
|
||||
override var thisReceiver: IrValueParameter?
|
||||
get() = getCarrier().thisReceiverField
|
||||
set(v) {
|
||||
if (thisReceiver !== v) {
|
||||
setCarrier().thisReceiverField = v
|
||||
}
|
||||
}
|
||||
|
||||
private var initialDeclarations: MutableList<IrDeclaration>? = null
|
||||
|
||||
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
||||
get() {
|
||||
if (createdOn < stageController.currentStage && initialDeclarations == null) {
|
||||
initialDeclarations = Collections.unmodifiableList(ArrayList(field))
|
||||
}
|
||||
|
||||
return if (stageController.canAccessDeclarationsOf(this)) {
|
||||
ensureLowered()
|
||||
field
|
||||
} else {
|
||||
initialDeclarations ?: field
|
||||
}
|
||||
}
|
||||
|
||||
override var typeParametersField: List<IrTypeParameter> = emptyList()
|
||||
|
||||
override var typeParameters: List<IrTypeParameter>
|
||||
get() = getCarrier().typeParametersField
|
||||
set(v) {
|
||||
if (typeParameters !== v) {
|
||||
setCarrier().typeParametersField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var superTypesField: List<IrType> = emptyList()
|
||||
|
||||
override var superTypes: List<IrType>
|
||||
get() = getCarrier().superTypesField
|
||||
set(v) {
|
||||
if (superTypes !== v) {
|
||||
setCarrier().superTypesField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var metadataField: MetadataSource? = null
|
||||
|
||||
override var metadata: MetadataSource?
|
||||
get() = getCarrier().metadataField
|
||||
set(v) {
|
||||
if (metadata !== v) {
|
||||
setCarrier().metadataField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var modalityField: Modality = modality
|
||||
|
||||
override var modality: Modality
|
||||
get() = getCarrier().modalityField
|
||||
set(v) {
|
||||
if (modality !== v) {
|
||||
setCarrier().modalityField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var attributeOwnerIdField: IrAttributeContainer = this
|
||||
|
||||
override var attributeOwnerId: IrAttributeContainer
|
||||
get() = getCarrier().attributeOwnerIdField
|
||||
set(v) {
|
||||
if (attributeOwnerId !== v) {
|
||||
setCarrier().attributeOwnerIdField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ConstructorCarrier
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class PersistentIrConstructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrConstructorSymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
override val isPrimary: Boolean,
|
||||
isExpect: Boolean
|
||||
) :
|
||||
PersistentIrFunctionBase<ConstructorCarrier>(
|
||||
startOffset, endOffset, origin, name,
|
||||
visibility,
|
||||
isInline, isExternal, isExpect,
|
||||
returnType
|
||||
),
|
||||
IrConstructor,
|
||||
ConstructorCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ClassConstructorDescriptor
|
||||
get() = symbol.descriptor
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.ir.IrElementBase
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.BodyCarrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.DeclarationCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
abstract class PersistentIrDeclarationBase<T : DeclarationCarrier>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin
|
||||
) : PersistentIrElementBase<T>(startOffset, endOffset),
|
||||
IrDeclaration,
|
||||
DeclarationCarrier {
|
||||
|
||||
override val factory: IrFactory
|
||||
get() = PersistentIrFactory
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
|
||||
// TODO reduce boilerplate
|
||||
override var parent: IrDeclarationParent
|
||||
get() = getCarrier().parentField ?: throw UninitializedPropertyAccessException("Parent not initialized: $this")
|
||||
set(p) {
|
||||
if (getCarrier().parentField !== p) {
|
||||
setCarrier().parentField = p
|
||||
}
|
||||
}
|
||||
|
||||
override var originField: IrDeclarationOrigin = origin
|
||||
|
||||
override var origin: IrDeclarationOrigin
|
||||
get() = getCarrier().originField
|
||||
set(p) {
|
||||
if (getCarrier().originField !== p) {
|
||||
setCarrier().originField = p
|
||||
}
|
||||
}
|
||||
|
||||
var removedOn: Int = Int.MAX_VALUE
|
||||
|
||||
override var annotationsField: List<IrConstructorCall> = emptyList()
|
||||
|
||||
override var annotations: List<IrConstructorCall>
|
||||
get() = getCarrier().annotationsField
|
||||
set(v) {
|
||||
if (getCarrier().annotationsField !== v) {
|
||||
setCarrier().annotationsField = v
|
||||
}
|
||||
}
|
||||
|
||||
override fun ensureLowered() {
|
||||
if (stageController.currentStage > loweredUpTo) {
|
||||
stageController.lazyLower(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
abstract class PersistentIrElementBase<T : Carrier>(
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
) : IrElementBase(startOffset, endOffset),
|
||||
Carrier {
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
|
||||
var loweredUpTo = stageController.currentStage
|
||||
|
||||
// TODO Array<T>?
|
||||
private var values: Array<Carrier>? = null
|
||||
|
||||
val createdOn: Int = stageController.currentStage
|
||||
// get() = values?.let { (it[0] as T).lastModified } ?: lastModified
|
||||
|
||||
abstract fun ensureLowered()
|
||||
|
||||
protected fun getCarrier(): T {
|
||||
stageController.currentStage.let { stage ->
|
||||
ensureLowered()
|
||||
|
||||
if (stage >= lastModified) return this as T
|
||||
|
||||
if (stage < createdOn) error("Access before creation")
|
||||
|
||||
val v = values
|
||||
?: error("How come?")
|
||||
|
||||
var l = -1
|
||||
var r = v.size
|
||||
while (r - l > 1) {
|
||||
val m = (l + r) / 2
|
||||
if ((v[m] as T).lastModified <= stage) {
|
||||
l = m
|
||||
} else {
|
||||
r = m
|
||||
}
|
||||
}
|
||||
if (l < 0) {
|
||||
error("access before creation")
|
||||
}
|
||||
|
||||
return v[l] as T
|
||||
}
|
||||
}
|
||||
|
||||
// TODO naming? e.g. `mutableCarrier`
|
||||
protected fun setCarrier(): T {
|
||||
val stage = stageController.currentStage
|
||||
|
||||
ensureLowered()
|
||||
|
||||
if (!stageController.canModify(this)) {
|
||||
error("Cannot modify this element!")
|
||||
}
|
||||
|
||||
if (loweredUpTo > stage) {
|
||||
error("retrospective modification")
|
||||
}
|
||||
|
||||
// TODO move up? i.e. fast path
|
||||
if (stage == lastModified) {
|
||||
return this as T
|
||||
} else {
|
||||
values = (values ?: emptyArray()) + this.clone() as T
|
||||
}
|
||||
|
||||
this.lastModified = stage
|
||||
|
||||
return this as T
|
||||
}
|
||||
}
|
||||
|
||||
abstract class PersistentIrBodyBase<B : PersistentIrBodyBase<B>>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
private var initializer: (B.() -> Unit)?
|
||||
) : PersistentIrElementBase<BodyCarrier>(startOffset, endOffset), IrBody, BodyCarrier {
|
||||
override var containerField: IrDeclaration? = null
|
||||
|
||||
var container: IrDeclaration
|
||||
get() = getCarrier().containerField!!
|
||||
set(p) {
|
||||
if (getCarrier().containerField !== p) {
|
||||
setCarrier().containerField = p
|
||||
}
|
||||
}
|
||||
|
||||
protected fun <T> checkEnabled(fn: () -> T): T {
|
||||
if (!stageController.bodiesEnabled) error("Bodies disabled!")
|
||||
ensureLowered()
|
||||
return fn()
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun ensureLowered() {
|
||||
initializer?.let { initFn ->
|
||||
initializer = null
|
||||
stageController.withStage(createdOn) {
|
||||
stageController.bodyLowering {
|
||||
initFn.invoke(this as B)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (loweredUpTo + 1 < stageController.currentStage) {
|
||||
stageController.lazyLower(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.EnumEntryCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class PersistentIrEnumEntry(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrEnumEntrySymbol,
|
||||
override val name: Name
|
||||
) : PersistentIrDeclarationBase<EnumEntryCarrier>(startOffset, endOffset, origin),
|
||||
IrEnumEntry,
|
||||
EnumEntryCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ClassDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
override var correspondingClassField: IrClass? = null
|
||||
|
||||
override var correspondingClass: IrClass?
|
||||
get() = getCarrier().correspondingClassField
|
||||
set(v) {
|
||||
if (correspondingClass !== v) {
|
||||
setCarrier().correspondingClassField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var initializerExpressionField: IrExpressionBody? = null
|
||||
|
||||
override var initializerExpression: IrExpressionBody?
|
||||
get() = getCarrier().initializerExpressionField
|
||||
set(v) {
|
||||
if (initializerExpression !== v) {
|
||||
if (v is PersistentIrBodyBase<*>) {
|
||||
v.container = this
|
||||
}
|
||||
setCarrier().initializerExpressionField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ErrorCarrier
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
class PersistentIrErrorDeclaration(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val descriptor: DeclarationDescriptor
|
||||
) : PersistentIrDeclarationBase<ErrorCarrier>(startOffset, endOffset, IrDeclarationOrigin.DEFINED), IrErrorDeclaration, ErrorCarrier
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.expressions.persistent.PersistentIrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.persistent.PersistentIrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
object PersistentIrFactory : IrFactory {
|
||||
override fun createAnonymousInitializer(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrAnonymousInitializerSymbol,
|
||||
isStatic: Boolean,
|
||||
): IrAnonymousInitializer =
|
||||
PersistentIrAnonymousInitializer(startOffset, endOffset, origin, symbol, isStatic)
|
||||
|
||||
override fun createClass(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrClassSymbol,
|
||||
name: Name,
|
||||
kind: ClassKind,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
isCompanion: Boolean,
|
||||
isInner: Boolean,
|
||||
isData: Boolean,
|
||||
isExternal: Boolean,
|
||||
isInline: Boolean,
|
||||
isExpect: Boolean,
|
||||
isFun: Boolean,
|
||||
source: SourceElement,
|
||||
): IrClass =
|
||||
PersistentIrClass(
|
||||
startOffset, endOffset, origin, symbol, name, kind, visibility, modality,
|
||||
isCompanion, isInner, isData, isExternal, isInline, isExpect, isFun, source,
|
||||
)
|
||||
|
||||
override fun createConstructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrConstructorSymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
isPrimary: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrConstructor =
|
||||
PersistentIrConstructor(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, returnType, isInline, isExternal, isPrimary, isExpect
|
||||
)
|
||||
|
||||
override fun createEnumEntry(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrEnumEntrySymbol,
|
||||
name: Name,
|
||||
): IrEnumEntry =
|
||||
PersistentIrEnumEntry(startOffset, endOffset, origin, symbol, name)
|
||||
|
||||
override fun createErrorDeclaration(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
descriptor: DeclarationDescriptor,
|
||||
): IrErrorDeclaration =
|
||||
PersistentIrErrorDeclaration(startOffset, endOffset, descriptor)
|
||||
|
||||
override fun createField(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrFieldSymbol,
|
||||
name: Name,
|
||||
type: IrType,
|
||||
visibility: Visibility,
|
||||
isFinal: Boolean,
|
||||
isExternal: Boolean,
|
||||
isStatic: Boolean,
|
||||
): IrField =
|
||||
PersistentIrField(startOffset, endOffset, origin, symbol, name, type, visibility, isFinal, isExternal, isStatic)
|
||||
|
||||
override fun createFunction(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrSimpleFunctionSymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
isTailrec: Boolean,
|
||||
isSuspend: Boolean,
|
||||
isOperator: Boolean,
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
isFakeOverride: Boolean,
|
||||
): IrSimpleFunction =
|
||||
PersistentIrFunction(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, modality, returnType,
|
||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, isFakeOverride,
|
||||
)
|
||||
|
||||
override fun createFakeOverrideFunction(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
isTailrec: Boolean,
|
||||
isSuspend: Boolean,
|
||||
isOperator: Boolean,
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrSimpleFunction =
|
||||
PersistentIrFakeOverrideFunction(
|
||||
startOffset, endOffset, origin, name, visibility, modality, returnType,
|
||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
)
|
||||
|
||||
override fun createLocalDelegatedProperty(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrLocalDelegatedPropertySymbol,
|
||||
name: Name,
|
||||
type: IrType,
|
||||
isVar: Boolean,
|
||||
): IrLocalDelegatedProperty =
|
||||
PersistentIrLocalDelegatedProperty(
|
||||
startOffset, endOffset, origin, symbol, name, type, isVar
|
||||
)
|
||||
|
||||
override fun createProperty(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrPropertySymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
isVar: Boolean,
|
||||
isConst: Boolean,
|
||||
isLateinit: Boolean,
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
isFakeOverride: Boolean,
|
||||
): IrProperty =
|
||||
PersistentIrProperty(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, modality,
|
||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, isFakeOverride,
|
||||
)
|
||||
|
||||
override fun createFakeOverrideProperty(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
isVar: Boolean,
|
||||
isConst: Boolean,
|
||||
isLateinit: Boolean,
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrFakeOverrideProperty =
|
||||
PersistentIrFakeOverrideProperty(
|
||||
startOffset, endOffset, origin, name, visibility, modality,
|
||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
)
|
||||
|
||||
override fun createTypeAlias(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
symbol: IrTypeAliasSymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
expandedType: IrType,
|
||||
isActual: Boolean,
|
||||
origin: IrDeclarationOrigin,
|
||||
): IrTypeAlias =
|
||||
PersistentIrTypeAlias(startOffset, endOffset, symbol, name, visibility, expandedType, isActual, origin)
|
||||
|
||||
override fun createTypeParameter(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrTypeParameterSymbol,
|
||||
name: Name,
|
||||
index: Int,
|
||||
isReified: Boolean,
|
||||
variance: Variance,
|
||||
): IrTypeParameter =
|
||||
PersistentIrTypeParameter(startOffset, endOffset, origin, symbol, name, index, isReified, variance)
|
||||
|
||||
override fun createValueParameter(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrValueParameterSymbol,
|
||||
name: Name,
|
||||
index: Int,
|
||||
type: IrType,
|
||||
varargElementType: IrType?,
|
||||
isCrossinline: Boolean,
|
||||
isNoinline: Boolean,
|
||||
): IrValueParameter =
|
||||
PersistentIrValueParameter(startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline)
|
||||
|
||||
override fun createExpressionBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
initializer: IrExpressionBody.() -> Unit,
|
||||
): IrExpressionBody =
|
||||
PersistentIrExpressionBody(startOffset, endOffset, initializer)
|
||||
|
||||
override fun createExpressionBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
expression: IrExpression,
|
||||
): IrExpressionBody =
|
||||
PersistentIrExpressionBody(startOffset, endOffset, expression)
|
||||
|
||||
override fun createExpressionBody(
|
||||
expression: IrExpression,
|
||||
): IrExpressionBody =
|
||||
PersistentIrExpressionBody(expression)
|
||||
|
||||
override fun createBlockBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
): IrBlockBody =
|
||||
PersistentIrBlockBody(startOffset, endOffset)
|
||||
|
||||
override fun createBlockBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
statements: List<IrStatement>,
|
||||
): IrBlockBody =
|
||||
PersistentIrBlockBody(startOffset, endOffset, statements)
|
||||
|
||||
override fun createBlockBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
initializer: IrBlockBody.() -> Unit,
|
||||
): IrBlockBody =
|
||||
PersistentIrBlockBody(startOffset, endOffset, initializer)
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FieldCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class PersistentIrField(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrFieldSymbol,
|
||||
override val name: Name,
|
||||
override val type: IrType,
|
||||
override var visibility: Visibility,
|
||||
override val isFinal: Boolean,
|
||||
override val isExternal: Boolean,
|
||||
override val isStatic: Boolean
|
||||
) : PersistentIrDeclarationBase<FieldCarrier>(startOffset, endOffset, origin),
|
||||
IrField,
|
||||
FieldCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: PropertyDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
override var initializerField: IrExpressionBody? = null
|
||||
|
||||
override var initializer: IrExpressionBody?
|
||||
get() = getCarrier().initializerField
|
||||
set(v) {
|
||||
if (initializer !== v) {
|
||||
if (v is PersistentIrBodyBase<*>) {
|
||||
v.container = this
|
||||
}
|
||||
setCarrier().initializerField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var correspondingPropertySymbolField: IrPropertySymbol? = null
|
||||
|
||||
override var correspondingPropertySymbol: IrPropertySymbol?
|
||||
get() = getCarrier().correspondingPropertySymbolField
|
||||
set(v) {
|
||||
if (correspondingPropertySymbol !== v) {
|
||||
setCarrier().correspondingPropertySymbolField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var metadataField: MetadataSource? = null
|
||||
|
||||
override var metadata: MetadataSource?
|
||||
get() = getCarrier().metadataField
|
||||
set(v) {
|
||||
if (metadata !== v) {
|
||||
setCarrier().metadataField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFakeOverrideFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
abstract class PersistentIrFunctionCommon(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
override val isTailrec: Boolean,
|
||||
override val isSuspend: Boolean,
|
||||
override val isOperator: Boolean,
|
||||
override val isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
) :
|
||||
PersistentIrFunctionBase<FunctionCarrier>(startOffset, endOffset, origin, name, visibility, isInline, isExternal, isExpect, returnType),
|
||||
IrSimpleFunction,
|
||||
FunctionCarrier {
|
||||
|
||||
override var overriddenSymbolsField: List<IrSimpleFunctionSymbol> = emptyList()
|
||||
|
||||
override var overriddenSymbols: List<IrSimpleFunctionSymbol>
|
||||
get() = getCarrier().overriddenSymbolsField
|
||||
set(v) {
|
||||
if (overriddenSymbols !== v) {
|
||||
setCarrier().overriddenSymbolsField = v
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("LeakingThis")
|
||||
override var attributeOwnerIdField: IrAttributeContainer = this
|
||||
|
||||
override var attributeOwnerId: IrAttributeContainer
|
||||
get() = getCarrier().attributeOwnerIdField
|
||||
set(v) {
|
||||
if (attributeOwnerId !== v) {
|
||||
setCarrier().attributeOwnerIdField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var correspondingPropertySymbolField: IrPropertySymbol? = null
|
||||
|
||||
override var correspondingPropertySymbol: IrPropertySymbol?
|
||||
get() = getCarrier().correspondingPropertySymbolField
|
||||
set(v) {
|
||||
if (correspondingPropertySymbol !== v) {
|
||||
setCarrier().correspondingPropertySymbolField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PersistentIrFunction(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrSimpleFunctionSymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
isTailrec: Boolean,
|
||||
isSuspend: Boolean,
|
||||
isOperator: Boolean,
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
) : PersistentIrFunctionCommon(
|
||||
startOffset, endOffset, origin, name, visibility, returnType, isInline,
|
||||
isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
) {
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: FunctionDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
}
|
||||
|
||||
class PersistentIrFakeOverrideFunction(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
name: Name,
|
||||
override var visibility: Visibility,
|
||||
override var modality: Modality,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
isTailrec: Boolean,
|
||||
isSuspend: Boolean,
|
||||
isOperator: Boolean,
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
) : PersistentIrFunctionCommon(
|
||||
startOffset, endOffset, origin, name, visibility, returnType, isInline,
|
||||
isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
), IrFakeOverrideFunction {
|
||||
override val isFakeOverride: Boolean
|
||||
get() = true
|
||||
|
||||
private var _symbol: IrSimpleFunctionSymbol? = null
|
||||
|
||||
override val symbol: IrSimpleFunctionSymbol
|
||||
get() = _symbol ?: error("$this has not acquired a symbol yet")
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor
|
||||
get() = _symbol?.descriptor ?: WrappedSimpleFunctionDescriptor()
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
override fun acquireSymbol(symbol: IrSimpleFunctionSymbol) {
|
||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||
_symbol = symbol
|
||||
symbol.bind(this)
|
||||
(symbol.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionBaseCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
abstract class PersistentIrFunctionBase<T : FunctionBaseCarrier>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val name: Name,
|
||||
visibility: Visibility,
|
||||
override val isInline: Boolean,
|
||||
override val isExternal: Boolean,
|
||||
override val isExpect: Boolean,
|
||||
returnType: IrType
|
||||
) :
|
||||
PersistentIrDeclarationBase<T>(startOffset, endOffset, origin),
|
||||
IrFunction,
|
||||
FunctionBaseCarrier {
|
||||
|
||||
override var returnTypeFieldField: IrType = returnType
|
||||
|
||||
private var returnTypeField: IrType
|
||||
get() = getCarrier().returnTypeFieldField
|
||||
set(v) {
|
||||
if (returnTypeField !== v) {
|
||||
setCarrier().returnTypeFieldField = v
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
final override var returnType: IrType
|
||||
get() = returnTypeField.let {
|
||||
if (it !== org.jetbrains.kotlin.ir.types.impl.IrUninitializedType) it else error("Return type is not initialized")
|
||||
}
|
||||
set(c) {
|
||||
returnTypeField = c
|
||||
}
|
||||
|
||||
override var typeParametersField: List<IrTypeParameter> = emptyList()
|
||||
|
||||
override var typeParameters: List<IrTypeParameter>
|
||||
get() = getCarrier().typeParametersField
|
||||
set(v) {
|
||||
if (typeParameters !== v) {
|
||||
setCarrier().typeParametersField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var dispatchReceiverParameterField: IrValueParameter? = null
|
||||
|
||||
override var dispatchReceiverParameter: IrValueParameter?
|
||||
get() = getCarrier().dispatchReceiverParameterField
|
||||
set(v) {
|
||||
if (dispatchReceiverParameter !== v) {
|
||||
setCarrier().dispatchReceiverParameterField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var extensionReceiverParameterField: IrValueParameter? = null
|
||||
|
||||
override var extensionReceiverParameter: IrValueParameter?
|
||||
get() = getCarrier().extensionReceiverParameterField
|
||||
set(v) {
|
||||
if (extensionReceiverParameter !== v) {
|
||||
setCarrier().extensionReceiverParameterField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var valueParametersField: List<IrValueParameter> = emptyList()
|
||||
|
||||
override var valueParameters: List<IrValueParameter>
|
||||
get() = getCarrier().valueParametersField
|
||||
set(v) {
|
||||
if (valueParameters !== v) {
|
||||
setCarrier().valueParametersField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var bodyField: IrBody? = null
|
||||
|
||||
final override var body: IrBody?
|
||||
get() = getCarrier().bodyField
|
||||
set(v) {
|
||||
if (body !== v) {
|
||||
if (v is PersistentIrBodyBase<*>) {
|
||||
v.container = this
|
||||
}
|
||||
setCarrier().bodyField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var metadataField: MetadataSource? = null
|
||||
|
||||
override var metadata: MetadataSource?
|
||||
get() = getCarrier().metadataField
|
||||
set(v) {
|
||||
if (metadata !== v) {
|
||||
setCarrier().metadataField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var visibilityField: Visibility = visibility
|
||||
|
||||
override var visibility: Visibility
|
||||
get() = getCarrier().visibilityField
|
||||
set(v) {
|
||||
if (visibility !== v) {
|
||||
setCarrier().visibilityField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.LocalDelegatedPropertyCarrier
|
||||
import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
// TODO make not persistent
|
||||
class PersistentIrLocalDelegatedProperty(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrLocalDelegatedPropertySymbol,
|
||||
override val name: Name,
|
||||
override val type: IrType,
|
||||
override val isVar: Boolean
|
||||
) :
|
||||
PersistentIrDeclarationBase<LocalDelegatedPropertyCarrier>(startOffset, endOffset, origin),
|
||||
IrLocalDelegatedProperty,
|
||||
LocalDelegatedPropertyCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: VariableDescriptorWithAccessors
|
||||
get() = symbol.descriptor
|
||||
|
||||
override var delegateField: IrVariable? = null
|
||||
|
||||
override var delegate: IrVariable
|
||||
get() = getCarrier().delegateField!!
|
||||
set(v) {
|
||||
if (getCarrier().delegateField !== v) {
|
||||
setCarrier().delegateField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var getterField: IrFunction? = null
|
||||
|
||||
override var getter: IrFunction
|
||||
get() = getCarrier().getterField!!
|
||||
set(v) {
|
||||
if (getCarrier().getterField !== v) {
|
||||
setCarrier().getterField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var setterField: IrFunction? = null
|
||||
|
||||
override var setter: IrFunction?
|
||||
get() = getCarrier().setterField
|
||||
set(v) {
|
||||
if (setter !== v) {
|
||||
setCarrier().setterField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var metadataField: MetadataSource? = null
|
||||
|
||||
override var metadata: MetadataSource?
|
||||
get() = getCarrier().metadataField
|
||||
set(v) {
|
||||
if (metadata !== v) {
|
||||
setCarrier().metadataField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.PropertyCarrier
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
abstract class PersistentIrPropertyCommon(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val name: Name,
|
||||
override var visibility: Visibility,
|
||||
override val isVar: Boolean,
|
||||
override val isConst: Boolean,
|
||||
override val isLateinit: Boolean,
|
||||
override val isDelegated: Boolean,
|
||||
override val isExternal: Boolean,
|
||||
override val isExpect: Boolean,
|
||||
) : PersistentIrDeclarationBase<PropertyCarrier>(startOffset, endOffset, origin),
|
||||
IrProperty,
|
||||
PropertyCarrier {
|
||||
|
||||
override var backingFieldField: IrField? = null
|
||||
|
||||
override var backingField: IrField?
|
||||
get() = getCarrier().backingFieldField
|
||||
set(v) {
|
||||
if (backingField !== v) {
|
||||
setCarrier().backingFieldField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var getterField: IrSimpleFunction? = null
|
||||
|
||||
override var getter: IrSimpleFunction?
|
||||
get() = getCarrier().getterField
|
||||
set(v) {
|
||||
if (getter !== v) {
|
||||
setCarrier().getterField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var setterField: IrSimpleFunction? = null
|
||||
|
||||
override var setter: IrSimpleFunction?
|
||||
get() = getCarrier().setterField
|
||||
set(v) {
|
||||
if (setter !== v) {
|
||||
setCarrier().setterField = v
|
||||
}
|
||||
}
|
||||
|
||||
override var metadataField: MetadataSource? = null
|
||||
|
||||
override var metadata: MetadataSource?
|
||||
get() = getCarrier().metadataField
|
||||
set(v) {
|
||||
if (metadata !== v) {
|
||||
setCarrier().metadataField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PersistentIrProperty(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrPropertySymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
isVar: Boolean,
|
||||
isConst: Boolean,
|
||||
isLateinit: Boolean,
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean = false,
|
||||
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
) : PersistentIrPropertyCommon(
|
||||
startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
) {
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: PropertyDescriptor
|
||||
get() = symbol.descriptor
|
||||
}
|
||||
|
||||
class PersistentIrFakeOverrideProperty(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
override var modality: Modality,
|
||||
isVar: Boolean,
|
||||
isConst: Boolean,
|
||||
isLateinit: Boolean,
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
) : PersistentIrPropertyCommon(
|
||||
startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit,
|
||||
isDelegated, isExternal, isExpect
|
||||
), IrFakeOverrideProperty {
|
||||
override val isFakeOverride: Boolean
|
||||
get() = true
|
||||
|
||||
private var _symbol: IrPropertySymbol? = null
|
||||
|
||||
override val symbol: IrPropertySymbol
|
||||
get() = _symbol ?: error("$this has not acquired a symbol yet")
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor
|
||||
get() = _symbol?.descriptor ?: WrappedPropertyDescriptor()
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
override fun acquireSymbol(symbol: IrPropertySymbol) {
|
||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||
_symbol = symbol
|
||||
symbol.bind(this)
|
||||
(symbol.descriptor as? WrappedPropertyDescriptor)?.bind(this)
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeAlias
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.TypeAliasCarrier
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class PersistentIrTypeAlias(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
override val symbol: IrTypeAliasSymbol,
|
||||
override val name: Name,
|
||||
override var visibility: Visibility,
|
||||
override val expandedType: IrType,
|
||||
override val isActual: Boolean,
|
||||
origin: IrDeclarationOrigin
|
||||
) :
|
||||
PersistentIrDeclarationBase<TypeAliasCarrier>(startOffset, endOffset, origin),
|
||||
IrTypeAlias,
|
||||
TypeAliasCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: TypeAliasDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
override var typeParametersField: List<IrTypeParameter> = emptyList()
|
||||
|
||||
override var typeParameters: List<IrTypeParameter>
|
||||
get() = getCarrier().typeParametersField
|
||||
set(v) {
|
||||
if (typeParameters !== v) {
|
||||
setCarrier().typeParametersField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.TypeParameterCarrier
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class PersistentIrTypeParameter(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrTypeParameterSymbol,
|
||||
override val name: Name,
|
||||
override val index: Int,
|
||||
override val isReified: Boolean,
|
||||
override val variance: Variance
|
||||
) :
|
||||
PersistentIrDeclarationBase<TypeParameterCarrier>(startOffset, endOffset, origin),
|
||||
IrTypeParameter,
|
||||
TypeParameterCarrier {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: TypeParameterDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
override val superTypes: MutableList<IrType> = SmartList()
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ValueParameterCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class PersistentIrValueParameter(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrValueParameterSymbol,
|
||||
override val name: Name,
|
||||
override val index: Int,
|
||||
override val type: IrType,
|
||||
override val varargElementType: IrType?,
|
||||
override val isCrossinline: Boolean,
|
||||
override val isNoinline: Boolean
|
||||
) :
|
||||
PersistentIrDeclarationBase<ValueParameterCarrier>(startOffset, endOffset, origin),
|
||||
IrValueParameter,
|
||||
ValueParameterCarrier {
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ParameterDescriptor
|
||||
get() = symbol.descriptor
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override var defaultValueField: IrExpressionBody? = null
|
||||
|
||||
override var defaultValue: IrExpressionBody?
|
||||
get() = getCarrier().defaultValueField
|
||||
set(v) {
|
||||
if (defaultValue !== v) {
|
||||
if (v is PersistentIrBodyBase<*>) {
|
||||
v.container = this
|
||||
}
|
||||
setCarrier().defaultValueField = v
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
@@ -30,4 +30,4 @@ class AnonymousInitializerCarrierImpl(
|
||||
override var originField: IrDeclarationOrigin,
|
||||
override var annotationsField: List<IrConstructorCall>,
|
||||
override var bodyField: IrBlockBody?
|
||||
) : AnonymousInitializerCarrier
|
||||
) : AnonymousInitializerCarrier
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
|
||||
@@ -19,4 +19,4 @@ interface BodyCarrier : Carrier {
|
||||
class BodyCarrierImpl(
|
||||
override val lastModified: Int,
|
||||
override var containerField: IrDeclaration?
|
||||
) : BodyCarrier
|
||||
) : BodyCarrier
|
||||
+2
-2
@@ -3,10 +3,10 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
interface Carrier {
|
||||
val lastModified: Int
|
||||
|
||||
fun clone(): Carrier
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
+2
-3
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
|
||||
|
||||
interface ConstructorCarrier : FunctionBaseCarrier {
|
||||
|
||||
override fun clone(): ConstructorCarrier {
|
||||
@@ -45,4 +44,4 @@ class ConstructorCarrierImpl(
|
||||
override var visibilityField: Visibility,
|
||||
override var typeParametersField: List<IrTypeParameter>,
|
||||
override var valueParametersField: List<IrValueParameter>
|
||||
) : ConstructorCarrier
|
||||
) : ConstructorCarrier
|
||||
+2
-3
@@ -3,15 +3,14 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
interface DeclarationCarrier: Carrier {
|
||||
var parentField: IrDeclarationParent?
|
||||
var originField: IrDeclarationOrigin
|
||||
var annotationsField: List<IrConstructorCall>
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
@@ -34,4 +34,4 @@ class EnumEntryCarrierImpl(
|
||||
override var annotationsField: List<IrConstructorCall>,
|
||||
override var correspondingClassField: IrClass?,
|
||||
override var initializerExpressionField: IrExpressionBody?
|
||||
) : EnumEntryCarrier
|
||||
) : EnumEntryCarrier
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
@@ -21,4 +21,4 @@ class ErrorCarrierImpl(
|
||||
override var parentField: IrDeclarationParent?,
|
||||
override var originField: IrDeclarationOrigin,
|
||||
override var annotationsField: List<IrConstructorCall>
|
||||
) : ErrorCarrier
|
||||
) : ErrorCarrier
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
@@ -38,4 +38,4 @@ class FieldCarrierImpl(
|
||||
override var initializerField: IrExpressionBody?,
|
||||
override var correspondingPropertySymbolField: IrPropertySymbol?,
|
||||
override var metadataField: MetadataSource?
|
||||
): FieldCarrier
|
||||
): FieldCarrier
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
@@ -55,4 +55,4 @@ class FunctionCarrierImpl(
|
||||
override var correspondingPropertySymbolField: IrPropertySymbol?,
|
||||
override var overriddenSymbolsField: List<IrSimpleFunctionSymbol>,
|
||||
override var attributeOwnerIdField: IrAttributeContainer
|
||||
) : FunctionCarrier
|
||||
) : FunctionCarrier
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
@@ -37,4 +37,4 @@ class PropertyCarrierImpl(
|
||||
override var getterField: IrSimpleFunction?,
|
||||
override var setterField: IrSimpleFunction?,
|
||||
override var metadataField: MetadataSource?
|
||||
) : PropertyCarrier
|
||||
) : PropertyCarrier
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
@@ -31,4 +31,4 @@ class TypeAliasCarrierImpl(
|
||||
override var originField: IrDeclarationOrigin,
|
||||
override var annotationsField: List<IrConstructorCall>,
|
||||
override var typeParametersField: List<IrTypeParameter>
|
||||
) : TypeAliasCarrier
|
||||
) : TypeAliasCarrier
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
@@ -21,4 +21,4 @@ class TypeParameterCarrierImpl(
|
||||
override var parentField: IrDeclarationParent?,
|
||||
override var originField: IrDeclarationOrigin,
|
||||
override var annotationsField: List<IrConstructorCall>
|
||||
) : TypeParameterCarrier
|
||||
) : TypeParameterCarrier
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
package org.jetbrains.kotlin.ir.declarations.persistent.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
@@ -24,4 +24,4 @@ class ValueParameterCarrierImpl(
|
||||
override var originField: IrDeclarationOrigin,
|
||||
override var annotationsField: List<IrConstructorCall>,
|
||||
override var defaultValueField: IrExpressionBody?
|
||||
) : ValueParameterCarrier
|
||||
) : ValueParameterCarrier
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.expressions.persistent
|
||||
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
|
||||
class PersistentIrBlockBody(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
initializer: (IrBlockBody.() -> Unit)? = null
|
||||
) :
|
||||
PersistentIrBodyBase<PersistentIrBlockBody>(startOffset, endOffset, initializer),
|
||||
IrBlockBody {
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, statements: List<IrStatement>) : this(startOffset, endOffset) {
|
||||
statementsField.addAll(statements)
|
||||
}
|
||||
|
||||
private var statementsField: MutableList<IrStatement> = ArrayList()
|
||||
|
||||
override val statements: MutableList<IrStatement>
|
||||
get() = checkEnabled { statementsField }
|
||||
|
||||
override val factory: IrFactory
|
||||
get() = PersistentIrFactory
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.expressions.persistent
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
|
||||
class PersistentIrExpressionBody private constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
private var expressionField: IrExpression? = null,
|
||||
initializer: (IrExpressionBody.() -> Unit)? = null
|
||||
) :
|
||||
PersistentIrBodyBase<PersistentIrExpressionBody>(startOffset, endOffset, initializer),
|
||||
IrExpressionBody {
|
||||
|
||||
constructor(expression: IrExpression) : this(expression.startOffset, expression.endOffset, expression, null)
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset, expression, null)
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, initializer: IrExpressionBody.() -> Unit) :
|
||||
this(startOffset, endOffset, null, initializer)
|
||||
|
||||
override var expression: IrExpression
|
||||
get() = checkEnabled { expressionField!! }
|
||||
set(e) {
|
||||
checkEnabled { expressionField = e }
|
||||
}
|
||||
|
||||
override val factory: IrFactory
|
||||
get() = PersistentIrFactory
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsIrModuleSeria
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsManglerDesc
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrFunctionFactory
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
@@ -448,7 +448,7 @@ class GenerateIrRuntime {
|
||||
|
||||
private fun doPsi2Ir(files: List<KtFile>, analysisResult: AnalysisResult): IrModuleFragment {
|
||||
val psi2Ir = Psi2IrTranslator(languageVersionSettings, Psi2IrConfiguration())
|
||||
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), IrFactoryImpl)
|
||||
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), PersistentIrFactory)
|
||||
val psi2IrContext = psi2Ir.createGeneratorContext(analysisResult.moduleDescriptor, analysisResult.bindingContext, symbolTable)
|
||||
|
||||
val irBuiltIns = psi2IrContext.irBuiltIns
|
||||
@@ -508,7 +508,7 @@ class GenerateIrRuntime {
|
||||
private fun doDeserializeIrModule(moduleDescriptor: ModuleDescriptorImpl): DeserializedModuleInfo {
|
||||
val mangler = JsManglerDesc
|
||||
val signaturer = IdSignatureDescriptor(mangler)
|
||||
val symbolTable = SymbolTable(signaturer, IrFactoryImpl)
|
||||
val symbolTable = SymbolTable(signaturer, PersistentIrFactory)
|
||||
val typeTranslator = TypeTranslator(symbolTable, languageVersionSettings, moduleDescriptor.builtIns).also {
|
||||
it.constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable)
|
||||
}
|
||||
@@ -537,7 +537,7 @@ class GenerateIrRuntime {
|
||||
val moduleDescriptor = doDeserializeModuleMetadata(moduleRef)
|
||||
val mangler = JsManglerDesc
|
||||
val signaturer = IdSignatureDescriptor(mangler)
|
||||
val symbolTable = SymbolTable(signaturer, IrFactoryImpl)
|
||||
val symbolTable = SymbolTable(signaturer, PersistentIrFactory)
|
||||
val typeTranslator = TypeTranslator(symbolTable, languageVersionSettings, moduleDescriptor.builtIns).also {
|
||||
it.constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.js.messageCollectorLogger
|
||||
import org.jetbrains.kotlin.ir.backend.js.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
import org.jetbrains.kotlin.js.facade.MainCallParameters
|
||||
@@ -180,7 +180,7 @@ abstract class BasicIrBoxTest(
|
||||
configuration = config.configuration,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = emptyList(),
|
||||
irFactory = IrFactoryImpl,
|
||||
irFactory = PersistentIrFactory,
|
||||
outputKlibPath = actualOutputFile,
|
||||
nopack = true
|
||||
)
|
||||
|
||||
@@ -62,6 +62,7 @@ val projectsToShadow by extra(listOf(
|
||||
":idea:idea-gradle-native",
|
||||
":compiler:ir.psi2ir",
|
||||
":compiler:ir.tree",
|
||||
":compiler:ir.tree.persistent",
|
||||
":js:js.ast",
|
||||
":js:js.frontend",
|
||||
":js:js.parser",
|
||||
|
||||
@@ -107,6 +107,7 @@ include ":benchmarks",
|
||||
":kotlin-compiler-runner",
|
||||
":compiler:cli-common",
|
||||
":compiler:ir.tree",
|
||||
":compiler:ir.tree.persistent",
|
||||
":compiler:ir.psi2ir",
|
||||
":compiler:ir.ir2cfg",
|
||||
":compiler:ir.backend.common",
|
||||
@@ -444,6 +445,7 @@ project(':kotlin-daemon-tests').projectDir = "$rootDir/compiler/daemon/daemon-te
|
||||
project(':kotlin-compiler-runner').projectDir = "$rootDir/compiler/compiler-runner" as File
|
||||
project(':kotlin-ant').projectDir = "$rootDir/ant" as File
|
||||
project(':compiler:ir.tree').projectDir = "$rootDir/compiler/ir/ir.tree" as File
|
||||
project(':compiler:ir.tree.persistent').projectDir = "$rootDir/compiler/ir/ir.tree.persistent" as File
|
||||
project(':compiler:ir.psi2ir').projectDir = "$rootDir/compiler/ir/ir.psi2ir" as File
|
||||
project(':compiler:ir.ir2cfg').projectDir = "$rootDir/compiler/ir/ir.ir2cfg" as File
|
||||
project(':compiler:ir.backend.common').projectDir = "$rootDir/compiler/ir/backend.common" as File
|
||||
|
||||
Reference in New Issue
Block a user