Exemplo n.º 1
0
 private void generateDefaultGetter(JetProperty p) {
   final PropertyDescriptor propertyDescriptor =
       (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, p);
   int flags =
       JetTypeMapper.getAccessModifiers(propertyDescriptor, 0)
           | (propertyDescriptor.getModality() == Modality.ABSTRACT ? Opcodes.ACC_ABSTRACT : 0);
   generateDefaultGetter(propertyDescriptor, flags, p);
 }
Exemplo n.º 2
0
 private void generateGetter(JetProperty p, PropertyDescriptor propertyDescriptor) {
   final JetPropertyAccessor getter = p.getGetter();
   if (getter != null) {
     if (getter.getBodyExpression() != null) {
       JvmPropertyAccessorSignature signature =
           state.getInjector().getJetTypeMapper().mapGetterSignature(propertyDescriptor, kind);
       functionCodegen.generateMethod(
           getter,
           signature.getJvmMethodSignature(),
           true,
           signature.getPropertyTypeKotlinSignature(),
           propertyDescriptor.getGetter());
     } else if (isExternallyAccessible(propertyDescriptor)) {
       generateDefaultGetter(p);
     }
   } else if (isExternallyAccessible(propertyDescriptor)) {
     generateDefaultGetter(p);
   }
 }
Exemplo n.º 3
0
 public void gen(JetProperty p) {
   final VariableDescriptor descriptor = state.getBindingContext().get(BindingContext.VARIABLE, p);
   if (!(descriptor instanceof PropertyDescriptor)) {
     throw new UnsupportedOperationException("expect a property to have a property descriptor");
   }
   final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
   if (kind == OwnerKind.NAMESPACE
       || kind == OwnerKind.IMPLEMENTATION
       || kind == OwnerKind.TRAIT_IMPL) {
     if (kind != OwnerKind.TRAIT_IMPL) generateBackingField(p, propertyDescriptor);
     generateGetter(p, propertyDescriptor);
     generateSetter(p, propertyDescriptor);
   } else if (kind instanceof OwnerKind.DelegateKind) {
     generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC, p);
     if (propertyDescriptor.isVar()) {
       generateDefaultSetter(propertyDescriptor, Opcodes.ACC_PUBLIC, p);
     }
   }
 }