[IR] Fix to make K/N work
This commit is contained in:
@@ -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
|
* 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) =
|
protected fun builtInsPackage(vararg packageNameSegments: String) =
|
||||||
builtIns.builtInsModule.getPackage(FqName.fromSegments(listOf(*packageNameSegments))).memberScope
|
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
|
// Some symbols below are used in kotlin-native, so they can't be private
|
||||||
@Suppress("MemberVisibilityCanBePrivate", "PropertyName")
|
@Suppress("MemberVisibilityCanBePrivate", "PropertyName")
|
||||||
abstract class Symbols<out T : CommonBackendContext>(val context: T, symbolTable: SymbolTable) :
|
abstract class Symbols<out T : CommonBackendContext>(val context: T, irBuiltIns: IrBuiltIns, symbolTable: SymbolTable) :
|
||||||
BuiltinSymbolsBase(context.irBuiltIns, context.builtIns, symbolTable) {
|
BuiltinSymbolsBase(irBuiltIns, context.builtIns, symbolTable) {
|
||||||
abstract val ThrowNullPointerException: IrFunctionSymbol
|
abstract val ThrowNullPointerException: IrFunctionSymbol
|
||||||
abstract val ThrowNoWhenBranchMatchedException: IrFunctionSymbol
|
abstract val ThrowNoWhenBranchMatchedException: IrFunctionSymbol
|
||||||
abstract val ThrowTypeCastException: IrFunctionSymbol
|
abstract val ThrowTypeCastException: IrFunctionSymbol
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class JsIrBackendContext(
|
|||||||
fun getOperatorByName(name: Name, type: IrSimpleType) = operatorMap[name]?.get(type.classifier)
|
fun getOperatorByName(name: Name, type: IrSimpleType) = operatorMap[name]?.get(type.classifier)
|
||||||
|
|
||||||
override val ir = object : Ir<JsIrBackendContext>(this, irModuleFragment) {
|
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 =
|
override val ThrowNullPointerException =
|
||||||
symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_NPE"))).single())
|
symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_NPE"))).single())
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.types.Variance
|
|||||||
class JvmSymbols(
|
class JvmSymbols(
|
||||||
context: JvmBackendContext,
|
context: JvmBackendContext,
|
||||||
private val symbolTable: SymbolTable
|
private val symbolTable: SymbolTable
|
||||||
) : Symbols<JvmBackendContext>(context, symbolTable) {
|
) : Symbols<JvmBackendContext>(context, context.irBuiltIns, symbolTable) {
|
||||||
private val storageManager = LockBasedStorageManager(this::class.java.simpleName)
|
private val storageManager = LockBasedStorageManager(this::class.java.simpleName)
|
||||||
private val kotlinPackage: IrPackageFragment = createPackage(FqName("kotlin"))
|
private val kotlinPackage: IrPackageFragment = createPackage(FqName("kotlin"))
|
||||||
private val kotlinCoroutinesPackage: IrPackageFragment = createPackage(FqName("kotlin.coroutines"))
|
private val kotlinCoroutinesPackage: IrPackageFragment = createPackage(FqName("kotlin.coroutines"))
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.types.SimpleType
|
|||||||
class WasmSymbols(
|
class WasmSymbols(
|
||||||
context: WasmBackendContext,
|
context: WasmBackendContext,
|
||||||
private val symbolTable: SymbolTable
|
private val symbolTable: SymbolTable
|
||||||
) : Symbols<WasmBackendContext>(context, symbolTable) {
|
) : Symbols<WasmBackendContext>(context, context.irBuiltIns, symbolTable) {
|
||||||
|
|
||||||
override val ThrowNullPointerException
|
override val ThrowNullPointerException
|
||||||
get() = TODO()
|
get() = TODO()
|
||||||
|
|||||||
Reference in New Issue
Block a user