Ejemplo n.º 1
0
 protected void writeData(XDataOutput out) {
   writeLength(out, 2 + items.size() * 10);
   out.writeShort(items.size());
   for (Item item : items) {
     out.writeShort(item.startpc);
     out.writeShort(item.length);
     item.name.writeReference(out);
     item.signature.writeReference(out);
     out.writeShort(item.index);
   }
 }
Ejemplo n.º 2
0
  public void save(XDataOutput out) {
    newContext();
    try {
      out.writeInt(magic);
      out.writeShort(minor);
      out.writeShort(major);

      ConstantPool pool = ConstantPool.create(true);
      registerConstants(pool);

      // cannot write directly to target (out):
      // pool must be written first but it is not completed
      // until all fields/methods/attributes and stuff is done
      ByteArrayDataOutput tmpout = new ByteArrayDataOutput();

      flags.save(tmpout);
      writeConstantReference(classname, tmpout);
      writeConstantReference(superclass, tmpout);

      // interfaces
      tmpout.writeShort(sizeof(interfaces));
      for (ClassRef i : iterable(interfaces)) {
        i.writeReference(tmpout);
      }

      save(tmpout, fields);
      save(tmpout, methods);
      save(tmpout, attributes);

      // done, ready to write the pool & the rest
      pool.save(out);
      out.write(tmpout.toByteArray());

    } finally {
      closeContext();
    }
  }
Ejemplo n.º 3
0
 private void save(XDataOutput out, List<? extends Base> items) {
   out.writeShort(sizeof(items));
   for (Base item : iterable(items)) {
     item.save(out);
   }
 }
Ejemplo n.º 4
0
 public void save(XDataOutput out) {
   Log.debug("\t%s", this);
   out.writeByte(opcode);
   saveOperands(out);
 }