Package org.candle.decompiler.intermediate

Examples of org.candle.decompiler.intermediate.IntermediateVariable


 
  public void visitLoadInstruction(LoadInstruction instruction) {
    int index = instruction.getIndex();
   
    if(index >=0) {
      IntermediateVariable localVar = context.getVariableResolver().getLocalVariable(index, context.getCurrentInstruction().getPosition());

      if(localVar == null) {
        LOG.debug("Did not find local variable: "+index + " for position: "+context.getCurrentInstruction().getPosition());
      }
      Variable variable = null;
      if(localVar == null) {
        //probably need to create a variable for enhanced loops...
        Type type = instruction.getType(context.getMethodGen().getConstantPool());
        localVar = context.getVariableResolver().addLocalVariable(index, context.getCurrentInstruction(), type);
       
        variable = new GeneratedVariable(context.getCurrentInstruction(), localVar.getType(), localVar.getName());
      }
      else {
        variable = new Variable(context.getCurrentInstruction(), localVar.getType(), localVar.getName());
      }
     
      //Variable variable = new Variable(context.getCurrentInstruction(), localVar.getType(), localVar.getName());
     
      context.getExpressions().push(variable);
View Full Code Here


 
  public void visitIINC(IINC instruction) {
    //increment variable.
    int index = instruction.getIndex();
   
    IntermediateVariable iv = context.getVariableResolver().getLocalVariable(index, context.getCurrentInstruction().getPosition());
   
    Variable variable = null;
    if(iv == null) {
      //generate IV.
      iv = context.getVariableResolver().addLocalVariable(index, context.getCurrentInstruction(), instruction.getType(context.getMethodGen().getConstantPool()));
      variable = new GeneratedVariable(context.getCurrentInstruction(), iv.getType(), iv.getName());
    }
    else {
      variable = new Variable(context.getCurrentInstruction(), iv.getType(), iv.getName());
    }
   
    //now, how much does it increment by?
    int incrementBy = instruction.getIncrement();
   
    StringBuilder incrementerBuilder = new StringBuilder(iv.getName());
    if(incrementBy == 1) {
      incrementerBuilder.append("++");
    }
    else if(incrementBy == -1) {
      incrementerBuilder.append("--");
View Full Code Here

    //first, check to see whether the variable currently has been declared.
    //this would be the case if we don't get null when looking up the local variable.
    int pc = context.getCurrentInstruction().getPosition();
    int lvtIndex = instruction.getIndex();
   
    IntermediateVariable iv = context.getVariableResolver().getLocalVariable(lvtIndex, pc);

    //if the variable is not null, it is declared.
    boolean declared = (iv != null);
   
    Variable variable = null;
    if(!declared) {
      //look it up from the next phase code.
      pc = this.context.getCurrentInstruction().getNext().getPosition();
      iv = context.getVariableResolver().getLocalVariable(lvtIndex, pc);

      if(iv == null) {
        //probably need to create a variable for enhanced loops...
        LOG.debug("Adding index: "+instruction.getIndex() + " as: "+type);
       
        //try and resolve the type for the variable from the right hand side.
        if(type == Type.OBJECT) {
          if(right instanceof TypedExpression) {
            type = ((TypedExpression) right).getType();
          }
        }
       
        //generate variable name...
        iv = context.getVariableResolver().addLocalVariable(instruction.getIndex(), context.getCurrentInstruction(), type);
        variable = new GeneratedVariable(context.getCurrentInstruction(), iv.getType(), iv.getName());
      }
    }
   
    //create the variable.
    if(variable == null) {
      variable = new Variable(context.getCurrentInstruction(), iv.getType(), iv.getName());
    }
   
    //create the assignment.
    Assignment assignment = new Assignment(context.getCurrentInstruction(), variable, right);
   
View Full Code Here

TOP

Related Classes of org.candle.decompiler.intermediate.IntermediateVariable

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.