mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 00:21:35 +00:00
Compare commits
45 Commits
rr/selezne
...
z/backup/i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1d95256d1 | ||
|
|
0835074e0a | ||
|
|
e01726a81a | ||
|
|
5169cb6d94 | ||
|
|
cd6cc33263 | ||
|
|
3eb3e9e9f8 | ||
|
|
997dbd6125 | ||
|
|
b98f2a261d | ||
|
|
078ab5d55e | ||
|
|
0cdb7122ee | ||
|
|
763cd8c202 | ||
|
|
490ec2b56d | ||
|
|
0cee28869f | ||
|
|
07b27856b0 | ||
|
|
2b9de1bcf2 | ||
|
|
f3883c3954 | ||
|
|
eace22c5c6 | ||
|
|
f749f04f3c | ||
|
|
749f19c948 | ||
|
|
297bbb570f | ||
|
|
2cddbc0e24 | ||
|
|
339ea318f7 | ||
|
|
871d254ecf | ||
|
|
eed1a49adb | ||
|
|
d5a35e0969 | ||
|
|
f880306142 | ||
|
|
8fb6839bb5 | ||
|
|
5c32300c0e | ||
|
|
2382320961 | ||
|
|
3d56dbc64a | ||
|
|
9668743e5e | ||
|
|
e0f569943d | ||
|
|
fc6ef0cb88 | ||
|
|
3ecf74d40d | ||
|
|
cc4231a1d4 | ||
|
|
30526d6310 | ||
|
|
c0b104f916 | ||
|
|
358343a9ee | ||
|
|
d479ba3b7a | ||
|
|
c506f800bf | ||
|
|
45e1268d2e | ||
|
|
2935535471 | ||
|
|
3b421ecf7c | ||
|
|
45f73b1eff | ||
|
|
e147d3c997 |
@@ -214,6 +214,7 @@ extra["compilerModules"] = arrayOf(
|
||||
":compiler:frontend.java",
|
||||
":compiler:cli-common",
|
||||
":compiler:ir.tree",
|
||||
":compiler:ir.tree.impl",
|
||||
":compiler:ir.psi2ir",
|
||||
":compiler:ir.backend.common",
|
||||
":compiler:backend.jvm",
|
||||
|
||||
@@ -14,6 +14,7 @@ dependencies {
|
||||
compile(project(":compiler:backend"))
|
||||
compile(project(":compiler:backend.jvm"))
|
||||
compile(project(":compiler:ir.backend.common"))
|
||||
implementation(project(":compiler:ir.tree.impl"))
|
||||
compile(project(":compiler:light-classes"))
|
||||
compile(project(":compiler:serialization"))
|
||||
compile(project(":compiler:plugin-api"))
|
||||
|
||||
@@ -8,6 +8,7 @@ jvmTarget = "1.8"
|
||||
dependencies {
|
||||
compile(project(":compiler:cli"))
|
||||
compile(project(":compiler:ir.serialization.js"))
|
||||
implementation(project(":compiler:ir.tree.impl"))
|
||||
compile(project(":kotlin-reflect"))
|
||||
compile(intellijDep()) { includeJars("picocontainer", "trove4j", "guava", "jdom", rootProject = rootProject) }
|
||||
compile(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
|
||||
@@ -16,6 +16,8 @@ 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.factories.DefaultIrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -69,7 +71,8 @@ fun buildKLib(
|
||||
sources: List<String>,
|
||||
outputPath: String,
|
||||
allDependencies: KotlinLibraryResolveResult,
|
||||
commonSources: List<String>
|
||||
commonSources: List<String>,
|
||||
irDeclarationFactory: IrDeclarationFactory
|
||||
) {
|
||||
generateKLib(
|
||||
project = environment.project,
|
||||
@@ -84,7 +87,8 @@ fun buildKLib(
|
||||
allDependencies = allDependencies,
|
||||
friendDependencies = emptyList(),
|
||||
outputKlibPath = outputPath,
|
||||
nopack = true
|
||||
nopack = true,
|
||||
irDeclarationFactory = irDeclarationFactory
|
||||
)
|
||||
}
|
||||
|
||||
@@ -131,7 +135,15 @@ fun main(args: Array<String>) {
|
||||
dependencies, messageCollectorLogger(MessageCollector.NONE)
|
||||
)
|
||||
|
||||
buildKLib(moduleName, listOfKtFilesFrom(inputFiles), outputPath, resolvedLibraries, listOfKtFilesFrom(commonSources))
|
||||
|
||||
buildKLib(
|
||||
moduleName,
|
||||
listOfKtFilesFrom(inputFiles),
|
||||
outputPath,
|
||||
resolvedLibraries,
|
||||
listOfKtFilesFrom(commonSources),
|
||||
DefaultIrDeclarationFactory.createAndRegister()
|
||||
)
|
||||
}
|
||||
|
||||
// Copied here from `K2JsIrCompiler` instead of reusing in order to avoid circular dependencies between Gradle tasks
|
||||
|
||||
@@ -14,6 +14,7 @@ dependencies {
|
||||
compile(project(":compiler:backend"))
|
||||
compile(project(":compiler:ir.backend.common"))
|
||||
compile(project(":compiler:ir.serialization.js"))
|
||||
implementation(project(":compiler:ir.tree.impl"))
|
||||
compile(project(":compiler:backend.js"))
|
||||
compile(project(":js:js.translator"))
|
||||
compile(project(":js:js.serializer"))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
* 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.cli.js
|
||||
@@ -32,6 +32,8 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||
import org.jetbrains.kotlin.ir.backend.js.*
|
||||
import org.jetbrains.kotlin.ir.factories.DefaultIrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.js.config.EcmaVersion
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
@@ -40,7 +42,6 @@ import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||
import org.jetbrains.kotlin.util.Logger
|
||||
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.kotlin.utils.fileUtils.withReplacedExtensionOrNull
|
||||
@@ -175,6 +176,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
it.libraryFile.absolutePath in friendAbsolutePaths
|
||||
}
|
||||
|
||||
val irDeclarationFactory = DefaultIrDeclarationFactory.createAndRegister()
|
||||
|
||||
if (arguments.irProduceKlibDir || arguments.irProduceKlibFile) {
|
||||
val outputKlibPath =
|
||||
if (arguments.irProduceKlibDir)
|
||||
@@ -190,10 +193,13 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
outputKlibPath = outputKlibPath,
|
||||
nopack = arguments.irProduceKlibDir
|
||||
nopack = arguments.irProduceKlibDir,
|
||||
irDeclarationFactory = irDeclarationFactory
|
||||
)
|
||||
} catch (e: JsIrCompilationError) {
|
||||
return COMPILATION_ERROR
|
||||
} finally {
|
||||
IrDeclarationFactory.resetDefaultIrDeclarationFactory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +212,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
sourcesFiles,
|
||||
config.configuration,
|
||||
phaseConfig,
|
||||
irDeclarationFactory = irDeclarationFactory,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
mainArguments = mainCallArguments,
|
||||
@@ -214,6 +221,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
)
|
||||
} catch (e: JsIrCompilationError) {
|
||||
return COMPILATION_ERROR
|
||||
} finally {
|
||||
IrDeclarationFactory.resetDefaultIrDeclarationFactory()
|
||||
}
|
||||
|
||||
val jsCode = if (arguments.irDce) compiledModule.dceJsCode!! else compiledModule.jsCode!!
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.cli.jvm.compiler
|
||||
@@ -59,6 +48,8 @@ import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.impl.FirProviderImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveTransformer
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector
|
||||
import org.jetbrains.kotlin.ir.factories.DefaultIrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.javac.JavacWrapper
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
|
||||
import org.jetbrains.kotlin.modules.Module
|
||||
@@ -338,11 +329,16 @@ object KotlinToJVMBytecodeCompiler {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
val irDeclarationFactory = DefaultIrDeclarationFactory.createAndRegister()
|
||||
|
||||
val (moduleFragment, symbolTable, sourceManager) =
|
||||
Fir2IrConverter.createModuleFragment(session, firFiles, moduleConfiguration.languageVersionSettings)
|
||||
Fir2IrConverter.createModuleFragment(session, firFiles, moduleConfiguration.languageVersionSettings, irDeclarationFactory)
|
||||
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
|
||||
|
||||
val codegenFactory = JvmIrCodegenFactory(moduleConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases))
|
||||
val codegenFactory = JvmIrCodegenFactory(
|
||||
moduleConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases),
|
||||
irDeclarationFactory
|
||||
)
|
||||
val generationState = GenerationState.Builder(
|
||||
environment.project, ClassBuilderFactories.BINARIES,
|
||||
moduleFragment.descriptor, dummyBindingContext, ktFiles,
|
||||
@@ -605,6 +601,20 @@ object KotlinToJVMBytecodeCompiler {
|
||||
result: AnalysisResult,
|
||||
sourceFiles: List<KtFile>,
|
||||
module: Module?
|
||||
): GenerationState {
|
||||
try {
|
||||
return generate0(environment, configuration, result, sourceFiles, module)
|
||||
} finally {
|
||||
IrDeclarationFactory.resetDefaultIrDeclarationFactory()
|
||||
}
|
||||
}
|
||||
|
||||
private fun generate0(
|
||||
environment: KotlinCoreEnvironment,
|
||||
configuration: CompilerConfiguration,
|
||||
result: AnalysisResult,
|
||||
sourceFiles: List<KtFile>,
|
||||
module: Module?
|
||||
): GenerationState {
|
||||
val isIR = configuration.getBoolean(JVMConfigurationKeys.IR) ||
|
||||
configuration.getBoolean(CommonConfigurationKeys.USE_FIR)
|
||||
@@ -618,7 +628,8 @@ object KotlinToJVMBytecodeCompiler {
|
||||
)
|
||||
.codegenFactory(
|
||||
if (isIR) JvmIrCodegenFactory(
|
||||
configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases)
|
||||
configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases),
|
||||
DefaultIrDeclarationFactory.createAndRegister()
|
||||
) else DefaultCodegenFactory
|
||||
)
|
||||
.withModule(module)
|
||||
|
||||
@@ -12,8 +12,9 @@ import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor
|
||||
import org.jetbrains.kotlin.fir.psi
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.createModuleFragment
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi2ir.PsiSourceManager
|
||||
@@ -24,17 +25,19 @@ object Fir2IrConverter {
|
||||
session: FirSession,
|
||||
firFiles: List<FirFile>,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
irDeclarationFactory: IrDeclarationFactory,
|
||||
fakeOverrideMode: FakeOverrideMode = FakeOverrideMode.NORMAL
|
||||
): Fir2IrResult {
|
||||
val moduleDescriptor = FirModuleDescriptor(session)
|
||||
val symbolTable = SymbolTable()
|
||||
val symbolTable = SymbolTable(irDeclarationFactory)
|
||||
val constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable)
|
||||
val typeTranslator = TypeTranslator(symbolTable, languageVersionSettings, moduleDescriptor.builtIns)
|
||||
constantValueGenerator.typeTranslator = typeTranslator
|
||||
typeTranslator.constantValueGenerator = constantValueGenerator
|
||||
val builtIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
val builtIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, irDeclarationFactory, symbolTable)
|
||||
val sourceManager = PsiSourceManager()
|
||||
val fir2irTransformer = Fir2IrVisitor(session, moduleDescriptor, symbolTable, sourceManager, builtIns, fakeOverrideMode)
|
||||
val fir2irTransformer =
|
||||
Fir2IrVisitor(session, moduleDescriptor, symbolTable, irDeclarationFactory, sourceManager, builtIns, fakeOverrideMode)
|
||||
val irFiles = mutableListOf<IrFile>()
|
||||
for (firFile in firFiles) {
|
||||
val irFile = firFile.accept(fir2irTransformer, null) as IrFile
|
||||
@@ -43,7 +46,7 @@ object Fir2IrConverter {
|
||||
irFiles += irFile
|
||||
}
|
||||
|
||||
val irModuleFragment = IrModuleFragmentImpl(moduleDescriptor, builtIns, irFiles)
|
||||
val irModuleFragment = irDeclarationFactory.createModuleFragment(moduleDescriptor, builtIns, irFiles)
|
||||
generateUnboundSymbolsAsDependencies(irModuleFragment, symbolTable, builtIns)
|
||||
return Fir2IrResult(irModuleFragment, symbolTable, sourceManager)
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments
|
||||
class Fir2IrDeclarationStorage(
|
||||
private val session: FirSession,
|
||||
private val irSymbolTable: SymbolTable,
|
||||
private val irDeclarationFactory: IrDeclarationFactory,
|
||||
private val moduleDescriptor: FirModuleDescriptor
|
||||
) {
|
||||
private val firSymbolProvider = session.firSymbolProvider
|
||||
@@ -105,7 +106,7 @@ class Fir2IrDeclarationStorage(
|
||||
thisReceiver = irSymbolTable.declareValueParameter(
|
||||
startOffset, endOffset, thisOrigin, WrappedReceiverParameterDescriptor(), thisType
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, thisOrigin, symbol,
|
||||
Name.special("<this>"), -1, thisType,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false
|
||||
@@ -137,7 +138,7 @@ class Fir2IrDeclarationStorage(
|
||||
val modality = regularClass?.modality ?: Modality.FINAL
|
||||
return klass.convertWithOffsets { startOffset, endOffset ->
|
||||
irSymbolTable.declareClass(startOffset, endOffset, origin, descriptor, modality) { symbol ->
|
||||
IrClassImpl(
|
||||
irDeclarationFactory.createClass(
|
||||
startOffset,
|
||||
endOffset,
|
||||
origin,
|
||||
@@ -194,7 +195,7 @@ class Fir2IrDeclarationStorage(
|
||||
val modality = Modality.FINAL
|
||||
return anonymousObject.convertWithOffsets { startOffset, endOffset ->
|
||||
irSymbolTable.declareClass(startOffset, endOffset, origin, descriptor, modality) { symbol ->
|
||||
IrClassImpl(
|
||||
irDeclarationFactory.createClass(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
Name.special("<no name provided>"), anonymousObject.classKind,
|
||||
Visibilities.LOCAL, modality,
|
||||
@@ -214,7 +215,7 @@ class Fir2IrDeclarationStorage(
|
||||
val irTypeParameter =
|
||||
convertWithOffsets { startOffset, endOffset ->
|
||||
irSymbolTable.declareGlobalTypeParameter(startOffset, endOffset, origin, descriptor) { symbol ->
|
||||
IrTypeParameterImpl(
|
||||
irDeclarationFactory.createTypeParameter(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name, index,
|
||||
isReified,
|
||||
@@ -271,7 +272,7 @@ class Fir2IrDeclarationStorage(
|
||||
valueParameters += irSymbolTable.declareValueParameter(
|
||||
startOffset, endOffset, origin, WrappedValueParameterDescriptor(), type
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, IrDeclarationOrigin.DEFINED, symbol,
|
||||
Name.special("<set-?>"), 0, type,
|
||||
varargElementType = null,
|
||||
@@ -306,7 +307,7 @@ class Fir2IrDeclarationStorage(
|
||||
startOffset, endOffset, thisOrigin,
|
||||
receiverDescriptor, type
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, thisOrigin, symbol,
|
||||
Name.special("<this>"), -1, type,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false
|
||||
@@ -324,7 +325,7 @@ class Fir2IrDeclarationStorage(
|
||||
startOffset, endOffset, thisOrigin, WrappedReceiverParameterDescriptor(),
|
||||
thisType
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, thisOrigin, symbol,
|
||||
Name.special("<this>"), -1, thisType,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false
|
||||
@@ -371,7 +372,7 @@ class Fir2IrDeclarationStorage(
|
||||
return function.convertWithOffsets { startOffset, endOffset ->
|
||||
enterScope(descriptor)
|
||||
val result = irSymbolTable.declareSimpleFunction(startOffset, endOffset, origin, descriptor) { symbol ->
|
||||
IrFunctionImpl(
|
||||
irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
function.name, function.visibility, function.modality!!,
|
||||
function.returnTypeRef.toIrType(session, this),
|
||||
@@ -413,7 +414,7 @@ class Fir2IrDeclarationStorage(
|
||||
val origin = if (isLambda) IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA else IrDeclarationOrigin.DEFINED
|
||||
return function.convertWithOffsets { startOffset, endOffset ->
|
||||
irSymbolTable.declareSimpleFunction(startOffset, endOffset, origin, descriptor) { symbol ->
|
||||
IrFunctionImpl(
|
||||
irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
if (isLambda) Name.special("<anonymous>") else Name.special("<no name provided>"),
|
||||
Visibilities.LOCAL, Modality.FINAL,
|
||||
@@ -450,7 +451,7 @@ class Fir2IrDeclarationStorage(
|
||||
}
|
||||
val created = constructor.convertWithOffsets { startOffset, endOffset ->
|
||||
irSymbolTable.declareConstructor(startOffset, endOffset, origin, descriptor) { symbol ->
|
||||
IrConstructorImpl(
|
||||
irDeclarationFactory.createConstructor(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
constructor.name, visibility,
|
||||
constructor.returnTypeRef.toIrType(session, this),
|
||||
@@ -480,7 +481,7 @@ class Fir2IrDeclarationStorage(
|
||||
origin, descriptor
|
||||
) { symbol ->
|
||||
val accessorReturnType = if (isSetter) unitType else propertyType
|
||||
IrFunctionImpl(
|
||||
irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
Name.special("<$prefix-${correspondingProperty.name}>"),
|
||||
propertyAccessor?.visibility ?: correspondingProperty.visibility,
|
||||
@@ -517,7 +518,7 @@ class Fir2IrDeclarationStorage(
|
||||
startOffset, endOffset,
|
||||
origin, descriptor, property.delegate != null
|
||||
) { symbol ->
|
||||
IrPropertyImpl(
|
||||
irDeclarationFactory.createProperty(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
property.name, property.visibility, property.modality!!,
|
||||
isVar = property.isVar,
|
||||
@@ -569,7 +570,7 @@ class Fir2IrDeclarationStorage(
|
||||
startOffset, endOffset,
|
||||
origin, descriptor, type
|
||||
) { symbol ->
|
||||
IrFieldImpl(
|
||||
irDeclarationFactory.createField(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
field.name, type, field.visibility,
|
||||
isFinal = field.modality == Modality.FINAL,
|
||||
@@ -592,7 +593,7 @@ class Fir2IrDeclarationStorage(
|
||||
irSymbolTable.declareValueParameter(
|
||||
startOffset, endOffset, origin, descriptor, type
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
valueParameter.name, index, type,
|
||||
null, valueParameter.isCrossinline, valueParameter.isNoinline
|
||||
@@ -620,7 +621,7 @@ class Fir2IrDeclarationStorage(
|
||||
): IrVariable {
|
||||
val descriptor = WrappedVariableDescriptor()
|
||||
return irSymbolTable.declareVariable(startOffset, endOffset, origin, descriptor, type) { symbol ->
|
||||
IrVariableImpl(
|
||||
irDeclarationFactory.createVariable(
|
||||
startOffset, endOffset, origin, symbol, name, type,
|
||||
isVar, isConst, isLateinit
|
||||
).apply {
|
||||
|
||||
@@ -36,13 +36,12 @@ import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.createFile
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
||||
@@ -61,6 +60,7 @@ class Fir2IrVisitor(
|
||||
private val session: FirSession,
|
||||
private val moduleDescriptor: FirModuleDescriptor,
|
||||
private val symbolTable: SymbolTable,
|
||||
private val irDeclarationFactory: IrDeclarationFactory,
|
||||
private val sourceManager: PsiSourceManager,
|
||||
override val irBuiltIns: IrBuiltIns,
|
||||
private val fakeOverrideMode: FakeOverrideMode
|
||||
@@ -75,7 +75,7 @@ class Fir2IrVisitor(
|
||||
|
||||
private val typeContext = session.typeContext
|
||||
|
||||
private val declarationStorage = Fir2IrDeclarationStorage(session, symbolTable, moduleDescriptor)
|
||||
private val declarationStorage = Fir2IrDeclarationStorage(session, symbolTable, irDeclarationFactory, moduleDescriptor)
|
||||
|
||||
private val nothingType = session.builtinTypes.nothingType.toIrType(session, declarationStorage)
|
||||
|
||||
@@ -143,7 +143,7 @@ class Fir2IrVisitor(
|
||||
}
|
||||
|
||||
override fun visitFile(file: FirFile, data: Any?): IrFile {
|
||||
return IrFileImpl(
|
||||
return irDeclarationFactory.createFile(
|
||||
sourceManager.getOrCreateFileEntry(file.psi as KtFile),
|
||||
moduleDescriptor.findPackageFragmentForFile(file)
|
||||
).withParent {
|
||||
@@ -313,7 +313,7 @@ class Fir2IrVisitor(
|
||||
startOffset, endOffset, thisOrigin, WrappedValueParameterDescriptor(),
|
||||
thisType
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, thisOrigin, symbol,
|
||||
Name.special("<this>"), -1, thisType,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false
|
||||
@@ -507,7 +507,7 @@ class Fir2IrVisitor(
|
||||
return symbolTable.declareField(
|
||||
startOffset, endOffset, origin, descriptor, inferredType
|
||||
) { symbol ->
|
||||
IrFieldImpl(
|
||||
irDeclarationFactory.createField(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name, inferredType,
|
||||
visibility, isFinal = isFinal, isExternal = false,
|
||||
|
||||
@@ -92,7 +92,7 @@ abstract class AbstractFir2IrTextTest : AbstractIrTextTestCase() {
|
||||
}
|
||||
|
||||
return Fir2IrConverter.createModuleFragment(
|
||||
session, firFiles, myEnvironment.configuration.languageVersionSettings
|
||||
session, firFiles, myEnvironment.configuration.languageVersionSettings, irDeclarationFactory
|
||||
).irModuleFragment
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.backend.common
|
||||
@@ -22,6 +11,7 @@ import org.jetbrains.kotlin.backend.common.ir.SharedVariablesManager
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -30,8 +20,9 @@ interface BackendContext {
|
||||
val ir: Ir<CommonBackendContext>
|
||||
val builtIns: KotlinBuiltIns
|
||||
val irBuiltIns: IrBuiltIns
|
||||
val irDeclarationFactory: IrDeclarationFactory
|
||||
val sharedVariablesManager: SharedVariablesManager
|
||||
val declarationFactory: DeclarationFactory
|
||||
val declarationFactory: DeclarationFactory ///
|
||||
val internalPackageFqn: FqName
|
||||
val transformedFunction: MutableMap<IrFunctionSymbol, IrSimpleFunctionSymbol>
|
||||
val lateinitNullableFields: MutableMap<IrField, IrField>
|
||||
|
||||
@@ -1,27 +1,16 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.backend.common
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrLoop
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.util.DeepCopyIrTreeWithSymbols
|
||||
import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper
|
||||
import org.jetbrains.kotlin.ir.util.DeepCopyTypeRemapper
|
||||
@@ -29,7 +18,7 @@ import org.jetbrains.kotlin.ir.util.DescriptorsRemapper
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : IrElement> T.deepCopyWithVariables(): T {
|
||||
fun <T : IrElement> T.deepCopyWithVariables(irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT): T {
|
||||
val descriptorsRemapper = object : DescriptorsRemapper {
|
||||
override fun remapDeclaredVariable(descriptor: VariableDescriptor) = WrappedVariableDescriptor()
|
||||
}
|
||||
@@ -40,7 +29,7 @@ fun <T : IrElement> T.deepCopyWithVariables(): T {
|
||||
val typesRemapper = DeepCopyTypeRemapper(symbolsRemapper)
|
||||
|
||||
return this.transform(
|
||||
object : DeepCopyIrTreeWithSymbols(symbolsRemapper, typesRemapper) {
|
||||
object : DeepCopyIrTreeWithSymbols(irDeclarationFactory, symbolsRemapper, typesRemapper) {
|
||||
override fun getNonTransformedLoop(irLoop: IrLoop): IrLoop {
|
||||
return irLoop
|
||||
}
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.backend.common
|
||||
@@ -26,12 +15,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
|
||||
open class ScopeWithIr(val scope: Scope, val irElement: IrElement)
|
||||
|
||||
abstract class IrElementTransformerVoidWithContext : IrElementTransformerVoid() {
|
||||
abstract class IrElementTransformerVoidWithContext(open protected val context: CommonBackendContext) : IrElementTransformerVoid() {
|
||||
|
||||
private val scopeStack = mutableListOf<ScopeWithIr>()
|
||||
|
||||
protected open fun createScope(declaration: IrSymbolOwner): ScopeWithIr =
|
||||
ScopeWithIr(Scope(declaration.symbol), declaration)
|
||||
ScopeWithIr(Scope(declaration.symbol, context.irDeclarationFactory), declaration)
|
||||
|
||||
final override fun visitFile(declaration: IrFile): IrFile {
|
||||
scopeStack.push(createScope(declaration))
|
||||
@@ -114,12 +103,12 @@ abstract class IrElementTransformerVoidWithContext : IrElementTransformerVoid()
|
||||
}
|
||||
}
|
||||
|
||||
abstract class IrElementVisitorVoidWithContext : IrElementVisitorVoid {
|
||||
abstract class IrElementVisitorVoidWithContext(open protected val context: CommonBackendContext) : IrElementVisitorVoid {
|
||||
|
||||
private val scopeStack = mutableListOf<ScopeWithIr>()
|
||||
|
||||
protected open fun createScope(declaration: IrSymbolOwner): ScopeWithIr =
|
||||
ScopeWithIr(Scope(declaration.symbol), declaration)
|
||||
ScopeWithIr(Scope(declaration.symbol, context.irDeclarationFactory), declaration)
|
||||
|
||||
final override fun visitFile(declaration: IrFile) {
|
||||
scopeStack.push(createScope(declaration))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.ir.builders.IrGeneratorContext
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -23,6 +24,7 @@ class IrPluginContext(
|
||||
val symbolTable: SymbolTable,
|
||||
val typeTranslator: TypeTranslator,
|
||||
override val irBuiltIns: IrBuiltIns,
|
||||
val irDeclarationFactory: IrDeclarationFactory,
|
||||
val symbols: BuiltinSymbolsBase = BuiltinSymbolsBase(irBuiltIns.builtIns, symbolTable)
|
||||
) : IrGeneratorContext()
|
||||
|
||||
|
||||
@@ -18,13 +18,11 @@ import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.Scope
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.createValueParameter
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
||||
@@ -59,9 +57,10 @@ fun IrClass.addSimpleDelegatingConstructor(
|
||||
superConstructor: IrConstructor,
|
||||
irBuiltIns: IrBuiltIns,
|
||||
isPrimary: Boolean = false,
|
||||
origin: IrDeclarationOrigin? = null
|
||||
origin: IrDeclarationOrigin? = null,
|
||||
irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT
|
||||
) = WrappedClassConstructorDescriptor().let { descriptor ->
|
||||
IrConstructorImpl(
|
||||
irDeclarationFactory.createConstructor(
|
||||
startOffset, endOffset,
|
||||
origin ?: this.origin,
|
||||
IrConstructorSymbolImpl(descriptor),
|
||||
@@ -143,7 +142,8 @@ fun IrValueParameter.copyTo(
|
||||
varargElementType: IrType? = this.varargElementType, // TODO: remapTypeParameters here as well
|
||||
defaultValue: IrExpressionBody? = this.defaultValue,
|
||||
isCrossinline: Boolean = this.isCrossinline,
|
||||
isNoinline: Boolean = this.isNoinline
|
||||
isNoinline: Boolean = this.isNoinline,
|
||||
irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT
|
||||
): IrValueParameter {
|
||||
val descriptor = if (index < 0) {
|
||||
WrappedReceiverParameterDescriptor(this.descriptor.annotations, this.descriptor.source)
|
||||
@@ -153,7 +153,7 @@ fun IrValueParameter.copyTo(
|
||||
val symbol = IrValueParameterSymbolImpl(descriptor)
|
||||
val defaultValueCopy = defaultValue?.deepCopyWithVariables()
|
||||
defaultValueCopy?.patchDeclarationParents(irFunction)
|
||||
return IrValueParameterImpl(
|
||||
return irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name, index, type, varargElementType, isCrossinline, isNoinline
|
||||
).also {
|
||||
@@ -167,22 +167,25 @@ fun IrValueParameter.copyTo(
|
||||
fun IrTypeParameter.copyToWithoutSuperTypes(
|
||||
target: IrTypeParametersContainer,
|
||||
shift: Int = 0,
|
||||
origin: IrDeclarationOrigin = this.origin
|
||||
origin: IrDeclarationOrigin = this.origin,
|
||||
irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT
|
||||
): IrTypeParameter {
|
||||
val descriptor = WrappedTypeParameterDescriptor(symbol.descriptor.annotations, symbol.descriptor.source)
|
||||
val symbol = IrTypeParameterSymbolImpl(descriptor)
|
||||
return IrTypeParameterImpl(startOffset, endOffset, origin, symbol, name, shift + index, isReified, variance).also { copied ->
|
||||
descriptor.bind(copied)
|
||||
copied.parent = target
|
||||
}
|
||||
return irDeclarationFactory.createTypeParameter(startOffset, endOffset, origin, symbol, name, shift + index, isReified, variance)
|
||||
.also { copied ->
|
||||
descriptor.bind(copied)
|
||||
copied.parent = target
|
||||
}
|
||||
}
|
||||
|
||||
fun IrFunction.copyValueParametersFrom(from: IrFunction) {
|
||||
fun IrFunction.copyValueParametersFrom(from: IrFunction, irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT) {
|
||||
// TODO: should dispatch receiver be copied?
|
||||
dispatchReceiverParameter = from.dispatchReceiverParameter?.let {
|
||||
IrValueParameterImpl(it.startOffset, it.endOffset, it.origin, it.descriptor, it.type, it.varargElementType).also {
|
||||
it.parent = this
|
||||
}
|
||||
irDeclarationFactory.createValueParameter(it.startOffset, it.endOffset, it.origin, it.descriptor, it.type, it.varargElementType)
|
||||
.also {
|
||||
it.parent = this
|
||||
}
|
||||
}
|
||||
extensionReceiverParameter = from.extensionReceiverParameter?.copyTo(this)
|
||||
|
||||
@@ -362,9 +365,9 @@ fun Scope.createTemporaryVariableWithWrappedDescriptor(
|
||||
).apply { descriptor.bind(this) }
|
||||
}
|
||||
|
||||
fun IrClass.createImplicitParameterDeclarationWithWrappedDescriptor() {
|
||||
fun IrClass.createImplicitParameterDeclarationWithWrappedDescriptor(irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT) {
|
||||
val thisReceiverDescriptor = WrappedReceiverParameterDescriptor()
|
||||
thisReceiver = IrValueParameterImpl(
|
||||
thisReceiver = irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset,
|
||||
IrDeclarationOrigin.INSTANCE_RECEIVER,
|
||||
IrValueParameterSymbolImpl(thisReceiverDescriptor),
|
||||
@@ -398,11 +401,11 @@ fun IrClass.simpleFunctions() = declarations.flatMap {
|
||||
}
|
||||
}
|
||||
|
||||
fun IrClass.createParameterDeclarations() {
|
||||
fun IrClass.createParameterDeclarations(irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT) {
|
||||
assert (thisReceiver == null)
|
||||
|
||||
thisReceiver = WrappedReceiverParameterDescriptor().let {
|
||||
IrValueParameterImpl(
|
||||
irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset,
|
||||
IrDeclarationOrigin.INSTANCE_RECEIVER,
|
||||
IrValueParameterSymbolImpl(it),
|
||||
@@ -419,10 +422,10 @@ fun IrClass.createParameterDeclarations() {
|
||||
}
|
||||
}
|
||||
|
||||
fun IrFunction.createDispatchReceiverParameter(origin: IrDeclarationOrigin? = null) {
|
||||
fun IrFunction.createDispatchReceiverParameter(origin: IrDeclarationOrigin? = null, irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT) {
|
||||
assert(dispatchReceiverParameter == null)
|
||||
|
||||
dispatchReceiverParameter = IrValueParameterImpl(
|
||||
dispatchReceiverParameter = irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset,
|
||||
origin ?: parentAsClass.origin,
|
||||
IrValueParameterSymbolImpl(parentAsClass.thisReceiver!!.descriptor),
|
||||
@@ -446,7 +449,7 @@ val IrFunction.allParameters: List<IrValueParameter>
|
||||
explicitParameters
|
||||
}
|
||||
|
||||
fun IrClass.addFakeOverrides() {
|
||||
fun IrClass.addFakeOverrides(irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT) {
|
||||
fun IrDeclaration.toList() = when (this) {
|
||||
is IrSimpleFunction -> listOf(this)
|
||||
is IrProperty -> listOfNotNull(getter, setter)
|
||||
@@ -474,7 +477,7 @@ fun IrClass.addFakeOverrides() {
|
||||
fun createFakeOverride(overriddenFunctions: List<IrSimpleFunction>) =
|
||||
overriddenFunctions.first().let { irFunction ->
|
||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
||||
IrFunctionImpl(
|
||||
irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
@@ -514,12 +517,13 @@ fun createStaticFunctionWithReceivers(
|
||||
dispatchReceiverType: IrType? = oldFunction.dispatchReceiverParameter?.type,
|
||||
origin: IrDeclarationOrigin = oldFunction.origin,
|
||||
modality: Modality = Modality.FINAL,
|
||||
copyMetadata: Boolean = true
|
||||
copyMetadata: Boolean = true,
|
||||
irDeclarationFactory: IrDeclarationFactory = IrDeclarationFactory.DEFAULT
|
||||
): IrSimpleFunction {
|
||||
val descriptor = (oldFunction.descriptor as? DescriptorWithContainerSource)?.let {
|
||||
WrappedFunctionDescriptorWithContainerSource(it.containerSource)
|
||||
} ?: WrappedSimpleFunctionDescriptor(Annotations.EMPTY, oldFunction.descriptor.source)
|
||||
return IrFunctionImpl(
|
||||
return irDeclarationFactory.createSimpleFunction(
|
||||
oldFunction.startOffset, oldFunction.endOffset,
|
||||
origin,
|
||||
IrSimpleFunctionSymbolImpl(descriptor),
|
||||
@@ -582,7 +586,7 @@ fun copyBodyWithParametersMapping(
|
||||
// Remap return targets to the static method so they do not appear to be
|
||||
// non-local returns.
|
||||
override fun visitReturn(expression: IrReturn): IrExpression {
|
||||
expression.transformChildrenVoid(this);
|
||||
expression.transformChildrenVoid(this)
|
||||
return if (expression.returnTargetSymbol == oldFunction.symbol) {
|
||||
IrReturnImpl(
|
||||
expression.startOffset,
|
||||
|
||||
@@ -13,10 +13,6 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
||||
@@ -281,7 +277,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
private val unboundFunctionParameters = boundFunctionParameters?.let { functionParameters - it }
|
||||
|
||||
private val coroutineClass: IrClass = WrappedClassDescriptor().let { d ->
|
||||
IrClassImpl(
|
||||
context.irDeclarationFactory.createClass(
|
||||
startOffset, endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
IrClassSymbolImpl(d),
|
||||
@@ -385,7 +381,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
}
|
||||
|
||||
fun buildConstructor(): IrConstructor = WrappedClassConstructorDescriptor().let { d ->
|
||||
IrConstructorImpl(
|
||||
context.irDeclarationFactory.createConstructor(
|
||||
startOffset, endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
IrConstructorSymbolImpl(d),
|
||||
@@ -431,7 +427,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
}
|
||||
|
||||
private fun buildFactoryConstructor(boundParams: List<IrValueParameter>) = WrappedClassConstructorDescriptor().let { d ->
|
||||
IrConstructorImpl(
|
||||
context.irDeclarationFactory.createConstructor(
|
||||
startOffset, endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
IrConstructorSymbolImpl(d),
|
||||
@@ -477,7 +473,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
superFunctionSymbol: IrSimpleFunctionSymbol?,
|
||||
coroutineConstructor: IrConstructor
|
||||
) = WrappedSimpleFunctionDescriptor().let { d ->
|
||||
IrFunctionImpl(
|
||||
context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
IrSimpleFunctionSymbolImpl(d),
|
||||
@@ -545,7 +541,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
createFunction: IrFunction,
|
||||
stateMachineFunction: IrFunction
|
||||
) = WrappedSimpleFunctionDescriptor().let { d ->
|
||||
IrFunctionImpl(
|
||||
context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
IrSimpleFunctionSymbolImpl(d),
|
||||
@@ -605,7 +601,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
coroutineClass: IrClass
|
||||
): IrSimpleFunction {
|
||||
val function = WrappedSimpleFunctionDescriptor().let { d ->
|
||||
IrFunctionImpl(
|
||||
context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
IrSimpleFunctionSymbolImpl(d),
|
||||
@@ -676,7 +672,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
fun IrClass.addField(name: Name, type: IrType, isMutable: Boolean): IrField {
|
||||
val descriptor = WrappedFieldDescriptor()
|
||||
val symbol = IrFieldSymbolImpl(descriptor)
|
||||
return IrFieldImpl(
|
||||
return context.irDeclarationFactory.createField(
|
||||
startOffset,
|
||||
endOffset,
|
||||
DECLARATION_ORIGIN_COROUTINE_IMPL,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
* 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.backend.common.lower
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.ir.util.patchDeclarationParents
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
class ArrayConstructorLowering(val context: CommonBackendContext) : IrElementTransformerVoidWithContext(), FileLoweringPass {
|
||||
class ArrayConstructorLowering(context: CommonBackendContext) : IrElementTransformerVoidWithContext(context), FileLoweringPass {
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.transformChildrenVoid(this)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.common.descriptors.synthesizedString
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
* Replace branches that are comparisons with compile-time known enum entries
|
||||
* with comparisons of ordinals.
|
||||
*/
|
||||
open class EnumWhenLowering(protected val context: CommonBackendContext) : IrElementTransformerVoidWithContext(), FileLoweringPass {
|
||||
open class EnumWhenLowering(context: CommonBackendContext) : IrElementTransformerVoidWithContext(context), FileLoweringPass {
|
||||
private val subjectWithOrdinalStack = mutableListOf<Pair<IrVariable, Lazy<IrVariable>>>()
|
||||
|
||||
protected open fun mapConstEnumEntry(entry: IrEnumEntry): Int =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -10,8 +10,9 @@ import org.jetbrains.kotlin.backend.common.ir.returnType
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
@@ -25,7 +26,9 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FinallyBlocksLowering(val context: CommonBackendContext, private val throwableType: IrType): FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
class FinallyBlocksLowering(
|
||||
context: CommonBackendContext, private val throwableType: IrType
|
||||
): FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
|
||||
private interface HighLevelJump {
|
||||
fun toIr(context: CommonBackendContext, startOffset: Int, endOffset: Int, value: IrExpression): IrExpression
|
||||
@@ -211,7 +214,7 @@ class FinallyBlocksLowering(val context: CommonBackendContext, private val throw
|
||||
irBuilder.run {
|
||||
val transformedFinallyExpression = finallyExpression.transform(transformer, null)
|
||||
val parameter = WrappedVariableDescriptor()
|
||||
val catchParameter = IrVariableImpl(
|
||||
val catchParameter = this@FinallyBlocksLowering.context.irDeclarationFactory.createVariable(
|
||||
startOffset, endOffset, IrDeclarationOrigin.CATCH_PARAMETER, IrVariableSymbolImpl(parameter),
|
||||
Name.identifier("t"), throwableType, isVar = false, isConst = false, isLateinit = false
|
||||
).also { parameter.bind(it) }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,7 @@ open class InitializersLowering(context: CommonBackendContext) : InitializersLow
|
||||
val instanceInitializerStatements = extractInitializers(irClass) {
|
||||
(it is IrField && !it.isStatic) || (it is IrAnonymousInitializer && !it.isStatic)
|
||||
}
|
||||
irClass.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
|
||||
irClass.transformChildrenVoid(object : IrElementTransformerVoidWithContext(context) {
|
||||
// Only transform constructors of current class.
|
||||
override fun visitClassNew(declaration: IrClass) = declaration
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.ir.util.transformDeclarationsFlat
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
|
||||
class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
|
||||
class InnerClassesLowering(val context: CommonBackendContext) : ClassLoweringPass {
|
||||
private val IrValueSymbol.classForImplicitThis: IrClass?
|
||||
// TODO: is this the correct way to get the class?
|
||||
get() =
|
||||
@@ -69,7 +69,7 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
|
||||
irClass.transformDeclarationsFlat { irMember -> (irMember as? IrConstructor)?.let { listOf(lowerConstructor(it)) } }
|
||||
irClass.transformChildrenVoid(VariableRemapper(oldConstructorParameterToNew))
|
||||
|
||||
irClass.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
|
||||
irClass.transformChildrenVoid(object : IrElementTransformerVoidWithContext(context) {
|
||||
override fun visitClassNew(declaration: IrClass): IrStatement =
|
||||
declaration
|
||||
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.backend.common.lower
|
||||
@@ -23,7 +12,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildField
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
@@ -79,7 +67,7 @@ class LateinitLowering(val backendContext: CommonBackendContext) : FileLoweringP
|
||||
|
||||
val descriptor = WrappedVariableDescriptor()
|
||||
val type = declaration.type.makeNullable()
|
||||
val newVar = IrVariableImpl(
|
||||
val newVar = backendContext.irDeclarationFactory.createVariable(
|
||||
declaration.startOffset,
|
||||
declaration.endOffset,
|
||||
declaration.origin,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.BackendContext
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.ScopeWithIr
|
||||
@@ -18,11 +18,11 @@ import org.jetbrains.kotlin.ir.declarations.IrScript
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
|
||||
|
||||
//This lower takes part of old LocalDeclarationLowering job to pop up local classes from functions
|
||||
open class LocalClassPopupLowering(val context: BackendContext) : FileLoweringPass {
|
||||
open class LocalClassPopupLowering(val context: CommonBackendContext) : FileLoweringPass {
|
||||
override fun lower(irFile: IrFile) {
|
||||
val extractedLocalClasses = arrayListOf<Pair<IrClass, IrDeclarationContainer>>()
|
||||
|
||||
irFile.transform(object : IrElementTransformerVoidWithContext() {
|
||||
irFile.transform(object : IrElementTransformerVoidWithContext(context) {
|
||||
|
||||
override fun visitClassNew(declaration: IrClass): IrStatement {
|
||||
val newDeclaration = super.visitClassNew(declaration)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.BackendContext
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.IrElementVisitorVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.ScopeWithIr
|
||||
@@ -20,10 +20,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.Scope
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
@@ -78,7 +74,7 @@ object BOUND_VALUE_PARAMETER : IrDeclarationOriginImpl("BOUND_VALUE_PARAMETER")
|
||||
object BOUND_RECEIVER_PARAMETER : IrDeclarationOriginImpl("BOUND_RECEIVER_PARAMETER")
|
||||
|
||||
class LocalDeclarationsLowering(
|
||||
val context: BackendContext,
|
||||
val context: CommonBackendContext,
|
||||
val localNameProvider: LocalNameProvider = LocalNameProvider.DEFAULT,
|
||||
val visibilityPolicy: VisibilityPolicy = VisibilityPolicy.DEFAULT
|
||||
) :
|
||||
@@ -517,7 +513,7 @@ class LocalDeclarationsLowering(
|
||||
// TODO: consider using fields to access the closure of enclosing class.
|
||||
val capturedValues = localFunctionContext.closure.capturedValues
|
||||
|
||||
val newDeclaration = IrFunctionImpl(
|
||||
val newDeclaration = context.irDeclarationFactory.createSimpleFunction(
|
||||
oldDeclaration.startOffset,
|
||||
oldDeclaration.endOffset,
|
||||
oldDeclaration.origin,
|
||||
@@ -565,7 +561,7 @@ class LocalDeclarationsLowering(
|
||||
capturedValues.mapIndexedTo(this) { i, capturedValue ->
|
||||
val parameterDescriptor = WrappedValueParameterDescriptor()
|
||||
val p = capturedValue.owner
|
||||
IrValueParameterImpl(
|
||||
context.irDeclarationFactory.createValueParameter(
|
||||
p.startOffset,
|
||||
p.endOffset,
|
||||
if (p.descriptor is ReceiverParameterDescriptor && newDeclaration is IrConstructor)
|
||||
@@ -621,7 +617,7 @@ class LocalDeclarationsLowering(
|
||||
val loweredConstructorVisibility =
|
||||
visibilityPolicy.forConstructor(oldDeclaration, constructorContext.inInlineFunctionScope)
|
||||
|
||||
val newDeclaration = IrConstructorImpl(
|
||||
val newDeclaration = context.irDeclarationFactory.createConstructor(
|
||||
oldDeclaration.startOffset, oldDeclaration.endOffset, oldDeclaration.origin,
|
||||
newSymbol, oldDeclaration.name, loweredConstructorVisibility, oldDeclaration.returnType,
|
||||
isInline = oldDeclaration.isInline,
|
||||
@@ -663,7 +659,7 @@ class LocalDeclarationsLowering(
|
||||
): IrField {
|
||||
val descriptor = WrappedFieldDescriptor()
|
||||
val symbol = IrFieldSymbolImpl(descriptor)
|
||||
return IrFieldImpl(
|
||||
return context.irDeclarationFactory.createField(
|
||||
startOffset,
|
||||
endOffset,
|
||||
if (isCrossinline) DECLARATION_ORIGIN_FIELD_FOR_CROSSINLINE_CAPTURED_VALUE else DECLARATION_ORIGIN_FIELD_FOR_CAPTURED_VALUE,
|
||||
@@ -746,14 +742,14 @@ class LocalDeclarationsLowering(
|
||||
var counter: Int = 0
|
||||
}
|
||||
|
||||
irFile.acceptVoid(object : IrElementVisitorVoidWithContext() {
|
||||
irFile.acceptVoid(object : IrElementVisitorVoidWithContext(context) {
|
||||
|
||||
override fun visitElement(element: IrElement) {
|
||||
element.acceptChildrenVoid(this)
|
||||
}
|
||||
|
||||
override fun createScope(declaration: IrSymbolOwner): ScopeWithIr {
|
||||
return ScopeWithCounter(Scope(declaration.symbol), declaration)
|
||||
return ScopeWithCounter(Scope(declaration.symbol, context.irDeclarationFactory), declaration)
|
||||
}
|
||||
|
||||
override fun visitSimpleFunction(declaration: IrSimpleFunction) {
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.backend.common.lower
|
||||
@@ -27,6 +16,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -44,7 +34,7 @@ class DeclarationIrBuilder(
|
||||
startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET
|
||||
) : IrBuilderWithScope(
|
||||
generatorContext,
|
||||
Scope(symbol),
|
||||
Scope(symbol, IrDeclarationFactory.DEFAULT), ///
|
||||
startOffset,
|
||||
endOffset
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
|
||||
@@ -79,10 +78,10 @@ class PropertiesLowering(
|
||||
else
|
||||
null
|
||||
|
||||
private fun createSyntheticMethodForAnnotations(declaration: IrProperty, origin: IrDeclarationOrigin, name: String): IrFunctionImpl {
|
||||
private fun createSyntheticMethodForAnnotations(declaration: IrProperty, origin: IrDeclarationOrigin, name: String): IrFunction {
|
||||
val descriptor = WrappedSimpleFunctionDescriptor(declaration.descriptor.annotations)
|
||||
val symbol = IrSimpleFunctionSymbolImpl(descriptor)
|
||||
return IrFunctionImpl(
|
||||
return context.irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, symbol, Name.identifier(name),
|
||||
declaration.visibility, Modality.OPEN, context.irBuiltIns.unitType,
|
||||
isInline = false, isExternal = false, isTailrec = false, isSuspend = false, isExpect = false, isFakeOverride = false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -75,7 +75,7 @@ class ReturnableBlockLowering(val context: CommonBackendContext) : FileLoweringP
|
||||
}
|
||||
}
|
||||
|
||||
class ReturnableBlockTransformer(val context: CommonBackendContext) : IrElementTransformerVoidWithContext() {
|
||||
class ReturnableBlockTransformer(context: CommonBackendContext) : IrElementTransformerVoidWithContext(context) {
|
||||
private var labelCnt = 0
|
||||
private val returnMap = mutableMapOf<IrReturnableBlockSymbol, (IrReturn) -> IrExpression>()
|
||||
|
||||
|
||||
@@ -119,5 +119,10 @@ internal class DeepCopyIrTreeWithSymbolsForInliner(
|
||||
|
||||
private val symbolRemapper = SymbolRemapperImpl(DescriptorsToIrRemapper)
|
||||
private val copier =
|
||||
DeepCopyIrTreeWithSymbols(symbolRemapper, InlinerTypeRemapper(symbolRemapper, typeArguments), InlinerSymbolRenamer())
|
||||
DeepCopyIrTreeWithSymbols(
|
||||
context.irDeclarationFactory,
|
||||
symbolRemapper,
|
||||
InlinerTypeRemapper(symbolRemapper, typeArguments),
|
||||
InlinerSymbolRenamer()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
class FunctionInlining(val context: CommonBackendContext) : IrElementTransformerVoidWithContext() {
|
||||
class FunctionInlining(context: CommonBackendContext) : IrElementTransformerVoidWithContext(context) {
|
||||
|
||||
fun inline(irModule: IrModuleFragment) = irModule.accept(this, data = null)
|
||||
|
||||
|
||||
@@ -113,9 +113,9 @@ class ForLoopsLowering(val context: CommonBackendContext) : FileLoweringPass {
|
||||
}
|
||||
|
||||
private class RangeLoopTransformer(
|
||||
val context: CommonBackendContext,
|
||||
context: CommonBackendContext,
|
||||
val oldLoopToNewLoop: MutableMap<IrLoop, IrLoop>
|
||||
) : IrElementTransformerVoidWithContext() {
|
||||
) : IrElementTransformerVoidWithContext(context) {
|
||||
|
||||
private val symbols = context.ir.symbols
|
||||
private val headerInfoBuilder = DefaultHeaderInfoBuilder(context, this::getScopeOwnerSymbol)
|
||||
|
||||
@@ -154,7 +154,10 @@ internal class UntilHandler(private val context: CommonBackendContext, private v
|
||||
// Condition is needed and untilArg is non-const.
|
||||
// Build the additional "not empty" condition: `untilArg != MIN_VALUE`.
|
||||
// Make sure to copy untilArgExpression as it is also used in `last`.
|
||||
irNotEquals(untilArgExpression.deepCopyWithSymbols(), minValueIrConst)
|
||||
irNotEquals(
|
||||
untilArgExpression.deepCopyWithSymbols(irDeclarationFactory = this@UntilHandler.context.irDeclarationFactory),
|
||||
minValueIrConst
|
||||
)
|
||||
it == minValueAsLong ->
|
||||
// Hardcode "false" as additional condition so that the progression is considered empty.
|
||||
// The entire lowered loop becomes a candidate for dead code elimination, depending on backend.
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.builders
|
||||
@@ -19,12 +8,14 @@ package org.jetbrains.kotlin.ir.builders
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrLoop
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBreakImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrContinueImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetObjectValueImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrWhileLoopImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -66,7 +57,7 @@ fun Scope.createTmpVariable(
|
||||
val varType = irType ?: irExpression.type
|
||||
val descriptor = WrappedVariableDescriptor()
|
||||
val symbol = IrVariableSymbolImpl(descriptor)
|
||||
return IrVariableImpl(
|
||||
return irDeclarationFactory.createVariable(
|
||||
irExpression.startOffset,
|
||||
irExpression.endOffset,
|
||||
origin,
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.builders.declarations
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.*
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -22,7 +20,7 @@ import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
fun IrClassBuilder.buildClass(): IrClass {
|
||||
val wrappedDescriptor = WrappedClassDescriptor()
|
||||
return IrClassImpl(
|
||||
return irDeclarationFactory.createClass(
|
||||
startOffset, endOffset, origin,
|
||||
IrClassSymbolImpl(wrappedDescriptor),
|
||||
name, kind, visibility, modality,
|
||||
@@ -41,7 +39,7 @@ inline fun buildClass(builder: IrClassBuilder.() -> Unit) =
|
||||
|
||||
fun IrFieldBuilder.buildField(): IrField {
|
||||
val wrappedDescriptor = WrappedFieldDescriptor()
|
||||
return IrFieldImpl(
|
||||
return irDeclarationFactory.createField(
|
||||
startOffset, endOffset, origin,
|
||||
IrFieldSymbolImpl(wrappedDescriptor),
|
||||
name, type, visibility, isFinal, isExternal, isStatic,
|
||||
@@ -72,7 +70,7 @@ fun IrClass.addField(fieldName: String, fieldType: IrType, fieldVisibility: Visi
|
||||
|
||||
fun IrPropertyBuilder.buildProperty(): IrProperty {
|
||||
val wrappedDescriptor = WrappedPropertyDescriptor()
|
||||
return IrPropertyImpl(
|
||||
return irDeclarationFactory.createProperty(
|
||||
startOffset, endOffset, origin,
|
||||
IrPropertySymbolImpl(wrappedDescriptor),
|
||||
name, visibility, modality,
|
||||
@@ -83,7 +81,7 @@ fun IrPropertyBuilder.buildProperty(): IrProperty {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun buildProperty(builder: IrPropertyBuilder.() -> Unit) =
|
||||
inline fun buildProperty(builder: IrPropertyBuilder.() -> Unit): IrProperty =
|
||||
IrPropertyBuilder().run {
|
||||
builder()
|
||||
buildProperty()
|
||||
@@ -115,7 +113,7 @@ inline fun IrProperty.addSetter(builder: IrFunctionBuilder.() -> Unit = {}): IrS
|
||||
}
|
||||
}
|
||||
|
||||
fun IrFunctionBuilder.buildFun(originalDescriptor: FunctionDescriptor? = null): IrFunctionImpl {
|
||||
fun IrFunctionBuilder.buildFun(originalDescriptor: FunctionDescriptor? = null): IrSimpleFunction {
|
||||
val wrappedDescriptor = when(originalDescriptor) {
|
||||
is DescriptorWithContainerSource -> WrappedFunctionDescriptorWithContainerSource(originalDescriptor.containerSource)
|
||||
is PropertyGetterDescriptor -> WrappedPropertyGetterDescriptor(originalDescriptor.annotations, originalDescriptor.source)
|
||||
@@ -123,7 +121,7 @@ fun IrFunctionBuilder.buildFun(originalDescriptor: FunctionDescriptor? = null):
|
||||
null -> WrappedSimpleFunctionDescriptor()
|
||||
else -> WrappedSimpleFunctionDescriptor(originalDescriptor)
|
||||
}
|
||||
return IrFunctionImpl(
|
||||
return irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, origin,
|
||||
IrSimpleFunctionSymbolImpl(wrappedDescriptor),
|
||||
name, visibility, modality, returnType,
|
||||
@@ -135,9 +133,9 @@ fun IrFunctionBuilder.buildFun(originalDescriptor: FunctionDescriptor? = null):
|
||||
}
|
||||
}
|
||||
|
||||
fun IrFunctionBuilder.buildConstructor(): IrConstructorImpl {
|
||||
fun IrFunctionBuilder.buildConstructor(): IrConstructor {
|
||||
val wrappedDescriptor = WrappedClassConstructorDescriptor()
|
||||
return IrConstructorImpl(
|
||||
return irDeclarationFactory.createConstructor(
|
||||
startOffset, endOffset, origin,
|
||||
IrConstructorSymbolImpl(wrappedDescriptor),
|
||||
Name.special("<init>"),
|
||||
@@ -153,19 +151,19 @@ fun IrFunctionBuilder.buildConstructor(): IrConstructorImpl {
|
||||
* potentially external function (e.g. in an IrCall) we have to ensure that we keep
|
||||
* information from the original descriptor so as not to break inlining.
|
||||
*/
|
||||
inline fun buildFunWithDescriptorForInlining(originalDescriptor: FunctionDescriptor, builder: IrFunctionBuilder.() -> Unit): IrFunctionImpl =
|
||||
inline fun buildFunWithDescriptorForInlining(originalDescriptor: FunctionDescriptor, builder: IrFunctionBuilder.() -> Unit): IrSimpleFunction =
|
||||
IrFunctionBuilder().run {
|
||||
builder()
|
||||
buildFun(originalDescriptor)
|
||||
}
|
||||
|
||||
inline fun buildFun(builder: IrFunctionBuilder.() -> Unit): IrFunctionImpl =
|
||||
inline fun buildFun(builder: IrFunctionBuilder.() -> Unit): IrSimpleFunction =
|
||||
IrFunctionBuilder().run {
|
||||
builder()
|
||||
buildFun()
|
||||
}
|
||||
|
||||
inline fun IrDeclarationContainer.addFunction(builder: IrFunctionBuilder.() -> Unit): IrFunctionImpl =
|
||||
inline fun IrDeclarationContainer.addFunction(builder: IrFunctionBuilder.() -> Unit): IrSimpleFunction =
|
||||
buildFun(builder).also { function ->
|
||||
declarations.add(function)
|
||||
function.parent = this@addFunction
|
||||
@@ -191,13 +189,13 @@ fun IrDeclarationContainer.addFunction(
|
||||
}
|
||||
}
|
||||
|
||||
inline fun buildConstructor(builder: IrFunctionBuilder.() -> Unit): IrConstructorImpl =
|
||||
inline fun buildConstructor(builder: IrFunctionBuilder.() -> Unit): IrConstructor =
|
||||
IrFunctionBuilder().run {
|
||||
builder()
|
||||
buildConstructor()
|
||||
}
|
||||
|
||||
inline fun IrClass.addConstructor(builder: IrFunctionBuilder.() -> Unit = {}): IrConstructorImpl =
|
||||
inline fun IrClass.addConstructor(builder: IrFunctionBuilder.() -> Unit = {}): IrConstructor =
|
||||
buildConstructor {
|
||||
builder()
|
||||
returnType = defaultType
|
||||
@@ -208,7 +206,7 @@ inline fun IrClass.addConstructor(builder: IrFunctionBuilder.() -> Unit = {}): I
|
||||
|
||||
fun IrValueParameterBuilder.build(): IrValueParameter {
|
||||
val wrappedDescriptor = WrappedValueParameterDescriptor()
|
||||
return IrValueParameterImpl(
|
||||
return irDeclarationFactory.createValueParameter(
|
||||
startOffset, endOffset, origin,
|
||||
IrValueParameterSymbolImpl(wrappedDescriptor),
|
||||
name, index, type, varargElementType, isCrossInline, isNoinline
|
||||
@@ -272,7 +270,7 @@ fun IrSimpleFunction.addExtensionReceiver(type: IrType, origin: IrDeclarationOri
|
||||
|
||||
fun IrTypeParameterBuilder.build(): IrTypeParameter {
|
||||
val wrappedDescriptor = WrappedTypeParameterDescriptor()
|
||||
return IrTypeParameterImpl(
|
||||
return irDeclarationFactory.createTypeParameter(
|
||||
startOffset, endOffset, origin,
|
||||
IrTypeParameterSymbolImpl(wrappedDescriptor),
|
||||
name, index, isReified, variance
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -15,10 +15,9 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.Namer
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -27,7 +26,7 @@ import org.jetbrains.kotlin.ir.util.dump
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import java.util.*
|
||||
|
||||
class JsDeclarationFactory : DeclarationFactory {
|
||||
class JsDeclarationFactory(private val irDeclarationFactory: IrDeclarationFactory) : DeclarationFactory {
|
||||
private val singletonFieldDescriptors = HashMap<IrClass, IrField>()
|
||||
private val outerThisFieldSymbols = HashMap<IrClass, IrField>()
|
||||
private val innerClassConstructors = HashMap<IrConstructor, IrConstructor>()
|
||||
@@ -54,7 +53,7 @@ class JsDeclarationFactory : DeclarationFactory {
|
||||
val descriptor = WrappedFieldDescriptor()
|
||||
val symbol = IrFieldSymbolImpl(descriptor)
|
||||
|
||||
return IrFieldImpl(
|
||||
return irDeclarationFactory.createField(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
origin,
|
||||
@@ -89,7 +88,7 @@ class JsDeclarationFactory : DeclarationFactory {
|
||||
val descriptor = WrappedClassConstructorDescriptor(oldConstructor.descriptor.annotations, oldConstructor.descriptor.source)
|
||||
val symbol = IrConstructorSymbolImpl(descriptor)
|
||||
|
||||
val newConstructor = IrConstructorImpl(
|
||||
val newConstructor = irDeclarationFactory.createConstructor(
|
||||
oldConstructor.startOffset,
|
||||
oldConstructor.endOffset,
|
||||
oldConstructor.origin,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -13,29 +13,26 @@ import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.factories.createExternalPackageFragment
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.defaultType
|
||||
import org.jetbrains.kotlin.ir.types.isLong
|
||||
import org.jetbrains.kotlin.ir.util.companionObject
|
||||
import org.jetbrains.kotlin.ir.util.constructors
|
||||
import org.jetbrains.kotlin.ir.util.findDeclaration
|
||||
import org.jetbrains.kotlin.ir.util.kotlinPackageFqn
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi2ir.findSingleFunction
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||
import java.util.*
|
||||
|
||||
class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendContext) {
|
||||
|
||||
private val externalPackageFragmentSymbol = IrExternalPackageFragmentSymbolImpl(context.internalPackageFragmentDescriptor)
|
||||
val externalPackageFragment = IrExternalPackageFragmentImpl(externalPackageFragmentSymbol)
|
||||
val externalPackageFragment = context.irDeclarationFactory.createExternalPackageFragment(externalPackageFragmentSymbol)
|
||||
|
||||
// TODO: Should we drop operator intrinsics in favor of IrDynamicOperatorExpression?
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -27,8 +27,9 @@ import org.jetbrains.kotlin.ir.backend.js.lower.CallableReferenceKey
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.ConstructorPair
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.OperatorNames
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.createFile
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrDynamicTypeImpl
|
||||
@@ -43,6 +44,7 @@ class JsIrBackendContext(
|
||||
val module: ModuleDescriptor,
|
||||
override val irBuiltIns: IrBuiltIns,
|
||||
val symbolTable: SymbolTable,
|
||||
override val irDeclarationFactory: IrDeclarationFactory,
|
||||
irModuleFragment: IrModuleFragment,
|
||||
val additionalExportedDeclarations: Set<FqName>,
|
||||
override val configuration: CompilerConfiguration, // TODO: remove configuration from backend context
|
||||
@@ -68,7 +70,7 @@ class JsIrBackendContext(
|
||||
|
||||
val internalPackageFragmentDescriptor = EmptyPackageFragmentDescriptor(builtIns.builtInsModule, FqName("kotlin.js.internal"))
|
||||
val implicitDeclarationFile by lazy {
|
||||
IrFileImpl(object : SourceManager.FileEntry {
|
||||
irDeclarationFactory.createFile(object : SourceManager.FileEntry {
|
||||
override val name = "<implicitDeclarations>"
|
||||
override val maxOffset = UNDEFINED_OFFSET
|
||||
|
||||
@@ -101,8 +103,8 @@ class JsIrBackendContext(
|
||||
implicitDeclarationFile.declarations += this
|
||||
}
|
||||
|
||||
override val sharedVariablesManager = JsSharedVariablesManager(irBuiltIns, implicitDeclarationFile)
|
||||
override val declarationFactory = JsDeclarationFactory()
|
||||
override val sharedVariablesManager = JsSharedVariablesManager(irBuiltIns, irDeclarationFactory, implicitDeclarationFile)
|
||||
override val declarationFactory = JsDeclarationFactory(irDeclarationFactory)
|
||||
|
||||
companion object {
|
||||
val KOTLIN_PACKAGE_FQN = FqName.fromSegments(listOf("kotlin"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -13,15 +13,12 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
||||
@@ -32,7 +29,11 @@ import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclarationsFile: IrPackageFragment) : SharedVariablesManager {
|
||||
class JsSharedVariablesManager(
|
||||
val builtIns: IrBuiltIns,
|
||||
private val irDeclarationFactory: IrDeclarationFactory,
|
||||
val implicitDeclarationsFile: IrPackageFragment
|
||||
) : SharedVariablesManager {
|
||||
|
||||
override fun declareSharedVariable(originalDeclaration: IrVariable): IrVariable {
|
||||
val valueType = originalDeclaration.type
|
||||
@@ -51,7 +52,7 @@ class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclaration
|
||||
}
|
||||
|
||||
val descriptor = WrappedVariableDescriptor()
|
||||
return IrVariableImpl(
|
||||
return irDeclarationFactory.createVariable(
|
||||
originalDeclaration.startOffset,
|
||||
originalDeclaration.endOffset,
|
||||
originalDeclaration.origin,
|
||||
@@ -123,7 +124,7 @@ class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclaration
|
||||
|
||||
private fun createClosureBoxClassDeclaration(): IrClass {
|
||||
val descriptor = WrappedClassDescriptor()
|
||||
val declaration = IrClassImpl(
|
||||
val declaration = irDeclarationFactory.createClass(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JsLoweredDeclarationOrigin.JS_CLOSURE_BOX_CLASS_DECLARATION, IrClassSymbolImpl(descriptor),
|
||||
Name.identifier(boxTypeName), ClassKind.CLASS, Visibilities.PUBLIC, Modality.FINAL,
|
||||
isCompanion = false, isInner = false, isData = false, isExternal = false, isInline = false, isExpect = false
|
||||
@@ -146,7 +147,7 @@ class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclaration
|
||||
val descriptor = WrappedFieldDescriptor()
|
||||
val symbol = IrFieldSymbolImpl(descriptor)
|
||||
val fieldName = Name.identifier("v")
|
||||
return IrFieldImpl(
|
||||
return irDeclarationFactory.createField(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
DeclarationFactory.FIELD_FOR_OUTER_THIS,
|
||||
@@ -169,7 +170,7 @@ class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclaration
|
||||
val descriptor = WrappedClassConstructorDescriptor()
|
||||
val symbol = IrConstructorSymbolImpl(descriptor)
|
||||
|
||||
val declaration = IrConstructorImpl(
|
||||
val declaration = irDeclarationFactory.createConstructor(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JsLoweredDeclarationOrigin.JS_CLOSURE_BOX_CLASS_DECLARATION, symbol,
|
||||
Name.special("<init>"), Visibilities.PUBLIC, closureBoxClassDeclaration.defaultType,
|
||||
isInline = false, isExternal = false, isPrimary = true, isExpect = false
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -9,20 +9,14 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||
import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.ir.backend.js.export.isExported
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.moveBodilessDeclarationsToSeparatePlace
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.JsMainFunctionDetector
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.NameTables
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.isJsExport
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithName
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
import org.jetbrains.kotlin.ir.util.generateTypicalIrProviderList
|
||||
import org.jetbrains.kotlin.ir.util.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
|
||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
|
||||
@@ -50,6 +44,7 @@ fun compile(
|
||||
files: List<KtFile>,
|
||||
configuration: CompilerConfiguration,
|
||||
phaseConfig: PhaseConfig,
|
||||
irDeclarationFactory: IrDeclarationFactory,
|
||||
allDependencies: KotlinLibraryResolveResult,
|
||||
friendDependencies: List<KotlinLibrary>,
|
||||
mainArguments: List<String>?,
|
||||
@@ -58,13 +53,13 @@ fun compile(
|
||||
generateDceJs: Boolean = false
|
||||
): CompilerResult {
|
||||
val (moduleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
||||
loadIr(project, files, configuration, allDependencies, friendDependencies)
|
||||
loadIr(project, files, configuration, irDeclarationFactory, allDependencies, friendDependencies)
|
||||
|
||||
val moduleDescriptor = moduleFragment.descriptor
|
||||
|
||||
val mainFunction = JsMainFunctionDetector.getMainFunctionOrNull(moduleFragment)
|
||||
|
||||
val context = JsIrBackendContext(moduleDescriptor, irBuiltIns, symbolTable, moduleFragment, exportedDeclarations, configuration)
|
||||
val context = JsIrBackendContext(moduleDescriptor, irBuiltIns, symbolTable, irDeclarationFactory, moduleFragment, exportedDeclarations, configuration)
|
||||
|
||||
// Load declarations referenced during `context` initialization
|
||||
dependencyModules.forEach {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,10 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -22,6 +22,8 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
object JsIrBuilder {
|
||||
/// HACK
|
||||
private val irDeclarationFactory = IrDeclarationFactory.DEFAULT
|
||||
|
||||
object SYNTHESIZED_STATEMENT : IrStatementOriginImpl("SYNTHESIZED_STATEMENT")
|
||||
object SYNTHESIZED_DECLARATION : IrDeclarationOriginImpl("SYNTHESIZED_DECLARATION")
|
||||
@@ -50,7 +52,7 @@ object JsIrBuilder {
|
||||
|
||||
fun buildValueParameter(name: Name, index: Int, type: IrType, origin: IrDeclarationOrigin = SYNTHESIZED_DECLARATION): IrValueParameter {
|
||||
val descriptor = WrappedValueParameterDescriptor()
|
||||
return IrValueParameterImpl(
|
||||
return irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
origin,
|
||||
@@ -68,7 +70,7 @@ object JsIrBuilder {
|
||||
|
||||
fun buildTypeParameter(name: Name, index: Int, isReified: Boolean, variance: Variance = Variance.INVARIANT): IrTypeParameter {
|
||||
val descriptor = WrappedTypeParameterDescriptor()
|
||||
return IrTypeParameterImpl(
|
||||
return irDeclarationFactory.createTypeParameter(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
SYNTHESIZED_DECLARATION,
|
||||
@@ -123,7 +125,7 @@ object JsIrBuilder {
|
||||
origin: IrDeclarationOrigin = SYNTHESIZED_DECLARATION
|
||||
): IrSimpleFunction {
|
||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
||||
return IrFunctionImpl(
|
||||
return irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
origin,
|
||||
@@ -146,9 +148,9 @@ object JsIrBuilder {
|
||||
}
|
||||
|
||||
fun buildAnonymousInitializer() =
|
||||
IrAnonymousInitializerImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, SYNTHESIZED_DECLARATION, IrAnonymousInitializerSymbolImpl(
|
||||
WrappedClassDescriptor()
|
||||
))
|
||||
irDeclarationFactory.createAnonymousInitializer(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, SYNTHESIZED_DECLARATION, IrAnonymousInitializerSymbolImpl(WrappedClassDescriptor())
|
||||
)
|
||||
|
||||
fun buildGetObjectValue(type: IrType, classSymbol: IrClassSymbol) =
|
||||
IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, classSymbol)
|
||||
@@ -201,7 +203,7 @@ object JsIrBuilder {
|
||||
initializer: IrExpression? = null
|
||||
): IrVariable {
|
||||
val descriptor = WrappedVariableDescriptor()
|
||||
return IrVariableImpl(
|
||||
return irDeclarationFactory.createVariable(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
SYNTHESIZED_DECLARATION,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.jetbrains.kotlin.ir.backend.js.utils.functionSignature
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsName
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.factories.createValueParameter
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrNull
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
@@ -132,7 +132,9 @@ class BridgesConstruction(val context: CommonBackendContext) : ClassLoweringPass
|
||||
copyTypeParametersFrom(bridge)
|
||||
// TODO: should dispatch receiver be copied?
|
||||
dispatchReceiverParameter = bridge.dispatchReceiverParameter?.run {
|
||||
IrValueParameterImpl(startOffset, endOffset, origin, descriptor, type, varargElementType).also { it.parent = this@apply }
|
||||
context.irDeclarationFactory
|
||||
.createValueParameter(startOffset, endOffset, origin, descriptor, type, varargElementType)
|
||||
.also { it.parent = this@apply }
|
||||
}
|
||||
extensionReceiverParameter = bridge.extensionReceiverParameter?.copyTo(this)
|
||||
valueParameters += bridge.valueParameters.map { p -> p.copyTo(this) }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -15,8 +15,6 @@ import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.Namer
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.asString
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
@@ -429,7 +427,7 @@ class CallableReferenceLowering(val context: JsIrBackendContext) : FileLoweringP
|
||||
|
||||
for ((i, p) in boundValueParameters.withIndex()) {
|
||||
val descriptor = WrappedValueParameterDescriptor()
|
||||
factoryDeclaration.valueParameters += IrValueParameterImpl(
|
||||
factoryDeclaration.valueParameters += context.irDeclarationFactory.createValueParameter(
|
||||
p.startOffset,
|
||||
p.endOffset,
|
||||
p.origin,
|
||||
@@ -451,7 +449,7 @@ class CallableReferenceLowering(val context: JsIrBackendContext) : FileLoweringP
|
||||
|
||||
for (t in typeParameters) {
|
||||
val descriptor = WrappedTypeParameterDescriptor()
|
||||
factoryDeclaration.typeParameters += IrTypeParameterImpl(
|
||||
factoryDeclaration.typeParameters += context.irDeclarationFactory.createTypeParameter(
|
||||
t.startOffset,
|
||||
t.endOffset,
|
||||
t.origin,
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.ir.util.isFunction
|
||||
import org.jetbrains.kotlin.ir.util.isThrowable
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
class ClassReferenceLowering(val context: JsIrBackendContext) : FileLoweringPass {
|
||||
private val intrinsics = context.intrinsics
|
||||
@@ -224,7 +224,7 @@ class ClassReferenceLowering(val context: JsIrBackendContext) : FileLoweringPass
|
||||
}
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
|
||||
irFile.transformChildrenVoid(object : IrElementTransformerVoidWithContext(context) {
|
||||
override fun visitGetClass(expression: IrGetClass) =
|
||||
callGetKClassFromExpression(
|
||||
returnType = expression.type,
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
@@ -95,11 +94,11 @@ class CreateScriptFunctionsPhase(val context: CommonBackendContext) : FileLoweri
|
||||
return (irScript.statements.lastOrNull() as? IrExpression)?.type ?: context.irBuiltIns.unitType
|
||||
}
|
||||
|
||||
private fun createFunction(irScript: IrScript, name: String, returnType: IrType): IrFunctionImpl {
|
||||
private fun createFunction(irScript: IrScript, name: String, returnType: IrType): IrSimpleFunction {
|
||||
val (startOffset, endOffset) = getFunctionBodyOffsets(irScript)
|
||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
||||
|
||||
return IrFunctionImpl(
|
||||
return context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, SCRIPT_FUNCTION,
|
||||
IrSimpleFunctionSymbolImpl(descriptor),
|
||||
Name.identifier(name),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -21,8 +21,6 @@ import org.jetbrains.kotlin.ir.backend.js.utils.toJsArrayLiteral
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildField
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
@@ -67,7 +65,7 @@ class EnumUsageLowering(val context: JsIrBackendContext) : FileLoweringPass {
|
||||
val descriptor = WrappedFieldDescriptor()
|
||||
val symbol = IrFieldSymbolImpl(descriptor)
|
||||
return entry.run {
|
||||
IrFieldImpl(
|
||||
context.irDeclarationFactory.createField(
|
||||
startOffset, endOffset, origin, symbol, name, irClass.defaultType, Visibilities.PUBLIC,
|
||||
isFinal = false, isExternal = true, isStatic = true,
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
@@ -189,7 +187,7 @@ class EnumClassConstructorTransformer(val context: CommonBackendContext, private
|
||||
val loweredConstructorDescriptor = WrappedClassConstructorDescriptor()
|
||||
val loweredConstructorSymbol = IrConstructorSymbolImpl(loweredConstructorDescriptor)
|
||||
|
||||
return IrConstructorImpl(
|
||||
return context.irDeclarationFactory.createConstructor(
|
||||
enumConstructor.startOffset,
|
||||
enumConstructor.endOffset,
|
||||
enumConstructor.origin,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -11,8 +11,6 @@ import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsModule
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsQualifier
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
||||
import org.jetbrains.kotlin.ir.util.UniqId
|
||||
@@ -82,7 +80,7 @@ private class DescriptorlessIrFileSymbol : IrFileSymbol {
|
||||
|
||||
fun moveBodilessDeclarationsToSeparatePlace(context: JsIrBackendContext, module: IrModuleFragment) {
|
||||
|
||||
val bodilessBuiltInsPackageFragment = IrExternalPackageFragmentImpl(
|
||||
val bodilessBuiltInsPackageFragment = context.irDeclarationFactory.createExternalPackageFragment(
|
||||
DescriptorlessExternalPackageFragmentSymbol(),
|
||||
FqName("kotlin")
|
||||
)
|
||||
@@ -108,9 +106,11 @@ fun moveBodilessDeclarationsToSeparatePlace(context: JsIrBackendContext, module:
|
||||
fun lowerFile(irFile: IrFile): IrFile? {
|
||||
val externalPackageFragment by lazy {
|
||||
context.externalPackageFragment.getOrPut(irFile.symbol) {
|
||||
IrFileImpl(fileEntry = irFile.fileEntry, fqName = irFile.fqName, symbol = DescriptorlessIrFileSymbol()).also {
|
||||
it.annotations += irFile.annotations
|
||||
}
|
||||
context.irDeclarationFactory
|
||||
.createFile(fileEntry = irFile.fileEntry, fqName = irFile.fqName, symbol = DescriptorlessIrFileSymbol())
|
||||
.also {
|
||||
it.annotations += irFile.annotations
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -12,8 +12,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
@@ -190,7 +188,7 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : FileLoweringPass
|
||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
||||
val symbol = IrSimpleFunctionSymbolImpl(descriptor)
|
||||
val staticFunction = function.run {
|
||||
IrFunctionImpl(
|
||||
context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, origin,
|
||||
symbol, name, visibility, modality,
|
||||
returnType,
|
||||
@@ -209,7 +207,7 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : FileLoweringPass
|
||||
staticFunction.extensionReceiverParameter = function.extensionReceiverParameter?.copyTo(staticFunction)
|
||||
val thisDesc = WrappedValueParameterDescriptor()
|
||||
val thisSymbol = IrValueParameterSymbolImpl(thisDesc)
|
||||
staticFunction.valueParameters += IrValueParameterImpl(
|
||||
staticFunction.valueParameters += context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET,
|
||||
UNDEFINED_OFFSET,
|
||||
STATIC_THIS_PARAMETER,
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
@@ -48,6 +49,7 @@ class JvmBackendContext(
|
||||
irModuleFragment: IrModuleFragment,
|
||||
private val symbolTable: SymbolTable,
|
||||
val phaseConfig: PhaseConfig,
|
||||
override val irDeclarationFactory: IrDeclarationFactory,
|
||||
// If the JVM fqname of a class differs from what is implied by its parent, e.g. if it's a file class
|
||||
// annotated with @JvmPackageName, the correct name is recorded here.
|
||||
internal val classNameOverride: MutableMap<IrClass, JvmClassName>
|
||||
@@ -61,8 +63,8 @@ class JvmBackendContext(
|
||||
val typeMapper = IrTypeMapper(this)
|
||||
val methodSignatureMapper = MethodSignatureMapper(this)
|
||||
|
||||
override val declarationFactory: JvmDeclarationFactory = JvmDeclarationFactory(methodSignatureMapper)
|
||||
override val sharedVariablesManager = JvmSharedVariablesManager(state.module, builtIns, irBuiltIns)
|
||||
override val declarationFactory: JvmDeclarationFactory = JvmDeclarationFactory(methodSignatureMapper, irDeclarationFactory)
|
||||
override val sharedVariablesManager = JvmSharedVariablesManager(state.module, builtIns, irBuiltIns, irDeclarationFactory)
|
||||
|
||||
override val ir = JvmIr(irModuleFragment, this.symbolTable)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.backend.jvm.serialization.JvmMangler
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.types.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -22,10 +23,18 @@ import org.jetbrains.kotlin.psi2ir.Psi2IrTranslator
|
||||
import org.jetbrains.kotlin.psi2ir.PsiSourceManager
|
||||
|
||||
object JvmBackendFacade {
|
||||
fun doGenerateFiles(files: Collection<KtFile>, state: GenerationState, phaseConfig: PhaseConfig) {
|
||||
fun doGenerateFiles(
|
||||
files: Collection<KtFile>,
|
||||
state: GenerationState,
|
||||
phaseConfig: PhaseConfig,
|
||||
irDeclarationFactory: IrDeclarationFactory
|
||||
) {
|
||||
val extensions = JvmGeneratorExtensions()
|
||||
val psi2ir = Psi2IrTranslator(state.languageVersionSettings, mangler = JvmMangler)
|
||||
val psi2irContext = psi2ir.createGeneratorContext(state.module, state.bindingContext, extensions = extensions)
|
||||
val psi2irContext = psi2ir.createGeneratorContext(
|
||||
state.module, state.bindingContext,
|
||||
extensions = extensions, irDeclarationFactory = irDeclarationFactory
|
||||
)
|
||||
|
||||
for (extension in IrGenerationExtension.getInstances(state.project)) {
|
||||
psi2ir.addPostprocessingStep { module ->
|
||||
@@ -37,7 +46,8 @@ object JvmBackendFacade {
|
||||
psi2irContext.languageVersionSettings,
|
||||
psi2irContext.symbolTable,
|
||||
psi2irContext.typeTranslator,
|
||||
psi2irContext.irBuiltIns
|
||||
psi2irContext.irBuiltIns,
|
||||
psi2irContext.irDeclarationFactory
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -49,7 +59,8 @@ object JvmBackendFacade {
|
||||
)
|
||||
val irModuleFragment = psi2ir.generateModuleFragment(psi2irContext, files, irProviders = irProviders, expectDescriptorToSymbol = null)
|
||||
doGenerateFilesInternal(
|
||||
state, irModuleFragment, psi2irContext.symbolTable, psi2irContext.sourceManager, phaseConfig, irProviders, extensions
|
||||
state, irModuleFragment, psi2irContext.symbolTable, psi2irContext.sourceManager,
|
||||
phaseConfig, irDeclarationFactory, irProviders, extensions
|
||||
)
|
||||
}
|
||||
|
||||
@@ -59,11 +70,13 @@ object JvmBackendFacade {
|
||||
symbolTable: SymbolTable,
|
||||
sourceManager: PsiSourceManager,
|
||||
phaseConfig: PhaseConfig,
|
||||
irDeclarationFactory: IrDeclarationFactory,
|
||||
irProviders: List<IrProvider>,
|
||||
extensions: JvmGeneratorExtensions
|
||||
) {
|
||||
val context = JvmBackendContext(
|
||||
state, sourceManager, irModuleFragment.irBuiltins, irModuleFragment, symbolTable, phaseConfig, extensions.classNameOverride
|
||||
state, sourceManager, irModuleFragment.irBuiltins, irModuleFragment,
|
||||
symbolTable, phaseConfig, irDeclarationFactory, extensions.classNameOverride
|
||||
)
|
||||
/* JvmBackendContext creates new unbound symbols, have to resolve them. */
|
||||
ExternalDependenciesGenerator(symbolTable, irProviders).generateUnboundSymbolsAsDependencies()
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.backend.jvm
|
||||
@@ -24,6 +13,7 @@ import org.jetbrains.kotlin.codegen.PackageCodegenImpl
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.generateTypicalIrProviderList
|
||||
@@ -31,10 +21,13 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi2ir.PsiSourceManager
|
||||
|
||||
class JvmIrCodegenFactory(private val phaseConfig: PhaseConfig) : CodegenFactory {
|
||||
class JvmIrCodegenFactory(
|
||||
private val phaseConfig: PhaseConfig,
|
||||
private val irDeclarationFactory: IrDeclarationFactory
|
||||
) : CodegenFactory {
|
||||
|
||||
override fun generateModule(state: GenerationState, files: Collection<KtFile>) {
|
||||
JvmBackendFacade.doGenerateFiles(files, state, phaseConfig)
|
||||
JvmBackendFacade.doGenerateFiles(files, state, phaseConfig, irDeclarationFactory)
|
||||
}
|
||||
|
||||
fun generateModuleInFrontendIRMode(
|
||||
@@ -46,7 +39,7 @@ class JvmIrCodegenFactory(private val phaseConfig: PhaseConfig) : CodegenFactory
|
||||
)
|
||||
ExternalDependenciesGenerator(symbolTable, irProviders).generateUnboundSymbolsAsDependencies()
|
||||
JvmBackendFacade.doGenerateFilesInternal(
|
||||
state, irModuleFragment, symbolTable, sourceManager, phaseConfig, irProviders, extensions
|
||||
state, irModuleFragment, symbolTable, sourceManager, phaseConfig, irDeclarationFactory, irProviders, extensions
|
||||
)
|
||||
}
|
||||
|
||||
@@ -55,7 +48,7 @@ class JvmIrCodegenFactory(private val phaseConfig: PhaseConfig) : CodegenFactory
|
||||
|
||||
return object : PackageCodegen {
|
||||
override fun generate() {
|
||||
JvmBackendFacade.doGenerateFiles(files, state, phaseConfig)
|
||||
JvmBackendFacade.doGenerateFiles(files, state, phaseConfig, irDeclarationFactory)
|
||||
}
|
||||
|
||||
override fun getPackageFragment(): PackageFragmentDescriptor {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.builders.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.factories.createExternalPackageFragment
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
@@ -74,7 +74,8 @@ class JvmSymbols(
|
||||
}
|
||||
|
||||
private fun createPackage(fqName: FqName): IrPackageFragment =
|
||||
IrExternalPackageFragmentImpl(IrExternalPackageFragmentSymbolImpl(EmptyPackageFragmentDescriptor(context.state.module, fqName)))
|
||||
context.irDeclarationFactory.createExternalPackageFragment(
|
||||
IrExternalPackageFragmentSymbolImpl(EmptyPackageFragmentDescriptor(context.state.module, fqName)))
|
||||
|
||||
private fun createClass(
|
||||
fqName: FqName,
|
||||
|
||||
@@ -333,7 +333,7 @@ open class ClassCodegen protected constructor(
|
||||
|
||||
AnnotationCodegen(this, context, fv::visitAnnotation).genAnnotations(field, fieldType)
|
||||
|
||||
val descriptor = field.metadata?.descriptor
|
||||
val descriptor = (field.metadata as MetadataSource.Property?)?.descriptor
|
||||
if (descriptor != null) {
|
||||
state.globalSerializationBindings.put(JvmSerializationBindings.FIELD_FOR_PROPERTY, descriptor, fieldType to fieldName)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFunctionDescriptorWithContainerSource
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
@@ -45,7 +44,6 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
@@ -159,7 +157,7 @@ private fun IrFunction.suspendFunctionView(context: JvmBackendContext): IrFuncti
|
||||
WrappedFunctionDescriptorWithContainerSource(originalDescriptor.containerSource!!)
|
||||
else
|
||||
WrappedSimpleFunctionDescriptor(sourceElement = originalDescriptor.source)
|
||||
return IrFunctionImpl(
|
||||
return context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset,
|
||||
if (origin == JvmLoweredDeclarationOrigin.FOR_INLINE_STATE_MACHINE_TEMPLATE_CAPTURES_CROSSINLINE)
|
||||
JvmLoweredDeclarationOrigin.FOR_INLINE_STATE_MACHINE_TEMPLATE_CAPTURES_CROSSINLINE_VIEW
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -20,11 +20,11 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildField
|
||||
import org.jetbrains.kotlin.ir.builders.setSourceRange
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
@@ -34,7 +34,8 @@ import org.jetbrains.kotlin.name.Name
|
||||
import java.util.*
|
||||
|
||||
class JvmDeclarationFactory(
|
||||
private val methodSignatureMapper: MethodSignatureMapper
|
||||
private val methodSignatureMapper: MethodSignatureMapper,
|
||||
private val irDeclarationFactory: IrDeclarationFactory
|
||||
) : DeclarationFactory {
|
||||
private val singletonFieldDeclarations = HashMap<IrSymbolOwner, IrField>()
|
||||
private val interfaceCompanionFieldDeclarations = HashMap<IrSymbolOwner, IrField>()
|
||||
@@ -84,7 +85,7 @@ class JvmDeclarationFactory(
|
||||
|
||||
private fun createInnerClassConstructorWithOuterThisParameter(oldConstructor: IrConstructor): IrConstructor {
|
||||
val newDescriptor = WrappedClassConstructorDescriptor(oldConstructor.descriptor.annotations)
|
||||
return IrConstructorImpl(
|
||||
return irDeclarationFactory.createConstructor(
|
||||
oldConstructor.startOffset,
|
||||
oldConstructor.endOffset,
|
||||
oldConstructor.origin,
|
||||
@@ -105,7 +106,7 @@ class JvmDeclarationFactory(
|
||||
|
||||
val outerThisType = oldConstructor.parentAsClass.parentAsClass.defaultType
|
||||
val outerThisDescriptor = WrappedValueParameterDescriptor()
|
||||
val outerThisValueParameter = IrValueParameterImpl(
|
||||
val outerThisValueParameter = irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.FIELD_FOR_OUTER_THIS,
|
||||
IrValueParameterSymbolImpl(outerThisDescriptor),
|
||||
Name.identifier(AsmUtil.CAPTURED_THIS_FIELD),
|
||||
@@ -181,7 +182,7 @@ class JvmDeclarationFactory(
|
||||
initializer = oldField.initializer
|
||||
?.replaceThisByStaticReference(this@JvmDeclarationFactory, oldParent, oldParent.thisReceiver!!)
|
||||
?.patchDeclarationParents(this) as IrExpressionBody?
|
||||
(this as IrFieldImpl).metadata = oldField.metadata
|
||||
this.metadata = oldField.metadata
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,7 +219,7 @@ class JvmDeclarationFactory(
|
||||
fun getDefaultImplsClass(interfaceClass: IrClass): IrClass =
|
||||
defaultImplsClasses.getOrPut(interfaceClass) {
|
||||
val descriptor = WrappedClassDescriptor()
|
||||
IrClassImpl(
|
||||
irDeclarationFactory.createClass(
|
||||
interfaceClass.startOffset, interfaceClass.endOffset,
|
||||
JvmLoweredDeclarationOrigin.DEFAULT_IMPLS,
|
||||
IrClassSymbolImpl(descriptor),
|
||||
@@ -245,7 +246,7 @@ class JvmDeclarationFactory(
|
||||
val irClass = fakeOverride.parentAsClass
|
||||
val descriptor = DescriptorsToIrRemapper.remapDeclaredSimpleFunction(fakeOverride.descriptor)
|
||||
with(fakeOverride) {
|
||||
IrFunctionImpl(
|
||||
irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.DEFAULT_IMPLS_BRIDGE,
|
||||
IrSimpleFunctionSymbolImpl(descriptor),
|
||||
name, visibility, modality, returnType,
|
||||
@@ -267,7 +268,7 @@ class JvmDeclarationFactory(
|
||||
// If both setter and getter are present, original property will be duplicated.
|
||||
val newPropertyDescriptor = DescriptorsToIrRemapper.remapDeclaredProperty(fakeOverrideProperty.descriptor)
|
||||
correspondingPropertySymbol = with(fakeOverrideProperty) {
|
||||
IrPropertyImpl(
|
||||
irDeclarationFactory.createProperty(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
IrDeclarationOrigin.DEFINED, IrPropertySymbolImpl(newPropertyDescriptor),
|
||||
name, visibility, modality, isVar, isConst, isLateinit, isDelegated,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -17,14 +17,13 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildConstructor
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildField
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.createExternalPackageFragment
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
|
||||
@@ -45,9 +44,10 @@ private val SHARED_VARIABLE_CONSTRUCTOR_CALL_ORIGIN = object : IrStatementOrigin
|
||||
class JvmSharedVariablesManager(
|
||||
module: ModuleDescriptor,
|
||||
val builtIns: KotlinBuiltIns,
|
||||
val irBuiltIns: IrBuiltIns
|
||||
val irBuiltIns: IrBuiltIns,
|
||||
val irDeclarationFactory: IrDeclarationFactory
|
||||
) : SharedVariablesManager {
|
||||
private val jvmInternalPackage = IrExternalPackageFragmentImpl(
|
||||
private val jvmInternalPackage = irDeclarationFactory.createExternalPackageFragment(
|
||||
IrExternalPackageFragmentSymbolImpl(
|
||||
EmptyPackageFragmentDescriptor(module, FqName("kotlin.jvm.internal"))
|
||||
)
|
||||
@@ -119,7 +119,7 @@ class JvmSharedVariablesManager(
|
||||
}.apply {
|
||||
val irClass = this
|
||||
typeParameters.add(
|
||||
IrTypeParameterImpl(
|
||||
irDeclarationFactory.createTypeParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
SHARED_VARIABLE_ORIGIN,
|
||||
IrTypeParameterSymbolImpl(WrappedTypeParameterDescriptor()),
|
||||
@@ -182,7 +182,7 @@ class JvmSharedVariablesManager(
|
||||
}
|
||||
}
|
||||
|
||||
return IrVariableImpl(
|
||||
return irDeclarationFactory.createVariable(
|
||||
originalDeclaration.startOffset, originalDeclaration.endOffset, originalDeclaration.origin,
|
||||
IrVariableSymbolImpl(WrappedVariableDescriptor()),
|
||||
originalDeclaration.name,
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
|
||||
internal open class IrInlineReferenceLocator(private val context: JvmBackendContext) : IrElementVisitorVoidWithContext() {
|
||||
internal open class IrInlineReferenceLocator(override val context: JvmBackendContext) : IrElementVisitorVoidWithContext(context) {
|
||||
val inlineReferences = mutableSetOf<IrCallableReference>()
|
||||
|
||||
// For crossinline lambdas, the call site is null as it's probably in a separate class somewhere.
|
||||
|
||||
@@ -126,7 +126,7 @@ class JvmIrBuilder(
|
||||
endOffset: Int = UNDEFINED_OFFSET
|
||||
) : IrBuilderWithScope(
|
||||
IrLoweringContext(backendContext),
|
||||
Scope(symbol),
|
||||
Scope(symbol, backendContext.irDeclarationFactory),
|
||||
startOffset,
|
||||
endOffset
|
||||
) {
|
||||
|
||||
@@ -64,7 +64,7 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
|
||||
for (lambda in suspendLambdas) {
|
||||
(lambda.function.parent as IrDeclarationContainer).declarations.remove(lambda.function)
|
||||
}
|
||||
irFile.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
|
||||
irFile.transformChildrenVoid(object : IrElementTransformerVoidWithContext(context) {
|
||||
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
|
||||
if (!expression.isSuspend)
|
||||
return expression
|
||||
|
||||
@@ -21,8 +21,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildClass
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildConstructor
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrEnumEntryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedEnumEntryDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
@@ -31,6 +29,7 @@ import org.jetbrains.kotlin.ir.expressions.IrVararg
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetEnumValueImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
|
||||
import org.jetbrains.kotlin.ir.factories.createExternalPackageFragment
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrEnumEntrySymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
@@ -54,7 +53,7 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
|
||||
|
||||
// TODO: import IR structures from the library?
|
||||
|
||||
private val annotationPackage: IrPackageFragment = IrExternalPackageFragmentImpl(
|
||||
private val annotationPackage: IrPackageFragment = context.irDeclarationFactory.createExternalPackageFragment(
|
||||
IrExternalPackageFragmentSymbolImpl(
|
||||
EmptyPackageFragmentDescriptor(
|
||||
context.ir.irModule.descriptor,
|
||||
@@ -87,7 +86,7 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
|
||||
returnType = annotationClass.defaultType
|
||||
}
|
||||
|
||||
private fun buildEnumEntry(enumClass: IrClass, entryName: String): IrEnumEntry = IrEnumEntryImpl(
|
||||
private fun buildEnumEntry(enumClass: IrClass, entryName: String): IrEnumEntry = context.irDeclarationFactory.createEnumEntry(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB,
|
||||
IrEnumEntrySymbolImpl(WrappedEnumEntryDescriptor()),
|
||||
Name.identifier(entryName)
|
||||
|
||||
@@ -54,7 +54,7 @@ internal val anonymousObjectSuperConstructorPhase = makeIrFilePhase(
|
||||
// attempts to read them from fields, causing a bytecode validation error.
|
||||
//
|
||||
// (TODO fix the inliner instead. Then keep this code for one more version for backwards compatibility.)
|
||||
private class AnonymousObjectSuperConstructorLowering(val context: JvmBackendContext) : IrElementTransformerVoidWithContext(),
|
||||
private class AnonymousObjectSuperConstructorLowering(context: JvmBackendContext) : IrElementTransformerVoidWithContext(context),
|
||||
FileLoweringPass {
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.transformChildrenVoid()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -24,8 +24,6 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
@@ -209,7 +207,7 @@ private class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass
|
||||
|
||||
private fun IrSimpleFunction.copyRenamingTo(newName: Name): IrSimpleFunction =
|
||||
WrappedSimpleFunctionDescriptor(descriptor.annotations).let { newDescriptor ->
|
||||
IrFunctionImpl(
|
||||
context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, origin,
|
||||
IrSimpleFunctionSymbolImpl(newDescriptor),
|
||||
newName,
|
||||
@@ -238,7 +236,7 @@ private class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass
|
||||
|
||||
val visibility = if (signatureFunction.visibility === Visibilities.INTERNAL) Visibilities.PUBLIC else signatureFunction.visibility
|
||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
||||
return IrFunctionImpl(
|
||||
return context.irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
origin,
|
||||
IrSimpleFunctionSymbolImpl(descriptor),
|
||||
@@ -389,7 +387,7 @@ private class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass
|
||||
else
|
||||
WrappedSimpleFunctionDescriptor(descriptor.annotations).let { wrappedDescriptor ->
|
||||
val newOrigin = if (origin == IrDeclarationOrigin.FAKE_OVERRIDE) IrDeclarationOrigin.DEFINED else origin
|
||||
IrFunctionImpl(
|
||||
context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, newOrigin,
|
||||
IrSimpleFunctionSymbolImpl(wrappedDescriptor),
|
||||
Name.identifier(getJvmName()),
|
||||
@@ -416,7 +414,7 @@ private class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass
|
||||
} else {
|
||||
WrappedValueParameterDescriptor(this.descriptor.annotations)
|
||||
}
|
||||
return IrValueParameterImpl(
|
||||
return context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
IrDeclarationOrigin.BRIDGE,
|
||||
IrValueParameterSymbolImpl(descriptor),
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl
|
||||
@@ -46,7 +45,9 @@ internal val callableReferencePhase = makeIrFilePhase(
|
||||
|
||||
|
||||
// Originally copied from K/Native
|
||||
internal class CallableReferenceLowering(private val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
internal class CallableReferenceLowering(
|
||||
override val context: JvmBackendContext
|
||||
) : FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
// This pass ignores suspend function references and function references used in inline arguments to inline functions.
|
||||
private val ignoredFunctionReferences = mutableSetOf<IrCallableReference>()
|
||||
|
||||
@@ -146,7 +147,7 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
|
||||
createImplicitParameterDeclarationWithWrappedDescriptor()
|
||||
copyAttributes(irFunctionReference)
|
||||
if (isLambda) {
|
||||
(this as IrClassImpl).metadata = irFunctionReference.symbol.owner.metadata
|
||||
this.metadata = irFunctionReference.symbol.owner.metadata
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ internal val checkNotNullPhase = makeIrFilePhase(
|
||||
description = "Lower calls to the CHECK_NOT_NULL intrinsic, which are generated by psi2ir for \"!!\" expressions."
|
||||
)
|
||||
|
||||
private class CheckNotNullLowering(private val backendContext: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
private class CheckNotNullLowering(
|
||||
private val backendContext: JvmBackendContext
|
||||
) : FileLoweringPass, IrElementTransformerVoidWithContext(backendContext) {
|
||||
override fun lower(irFile: IrFile) = irFile.transformChildrenVoid()
|
||||
|
||||
override fun visitCall(expression: IrCall): IrExpression {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
* 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.backend.jvm.lower
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
@@ -104,7 +103,7 @@ private class CollectionStubMethodLowering(val context: JvmBackendContext) : Cla
|
||||
private fun IrValueParameter.copyWithSubstitution(target: IrSimpleFunction, substitutionMap: Map<IrTypeParameterSymbol, IrType>)
|
||||
: IrValueParameter {
|
||||
val descriptor = WrappedValueParameterDescriptor(this.descriptor.annotations)
|
||||
return IrValueParameterImpl(
|
||||
return context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
IrDeclarationOrigin.IR_BUILTINS_STUB,
|
||||
IrValueParameterSymbolImpl(descriptor),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -18,9 +18,6 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
@@ -59,7 +56,7 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP
|
||||
private inner class EnumClassTransformer(val irClass: IrClass) {
|
||||
private val enumEntryOrdinals = TObjectIntHashMap<IrEnumEntry>()
|
||||
private val enumEntryClassToEntry = HashMap<IrClass, IrEnumEntry>()
|
||||
private val loweredEnumConstructors = HashMap<IrConstructorSymbol, IrConstructorImpl>()
|
||||
private val loweredEnumConstructors = HashMap<IrConstructorSymbol, IrConstructor>()
|
||||
private val loweredEnumConstructorParameters = HashMap<IrValueParameterSymbol, IrValueParameter>()
|
||||
private val enumEntriesByField = HashMap<IrField, IrEnumEntry>()
|
||||
private val enumEntryFields = ArrayList<IrField>()
|
||||
@@ -133,7 +130,7 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP
|
||||
enumClass: IrClass
|
||||
): IrConstructor {
|
||||
val descriptor = WrappedClassConstructorDescriptor(enumConstructor.descriptor.annotations, enumConstructor.descriptor.source)
|
||||
return IrConstructorImpl(
|
||||
return context.irDeclarationFactory.createConstructor(
|
||||
enumConstructor.startOffset, enumConstructor.endOffset,
|
||||
enumConstructor.origin,
|
||||
IrConstructorSymbolImpl(descriptor),
|
||||
@@ -168,7 +165,7 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP
|
||||
|
||||
private fun makeNameValueParameter(constructor: IrConstructor): IrValueParameter {
|
||||
val descriptor = WrappedValueParameterDescriptor()
|
||||
return IrValueParameterImpl(
|
||||
return context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.ENUM_CONSTRUCTOR_SYNTHETIC_PARAMETER,
|
||||
IrValueParameterSymbolImpl(descriptor),
|
||||
@@ -186,7 +183,7 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP
|
||||
|
||||
private fun makeOrdinalValueParameter(constructor: IrConstructor): IrValueParameter {
|
||||
val descriptor = WrappedValueParameterDescriptor()
|
||||
return IrValueParameterImpl(
|
||||
return context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.ENUM_CONSTRUCTOR_SYNTHETIC_PARAMETER,
|
||||
IrValueParameterSymbolImpl(descriptor),
|
||||
@@ -251,14 +248,14 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP
|
||||
}
|
||||
|
||||
|
||||
private fun createSyntheticValuesFieldDeclaration(): IrFieldImpl {
|
||||
private fun createSyntheticValuesFieldDeclaration(): IrField {
|
||||
val valuesArrayType = context.irBuiltIns.arrayClass.typeWith(irClass.defaultType)
|
||||
|
||||
val irValuesInitializer = createSyntheticValuesFieldInitializerExpression()
|
||||
|
||||
val descriptor = WrappedFieldDescriptor()
|
||||
// TODO: mark ACC_SYNTHETIC
|
||||
return IrFieldImpl(
|
||||
return context.irDeclarationFactory.createField(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.FIELD_FOR_ENUM_VALUES,
|
||||
IrFieldSymbolImpl(descriptor),
|
||||
Name.identifier("\$VALUES"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ internal val fakeInliningLocalVariablesLowering = makeIrFilePhase(
|
||||
description = "Add fake locals to identify the range of inlined functions and lambdas"
|
||||
)
|
||||
|
||||
internal class FakeInliningLocalVariablesLowering(val context: JvmBackendContext) : IrInlineReferenceLocator(context), FileLoweringPass {
|
||||
internal class FakeInliningLocalVariablesLowering(context: JvmBackendContext) : IrInlineReferenceLocator(context), FileLoweringPass {
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.acceptVoid(this)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.backend.jvm.lower
|
||||
@@ -26,7 +15,6 @@ import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
@@ -75,7 +63,7 @@ private class FileClassLowering(val context: JvmBackendContext) : FileLoweringPa
|
||||
?: throw AssertionError("Unexpected file entry: $fileEntry")
|
||||
val fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(ktFile)
|
||||
val descriptor = WrappedClassDescriptor(sourceElement = KotlinSourceElement(ktFile))
|
||||
return IrClassImpl(
|
||||
return context.irDeclarationFactory.createClass(
|
||||
0, fileEntry.maxOffset,
|
||||
IrDeclarationOrigin.FILE_CLASS,
|
||||
symbol = IrClassSymbolImpl(descriptor),
|
||||
|
||||
@@ -41,8 +41,8 @@ internal val functionNVarargBridgePhase = makeIrFilePhase(
|
||||
// inherit from the generic FunctionN class which has a vararg invoke method. This phase
|
||||
// adds a bridge method for such large arity functions, which checks the number of arguments
|
||||
// dynamically.
|
||||
private class FunctionNVarargBridgeLowering(val context: JvmBackendContext) :
|
||||
FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
private class FunctionNVarargBridgeLowering(override val context: JvmBackendContext) :
|
||||
FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
override fun lower(irFile: IrFile) = irFile.transformChildrenVoid(this)
|
||||
|
||||
// Change calls to big arity invoke functions to vararg calls.
|
||||
|
||||
@@ -27,10 +27,10 @@ import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addConstructor
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildClass
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||
import org.jetbrains.kotlin.ir.factories.createFile
|
||||
import org.jetbrains.kotlin.ir.types.typeWith
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
@@ -106,7 +106,7 @@ private fun generateMultifileFacades(
|
||||
}
|
||||
|
||||
val fileEntry = MultifileFacadeFileEntry(jvmClassName, partClasses.map(IrClass::fileParent))
|
||||
val file = IrFileImpl(fileEntry, EmptyPackageFragmentDescriptor(module, kotlinPackageFqName))
|
||||
val file = context.irDeclarationFactory.createFile(fileEntry, EmptyPackageFragmentDescriptor(module, kotlinPackageFqName))
|
||||
|
||||
context.log {
|
||||
"Multifile facade $jvmClassName:\n ${partClasses.joinToString("\n ") { it.fqNameWhenAvailable!!.asString() }}\n"
|
||||
|
||||
@@ -44,8 +44,8 @@ internal val inlineCallableReferenceToLambdaPhase = makeIrFilePhase(
|
||||
//
|
||||
// foo(::smth) -> foo { a -> smth(a) }
|
||||
//
|
||||
internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendContext) : FileLoweringPass,
|
||||
IrElementTransformerVoidWithContext() {
|
||||
internal class InlineCallableReferenceToLambdaPhase(override val context: JvmBackendContext) : FileLoweringPass,
|
||||
IrElementTransformerVoidWithContext(context) {
|
||||
|
||||
private var inlinableReferences = mutableSetOf<IrCallableReference>()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -165,7 +165,9 @@ internal val interfaceDefaultCallsPhase = makeIrFilePhase(
|
||||
description = "Redirect interface calls with default arguments to DefaultImpls"
|
||||
)
|
||||
|
||||
private class InterfaceDefaultCallsLowering(val context: JvmBackendContext) : IrElementTransformerVoidWithContext(), FileLoweringPass {
|
||||
private class InterfaceDefaultCallsLowering(
|
||||
override val context: JvmBackendContext
|
||||
) : IrElementTransformerVoidWithContext(context), FileLoweringPass {
|
||||
// TODO If there are no default _implementations_ we can avoid generating defaultImpls class entirely by moving default arg dispatchers to the interface class
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.transformChildrenVoid(this)
|
||||
|
||||
@@ -52,7 +52,9 @@ val jvmInlineClassPhase = makeIrFilePhase(
|
||||
* We do not unfold inline class types here. Instead, the type mapper will lower inline class
|
||||
* types to the types of their underlying field.
|
||||
*/
|
||||
private class JvmInlineClassLowering(private val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
private class JvmInlineClassLowering(
|
||||
override val context: JvmBackendContext
|
||||
) : FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
private val valueMap = mutableMapOf<IrValueSymbol, IrValueDeclaration>()
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.backend.jvm.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
@@ -120,7 +118,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
|
||||
val res = when (oldFunction) {
|
||||
is IrConstructor -> {
|
||||
val descriptor = WrappedClassConstructorDescriptor(oldFunction.descriptor.annotations)
|
||||
IrConstructorImpl(
|
||||
context.irDeclarationFactory.createConstructor(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
|
||||
IrConstructorSymbolImpl(descriptor),
|
||||
@@ -137,7 +135,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
|
||||
}
|
||||
is IrSimpleFunction -> {
|
||||
val descriptor = WrappedSimpleFunctionDescriptor(oldFunction.descriptor.annotations)
|
||||
IrFunctionImpl(
|
||||
context.irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
|
||||
IrSimpleFunctionSymbolImpl(descriptor),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFunctionDescriptorWithContainerSource
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
@@ -99,7 +98,7 @@ private class CompanionObjectJvmStaticLowering(val context: JvmBackendContext) :
|
||||
val origin =
|
||||
if (isSynthetic) JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER_SYNTHETIC else JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER
|
||||
val descriptor = WrappedSimpleFunctionDescriptor(target.descriptor.annotations)
|
||||
return IrFunctionImpl(
|
||||
return context.irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
origin,
|
||||
IrSimpleFunctionSymbolImpl(descriptor),
|
||||
@@ -229,7 +228,7 @@ private class MakeCallsStatic(
|
||||
val newDescriptor = (descriptor as? DescriptorWithContainerSource)?.let {
|
||||
WrappedFunctionDescriptorWithContainerSource(it.containerSource)
|
||||
} ?: WrappedSimpleFunctionDescriptor(descriptor)
|
||||
return IrFunctionImpl(
|
||||
return context.irDeclarationFactory.createSimpleFunction(
|
||||
startOffset, endOffset, origin,
|
||||
IrSimpleFunctionSymbolImpl(newDescriptor),
|
||||
name,
|
||||
|
||||
@@ -45,7 +45,9 @@ internal val jvmStringConcatenationLowering = makeIrFilePhase(
|
||||
* is that this pass also handles JVM specific optimizations, such as calling stringPlus
|
||||
* for two arguments, and properly handles inline classes.
|
||||
*/
|
||||
private class JvmStringConcatenationLowering(val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
private class JvmStringConcatenationLowering(
|
||||
override val context: JvmBackendContext
|
||||
) : FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
override fun lower(irFile: IrFile) = irFile.transformChildrenVoid()
|
||||
|
||||
private val stringBuilder = context.ir.symbols.stringBuilder.owner
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.backend.jvm.ir.replaceThisByStaticReference
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addField
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrAnonymousInitializerImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
||||
@@ -94,7 +93,7 @@ private class MoveOrCopyCompanionObjectFieldsLowering(val context: JvmBackendCon
|
||||
with(oldInitializer) {
|
||||
val oldParent = parentAsClass
|
||||
val newSymbol = IrAnonymousInitializerSymbolImpl(newParent.symbol)
|
||||
IrAnonymousInitializerImpl(startOffset, endOffset, origin, newSymbol, isStatic = true).apply {
|
||||
context.irDeclarationFactory.createAnonymousInitializer(startOffset, endOffset, origin, newSymbol, isStatic = true).apply {
|
||||
parent = newParent
|
||||
body = this@with.body
|
||||
.replaceThisByStaticReference(context.declarationFactory, oldParent, oldParent.thisReceiver!!)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -7,15 +7,18 @@ package org.jetbrains.kotlin.backend.jvm.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.irCall
|
||||
import org.jetbrains.kotlin.ir.builders.irExprBody
|
||||
import org.jetbrains.kotlin.ir.builders.irGetField
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.util.constructors
|
||||
import org.jetbrains.kotlin.ir.util.isObject
|
||||
|
||||
internal val objectClassPhase = makeIrFilePhase(
|
||||
::ObjectClassLowering,
|
||||
@@ -23,7 +26,9 @@ internal val objectClassPhase = makeIrFilePhase(
|
||||
description = "Handle object classes"
|
||||
)
|
||||
|
||||
private class ObjectClassLowering(val context: JvmBackendContext) : IrElementTransformerVoidWithContext(), FileLoweringPass {
|
||||
private class ObjectClassLowering(
|
||||
override val context: JvmBackendContext
|
||||
) : IrElementTransformerVoidWithContext(context), FileLoweringPass {
|
||||
|
||||
private var pendingTransformations = mutableListOf<Function0<Unit>>()
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
|
||||
}
|
||||
var localPropertiesInClass = 0
|
||||
|
||||
irClass.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
|
||||
irClass.transformChildrenVoid(object : IrElementTransformerVoidWithContext(context) {
|
||||
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrStatement {
|
||||
localPropertyIndices[declaration.getter.symbol] = localPropertiesInClass++
|
||||
return super.visitLocalDelegatedProperty(declaration)
|
||||
|
||||
@@ -14,13 +14,13 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetField
|
||||
import org.jetbrains.kotlin.ir.expressions.IrSetField
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
||||
@@ -72,7 +72,7 @@ private class RenameFieldsLowering(val context: CommonBackendContext) : FileLowe
|
||||
}
|
||||
}
|
||||
|
||||
val renamer = FieldRenamer(newNames)
|
||||
val renamer = FieldRenamer(newNames, context.irDeclarationFactory)
|
||||
irFile.transform(renamer, null)
|
||||
|
||||
irFile.transform(FieldAccessTransformer(renamer.newSymbols), null)
|
||||
@@ -94,7 +94,10 @@ private class FieldNameCollector : IrElementVisitorVoid {
|
||||
}
|
||||
}
|
||||
|
||||
private class FieldRenamer(private val newNames: Map<IrField, Name>) : IrElementTransformerVoid() {
|
||||
private class FieldRenamer(
|
||||
private val newNames: Map<IrField, Name>,
|
||||
private val irDeclarationFactory: IrDeclarationFactory
|
||||
) : IrElementTransformerVoid() {
|
||||
val newSymbols = mutableMapOf<IrField, IrFieldSymbol>()
|
||||
|
||||
override fun visitField(declaration: IrField): IrStatement {
|
||||
@@ -102,7 +105,7 @@ private class FieldRenamer(private val newNames: Map<IrField, Name>) : IrElement
|
||||
|
||||
val descriptor = WrappedFieldDescriptor()
|
||||
val symbol = IrFieldSymbolImpl(descriptor)
|
||||
return IrFieldImpl(
|
||||
return irDeclarationFactory.createField(
|
||||
declaration.startOffset, declaration.endOffset, declaration.origin, symbol, newName,
|
||||
declaration.type, declaration.visibility, declaration.isFinal, declaration.isExternal, declaration.isStatic,
|
||||
isFakeOverride = declaration.origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
|
||||
@@ -47,7 +47,7 @@ internal val singleAbstractMethodPhase = makeIrFilePhase(
|
||||
description = "Replace SAM conversions with instances of interface-implementing classes"
|
||||
)
|
||||
|
||||
class SingleAbstractMethodLowering(val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
class SingleAbstractMethodLowering(context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
// SAM wrappers are cached, either in the file class (if it exists), or in a top-level enclosing class.
|
||||
// In the latter case, the names of SAM wrappers depend on the order of classes in the file. For example:
|
||||
//
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.backend.jvm.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.*
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.common.pop
|
||||
import org.jetbrains.kotlin.backend.common.push
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetObjectValue
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
@@ -21,7 +27,9 @@ internal val singletonReferencesPhase = makeIrFilePhase(
|
||||
description = "Handle singleton references"
|
||||
)
|
||||
|
||||
private class SingletonReferencesLowering(val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
private class SingletonReferencesLowering(
|
||||
override val context: JvmBackendContext
|
||||
) : FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
private val constructingEnums = arrayListOf<IrDeclarationParent>()
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildConstructor
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildFun
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
@@ -38,7 +37,9 @@ import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTransformerVoidWithContext(), FileLoweringPass {
|
||||
internal class SyntheticAccessorLowering(
|
||||
override val context: JvmBackendContext
|
||||
) : IrElementTransformerVoidWithContext(context), FileLoweringPass {
|
||||
private val pendingTransformations = mutableListOf<Function0<Unit>>()
|
||||
private val inlineLambdaToCallSite = mutableMapOf<IrFunction, IrDeclaration?>()
|
||||
|
||||
@@ -133,7 +134,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
|
||||
// attaching the metadata directly to the bridge. We also have to move all annotations
|
||||
// to the bridge method. Parameter annotations are already moved by the copyTo method.
|
||||
accessor.metadata = declaration.metadata
|
||||
declaration.safeAs<IrConstructorImpl>()?.metadata = null
|
||||
declaration.safeAs<IrConstructor>()?.metadata = null
|
||||
accessor.annotations += declaration.annotations
|
||||
declaration.annotations.clear()
|
||||
declaration.valueParameters.forEach { it.annotations.clear() }
|
||||
@@ -148,7 +149,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
|
||||
classes.lastOrNull { parent is IrClass && it.isSubclassOf(parent) } ?: classes.last()
|
||||
} else parent
|
||||
|
||||
private fun IrConstructor.makeConstructorAccessor(): IrConstructorImpl {
|
||||
private fun IrConstructor.makeConstructorAccessor(): IrConstructor {
|
||||
val source = this
|
||||
|
||||
return buildConstructor {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isJvmInterface
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
@@ -21,9 +20,6 @@ import org.jetbrains.kotlin.ir.builders.irReturn
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
||||
@@ -35,9 +31,7 @@ import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.isClass
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
|
||||
internal val toArrayPhase = makeIrFilePhase(
|
||||
@@ -60,7 +54,7 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
if (genericToArray == null) {
|
||||
if (isDirectCollectionSubClass) {
|
||||
val typeParameterDescriptor = WrappedTypeParameterDescriptor()
|
||||
val typeParameter = IrTypeParameterImpl(
|
||||
val typeParameter = context.irDeclarationFactory.createTypeParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.TO_ARRAY,
|
||||
IrTypeParameterSymbolImpl(typeParameterDescriptor),
|
||||
@@ -75,7 +69,7 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
|
||||
val substitutedArrayType = irBuiltIns.arrayClass.typeWith(typeParameter.defaultType)
|
||||
val functionDescriptor = WrappedSimpleFunctionDescriptor()
|
||||
val irFunction = IrFunctionImpl(
|
||||
val irFunction = context.irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.TO_ARRAY,
|
||||
IrSimpleFunctionSymbolImpl(functionDescriptor),
|
||||
@@ -98,7 +92,7 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
irFunction.typeParameters.add(typeParameter)
|
||||
|
||||
val dispatchReceiverParameterDescriptor = WrappedValueParameterDescriptor()
|
||||
irFunction.dispatchReceiverParameter = IrValueParameterImpl(
|
||||
irFunction.dispatchReceiverParameter = context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.TO_ARRAY,
|
||||
IrValueParameterSymbolImpl(dispatchReceiverParameterDescriptor),
|
||||
@@ -113,7 +107,7 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
}
|
||||
val valueParameterDescriptor = WrappedValueParameterDescriptor()
|
||||
irFunction.valueParameters.add(
|
||||
IrValueParameterImpl(
|
||||
context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.TO_ARRAY,
|
||||
IrValueParameterSymbolImpl(valueParameterDescriptor),
|
||||
@@ -143,13 +137,13 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
irClass.declarations.add(irFunction)
|
||||
}
|
||||
} else {
|
||||
(genericToArray as IrFunctionImpl).visibility = Visibilities.PUBLIC
|
||||
genericToArray.visibility = Visibilities.PUBLIC
|
||||
}
|
||||
|
||||
if (nonGenericToArray == null) {
|
||||
if (isDirectCollectionSubClass) {
|
||||
val functionDescriptor = WrappedSimpleFunctionDescriptor()
|
||||
val irFunction = IrFunctionImpl(
|
||||
val irFunction = context.irDeclarationFactory.createSimpleFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.TO_ARRAY,
|
||||
IrSimpleFunctionSymbolImpl(functionDescriptor),
|
||||
@@ -169,7 +163,7 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
irFunction.parent = irClass
|
||||
|
||||
val dispatchReceiverParameterDescriptor = WrappedValueParameterDescriptor()
|
||||
irFunction.dispatchReceiverParameter = IrValueParameterImpl(
|
||||
irFunction.dispatchReceiverParameter = context.irDeclarationFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
JvmLoweredDeclarationOrigin.TO_ARRAY,
|
||||
IrValueParameterSymbolImpl(dispatchReceiverParameterDescriptor),
|
||||
@@ -196,7 +190,7 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
irClass.declarations.add(irFunction)
|
||||
}
|
||||
} else {
|
||||
(nonGenericToArray as IrFunctionImpl).visibility = Visibilities.PUBLIC
|
||||
nonGenericToArray.visibility = Visibilities.PUBLIC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ val varargPhase = makeIrFilePhase(
|
||||
prerequisite = setOf(polymorphicSignaturePhase)
|
||||
)
|
||||
|
||||
private class VarargLowering(val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
|
||||
private class VarargLowering(override val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext(context) {
|
||||
override fun lower(irFile: IrFile) = irFile.transformChildrenVoid()
|
||||
|
||||
// Ignore annotations
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildFun
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildFunWithDescriptorForInlining
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
||||
@@ -189,7 +188,7 @@ class MemoizedInlineClassReplacements {
|
||||
return IrReplacementFunction(replacement, parameterMap)
|
||||
}
|
||||
|
||||
private fun buildReplacement(function: IrFunction, body: IrFunctionImpl.() -> Unit) =
|
||||
private fun buildReplacement(function: IrFunction, body: IrSimpleFunction.() -> Unit) =
|
||||
buildFunWithDescriptorForInlining(function.descriptor) {
|
||||
updateFrom(function)
|
||||
if (function.origin == IrDeclarationOrigin.GENERATED_INLINE_CLASS_MEMBER) {
|
||||
|
||||
@@ -16,12 +16,13 @@ import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsSharedVariablesManager
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.createExternalPackageFragment
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.UniqId
|
||||
@@ -31,6 +32,7 @@ class WasmBackendContext(
|
||||
val module: ModuleDescriptor,
|
||||
override val irBuiltIns: IrBuiltIns,
|
||||
symbolTable: SymbolTable,
|
||||
override val irDeclarationFactory: IrDeclarationFactory,
|
||||
irModuleFragment: IrModuleFragment,
|
||||
val additionalExportedDeclarations: Set<FqName>,
|
||||
override val configuration: CompilerConfiguration
|
||||
@@ -43,24 +45,24 @@ class WasmBackendContext(
|
||||
|
||||
// Place to store declarations excluded from code generation
|
||||
val excludedDeclarations: IrPackageFragment by lazy {
|
||||
IrExternalPackageFragmentImpl(
|
||||
irDeclarationFactory.createExternalPackageFragment(
|
||||
DescriptorlessExternalPackageFragmentSymbol(),
|
||||
FqName("kotlin")
|
||||
)
|
||||
}
|
||||
|
||||
override val declarationFactory = JsDeclarationFactory()
|
||||
override val declarationFactory = JsDeclarationFactory(irDeclarationFactory)
|
||||
|
||||
val objectToGetInstanceFunction = mutableMapOf<IrClassSymbol, IrSimpleFunction>()
|
||||
override val internalPackageFqn = FqName("kotlin.wasm")
|
||||
|
||||
private val internalPackageFragment = IrExternalPackageFragmentImpl(
|
||||
private val internalPackageFragment = irDeclarationFactory.createExternalPackageFragment(
|
||||
IrExternalPackageFragmentSymbolImpl(
|
||||
EmptyPackageFragmentDescriptor(builtIns.builtInsModule, FqName("kotlin.wasm.internal"))
|
||||
)
|
||||
)
|
||||
|
||||
override val sharedVariablesManager = JsSharedVariablesManager(irBuiltIns, internalPackageFragment)
|
||||
override val sharedVariablesManager = JsSharedVariablesManager(irBuiltIns, irDeclarationFactory, internalPackageFragment)
|
||||
|
||||
val wasmSymbols: WasmSymbols = WasmSymbols(this@WasmBackendContext, symbolTable)
|
||||
override val ir = object : Ir<WasmBackendContext>(this, irModuleFragment) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel
|
||||
import org.jetbrains.kotlin.backend.wasm.codegen.IrModuleToWasm
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.ir.backend.js.loadIr
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.generateTypicalIrProviderList
|
||||
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
|
||||
@@ -26,15 +27,16 @@ fun compileWasm(
|
||||
files: List<KtFile>,
|
||||
configuration: CompilerConfiguration,
|
||||
phaseConfig: PhaseConfig,
|
||||
irDeclarationFactory: IrDeclarationFactory,
|
||||
allDependencies: KotlinLibraryResolveResult,
|
||||
friendDependencies: List<KotlinLibrary>,
|
||||
exportedDeclarations: Set<FqName> = emptySet()
|
||||
): WasmCompilerResult {
|
||||
val (moduleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
||||
loadIr(project, files, configuration, allDependencies, friendDependencies)
|
||||
loadIr(project, files, configuration, irDeclarationFactory, allDependencies, friendDependencies)
|
||||
|
||||
val moduleDescriptor = moduleFragment.descriptor
|
||||
val context = WasmBackendContext(moduleDescriptor, irBuiltIns, symbolTable, moduleFragment, exportedDeclarations, configuration)
|
||||
val context = WasmBackendContext(moduleDescriptor, irBuiltIns, symbolTable, irDeclarationFactory, moduleFragment, exportedDeclarations, configuration)
|
||||
|
||||
// Load declarations referenced during `context` initialization
|
||||
dependencyModules.forEach {
|
||||
|
||||
@@ -8,6 +8,7 @@ dependencies {
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:backend-common"))
|
||||
compile(project(":compiler:ir.tree"))
|
||||
implementation(project(":compiler:ir.tree.impl"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.psi2ir
|
||||
@@ -21,6 +10,8 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.factories.DefaultIrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
@@ -49,7 +40,11 @@ class Psi2IrTranslator(
|
||||
bindingContext: BindingContext,
|
||||
generatorExtensions: GeneratorExtensions
|
||||
): IrModuleFragment {
|
||||
val context = createGeneratorContext(moduleDescriptor, bindingContext, extensions = generatorExtensions)
|
||||
val context = createGeneratorContext(
|
||||
moduleDescriptor, bindingContext,
|
||||
extensions = generatorExtensions,
|
||||
irDeclarationFactory = DefaultIrDeclarationFactory() ///
|
||||
)
|
||||
val irProviders = generateTypicalIrProviderList(
|
||||
moduleDescriptor, context.irBuiltIns, context.symbolTable, extensions = generatorExtensions
|
||||
)
|
||||
@@ -59,10 +54,12 @@ class Psi2IrTranslator(
|
||||
fun createGeneratorContext(
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
bindingContext: BindingContext,
|
||||
symbolTable: SymbolTable = SymbolTable(mangler),
|
||||
irDeclarationFactory: IrDeclarationFactory,
|
||||
symbolTable: SymbolTable = SymbolTable(irDeclarationFactory, mangler),
|
||||
extensions: GeneratorExtensions = GeneratorExtensions()
|
||||
): GeneratorContext =
|
||||
GeneratorContext(configuration, moduleDescriptor, bindingContext, languageVersionSettings, symbolTable, extensions)
|
||||
GeneratorContext(configuration, moduleDescriptor, bindingContext,
|
||||
languageVersionSettings, symbolTable, irDeclarationFactory, extensions)
|
||||
|
||||
fun generateModuleFragment(
|
||||
context: GeneratorContext,
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.psi2ir.generators
|
||||
@@ -48,7 +37,7 @@ class BodyGenerator(
|
||||
private val typeTranslator = context.typeTranslator
|
||||
private fun KotlinType.toIrType() = typeTranslator.translateType(this)
|
||||
|
||||
override val scope = Scope(scopeOwnerSymbol)
|
||||
override val scope = Scope(scopeOwnerSymbol, context.irDeclarationFactory)
|
||||
private val loopTable = HashMap<KtLoopExpression, IrLoop>()
|
||||
|
||||
fun generateFunctionBody(ktBody: KtExpression): IrBody {
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.psi2ir.generators
|
||||
@@ -69,7 +58,7 @@ class DataClassMembersGenerator(
|
||||
startOffset: Int = UNDEFINED_OFFSET,
|
||||
endOffset: Int = UNDEFINED_OFFSET,
|
||||
val irFunction: IrFunction = declareSimpleFunction(startOffset, endOffset, origin, function)
|
||||
) : IrBlockBodyBuilder(context, Scope(irFunction.symbol), startOffset, endOffset) {
|
||||
) : IrBlockBodyBuilder(context, Scope(irFunction.symbol, context.irDeclarationFactory), startOffset, endOffset) {
|
||||
inline fun addToClass(builder: MemberFunctionBuilder.(IrFunction) -> Unit): IrFunction {
|
||||
irFunction.buildWithScope {
|
||||
builder(irFunction)
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrErrorDeclarationImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeAliasImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.factories.createTypeAlias
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.withScope
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -51,7 +42,7 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator {
|
||||
is KtScript ->
|
||||
ScriptGenerator(this).generateScriptDeclaration(ktDeclaration)
|
||||
else ->
|
||||
IrErrorDeclarationImpl(
|
||||
context.irDeclarationFactory.createErrorDeclaration(
|
||||
ktDeclaration.startOffsetSkippingComments, ktDeclaration.endOffset,
|
||||
getOrFail(BindingContext.DECLARATION_TO_DESCRIPTOR, ktDeclaration)
|
||||
)
|
||||
@@ -82,7 +73,7 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator {
|
||||
private fun generateTypeAliasDeclaration(ktTypeAlias: KtTypeAlias): IrTypeAlias {
|
||||
val typeAliasDescriptor = getOrFail(BindingContext.TYPE_ALIAS, ktTypeAlias)
|
||||
val irTypeAlias = context.symbolTable.declareTypeAlias(typeAliasDescriptor) { symbol ->
|
||||
IrTypeAliasImpl.fromSymbolDescriptor(
|
||||
context.irDeclarationFactory.createTypeAlias(
|
||||
ktTypeAlias.startOffsetSkippingComments, ktTypeAlias.endOffset,
|
||||
symbol,
|
||||
typeAliasDescriptor.expandedType.toIrType(),
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.psi2ir.generators
|
||||
@@ -22,7 +11,6 @@ import org.jetbrains.kotlin.ir.builders.irBlockBody
|
||||
import org.jetbrains.kotlin.ir.builders.irGet
|
||||
import org.jetbrains.kotlin.ir.builders.irReturn
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrLocalDelegatedPropertyDelegateDescriptor
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrLocalDelegatedPropertyDelegateDescriptorImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor
|
||||
@@ -30,6 +18,7 @@ import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptorImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||
import org.jetbrains.kotlin.ir.factories.createField
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||
@@ -130,7 +119,7 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D
|
||||
return context.symbolTable.declareField(
|
||||
startOffset, endOffset, origin, delegateDescriptor, type
|
||||
) {
|
||||
IrFieldImpl(startOffset, endOffset, origin, it, type).apply {
|
||||
context.irDeclarationFactory.createField(startOffset, endOffset, origin, it, type).apply {
|
||||
metadata = MetadataSource.Property(propertyDescriptor)
|
||||
}
|
||||
}.also { irDelegate ->
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.psi2ir.generators
|
||||
@@ -24,6 +13,7 @@ import org.jetbrains.kotlin.descriptors.NotFoundClasses
|
||||
import org.jetbrains.kotlin.ir.builders.IrGeneratorContext
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
||||
import org.jetbrains.kotlin.ir.factories.IrDeclarationFactory
|
||||
import org.jetbrains.kotlin.ir.util.ConstantValueGenerator
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||
@@ -38,6 +28,7 @@ class GeneratorContext(
|
||||
val bindingContext: BindingContext,
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
val symbolTable: SymbolTable,
|
||||
val irDeclarationFactory: IrDeclarationFactory,
|
||||
val extensions: GeneratorExtensions
|
||||
) : IrGeneratorContext() {
|
||||
|
||||
@@ -50,7 +41,7 @@ class GeneratorContext(
|
||||
constantValueGenerator.typeTranslator = typeTranslator
|
||||
}
|
||||
|
||||
override val irBuiltIns: IrBuiltIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
override val irBuiltIns: IrBuiltIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, irDeclarationFactory, symbolTable)
|
||||
|
||||
val sourceManager = PsiSourceManager()
|
||||
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.psi2ir.generators
|
||||
@@ -20,8 +9,7 @@ import org.jetbrains.kotlin.backend.common.CodegenUtil
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.factories.createFile
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -38,7 +26,7 @@ class ModuleGenerator(override val context: GeneratorContext) : Generator {
|
||||
}
|
||||
|
||||
fun generateModuleFragmentWithoutDependencies(ktFiles: Collection<KtFile>): IrModuleFragment =
|
||||
IrModuleFragmentImpl(context.moduleDescriptor, context.irBuiltIns).also { irModule ->
|
||||
context.irDeclarationFactory.createModuleFragment(context.moduleDescriptor, context.irBuiltIns).also { irModule ->
|
||||
irModule.files.addAll(generateFiles(ktFiles))
|
||||
}
|
||||
|
||||
@@ -66,7 +54,7 @@ class ModuleGenerator(override val context: GeneratorContext) : Generator {
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateSingleFile(irDeclarationGenerator: DeclarationGenerator, ktFile: KtFile): IrFileImpl {
|
||||
private fun generateSingleFile(irDeclarationGenerator: DeclarationGenerator, ktFile: KtFile): IrFile {
|
||||
val irFile = createEmptyIrFile(ktFile)
|
||||
|
||||
for (ktAnnotationEntry in ktFile.annotationEntries) {
|
||||
@@ -81,10 +69,10 @@ class ModuleGenerator(override val context: GeneratorContext) : Generator {
|
||||
return irFile
|
||||
}
|
||||
|
||||
private fun createEmptyIrFile(ktFile: KtFile): IrFileImpl {
|
||||
private fun createEmptyIrFile(ktFile: KtFile): IrFile {
|
||||
val fileEntry = context.sourceManager.getOrCreateFileEntry(ktFile)
|
||||
val packageFragmentDescriptor = context.moduleDescriptor.findPackageFragmentForFile(ktFile)!!
|
||||
val irFile = IrFileImpl(fileEntry, packageFragmentDescriptor).apply {
|
||||
val irFile = context.irDeclarationFactory.createFile(fileEntry, packageFragmentDescriptor).apply {
|
||||
metadata = MetadataSource.File(CodegenUtil.getMemberDescriptorsToGenerate(ktFile, context.bindingContext))
|
||||
}
|
||||
context.sourceManager.putFileEntry(irFile, fileEntry)
|
||||
|
||||
18
compiler/ir/ir.tree.impl/build.gradle.kts
Normal file
18
compiler/ir/ir.tree.impl/build.gradle.kts
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// compile(project(":compiler:util"))
|
||||
// compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:ir.tree"))
|
||||
// compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.impl
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.impl
|
||||
@@ -27,7 +16,6 @@ import org.jetbrains.kotlin.ir.util.transform
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class IrClassImpl(
|
||||
@@ -49,26 +37,6 @@ class IrClassImpl(
|
||||
IrDeclarationBase(startOffset, endOffset, origin),
|
||||
IrClass {
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrClassSymbol,
|
||||
modality: Modality = symbol.descriptor.modality
|
||||
) :
|
||||
this(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
symbol.descriptor.name, symbol.descriptor.kind,
|
||||
symbol.descriptor.visibility,
|
||||
modality = modality,
|
||||
isCompanion = symbol.descriptor.isCompanionObject,
|
||||
isInner = symbol.descriptor.isInner,
|
||||
isData = symbol.descriptor.isData,
|
||||
isExternal = symbol.descriptor.isEffectivelyExternal(),
|
||||
isInline = symbol.descriptor.isInline,
|
||||
isExpect = symbol.descriptor.isExpect
|
||||
)
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class IrConstructorImpl(
|
||||
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
|
||||
) :
|
||||
IrFunctionBase(
|
||||
startOffset, endOffset, origin, name,
|
||||
visibility,
|
||||
isInline, isExternal, isExpect,
|
||||
returnType
|
||||
),
|
||||
IrConstructor {
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitConstructor(this, data)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user