Esempio n. 1
0
  private void generateDefaultSetter(JetProperty p) {
    final PropertyDescriptor propertyDescriptor =
        (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, p);
    assert propertyDescriptor != null;

    int modifiers = JetTypeMapper.getAccessModifiers(propertyDescriptor, 0);
    PropertySetterDescriptor setter = propertyDescriptor.getSetter();
    int flags = setter == null ? modifiers : JetTypeMapper.getAccessModifiers(setter, modifiers);
    generateDefaultSetter(propertyDescriptor, flags, p);
  }
Esempio n. 2
0
 private void generateSetter(JetProperty p, PropertyDescriptor propertyDescriptor) {
   final JetPropertyAccessor setter = p.getSetter();
   if (setter != null) {
     if (setter.getBodyExpression() != null) {
       final PropertySetterDescriptor setterDescriptor = propertyDescriptor.getSetter();
       assert setterDescriptor != null;
       JvmPropertyAccessorSignature signature =
           state.getInjector().getJetTypeMapper().mapSetterSignature(propertyDescriptor, kind);
       functionCodegen.generateMethod(
           setter,
           signature.getJvmMethodSignature(),
           true,
           signature.getPropertyTypeKotlinSignature(),
           setterDescriptor);
     } else if (isExternallyAccessible(propertyDescriptor)) {
       generateDefaultSetter(p);
     }
   } else if (isExternallyAccessible(propertyDescriptor) && propertyDescriptor.isVar()) {
     generateDefaultSetter(p);
   }
 }
Esempio 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);
     }
   }
 }