JVM: add more flags to JvmBackendConfig
And use them instead of CompilerConfiguration, to reduce dependencies of backend on the whole compiler (as opposed to just backend) configuration.
This commit is contained in:
committed by
Space Team
parent
72b5123fc8
commit
9943c7078c
+27
-25
@@ -21,13 +21,15 @@ import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmSymbols
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.*
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isInlineClassType
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isOptionalAnnotationClass
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isWithFlexibleNullability
|
||||
import org.jetbrains.kotlin.backend.jvm.mapping.mapClass
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.TypeAnnotationCollector
|
||||
import org.jetbrains.kotlin.codegen.TypePathInfo
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
@@ -311,29 +313,29 @@ abstract class AnnotationCodegen(
|
||||
}
|
||||
}.genAnnotations(typeParameter, null, null)
|
||||
|
||||
if (context.state.configuration.getBoolean(JVMConfigurationKeys.EMIT_JVM_TYPE_ANNOTATIONS)) {
|
||||
var superInterfaceIndex = 1
|
||||
typeParameter.superTypes.forEach { superType ->
|
||||
val isClassOrTypeParameter = !superType.isInterface() && !superType.isAnnotation()
|
||||
val superIndex = if (isClassOrTypeParameter) 0 else superInterfaceIndex++
|
||||
object : AnnotationCodegen(classCodegen, true) {
|
||||
override fun visitAnnotation(descr: String, visible: Boolean): AnnotationVisitor {
|
||||
throw RuntimeException(
|
||||
"Error during generation: only type annotations should be presented on type parameters bounds: " +
|
||||
"${ir2string(typeParameter)} in ${ir2string(typeParameter)}"
|
||||
)
|
||||
}
|
||||
if (!context.config.emitJvmTypeAnnotations) return
|
||||
|
||||
override fun visitTypeAnnotation(descr: String, path: TypePath?, visible: Boolean): AnnotationVisitor {
|
||||
return visitor(
|
||||
TypeReference.newTypeParameterBoundReference(boundType, index, superIndex).value,
|
||||
path,
|
||||
descr,
|
||||
visible
|
||||
)
|
||||
}
|
||||
}.generateTypeAnnotations(typeParameterContainer, superType)
|
||||
}
|
||||
var superInterfaceIndex = 1
|
||||
typeParameter.superTypes.forEach { superType ->
|
||||
val isClassOrTypeParameter = !superType.isInterface() && !superType.isAnnotation()
|
||||
val superIndex = if (isClassOrTypeParameter) 0 else superInterfaceIndex++
|
||||
object : AnnotationCodegen(classCodegen, true) {
|
||||
override fun visitAnnotation(descr: String, visible: Boolean): AnnotationVisitor {
|
||||
throw RuntimeException(
|
||||
"Error during generation: only type annotations should be presented on type parameters bounds: " +
|
||||
"${ir2string(typeParameter)} in ${ir2string(typeParameter)}"
|
||||
)
|
||||
}
|
||||
|
||||
override fun visitTypeAnnotation(descr: String, path: TypePath?, visible: Boolean): AnnotationVisitor {
|
||||
return visitor(
|
||||
TypeReference.newTypeParameterBoundReference(boundType, index, superIndex).value,
|
||||
path,
|
||||
descr,
|
||||
visible
|
||||
)
|
||||
}
|
||||
}.generateTypeAnnotations(typeParameterContainer, superType)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -398,7 +400,7 @@ abstract class AnnotationCodegen(
|
||||
type: IrType?
|
||||
) {
|
||||
if ((annotated as? IrDeclaration)?.origin == JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR ||
|
||||
type == null || !context.state.configuration.getBoolean(JVMConfigurationKeys.EMIT_JVM_TYPE_ANNOTATIONS)
|
||||
type == null || !context.config.emitJvmTypeAnnotations
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
+9
-4
@@ -7,11 +7,13 @@ package org.jetbrains.kotlin.backend.jvm.codegen
|
||||
|
||||
import org.jetbrains.kotlin.backend.jvm.InlineClassAbi
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.*
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.hasContinuation
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isReadOfCrossinline
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.suspendFunctionOriginal
|
||||
import org.jetbrains.kotlin.backend.jvm.unboxInlineClass
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilder
|
||||
import org.jetbrains.kotlin.codegen.coroutines.CoroutineTransformerMethodVisitor
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
@@ -19,7 +21,10 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.util.allOverridden
|
||||
import org.jetbrains.kotlin.ir.util.file
|
||||
import org.jetbrains.kotlin.ir.util.isSuspend
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmBackendErrors
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -66,7 +71,7 @@ internal fun MethodNode.acceptWithStateMachine(
|
||||
internalNameForDispatchReceiver = classCodegen.type.internalName,
|
||||
putContinuationParameterToLvt = false,
|
||||
initialVarsCountByType = varsCountByType,
|
||||
shouldOptimiseUnusedVariables = !context.configuration.getBoolean(JVMConfigurationKeys.ENABLE_DEBUG_MODE)
|
||||
shouldOptimiseUnusedVariables = !context.config.enableDebugMode
|
||||
)
|
||||
accept(visitor)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user