Package net.sf.rej.java

Examples of net.sf.rej.java.InstructionCopier


    this.oldPoolSize = this.cf.getPool().size();
    List<Instruction> list = new ArrayList<Instruction>();
    for (Instruction inst : this.newCode.getInstructions()) {
      list.add(inst);
    }
    InstructionCopier instructionCopier = new InstructionCopier();
    for (Instruction inst : this.newCode.getInstructions()) {
      if (inst instanceof Label) continue;
     
      Instruction copy = instructionCopier.copyInstruction(inst, this.newCode.createDecompilationContext().getConstantPool(), this.cf.getPool());
      this.addedInstructions.add(copy);
      int index = list.indexOf(inst);
      list.set(index, copy);
      List<Label> labels = inst.getLabels();
      List<Label> copyLabels = copy.getLabels();
View Full Code Here


              }
            }

            ConstantPool newPool = new ConstantPool();
            Code codeBlock = new Code(newPool);
            InstructionCopier instructionCopier = new InstructionCopier();
            for (EditorRow er : mdr.getCodeRows()) {
              if (er instanceof LabelRow)
                continue;
              CodeRow cr = (CodeRow) er;

              Instruction inst = cr.getInstruction();

              Instruction copy = instructionCopier
                  .copyInstruction(inst, cr
                      .getDecompilationContext()
                      .getConstantPool(), newPool);
             
              if (copy == null) {
                throw new AssertionError("Copied instruction is null for instruction: " + inst);
              }
              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++) {
                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();
View Full Code Here

TOP

Related Classes of net.sf.rej.java.InstructionCopier

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.