[IR] Fix to make K/N work

This commit is contained in:
Roman Artemev
2020-04-29 10:43:16 +03:00
committed by romanart
parent aac4649845
commit 8335ce8665
4 changed files with 6 additions and 6 deletions
@@ -48,7 +48,7 @@ abstract class Ir<out T : CommonBackendContext>(val context: T, val irModule: Ir
/**
* Symbols for builtins that are available without any context and are not specific to any backend
*/
open class BuiltinSymbolsBase(protected val irBuiltIns: IrBuiltIns, private val builtIns: KotlinBuiltIns, private val symbolTable: ReferenceSymbolTable) {
open class BuiltinSymbolsBase(protected val irBuiltIns: IrBuiltIns, protected val builtIns: KotlinBuiltIns, private val symbolTable: ReferenceSymbolTable) {
protected fun builtInsPackage(vararg packageNameSegments: String) =
builtIns.builtInsModule.getPackage(FqName.fromSegments(listOf(*packageNameSegments))).memberScope
@@ -231,8 +231,8 @@ open class BuiltinSymbolsBase(protected val irBuiltIns: IrBuiltIns, private val
// Some symbols below are used in kotlin-native, so they can't be private
@Suppress("MemberVisibilityCanBePrivate", "PropertyName")
abstract class Symbols<out T : CommonBackendContext>(val context: T, symbolTable: SymbolTable) :
BuiltinSymbolsBase(context.irBuiltIns, context.builtIns, symbolTable) {
abstract class Symbols<out T : CommonBackendContext>(val context: T, irBuiltIns: IrBuiltIns, symbolTable: SymbolTable) :
BuiltinSymbolsBase(irBuiltIns, context.builtIns, symbolTable) {
abstract val ThrowNullPointerException: IrFunctionSymbol
abstract val ThrowNoWhenBranchMatchedException: IrFunctionSymbol
abstract val ThrowTypeCastException: IrFunctionSymbol
@@ -181,7 +181,7 @@ class JsIrBackendContext(
fun getOperatorByName(name: Name, type: IrSimpleType) = operatorMap[name]?.get(type.classifier)
override val ir = object : Ir<JsIrBackendContext>(this, irModuleFragment) {
override val symbols = object : Symbols<JsIrBackendContext>(this@JsIrBackendContext, symbolTable) {
override val symbols = object : Symbols<JsIrBackendContext>(this@JsIrBackendContext, irBuiltIns, symbolTable) {
override val ThrowNullPointerException =
symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_NPE"))).single())
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.types.Variance
class JvmSymbols(
context: JvmBackendContext,
private val symbolTable: SymbolTable
) : Symbols<JvmBackendContext>(context, symbolTable) {
) : Symbols<JvmBackendContext>(context, context.irBuiltIns, symbolTable) {
private val storageManager = LockBasedStorageManager(this::class.java.simpleName)
private val kotlinPackage: IrPackageFragment = createPackage(FqName("kotlin"))
private val kotlinCoroutinesPackage: IrPackageFragment = createPackage(FqName("kotlin.coroutines"))
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.types.SimpleType
class WasmSymbols(
context: WasmBackendContext,
private val symbolTable: SymbolTable
) : Symbols<WasmBackendContext>(context, symbolTable) {
) : Symbols<WasmBackendContext>(context, context.irBuiltIns, symbolTable) {
override val ThrowNullPointerException
get() = TODO()