Remove CommonBackendContext.getInternalFunctions
Similarly to getInternalClass, move to subclasses
This commit is contained in:
-4
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.backend.common
|
|||||||
import org.jetbrains.kotlin.backend.common.ir.Ir
|
import org.jetbrains.kotlin.backend.common.ir.Ir
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -23,9 +22,6 @@ interface CommonBackendContext : BackendContext, LoggingContext {
|
|||||||
|
|
||||||
fun getClass(fqName: FqName): ClassDescriptor
|
fun getClass(fqName: FqName): ClassDescriptor
|
||||||
|
|
||||||
//TODO move to builtins
|
|
||||||
fun getInternalFunctions(name: String): List<FunctionDescriptor>
|
|
||||||
|
|
||||||
fun report(element: IrElement?, irFile: IrFile?, message: String, isError: Boolean)
|
fun report(element: IrElement?, irFile: IrFile?, message: String, isError: Boolean)
|
||||||
|
|
||||||
val configuration: CompilerConfiguration
|
val configuration: CompilerConfiguration
|
||||||
|
|||||||
@@ -158,10 +158,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
|||||||
|
|
||||||
val jsCoroutineContext = context.symbolTable.referenceSimpleFunction(context.coroutineContextProperty.getter!!)
|
val jsCoroutineContext = context.symbolTable.referenceSimpleFunction(context.coroutineContextProperty.getter!!)
|
||||||
|
|
||||||
val jsGetContinuation = context.run {
|
val jsGetContinuation = getInternalFunction("getContinuation")
|
||||||
val f = getInternalFunctions("getContinuation")
|
|
||||||
symbolTable.referenceSimpleFunction(f.single())
|
|
||||||
}
|
|
||||||
val jsGetKClass = getInternalWithoutPackage("getKClass")
|
val jsGetKClass = getInternalWithoutPackage("getKClass")
|
||||||
val jsGetKClassFromExpression = getInternalWithoutPackage("getKClassFromExpression")
|
val jsGetKClassFromExpression = getInternalWithoutPackage("getKClassFromExpression")
|
||||||
val jsClass = getInternalFunction("jsClass")
|
val jsClass = getInternalFunction("jsClass")
|
||||||
@@ -274,7 +271,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
|||||||
// Helpers:
|
// Helpers:
|
||||||
|
|
||||||
private fun getInternalFunction(name: String) =
|
private fun getInternalFunction(name: String) =
|
||||||
context.symbolTable.referenceSimpleFunction(context.getInternalFunctions(name).single())
|
context.symbolTable.referenceSimpleFunction(context.getJsInternalFunction(name))
|
||||||
|
|
||||||
private fun getInternalWithoutPackage(name: String) =
|
private fun getInternalWithoutPackage(name: String) =
|
||||||
context.symbolTable.referenceSimpleFunction(context.getFunctions(FqName(name)).single())
|
context.symbolTable.referenceSimpleFunction(context.getFunctions(FqName(name)).single())
|
||||||
|
|||||||
+13
-12
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.builtins.PrimitiveType
|
|||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
@@ -204,7 +205,7 @@ class JsIrBackendContext(
|
|||||||
|
|
||||||
// Top-level functions forced to be loaded
|
// Top-level functions forced to be loaded
|
||||||
|
|
||||||
val coroutineSuspendOrReturn = symbolTable.referenceSimpleFunction(getInternalFunctions(COROUTINE_SUSPEND_OR_RETURN_JS_NAME).single())
|
val coroutineSuspendOrReturn = symbolTable.referenceSimpleFunction(getJsInternalFunction(COROUTINE_SUSPEND_OR_RETURN_JS_NAME))
|
||||||
val coroutineSuspendGetter = ir.symbols.coroutineSuspendedGetter
|
val coroutineSuspendGetter = ir.symbols.coroutineSuspendedGetter
|
||||||
val coroutineGetContext: IrFunctionSymbol
|
val coroutineGetContext: IrFunctionSymbol
|
||||||
get() {
|
get() {
|
||||||
@@ -214,7 +215,7 @@ class JsIrBackendContext(
|
|||||||
return contextGetter.symbol
|
return contextGetter.symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
val coroutineGetContextJs = symbolTable.referenceSimpleFunction(getInternalFunctions(GET_COROUTINE_CONTEXT_NAME).single())
|
val coroutineGetContextJs = symbolTable.referenceSimpleFunction(getJsInternalFunction(GET_COROUTINE_CONTEXT_NAME))
|
||||||
|
|
||||||
val coroutineContextProperty: PropertyDescriptor
|
val coroutineContextProperty: PropertyDescriptor
|
||||||
get() {
|
get() {
|
||||||
@@ -225,8 +226,8 @@ class JsIrBackendContext(
|
|||||||
return vars.single()
|
return vars.single()
|
||||||
}
|
}
|
||||||
|
|
||||||
val captureStackSymbol = symbolTable.referenceSimpleFunction(getInternalFunctions("captureStack").single())
|
val captureStackSymbol = symbolTable.referenceSimpleFunction(getJsInternalFunction("captureStack"))
|
||||||
val newThrowableSymbol = symbolTable.referenceSimpleFunction(getInternalFunctions("newThrowable").single())
|
val newThrowableSymbol = symbolTable.referenceSimpleFunction(getJsInternalFunction("newThrowable"))
|
||||||
|
|
||||||
val throwISEymbol = symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))).single())
|
val throwISEymbol = symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))).single())
|
||||||
val throwNPESymbol = ir.symbols.ThrowNullPointerException
|
val throwNPESymbol = ir.symbols.ThrowNullPointerException
|
||||||
@@ -265,23 +266,23 @@ class JsIrBackendContext(
|
|||||||
}
|
}
|
||||||
}.toMap()
|
}.toMap()
|
||||||
|
|
||||||
private fun findClass(memberScope: MemberScope, name: Name) =
|
private fun findClass(memberScope: MemberScope, name: Name): ClassDescriptor =
|
||||||
memberScope.getContributedClassifier(name, NoLookupLocation.FROM_BACKEND) as ClassDescriptor
|
memberScope.getContributedClassifier(name, NoLookupLocation.FROM_BACKEND) as ClassDescriptor
|
||||||
|
|
||||||
private fun findFunctions(memberScope: MemberScope, className: String) =
|
private fun findFunctions(memberScope: MemberScope, name: Name): List<SimpleFunctionDescriptor> =
|
||||||
findFunctions(memberScope, Name.identifier(className))
|
|
||||||
|
|
||||||
private fun findFunctions(memberScope: MemberScope, name: Name) =
|
|
||||||
memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND).toList()
|
memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND).toList()
|
||||||
|
|
||||||
internal fun getJsInternalClass(name: String): ClassDescriptor =
|
internal fun getJsInternalClass(name: String): ClassDescriptor =
|
||||||
findClass(internalPackage.memberScope, Name.identifier(name))
|
findClass(internalPackage.memberScope, Name.identifier(name))
|
||||||
|
|
||||||
override fun getClass(fqName: FqName) = findClass(module.getPackage(fqName.parent()).memberScope, fqName.shortName())
|
override fun getClass(fqName: FqName): ClassDescriptor =
|
||||||
|
findClass(module.getPackage(fqName.parent()).memberScope, fqName.shortName())
|
||||||
|
|
||||||
override fun getInternalFunctions(name: String) = findFunctions(internalPackage.memberScope, name)
|
internal fun getJsInternalFunction(name: String): SimpleFunctionDescriptor =
|
||||||
|
findFunctions(internalPackage.memberScope, Name.identifier(name)).single()
|
||||||
|
|
||||||
fun getFunctions(fqName: FqName) = findFunctions(module.getPackage(fqName.parent()).memberScope, fqName.shortName())
|
fun getFunctions(fqName: FqName): List<SimpleFunctionDescriptor> =
|
||||||
|
findFunctions(module.getPackage(fqName.parent()).memberScope, fqName.shortName())
|
||||||
|
|
||||||
override fun log(message: () -> String) {
|
override fun log(message: () -> String) {
|
||||||
/*TODO*/
|
/*TODO*/
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.backend.jvm.descriptors.JvmSharedVariablesManager
|
|||||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
@@ -71,17 +70,6 @@ class JvmBackendContext(
|
|||||||
return ir.symbols.externalSymbolTable.referenceClass(getClass(fqName))
|
return ir.symbols.externalSymbolTable.referenceClass(getClass(fqName))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getInternalFunctions(name: String): List<FunctionDescriptor> {
|
|
||||||
return when (name) {
|
|
||||||
"ThrowUninitializedPropertyAccessException" ->
|
|
||||||
getJvmInternalClass("Intrinsics").staticScope.getContributedFunctions(
|
|
||||||
Name.identifier("throwUninitializedPropertyAccessException"),
|
|
||||||
NoLookupLocation.FROM_BACKEND
|
|
||||||
).toList()
|
|
||||||
else -> TODO(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun log(message: () -> String) {
|
override fun log(message: () -> String) {
|
||||||
/*TODO*/
|
/*TODO*/
|
||||||
if (inVerbosePhase) {
|
if (inVerbosePhase) {
|
||||||
@@ -102,16 +90,21 @@ class JvmBackendContext(
|
|||||||
|
|
||||||
inner class JvmSymbols : Symbols<JvmBackendContext>(this@JvmBackendContext, symbolTable.lazyWrapper) {
|
inner class JvmSymbols : Symbols<JvmBackendContext>(this@JvmBackendContext, symbolTable.lazyWrapper) {
|
||||||
override val ThrowNullPointerException: IrSimpleFunctionSymbol
|
override val ThrowNullPointerException: IrSimpleFunctionSymbol
|
||||||
get() = symbolTable.referenceSimpleFunction(context.getInternalFunctions("ThrowNullPointerException").single())
|
get() = error("Unused in JVM IR")
|
||||||
|
|
||||||
override val ThrowNoWhenBranchMatchedException: IrSimpleFunctionSymbol
|
override val ThrowNoWhenBranchMatchedException: IrSimpleFunctionSymbol
|
||||||
get() = symbolTable.referenceSimpleFunction(context.getInternalFunctions("ThrowNoWhenBranchMatchedException").single())
|
get() = error("Unused in JVM IR")
|
||||||
|
|
||||||
override val ThrowTypeCastException: IrSimpleFunctionSymbol
|
override val ThrowTypeCastException: IrSimpleFunctionSymbol
|
||||||
get() = symbolTable.referenceSimpleFunction(context.getInternalFunctions("ThrowTypeCastException").single())
|
get() = error("Unused in JVM IR")
|
||||||
|
|
||||||
override val ThrowUninitializedPropertyAccessException: IrSimpleFunctionSymbol =
|
override val ThrowUninitializedPropertyAccessException: IrSimpleFunctionSymbol =
|
||||||
symbolTable.referenceSimpleFunction(context.getInternalFunctions("ThrowUninitializedPropertyAccessException").single())
|
symbolTable.referenceSimpleFunction(
|
||||||
|
getJvmInternalClass("Intrinsics").staticScope.getContributedFunctions(
|
||||||
|
Name.identifier("throwUninitializedPropertyAccessException"),
|
||||||
|
NoLookupLocation.FROM_BACKEND
|
||||||
|
).single()
|
||||||
|
)
|
||||||
|
|
||||||
override val stringBuilder: IrClassSymbol
|
override val stringBuilder: IrClassSymbol
|
||||||
get() = symbolTable.referenceClass(context.getClass(FqName("java.lang.StringBuilder")))
|
get() = symbolTable.referenceClass(context.getClass(FqName("java.lang.StringBuilder")))
|
||||||
@@ -120,11 +113,13 @@ class JvmBackendContext(
|
|||||||
symbolTable.referenceClass(context.getJvmInternalClass("DefaultConstructorMarker"))
|
symbolTable.referenceClass(context.getJvmInternalClass("DefaultConstructorMarker"))
|
||||||
|
|
||||||
override val copyRangeTo: Map<ClassDescriptor, IrSimpleFunctionSymbol>
|
override val copyRangeTo: Map<ClassDescriptor, IrSimpleFunctionSymbol>
|
||||||
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
get() = error("Unused in JVM IR")
|
||||||
|
|
||||||
override val coroutineImpl: IrClassSymbol
|
override val coroutineImpl: IrClassSymbol
|
||||||
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
get() = TODO("not implemented")
|
||||||
|
|
||||||
override val coroutineSuspendedGetter: IrSimpleFunctionSymbol
|
override val coroutineSuspendedGetter: IrSimpleFunctionSymbol
|
||||||
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
get() = TODO("not implemented")
|
||||||
|
|
||||||
val lambdaClass: IrClassSymbol =
|
val lambdaClass: IrClassSymbol =
|
||||||
symbolTable.referenceClass(context.getJvmInternalClass("Lambda"))
|
symbolTable.referenceClass(context.getJvmInternalClass("Lambda"))
|
||||||
|
|||||||
Reference in New Issue
Block a user