[FIR2IR] Implement JvmBackendClassResolver for boxing optimizer
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2018 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.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":core:descriptors"))
|
||||
compileOnly(project(":compiler:fir:cones"))
|
||||
compileOnly(project(":compiler:fir:resolve"))
|
||||
compileOnly(project(":compiler:fir:tree"))
|
||||
compileOnly(project(":compiler:fir:fir2ir"))
|
||||
compileOnly(project(":compiler:ir.tree"))
|
||||
compileOnly(project(":compiler:ir.psi2ir"))
|
||||
compileOnly(project(":compiler:ir.backend.common"))
|
||||
compileOnly(project(":compiler:backend"))
|
||||
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "asm-all", rootProject = rootProject) }
|
||||
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.backend.jvm
|
||||
|
||||
import org.jetbrains.kotlin.codegen.JvmBackendClassResolver
|
||||
import org.jetbrains.kotlin.codegen.classId
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
class FirJvmBackendClassResolver(val components: Fir2IrComponents) : JvmBackendClassResolver {
|
||||
override fun resolveToClassDescriptors(type: Type): List<ClassDescriptor> {
|
||||
if (type.sort != Type.OBJECT) return emptyList()
|
||||
|
||||
val symbol = components.session.firSymbolProvider.getClassLikeSymbolByFqName(type.classId) ?: return emptyList()
|
||||
require(symbol is FirClassSymbol<*>)
|
||||
return listOf(components.classifierStorage.getIrClassSymbol(symbol).descriptor)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -204,7 +204,7 @@ class Fir2IrConverter(
|
||||
}
|
||||
|
||||
externalDependenciesGenerator.generateUnboundSymbolsAsDependencies()
|
||||
return Fir2IrResult(irModuleFragment, symbolTable, sourceManager)
|
||||
return Fir2IrResult(irModuleFragment, symbolTable, sourceManager, components)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,4 +9,4 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.psi2ir.PsiSourceManager
|
||||
|
||||
data class Fir2IrResult(val irModuleFragment: IrModuleFragment, val symbolTable: SymbolTable, val sourceManager: PsiSourceManager)
|
||||
data class Fir2IrResult(val irModuleFragment: IrModuleFragment, val symbolTable: SymbolTable, val sourceManager: PsiSourceManager, val components: Fir2IrComponents)
|
||||
Reference in New Issue
Block a user