IR: remove SourceManager, make PsiSourceManager a singleton

This commit is contained in:
Alexander Udalov
2021-02-21 20:39:05 +01:00
parent 8ff0b1e243
commit f332192de8
33 changed files with 135 additions and 212 deletions
@@ -10,7 +10,7 @@ import kotlinx.cinterop.memScoped
import kotlinx.cinterop.reinterpret
import llvm.*
import org.jetbrains.kotlin.backend.konan.*
import org.jetbrains.kotlin.ir.SourceManager.FileEntry
import org.jetbrains.kotlin.ir.IrFileEntry
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.types.IrType
@@ -95,7 +95,7 @@ internal class DebugInfo internal constructor(override val context: Context):Con
* File entry starts offsets from zero while dwarf number lines/column starting from 1.
*/
private val NO_SOURCE_FILE = "no source file"
private fun FileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int {
private fun IrFileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int {
assert(offset != UNDEFINED_OFFSET)
// Part "name.isEmpty() || name == NO_SOURCE_FILE" is an awful hack, @minamoto, please fix properly.
if (offset == SYNTHETIC_OFFSET || name.isEmpty() || name == NO_SOURCE_FILE) return 1
@@ -105,9 +105,9 @@ private fun FileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int {
return result
}
internal fun FileEntry.line(offset: Int) = location(offset, this::getLineNumber)
internal fun IrFileEntry.line(offset: Int) = location(offset, this::getLineNumber)
internal fun FileEntry.column(offset: Int) = location(offset, this::getColumnNumber)
internal fun IrFileEntry.column(offset: Int) = location(offset, this::getColumnNumber)
internal data class FileAndFolder(val file: String, val folder: String) {
companion object {
@@ -10,13 +10,12 @@ import org.jetbrains.kotlin.backend.konan.KonanBackendContext
import org.jetbrains.kotlin.backend.konan.KonanCompilationException
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
import org.jetbrains.kotlin.backend.konan.ir.buildSimpleAnnotation
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.SourceManager
import org.jetbrains.kotlin.ir.IrFileEntry
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.*
@@ -88,7 +87,7 @@ internal fun IrFile.addTopLevelInitializer(expression: IrExpression, context: Ko
addChild(irField)
}
fun IrModuleFragment.addFile(fileEntry: SourceManager.FileEntry, packageFqName: FqName): IrFile {
fun IrModuleFragment.addFile(fileEntry: IrFileEntry, packageFqName: FqName): IrFile {
val packageFragmentDescriptor = object : PackageFragmentDescriptorImpl(this.descriptor, packageFqName) {
override fun getMemberScope(): MemberScope = MemberScope.Empty
}