Package net.sf.rej.java.instruction

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


    }
  }

  @Override
  public void processInstruction(IterationContext sc, Instruction instruction) {
    Parameters params = instruction.getParameters();
    for (int i = 0; i < params.getCount(); i++) {
      if (params.getType(i) == ParameterType.TYPE_CONSTANT_POOL_FIELD_REF) {
        ConstantPoolInfo cpi = sc.getDc().getConstantPool().get(
            params.getInt(i));
        RefInfo ri = (RefInfo) cpi;
        boolean classNamesMatch = ri.getClassName().equals(className);

        if (classNamesMatch) {
          String instructionLine = instruction.getMnemonic() + " "
              + instruction.getParameters().getString(sc.getDc());
          Link link = new Link();
          link.setText("Field Ref : " + sc.getCf().getFullClassName() + "." + sc.getMethod().getName() + " / " + instructionLine);
          link.setAnchor(Link.ANCHOR_METHOD_CODE);
          link.setProject(sc.getProject());
          link.setFile(sc.getFilename());
          link.setTab(Tab.EDITOR);
          link.setMethod(sc.getMethod());
          link.setPosition(sc.getDc().getPosition());

          MainWindow.getInstance().getSearchTab().addResult(link);
          this.resultCount++;
        }

      } else if (params.getType(i) == ParameterType.TYPE_CONSTANT_POOL_METHOD_REF) {
        ConstantPoolInfo cpi = sc.getDc().getConstantPool().get(
            params.getInt(i));
        RefInfo ri = (RefInfo) cpi;
        boolean classNamesMatch = ri.getClassName().equals(className);

        if (classNamesMatch) {
          String instructionLine = instruction.getMnemonic() + " "
              + instruction.getParameters().getString(sc.getDc());
          Link link = new Link();
          link.setText("Method Call : " + sc.getCf().getFullClassName() + "."  + sc.getMethod().getName() + " / " + instructionLine);
          link.setAnchor(Link.ANCHOR_METHOD_CODE);
          link.setProject(sc.getProject());
          link.setFile(sc.getFilename());
          link.setTab(Tab.EDITOR);
          link.setMethod(sc.getMethod());
          link.setPosition(sc.getDc().getPosition());
          MainWindow.getInstance().getSearchTab().addResult(link);
          this.resultCount++;
        }

      } else if (params.getType(i) == ParameterType.TYPE_CONSTANT_POOL_CLASS) {
        ConstantPoolInfo cpi = sc.getDc().getConstantPool().get(
            params.getInt(i));
        ClassInfo ci = (ClassInfo) cpi;
        boolean classNamesMatch = ci.getName().equals(className);

        if (classNamesMatch) {
          String instructionLine = instruction.getMnemonic() + " "
View Full Code Here


        this.paramIndex = index;
        this.value = value;
    }

    public void execute() {
        Parameters params = this.instruction.getParameters();
        this.originalValue = params.getObject(this.paramIndex);
        params.setValue(this.paramIndex, this.value);
        this.instruction.setParameters(params);
    }
View Full Code Here

        params.setValue(this.paramIndex, this.value);
        this.instruction.setParameters(params);
    }

    public void undo() {
        Parameters params = this.instruction.getParameters();
        params.setValue(this.paramIndex, this.originalValue);
        this.instruction.setParameters(params);
    }
View Full Code Here

        if (index == -1) {
            this.createdRefIndex = this.pool.optionalAddFieldRef(this.className, this.fieldName, this.typeName);
            index = this.createdRefIndex;
        }

        Parameters params = this.instruction.getParameters();
        this.originalParamValue = params.getInt(this.paramIndex);
        params.setValue(this.paramIndex, Integer.valueOf(index));
        this.instruction.setParameters(params);
    }
View Full Code Here

        if (this.createdNameAndTypeIndex != -1) {
            this.pool.removeLast();
        }

        Parameters params = this.instruction.getParameters();
        params.setValue(this.paramIndex, Integer.valueOf(this.originalParamValue));
        this.instruction.setParameters(params);
    }
View Full Code Here

        if (index == -1) {
            this.createdRefIndex = this.pool.optionalAddMethodRef(this.className, this.methodName, this.typeName);
            index = this.createdRefIndex;
        }

        Parameters params = this.instruction.getParameters();
        this.originalParamValue = params.getInt(this.paramIndex);
        params.setValue(this.paramIndex, Integer.valueOf(index));
        this.instruction.setParameters(params);
    }
