Package net.sf.rej.java.instruction

Examples of net.sf.rej.java.instruction.Label


    int startPc = parser.getShortAsInt();
    int length = parser.getShortAsInt();
    this.nameIndex = parser.getShortAsInt();
    this.descriptorIndex = parser.getShortAsInt();
    this.index = parser.getShortAsInt();
    this.startLabel = new Label(startPc, getName() + "_start");
    this.endLabel = new Label(startPc + length, getName() + "_end");
  }
View Full Code Here


      int index = list.indexOf(inst);
      list.set(index, copy);
      List<Label> labels = inst.getLabels();
      List<Label> copyLabels = copy.getLabels();
      for (int i=0; i < labels.size(); i++) {
        Label label = labels.get(i);
        int labelIndex = list.indexOf(label);
        if (labelIndex != -1) {
          list.set(labelIndex, copyLabels.get(i));
        } else {
          list.add(copyLabels.get(i));
View Full Code Here

        int endPc = parser.getShortAsInt();
        int handlerPc = parser.getShortAsInt();
        this.catchType = parser.getShortAsInt();

        // create the labels
        this.startLabel = new Label(startPc, "try-block_start(" + getType()
                + ")_" + startPc);
        this.endLabel = new Label(endPc, "try-block_end(" + getType() + ")_"
                + endPc);
        this.handlerLabel = new Label(handlerPc, "exception_handler("
                + getType() + ")_" + handlerPc);
    }
View Full Code Here

              int index = destinationPool.optionalAddMethodRef(ri.getClassName(), ri.getTargetName(), ri.getMethodType());
            copyParams.addValue(index);
              break;
            }
            case TYPE_LABEL:
              Label label = (Label) params.getObject(i);
              copyParams.addValue(new Label(label.getPosition()));
              break;
            case TYPE_SWITCH:
              // TODO: Switch
              break;
            }
View Full Code Here

                           ConstantPoolInfo cpi = pool.get(index);
                           renderConstant(sd, cpi, index);
                           break;
                        }
                        case TYPE_LABEL: {
                            Label label = (Label) params.getObject(i);
                            sd.drawDefault(" " + label.getId());
                            break;
                        }
                        case TYPE_SWITCH: {
                          @SuppressWarnings("unchecked")
                            Map<Integer, Label> offsets = (Map<Integer, Label>) params.getObject(i);
View Full Code Here

              List<Label> copyLabels = copy.getLabels();
              for (int i = 0; i < labels.size(); i++) {
                if (copyLabels.get(i) == null) {
                  throw new AssertionError("Copied label is null for instruction: " + inst + " : " + copyLabels);
                }
                Label label = labels.get(i);
                int labelIndex = list.indexOf(label);
                if (labelIndex != -1) {
                  list.set(labelIndex, copyLabels.get(i));
                } else {
                  list.add(copyLabels.get(i));
                }
              }

            }
            codeBlock.add(0, list);
            transferrable.setCode(codeBlock);
          }
          transferrable.setExceptions(exceptionNames);
          transferables.add(transferrable);
        }

      } else if (obj instanceof FieldDefRow) {
        FieldDefRow fdr = (FieldDefRow) obj;
        Field field = fdr.getField();
        // TODO: Attributes are not being copied

        TransferrableField transferrable = new TransferrableField();
        transferrable.setFieldName(field.getName());
        transferrable.setDescriptor(field.getDescriptor());
        transferrable.setAccessFlags(field.getAccessFlags());
        transferables.add(transferrable);
      } else if (obj instanceof CodeRow || obj instanceof LabelRow) {
        code.add((EditorRow) obj);
      }
    }

    if (!transferables.isEmpty()) {
      return transferables;
    } else {
      List<Instruction> list = new ArrayList<Instruction>();
      for (EditorRow er : code) {
        if (er instanceof CodeRow) {
          list.add(((CodeRow) er).getInstruction());
        } else if (er instanceof LabelRow) {
          list.add(((LabelRow) er).getLabel());
        } else {
          throw new AssertionError(
              "Object of invalid class (not CodeRow and not LabelRow) in list: "
                  + er.getClass());
        }
      }

      ConstantPool newPool = new ConstantPool();
      Code codeBlock = new Code(newPool);
      InstructionCopier instructionCopier = new InstructionCopier();
      for (EditorRow er : code) {
        if (er instanceof LabelRow)
          continue;
        CodeRow cr = (CodeRow) er;
        Instruction inst = cr.getInstruction();

        Instruction copy = instructionCopier.copyInstruction(inst, cr
            .getDecompilationContext().getConstantPool(), newPool);
        int index = list.indexOf(inst);
        list.set(index, copy);
        List<Label> labels = inst.getLabels();
        List<Label> copyLabels = copy.getLabels();
        for (int i = 0; i < labels.size(); i++) {
          Label label = labels.get(i);
          int labelIndex = list.indexOf(label);
          if (labelIndex != -1) {
            list.set(labelIndex, copyLabels.get(i));
          } else {
            list.add(copyLabels.get(i));
View Full Code Here

TOP

Related Classes of net.sf.rej.java.instruction.Label

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.