Beispiel #1
0
 public void writeU32(long v) {
   if (v < 128 && v > -1) {
     resize(1);
     bytecodes[size++] = (byte) v;
   } else if (v < 16384 && v > -1) {
     resize(2);
     bytecodes[size++] = (byte) ((v & 0x7F) | 0x80);
     bytecodes[size++] = (byte) ((v >> 7) & 0x7F);
   } else if (v < 2097152 && v > -1) {
     resize(3);
     bytecodes[size++] = (byte) ((v & 0x7F) | 0x80);
     bytecodes[size++] = (byte) ((v >> 7) | 0x80);
     bytecodes[size++] = (byte) ((v >> 14) & 0x7F);
   } else if (v < 268435456 && v > -1) {
     resize(4);
     bytecodes[size++] = (byte) ((v & 0x7F) | 0x80);
     bytecodes[size++] = (byte) (v >> 7 | 0x80);
     bytecodes[size++] = (byte) (v >> 14 | 0x80);
     bytecodes[size++] = (byte) ((v >> 21) & 0x7F);
   } else {
     resize(5);
     bytecodes[size++] = (byte) ((v & 0x7F) | 0x80);
     bytecodes[size++] = (byte) (v >> 7 | 0x80);
     bytecodes[size++] = (byte) (v >> 14 | 0x80);
     bytecodes[size++] = (byte) (v >> 21 | 0x80);
     bytecodes[size++] = (byte) ((v >> 28) & 0x0F);
   }
 }
Beispiel #2
0
 public void writeDouble(double v) {
   resize(8);
   // todo switch for endianness on Mac
   long bits = Double.doubleToLongBits(v);
   bytecodes[size++] = (byte) bits;
   bytecodes[size++] = (byte) (bits >> 8);
   bytecodes[size++] = (byte) (bits >> 16);
   bytecodes[size++] = (byte) (bits >> 24);
   bytecodes[size++] = (byte) (bits >> 32);
   bytecodes[size++] = (byte) (bits >> 40);
   bytecodes[size++] = (byte) (bits >> 48);
   bytecodes[size++] = (byte) (bits >> 56);
 }
Beispiel #3
0
 public void writeU16(int v) {
   resize(2);
   bytecodes[size++] = (byte) v;
   bytecodes[size++] = (byte) (v >> 8);
 }
Beispiel #4
0
 public void writeU8(int v) {
   resize(1);
   bytecodes[size++] = (byte) v;
 }
Beispiel #5
0
 /**
  * @param start - inclusive
  * @param end - exclusive
  */
 public void writeBytes(BytecodeBuffer b, int start, int end) {
   resize(end - start);
   for (int i = start; i < end; i++) {
     bytecodes[size++] = b.bytecodes[i];
   }
 }
Beispiel #6
0
 public void writeU24(int v) {
   resize(3);
   bytecodes[size++] = (byte) v;
   bytecodes[size++] = (byte) (v >> 8);
   bytecodes[size++] = (byte) (v >> 16);
 }