View Full Code Here

        if (this.createdNameAndTypeIndex != -1) {
            this.pool.removeLast();
        }

        Parameters params = this.instruction.getParameters();
        params.setValue(this.paramIndex, Integer.valueOf(this.originalParamValue));
        this.instruction.setParameters(params);
    }
View Full Code Here

        this.cp = cp;
    }

    public void execute() {
        this.createdClassRef = this.cp.forceAddClassRef(this.className);
        Parameters params = this.instruction.getParameters();
        this.originalParamValue = params.getInt(this.paramIndex);
        params.setValue(this.paramIndex, Integer.valueOf(this.createdClassRef));
        this.instruction.setParameters(params);
    }
View Full Code Here

        params.setValue(this.paramIndex, Integer.valueOf(this.createdClassRef));
        this.instruction.setParameters(params);
    }

    public void undo() {
        Parameters params = this.instruction.getParameters();
        params.setValue(this.paramIndex, Integer.valueOf(this.originalParamValue));
        this.instruction.setParameters(params);
        this.cp.removeLast();
    }
View Full Code Here

import net.sf.rej.java.instruction.Parameters;

public class InstructionCopier {
  public Instruction copyInstruction(Instruction inst, ConstantPool sourcePool, ConstantPool destinationPool) {
    Instruction copy = InstructionSet.getInstance().getInstruction(inst.getOpcode());
    Parameters params = inst.getParameters();
    Parameters copyParams = new Parameters();
    for(int i=0; i < params.getCount(); i++) {
          copyParams.addParam(params.getType(i));
            switch (params.getType(i)) {
            case TYPE_ARRAYTYPE:
              copyParams.addValue(params.getObject(i));
              break;
            case TYPE_LOCAL_VARIABLE:
            case TYPE_LOCAL_VARIABLE_READONLY:
            case TYPE_LOCAL_VARIABLE_WIDE:
              // TODO: should be done differently?
              copyParams.addValue(params.getObject(i));
              break;
            case TYPE_CONSTANT_WIDE:
            case TYPE_CONSTANT_READONLY:
            case TYPE_CONSTANT:
              copyParams.addValue(params.getObject(i));
              break;
            case TYPE_CONSTANT_POOL_CLASS: {
              ClassInfo ci = (ClassInfo) sourcePool.get(params.getInt(i));
                int index = destinationPool.optionalAddClassRef(ci.getName());
                copyParams.addValue(index);
                break;
            }
            case TYPE_CONSTANT_POOL_CONSTANT: {
              ConstantPoolInfo cpi = sourcePool.get(params.getInt(i));
              switch (cpi.getType()) {
              case ConstantPoolInfo.DOUBLE: {
                DoubleInfo di = (DoubleInfo)cpi;
                DoubleInfo diCopy = new DoubleInfo(di.getHighBytes(), di.getLowBytes(), destinationPool);
                int index = destinationPool.optionalAdd(diCopy);
                copyParams.addValue(index);
                break;
              }
              case ConstantPoolInfo.FLOAT: {
                FloatInfo fi = (FloatInfo)cpi;
                FloatInfo fiCopy = new FloatInfo(fi.getBytes(), destinationPool);
                int index = destinationPool.optionalAdd(fiCopy);
                copyParams.addValue(index);
                break;                   
              }
              case ConstantPoolInfo.INTEGER: {
                IntegerInfo ii = (IntegerInfo)cpi;
                IntegerInfo iiCopy = new IntegerInfo(ii.getIntValue(), destinationPool);
                int index = destinationPool.optionalAdd(iiCopy);
                copyParams.addValue(index);
                break;                                       
              }
              case ConstantPoolInfo.LONG: {
                LongInfo li = (LongInfo)cpi;
                LongInfo liCopy = new LongInfo(li.getLongValue(), destinationPool);
                int index = destinationPool.optionalAdd(liCopy);
                copyParams.addValue(index);
                break;                     
              }
              case ConstantPoolInfo.STRING: {
                StringInfo si = (StringInfo)cpi;
                int index = destinationPool.optionalAddString(si.getString());
                copyParams.addValue(index);
                break;                                       
               
              }
              }
             
              break;
            }
            case TYPE_CONSTANT_POOL_FIELD_REF: {
              RefInfo ri = (RefInfo) sourcePool.get(params.getInt(i));
              int index = destinationPool.optionalAddFieldRef(ri.getClassName(), ri.getTargetName(), ri.getMethodType());
            copyParams.addValue(index);
              break;
            }
            case TYPE_CONSTANT_POOL_METHOD_REF: {
              RefInfo ri = (RefInfo) sourcePool.get(params.getInt(i));
              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

TOP

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

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.