Exemple #1
0
  /** Collect all constants into the constant table */
  public void collect(Environment env, MemberDefinition field, ConstantPool tab) {
    // Collect constants for arguments only
    // if a local variable table is generated
    if ((field != null) && env.debug_vars()) {
      if (field.getArguments() != null) {
        for (Enumeration e = field.getArguments().elements(); e.hasMoreElements(); ) {
          MemberDefinition f = (MemberDefinition) e.nextElement();
          tab.put(f.getName().toString());
          tab.put(f.getType().getTypeSignature());
        }
      }
    }

    // Collect constants from the instructions
    for (Instruction inst = first; inst != null; inst = inst.next) {
      inst.collect(tab);
    }
  }
Exemple #2
0
 /** Write the exceptions table */
 void writeExceptions(
     Environment env, DataOutputStream out, ConstantPool tab, Instruction first, Instruction last)
     throws IOException {
   for (Instruction inst = first; inst != last.next; inst = inst.next) {
     if (inst.opc == opc_try) {
       TryData td = (TryData) inst.value;
       writeExceptions(env, out, tab, inst.next, td.getEndLabel());
       for (Enumeration e = td.catches.elements(); e.hasMoreElements(); ) {
         CatchData cd = (CatchData) e.nextElement();
         // System.out.println("EXCEPTION: " + env.getSource() + ", pc=" + inst.pc + ", end=" +
         // td.getEndLabel().pc + ", hdl=" + cd.getLabel().pc + ", tp=" + cd.getType());
         out.writeShort(inst.pc);
         out.writeShort(td.getEndLabel().pc);
         out.writeShort(cd.getLabel().pc);
         if (cd.getType() != null) {
           out.writeShort(tab.index(cd.getType()));
         } else {
           out.writeShort(0);
         }
       }
       inst = td.getEndLabel();
     }
   }
 }