All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.fir.backend.Fir2IrCommonMemberStorage.kt Maven / Gradle / Ivy

There is a newer version: 2.1.20-Beta1
Show newest version
/*
 * Copyright 2010-2023 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.fir.backend

import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.signaturer.FirBasedSignatureComposer
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.util.IdSignatureComposer
import org.jetbrains.kotlin.ir.util.SymbolTable
import java.util.concurrent.ConcurrentHashMap

/**
 * This storage contains the shared state of FIR2IR.
 *
 * State is shared between the conversions of different modules in the same platform compilation.
 *
 * See `/docs/fir/k2_kmp.md`
 */
class Fir2IrCommonMemberStorage(
    signatureComposer: IdSignatureComposer,
    firMangler: FirMangler
) {
    val firSignatureComposer = FirBasedSignatureComposer(firMangler)

    val symbolTable = SymbolTable(signaturer = signatureComposer, irFactory = IrFactoryImpl)

    val classCache: MutableMap = mutableMapOf()

    val typeParameterCache: MutableMap = mutableMapOf()

    val enumEntryCache: MutableMap = mutableMapOf()

    val localClassCache: MutableMap = mutableMapOf()

    val functionCache: ConcurrentHashMap = ConcurrentHashMap()

    val constructorCache: ConcurrentHashMap = ConcurrentHashMap()

    val fieldCache: ConcurrentHashMap = ConcurrentHashMap()

    val propertyCache: ConcurrentHashMap = ConcurrentHashMap()
    val getterForPropertyCache: ConcurrentHashMap = ConcurrentHashMap()
    val setterForPropertyCache: ConcurrentHashMap = ConcurrentHashMap()
    val backingFieldForPropertyCache: ConcurrentHashMap = ConcurrentHashMap()
    val propertyForBackingFieldCache: ConcurrentHashMap = ConcurrentHashMap()
    val delegateVariableForPropertyCache: ConcurrentHashMap = ConcurrentHashMap()

    val fakeOverridesInClass: MutableMap> = mutableMapOf()

    val irForFirSessionDependantDeclarationMap: MutableMap = mutableMapOf()

    fun registerFirProvider(moduleData: FirModuleData, firProvider: FirProviderWithGeneratedFiles) {
        require(moduleData !in _previousFirProviders) { "FirProvider for $moduleData already registered"}
        _previousFirProviders[moduleData] = firProvider
    }

    val previousFirProviders: Map
        get() = _previousFirProviders

    private val _previousFirProviders: MutableMap = mutableMapOf()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy