public static void generateFinallyMarker(
     @NotNull InstructionAdapter v, int depth, boolean start) {
   v.iconst(depth);
   v.invokestatic(
       INLINE_MARKER_CLASS_NAME,
       start ? INLINE_MARKER_FINALLY_START : INLINE_MARKER_FINALLY_END,
       "(I)V",
       false);
 }
示例#2
0
  private static void equipFunctionReferenceWithReflection(
      @NotNull InstructionAdapter v, @NotNull FunctionDescriptor target) {
    DeclarationDescriptor container = target.getContainingDeclaration();

    Type type;
    if (container instanceof PackageFragmentDescriptor) {
      type =
          target.getExtensionReceiverParameter() != null
              ? K_TOP_LEVEL_EXTENSION_FUNCTION
              : K_TOP_LEVEL_FUNCTION;
    } else if (container instanceof ClassDescriptor) {
      type = K_MEMBER_FUNCTION;
    } else {
      type = K_LOCAL_FUNCTION;
    }

    Method method = method("function", K_FUNCTION, FUNCTION_REFERENCE);
    v.invokestatic(REFLECTION, method.getName(), method.getDescriptor(), false);
    StackValue.coerce(K_FUNCTION, type, v);
  }
示例#3
0
  private static void generateDelegateToMethodBody(
      boolean isStatic,
      @NotNull MethodVisitor mv,
      @NotNull Method asmMethod,
      @NotNull String classToDelegateTo) {
    InstructionAdapter iv = new InstructionAdapter(mv);
    Type[] argTypes = asmMethod.getArgumentTypes();

    // The first line of some package file is written to the line number attribute of a static
    // delegate to allow to 'step into' it
    // This is similar to what javac does with bridge methods
    Label label = new Label();
    iv.visitLabel(label);
    iv.visitLineNumber(1, label);

    int k = isStatic ? 0 : 1;
    for (Type argType : argTypes) {
      iv.load(k, argType);
      k += argType.getSize();
    }
    iv.invokestatic(classToDelegateTo, asmMethod.getName(), asmMethod.getDescriptor(), false);
    iv.areturn(asmMethod.getReturnType());
  }
 public static void generateGlobalReturnFlag(
     @NotNull InstructionAdapter iv, @NotNull String labelName) {
   iv.invokestatic(NON_LOCAL_RETURN, labelName, "()V", false);
 }