diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt index 34d25acc994..9916b7e0bb1 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt @@ -7,12 +7,10 @@ package org.jetbrains.kotlin.backend.jvm import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.ir.Ir -import org.jetbrains.kotlin.backend.common.ir.Symbols import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig import org.jetbrains.kotlin.backend.jvm.descriptors.JvmDeclarationFactory import org.jetbrains.kotlin.backend.jvm.descriptors.JvmSharedVariablesManager import org.jetbrains.kotlin.codegen.state.GenerationState -import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.ir.IrElement @@ -20,7 +18,6 @@ import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.util.SymbolTable import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -44,11 +41,11 @@ class JvmBackendContext( override val configuration get() = state.configuration - private fun getJvmInternalClass(name: String): ClassDescriptor { + internal fun getJvmInternalClass(name: String): ClassDescriptor { return getClass(FqName("kotlin.jvm.internal").child(Name.identifier(name))) } - private fun getClass(fqName: FqName): ClassDescriptor { + internal fun getClass(fqName: FqName): ClassDescriptor { return state.module.getPackage(fqName.parent()).memberScope.getContributedClassifier( fqName.shortName(), NoLookupLocation.FROM_BACKEND ) as ClassDescriptor? ?: error("Class is not found: $fqName") @@ -70,54 +67,8 @@ class JvmBackendContext( print(message) } - inner class JvmIr( - irModuleFragment: IrModuleFragment, - private val symbolTable: SymbolTable - ) : Ir(this, irModuleFragment) { - override val symbols = JvmSymbols() - - inner class JvmSymbols : Symbols(this@JvmBackendContext, symbolTable.lazyWrapper) { - override val ThrowNullPointerException: IrSimpleFunctionSymbol - get() = error("Unused in JVM IR") - - override val ThrowNoWhenBranchMatchedException: IrSimpleFunctionSymbol - get() = error("Unused in JVM IR") - - override val ThrowTypeCastException: IrSimpleFunctionSymbol - get() = error("Unused in JVM IR") - - override val ThrowUninitializedPropertyAccessException: IrSimpleFunctionSymbol = - symbolTable.referenceSimpleFunction( - getJvmInternalClass("Intrinsics").staticScope.getContributedFunctions( - Name.identifier("throwUninitializedPropertyAccessException"), - NoLookupLocation.FROM_BACKEND - ).single() - ) - - override val stringBuilder: IrClassSymbol - get() = symbolTable.referenceClass(context.getClass(FqName("java.lang.StringBuilder"))) - - override val defaultConstructorMarker: IrClassSymbol = - symbolTable.referenceClass(context.getJvmInternalClass("DefaultConstructorMarker")) - - override val copyRangeTo: Map - get() = error("Unused in JVM IR") - - override val coroutineImpl: IrClassSymbol - get() = TODO("not implemented") - - override val coroutineSuspendedGetter: IrSimpleFunctionSymbol - get() = TODO("not implemented") - - val lambdaClass: IrClassSymbol = - symbolTable.referenceClass(context.getJvmInternalClass("Lambda")) - - val functionReference: IrClassSymbol = - symbolTable.referenceClass(context.getJvmInternalClass("FunctionReference")) - - fun getFunction(parameterCount: Int): IrClassSymbol = - symbolTable.referenceClass(context.builtIns.getFunction(parameterCount)) - } + inner class JvmIr(irModuleFragment: IrModuleFragment, symbolTable: SymbolTable) : Ir(this, irModuleFragment) { + override val symbols = JvmSymbols(this@JvmBackendContext, symbolTable.lazyWrapper) override fun shouldGenerateHandlerParameterForDefaultBodyFun() = true } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt new file mode 100644 index 00000000000..aefb42c29fb --- /dev/null +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. 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.backend.jvm + +import org.jetbrains.kotlin.backend.common.ir.Symbols +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name + +class JvmSymbols( + context: JvmBackendContext, + private val symbolTable: ReferenceSymbolTable +) : Symbols(context, symbolTable) { + override val ThrowNullPointerException: IrSimpleFunctionSymbol + get() = error("Unused in JVM IR") + + override val ThrowNoWhenBranchMatchedException: IrSimpleFunctionSymbol + get() = error("Unused in JVM IR") + + override val ThrowTypeCastException: IrSimpleFunctionSymbol + get() = error("Unused in JVM IR") + + override val ThrowUninitializedPropertyAccessException: IrSimpleFunctionSymbol = + symbolTable.referenceSimpleFunction( + context.getJvmInternalClass("Intrinsics").staticScope.getContributedFunctions( + Name.identifier("throwUninitializedPropertyAccessException"), + NoLookupLocation.FROM_BACKEND + ).single() + ) + + override val stringBuilder: IrClassSymbol + get() = symbolTable.referenceClass(context.getClass(FqName("java.lang.StringBuilder"))) + + override val defaultConstructorMarker: IrClassSymbol = + symbolTable.referenceClass(context.getJvmInternalClass("DefaultConstructorMarker")) + + override val copyRangeTo: Map + get() = error("Unused in JVM IR") + + override val coroutineImpl: IrClassSymbol + get() = TODO("not implemented") + + override val coroutineSuspendedGetter: IrSimpleFunctionSymbol + get() = TODO("not implemented") + + val lambdaClass: IrClassSymbol = + symbolTable.referenceClass(context.getJvmInternalClass("Lambda")) + + val functionReference: IrClassSymbol = + symbolTable.referenceClass(context.getJvmInternalClass("FunctionReference")) + + fun getFunction(parameterCount: Int): IrClassSymbol = + symbolTable.referenceClass(context.builtIns.getFunction(parameterCount)) +} +