Add ModuleDescriptor to AnnotationCodegen

This commit is contained in:
Alexander Udalov
2018-09-05 13:18:10 +03:00
parent ffdfec4815
commit 9183d7ca27
10 changed files with 35 additions and 38 deletions
@@ -36,7 +36,6 @@ import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import java.lang.RuntimeException
open class ClassCodegen protected constructor(
internal val irClass: IrClass,
@@ -84,7 +83,7 @@ open class ClassCodegen protected constructor(
signature.superclassName,
signature.interfaces.toTypedArray()
)
AnnotationCodegen.forClass(visitor.visitor, this, typeMapper).genAnnotations(descriptor, null)
AnnotationCodegen.forClass(visitor.visitor, this, state).genAnnotations(descriptor, null)
visitor.visitSource(irClass.symbol.descriptor.source.containingFile.name!!, null)
irClass.declarations.forEach {
@@ -159,7 +158,7 @@ open class ClassCodegen protected constructor(
)
if (field.origin == IrDeclarationOrigin.FIELD_FOR_ENUM_ENTRY) {
AnnotationCodegen.forField(fv, this, typeMapper).genAnnotations(field.descriptor, null)
AnnotationCodegen.forField(fv, this, state).genAnnotations(field.descriptor, null)
} else {
}
@@ -48,9 +48,7 @@ open class FunctionCodegen(private val irFunction: IrFunction, private val class
val flags = calculateMethodFlags(irFunction.isStatic)
val methodVisitor = createMethod(flags, signature)
AnnotationCodegen.forMethod(methodVisitor, classCodegen, state.typeMapper).genAnnotations(
descriptor, signature.asmMethod.returnType
)
AnnotationCodegen.forMethod(methodVisitor, classCodegen, state).genAnnotations(descriptor, signature.asmMethod.returnType)
FunctionCodegen.generateParameterAnnotations(descriptor, methodVisitor, signature, classCodegen, state)
if (!state.classBuilderMode.generateBodies || flags.and(Opcodes.ACC_ABSTRACT) != 0 || irFunction.isExternal) {
@@ -113,7 +111,7 @@ open class FunctionCodegen(private val irFunction: IrFunction, private val class
)
assert(!state.classBuilderMode.generateBodies || constant != null) { "Default value for annotation parameter should be compile time value: " + defaultValue.text }
if (constant != null) {
val annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(methodVisitor, classCodegen, state.typeMapper)
val annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(methodVisitor, classCodegen, state)
annotationCodegen.generateAnnotationDefaultValue(constant, descriptor.returnType!!)
}
}