コード例 #1
0
  @NotNull
  public static JvmClassName getJvmInternalName(
      BindingTrace bindingTrace, @NotNull DeclarationDescriptor descriptor) {
    descriptor = descriptor.getOriginal();
    JvmClassName name = bindingTrace.getBindingContext().get(FQN, descriptor);
    if (name != null) {
      return name;
    }

    name = JvmClassName.byInternalName(getJvmInternalFQNameImpl(bindingTrace, descriptor));

    assert PsiCodegenPredictor.checkPredictedNameFromPsi(bindingTrace, descriptor, name);
    bindingTrace.record(FQN, descriptor, name);
    return name;
  }
コード例 #2
0
  @Override
  public void visitEnumEntry(JetEnumEntry enumEntry) {
    ClassDescriptor descriptor = bindingContext.get(CLASS, enumEntry);
    assert descriptor != null;

    final boolean trivial = enumEntry.getDeclarations().isEmpty();
    if (!trivial) {
      bindingTrace.record(ENUM_ENTRY_CLASS_NEED_SUBCLASS, descriptor);
      super.visitEnumEntry(enumEntry);
    } else {
      JvmClassName jvmClassName = bindingTrace.get(FQN, peekFromStack(classStack));
      assert PsiCodegenPredictor.checkPredictedNameFromPsi(bindingTrace, descriptor, jvmClassName);
      bindingTrace.record(FQN, descriptor, jvmClassName);
    }
  }
コード例 #3
0
  static void recordClosure(
      BindingTrace bindingTrace,
      @Nullable JetElement element,
      ClassDescriptor classDescriptor,
      @Nullable ClassDescriptor enclosing,
      JvmClassName name,
      boolean functionLiteral) {
    JetDelegatorToSuperCall superCall = findSuperCall(bindingTrace.getBindingContext(), element);

    CallableDescriptor enclosingReceiver = null;
    if (classDescriptor.getContainingDeclaration() instanceof CallableDescriptor) {
      enclosingReceiver = (CallableDescriptor) classDescriptor.getContainingDeclaration();
      enclosingReceiver =
          enclosingReceiver instanceof PropertyAccessorDescriptor
              ? ((PropertyAccessorDescriptor) enclosingReceiver).getCorrespondingProperty()
              : enclosingReceiver;

      if (enclosingReceiver.getReceiverParameter() == null) {
        enclosingReceiver = null;
      }
    }

    MutableClosure closure = new MutableClosure(superCall, enclosing, enclosingReceiver);

    assert PsiCodegenPredictor.checkPredictedNameFromPsi(bindingTrace, classDescriptor, name);
    bindingTrace.record(FQN, classDescriptor, name);
    bindingTrace.record(CLOSURE, classDescriptor, closure);

    // TODO: this is temporary before we have proper inner classes
    if (canHaveOuter(bindingTrace.getBindingContext(), classDescriptor) && !functionLiteral) {
      closure.setCaptureThis();
    }

    if (enclosing != null) {
      recordInnerClass(bindingTrace, enclosing, classDescriptor);
    }
  }