Exemple #1
0
 private Code readOther(
     int opcode,
     boolean wideBase,
     boolean wideRest,
     int offset,
     HashMap<Integer, Code.Label> labels)
     throws IOException {
   switch (opcode) {
     case Code.OPCODE_trycatch:
       {
         int operand = readBase(wideBase);
         int target = readTarget(wideRest, offset);
         Code.Label l = findLabel(target, labels);
         int nCatches = readRest(wideRest);
         ArrayList<Pair<Type, String>> catches = new ArrayList<Pair<Type, String>>();
         for (int i = 0; i != nCatches; ++i) {
           Type type = typePool[readRest(wideRest)];
           Code.Label handler = findLabel(readTarget(wideRest, offset), labels);
           catches.add(new Pair<Type, String>(type, handler.label));
         }
         return Code.TryCatch(operand, l.label, catches);
       }
     case Code.OPCODE_update:
       {
         int target = readBase(wideBase);
         int nOperands = readBase(wideBase) - 1;
         int operand = readBase(wideBase);
         int[] operands = new int[nOperands];
         for (int i = 0; i != nOperands; ++i) {
           operands[i] = readBase(wideBase);
         }
         Type beforeType = typePool[readRest(wideRest)];
         Type afterType = typePool[readRest(wideRest)];
         int nFields = readRest(wideRest);
         ArrayList<String> fields = new ArrayList<String>();
         for (int i = 0; i != nFields; ++i) {
           String field = stringPool[readRest(wideRest)];
           fields.add(field);
         }
         return Code.Update(beforeType, target, operand, operands, afterType, fields);
       }
   }
   throw new RuntimeException("unknown opcode encountered (" + opcode + ")");
 }