Initial KClassJavaProperty support
This commit is contained in:
committed by
Dmitry Petrov
parent
607cf4c86d
commit
26b2a069fd
+38
@@ -16,15 +16,53 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.jvm.intrinsics
|
||||
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.BlockInfo
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.putJavaLangClassInstance
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.wrapJavaClassIntoKClass
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
||||
import org.jetbrains.kotlin.psi.KtClassLiteralExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.DOUBLE_COLON_LHS
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
class KClassJavaProperty : IntrinsicMethod() {
|
||||
override fun toCallable(expression: IrMemberAccessExpression, signature: JvmMethodSignature, context: JvmBackendContext): IrIntrinsicFunction {
|
||||
return object: IrIntrinsicFunction(expression, signature, context) {
|
||||
override fun invoke(v: InstructionAdapter, codegen: org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen, data: BlockInfo): StackValue {
|
||||
putJavaLangClassInstance(v, signature.returnType)
|
||||
wrapJavaClassIntoKClass(v)
|
||||
return StackValue.onStack(signature.returnType)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// val type = lhs.type
|
||||
// if (lhs is DoubleColonLHS.Expression && !(lhs as DoubleColonLHS.Expression).isObject) {
|
||||
// JavaClassProperty.generateImpl(v, gen(receiverExpression))
|
||||
// }
|
||||
// else {
|
||||
// if (TypeUtils.isTypeParameter(type)) {
|
||||
// assert(TypeUtils.isReifiedTypeParameter(type)) { "Non-reified type parameter under ::class should be rejected by type checker: " + type }
|
||||
// putReifiedOperationMarkerIfTypeIsReifiedParameter(type, ReifiedTypeInliner.OperationKind.JAVA_CLASS)
|
||||
// }
|
||||
|
||||
// putJavaLangClassInstance(v, typeMapper.mapType(type))
|
||||
// }
|
||||
|
||||
// if (wrapIntoKClass) {
|
||||
// wrapJavaClassIntoKClass(v)
|
||||
// }
|
||||
|
||||
// return Unit
|
||||
}
|
||||
|
||||
|
||||
fun generate(resolvedCall: ResolvedCall<*>?, codegen: ExpressionCodegen, returnType: Type, receiver: StackValue): StackValue? {
|
||||
val receiverValue = resolvedCall!!.extensionReceiver as? ExpressionReceiver ?: return null
|
||||
val classLiteralExpression = receiverValue.expression as? KtClassLiteralExpression ?: return null
|
||||
|
||||
Reference in New Issue
Block a user