Example #1
0
  public static void genClosureFields(
      CalculatedClosure closure, ClassBuilder v, JetTypeMapper typeMapper) {
    ClassifierDescriptor captureThis = closure.getCaptureThis();
    int access = NO_FLAG_PACKAGE_PRIVATE | ACC_SYNTHETIC | ACC_FINAL;
    if (captureThis != null) {
      v.newField(
          null,
          access,
          CAPTURED_THIS_FIELD,
          typeMapper.mapType(captureThis).getDescriptor(),
          null,
          null);
    }

    ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
    if (captureReceiver != null) {
      v.newField(
          null,
          access,
          CAPTURED_RECEIVER_FIELD,
          typeMapper.mapType(captureReceiver).getDescriptor(),
          null,
          null);
    }

    List<Pair<String, Type>> fields = closure.getRecordedFields();
    for (Pair<String, Type> field : fields) {
      v.newField(null, access, field.first, field.second.getDescriptor(), null, null);
    }
  }
Example #2
0
 @NotNull
 public static Type getTraitImplThisParameterType(
     @NotNull ClassDescriptor traitDescriptor, @NotNull JetTypeMapper typeMapper) {
   JetType jetType = getSuperClass(traitDescriptor);
   Type type = typeMapper.mapType(jetType);
   if (type.getInternalName().equals("java/lang/Object")) {
     return typeMapper.mapType(traitDescriptor.getDefaultType());
   }
   return type;
 }
Example #3
0
  public static int getMethodAsmFlags(FunctionDescriptor functionDescriptor, OwnerKind kind) {
    int flags = getCommonCallableFlags(functionDescriptor);

    if (functionDescriptor.getModality() == Modality.FINAL
        && !(functionDescriptor instanceof ConstructorDescriptor)) {
      DeclarationDescriptor containingDeclaration = functionDescriptor.getContainingDeclaration();
      if (!(containingDeclaration instanceof ClassDescriptor)
          || ((ClassDescriptor) containingDeclaration).getKind() != ClassKind.TRAIT) {
        flags |= ACC_FINAL;
      }
    }

    if (isStaticMethod(kind, functionDescriptor)) {
      flags |= ACC_STATIC;
    }

    if (isAbstractMethod(functionDescriptor, kind)) {
      flags |= ACC_ABSTRACT;
    }

    if (JetTypeMapper.isAccessor(functionDescriptor)) {
      flags |= ACC_SYNTHETIC;
    }

    return flags;
  }
Example #4
0
 public static boolean isStaticMethod(OwnerKind kind, FunctionDescriptor functionDescriptor) {
   return isStatic(kind) || JetTypeMapper.isAccessor(functionDescriptor);
 }