Exemplo n.º 1
0
  /** Print LocalVariableTable attribute information. */
  public void printLocVarTable(MethodData method) {
    int siz = method.getloc_var_tbsize();
    if (siz > 0) {
      out.println("  LocalVariableTable: ");
      out.print("   ");
      out.println("Start  Length  Slot  Name   Signature");
    }
    Vector loc_var_tb = method.getloc_var_tb();

    for (int i = 0; i < siz; i++) {
      LocVarData entry = (LocVarData) loc_var_tb.elementAt(i);

      out.println(
          "   "
              + entry.start_pc
              + "      "
              + entry.length
              + "      "
              + entry.slot
              + "    "
              + cls.StringValue(entry.name_cpx)
              + "       "
              + cls.StringValue(entry.sig_cpx));
    }
    out.println();
  }
Exemplo n.º 2
0
  /** Print code attribute details. */
  public void printVerboseHeader(MethodData method) {
    int argCount = method.getArgumentlength();
    if (!method.isStatic()) ++argCount; // for 'this'

    out.println(
        "   Stack="
            + method.getMaxStack()
            + ", Locals="
            + method.getMaxLocals()
            + ", Args_size="
            + argCount);
  }
Exemplo n.º 3
0
 /** Print LineNumberTable attribute information. */
 public void printLineNumTable(MethodData method) {
   int numlines = method.getnumlines();
   Vector lin_num_tb = method.getlin_num_tb();
   if (lin_num_tb.size() > 0) {
     out.println("  LineNumberTable: ");
     for (int i = 0; i < numlines; i++) {
       LineNumData linnumtb_entry = (LineNumData) lin_num_tb.elementAt(i);
       out.println("   line " + linnumtb_entry.line_number + ": " + linnumtb_entry.start_pc);
     }
   }
   out.println();
 }
Exemplo n.º 4
0
  public static boolean inferPurity(@NotNull final PsiMethod method) {
    if (!InferenceFromSourceUtil.shouldInferFromSource(method)
        || PsiType.VOID.equals(method.getReturnType())
        || method.isConstructor()) {
      return false;
    }

    return CachedValuesManager.getCachedValue(
        method,
        () -> {
          MethodData data = ContractInferenceIndexKt.getIndexedData(method);
          PurityInferenceResult result = data == null ? null : data.getPurity();
          Boolean pure =
              RecursionManager.doPreventingRecursion(
                  method,
                  true,
                  () -> result != null && result.isPure(method, data.methodBody(method)));
          return CachedValueProvider.Result.create(pure == Boolean.TRUE, method);
        });
  }
Exemplo n.º 5
0
  /** Print StackMapTable attribute information. */
  public void printStackMapTable(MethodData method) {
    StackMapTableData[] stack_map_tb = method.getStackMapTable();
    int number_of_entries = stack_map_tb.length;
    if (number_of_entries > 0) {
      out.println("  StackMapTable: number_of_entries = " + number_of_entries);

      for (StackMapTableData frame : stack_map_tb) {
        frame.print(this);
      }
    }
    out.println();
  }
Exemplo n.º 6
0
 /** print method attribute information. */
 public void printMethodAttributes(MethodData method) {
   Vector methodattrs = method.getAttributes();
   Vector codeattrs = method.getCodeAttributes();
   for (int k = 0; k < methodattrs.size(); k++) {
     String methodattrname = ((AttrData) methodattrs.elementAt(k)).getAttrName();
     if (methodattrname.equals("Code")) {
       printcodeSequence(method);
       printExceptionTable(method);
       for (int c = 0; c < codeattrs.size(); c++) {
         String codeattrname = ((AttrData) codeattrs.elementAt(c)).getAttrName();
         if (codeattrname.equals("LineNumberTable")) {
           printLineNumTable(method);
         } else if (codeattrname.equals("LocalVariableTable")) {
           printLocVarTable(method);
         } else if (codeattrname.equals("StackMapTable")) {
           // Java SE JSR 202 stack map tables
           printStackMapTable(method);
         } else if (codeattrname.equals("StackMap")) {
           // Java ME CLDC stack maps
           printStackMap(method);
         } else {
           printAttrData((AttrData) codeattrs.elementAt(c));
         }
       }
     } else if (methodattrname.equals("Exceptions")) {
       out.println("  Exceptions: ");
       printExceptions(method);
     } else if (methodattrname.equals("Deprecated")) {
       out.println("  Deprecated: " + method.isDeprecated());
     } else if (methodattrname.equals("Synthetic")) {
       out.println("  Synthetic: " + method.isSynthetic());
     } else {
       printAttrData((AttrData) methodattrs.elementAt(k));
     }
   }
   out.println();
 }
Exemplo n.º 7
0
  /** Print code sequence. */
  public void printcodeSequence(MethodData method) {
    code = method.getCode();
    if (code != null) {
      out.println("  Code:");
      if (env.showVerbose) {
        printVerboseHeader(method);
      }

      for (int pc = 0; pc < code.length; ) {
        out.print("   " + pc + ":\t");
        pc = pc + printInstr(pc);
        out.println();
      }
    }
  }
Exemplo n.º 8
0
  /** Print method signature. */
  public void printMethodSignature(MethodData method, String[] accflags) {
    printAccess(accflags);

    if ((method.getName()).equals("<init>")) {
      out.print(javaclassname(cls.getClassName()));
      out.print(method.getParameters());
    } else if ((method.getName()).equals("<clinit>")) {
      out.print("{}");
    } else {
      out.print(method.getReturnType() + " ");
      out.print(method.getName());
      out.print(method.getParameters());
    }
  }
Exemplo n.º 9
0
  /** Print exceptions. */
  public void printExceptions(MethodData method) {
    int[] exc_index_table = method.get_exc_index_table();
    if (exc_index_table != null) {
      if (!(env.showLineAndLocal
          || env.showDisassembled
          || env.showVerbose
          || env.showInternalSigs
          || env.showallAttr)) {
        out.print("    ");
      }
      out.print("   throws ");
      int k;
      int l = exc_index_table.length;

      for (k = 0; k < l; k++) {
        out.print(javaclassname(cls.getClassName(exc_index_table[k])));
        if (k < l - 1) out.print(", ");
      }
    }
  }
Exemplo n.º 10
0
 /** Print the exception table for this method code */
 void printExceptionTable(MethodData method) { // throws IOException
   Vector exception_table = method.getexception_table();
   if (exception_table.size() > 0) {
     out.println("  Exception table:");
     out.println("   from   to  target type");
     for (int idx = 0; idx < exception_table.size(); ++idx) {
       TrapData handler = (TrapData) exception_table.elementAt(idx);
       printFixedWidthInt(handler.start_pc, 6);
       printFixedWidthInt(handler.end_pc, 6);
       printFixedWidthInt(handler.handler_pc, 6);
       out.print("   ");
       int catch_cpx = handler.catch_cpx;
       if (catch_cpx == 0) {
         out.println("any");
       } else {
         out.print("Class ");
         out.println(cls.getClassName(catch_cpx));
         out.println("");
       }
     }
   }
 }