Exemple #1
0
 private StringBuffer printLocalVariableEntry(StringBuffer buf, int i)
     throws ConstantPoolException {
   if (lvt != null) {
     int len = lvt.local_variable_table_length;
     if (i >= 0 && i < len) {
       LocalVariableTable_attribute.Entry entry = lvt.local_variable_table[i];
       int start_pc = entry.start_pc;
       int length = entry.length;
       int name_index = entry.name_index;
       int descriptor_index = entry.descriptor_index;
       String name = cf.constant_pool.getUTF8Value(name_index);
       String desc = cf.constant_pool.getUTF8Value(descriptor_index);
       buf.append(
           "("
               + start_pc
               + " "
               + (start_pc + length)
               + " "
               + name
               + " "
               + ACL2utils.classNameToACL2TypeStr(desc)
               + ")\n");
     }
   }
   return buf;
 }
Exemple #2
0
 private static void appendStackMapType(
     StringBuilder sb, StackMapTable_attribute.verification_type_info typeInfo, ConstantPool cp)
     throws ConstantPoolException {
   if (typeInfo == null) {
     sb.append(type_names[0]);
     return;
   }
   int type = typeInfo.tag;
   switch (type) {
     case 0:
     case 1:
     case 2:
     case 3:
     case 4:
     case 5:
     case 6:
       sb.append(type_names[type]);
       break;
     case 7:
       {
         StackMapTable_attribute.Object_variable_info typeInfoObject =
             (StackMapTable_attribute.Object_variable_info) typeInfo;
         int index = typeInfoObject.cpool_index;
         ConstantPool.CONSTANT_Class_info info = cp.getClassInfo(index);
         sb.append(ACL2utils.classNameToACL2TypeStr(info.getName()));
       }
       break;
     case 8:
       {
         StackMapTable_attribute.Uninitialized_variable_info typeInfoUninitialized =
             (StackMapTable_attribute.Uninitialized_variable_info) typeInfo;
         int offset = typeInfoUninitialized.offset;
         sb.append("(uninitialized " + offset + ")");
       }
       break;
     case 9:
       {
         assert false;
         //                int offset;
         //                offset = file.readUnsignedShort();
         //                type_name = "(returnAddress " + offset + ")";
       }
       break;
     default:
       throw new RuntimeException("Illeagal Type in StackMap" + type);
   }
 }
Exemple #3
0
  /**
   * returns a pretty-printed String representing this method.
   *
   * @param lmargin The number of spaces of indentation to place before the output
   * @return A pretty-printed String representing this method.
   */
  public String toString(int lmargin) throws ConstantPoolException {
    if (!processed) {
      return "You must call processMethod first!";
    }

    StringBuilder sb = new StringBuilder();
    indent(sb, lmargin);
    sb.append("(method \"" + name + "\"");
    nl(sb, lmargin + 6, "(parameters ");
    for (int i = 0; i < params.size(); i++) {
      sb.append(ACL2utils.descToACL2TypeStr(params.get(i)));

      if (i < (params.size() - 1)) {
        sb.append(" ");
      }
    }
    sb.append(")");
    nl(sb, lmargin + 6, "(returntype . " + ACL2utils.descToACL2TypeStr(returntype) + ")");
    nl(sb, lmargin + 6, ACL2utils.accessFlagsToString(m.access_flags));

    nl(sb, lmargin + 6, "(code");
    if (cai != null && !no_method_body) {
      nl(
          sb,
          lmargin + 11,
          "(max_stack . "
              + max_stack
              + ")"
              + " (max_locals . "
              + max_locals
              + ")"
              + " (code_length . "
              + code_length
              + ")");
      nl(sb, lmargin + 11, "(parsedcode");

      for (int i = 0; i < m6instructions.size(); i++) {
        nl(sb, lmargin + 14, m6instructions.get(i));
      }
      sb.append(")");

      nl(sb, lmargin + 11, "(Exceptions ");
      for (int i = 0; i < cai.exception_table.length; i++) {
        Code_attribute.Exception_data ed = cai.exception_table[i];
        String catchType =
            ed.catch_type != 0
                ? cf.constant_pool.getClassInfo(ed.catch_type).getName().replace('/', '.')
                : "java/lang.Throwable";
        String acl2Type = ACL2utils.classNameToACL2TypeStr(catchType);
        nl(
            sb,
            lmargin + 13,
            "(handler "
                + ed.start_pc
                + " "
                + ed.end_pc
                + "  "
                + ed.handler_pc
                + " "
                + acl2Type
                + ")");
      }
      sb.append(')');

      nl(sb, lmargin + (sm != null ? 12 : 11), "(StackMap ");
      if (sm != null) {
        for (int i = 0; i < sm.entries.length; i++) {
          sb.append('\n');
          StackMap_attribute.stack_map_frame smf =
              (StackMap_attribute.stack_map_frame) sm.entries[i];
          appendStackMapFrame(sb, lmargin + 17, smf, cf.constant_pool, max_locals);
        }
      }
      sb.append(")");
    }
    sb.append("))");
    return sb.toString();
  }