Package org.candle.decompiler.intermediate.expression

Examples of org.candle.decompiler.intermediate.expression.Expression


    Type[] types = instruction.getArgumentTypes(context.getMethodGen().getConstantPool());

    final List<Expression> parameters = new ArrayList<Expression>(types.length);
    for(int i=0, j=types.length; i<j; i++)
    {
      Expression param = context.getExpressions().pop();
      LOG.debug("Parameter: "+param);
      parameters.add(param);
    }
   
    //now, get the target that we are calling the method on.
    Expression target = context.getExpressions().pop();
   
    //collect the method name we are calling.
    String methodName = instruction.getMethodName(context.getMethodGen().getConstantPool());
   
   
    MethodInvocation methodInvocation = null;
    //create the expression..
    if(StringUtils.equals(Constants.CONSTRUCTOR_NAME, methodName)) {
      LOG.debug(target.getClass());
      //pop the duplicate..
      //TODO: Figure out why the dup / new causes issues.
      if(target instanceof NewInstance) {
        //get rid of this.
        context.getExpressions().pop();
View Full Code Here


    Type[] types = instruction.getArgumentTypes(context.getMethodGen().getConstantPool());
   
    final List<Expression> parameters = new ArrayList<Expression>(types.length);
    for(int i=0, j=types.length; i<j; i++)
    {
      Expression param = context.getExpressions().pop();
      LOG.debug("Parameter: "+param);
     
      parameters.add(param);
    }
   
View Full Code Here

    Type[] types = instruction.getArgumentTypes(cpg);
   
    final List<Expression> parameters = new ArrayList<Expression>(types.length);
    for(int i=0, j=types.length; i<j; i++
    {
      Expression param = context.getExpressions().pop();
      LOG.debug("Parameter: "+param);
      parameters.add(param);
    }
   
    //collect the method name we are calling.
    String methodName = instruction.getMethodName(context.getMethodGen().getConstantPool());
   
    Expression left = context.getExpressions().pop();
   
    //create the expression..
    MethodInvocation methodInvocation = new MethodInvocation(context.getCurrentInstruction(), left, methodName, parameters);
   
    Type returned = instruction.getReturnType(context.getMethodGen().getConstantPool());
View Full Code Here

    //collect all parameters from the stack.

    final List<Expression> parameters = new ArrayList<Expression>(nparams);
    for(int i=0; i<nparams; i++)
    {
      Expression param = context.getExpressions().pop();
      LOG.debug("Parameter: "+param);
      parameters.add(param);
    }
   
    //now, get the target that we are calling the method on.
    Expression target = context.getExpressions().pop();
   
    //collect the method name we are calling.
    String methodName = instruction.getMethodName(context.getMethodGen().getConstantPool());
   
    //create the expression..
View Full Code Here

  public void visitDSTORE(DSTORE instruction) {
    //fall to store instruction.
  }

  public void visitStoreInstruction(StoreInstruction instruction) {
    Expression right = this.context.getExpressions().pop();
    Type type = instruction.getType(context.getMethodGen().getConstantPool());
   
    //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);
   
    Expression left = null;
    if(declared) {
      left = assignment;
    }
    else {
      //if it is currently not declared... create the declaration.
View Full Code Here

  public void visitArithmeticInstruction(ArithmeticInstruction instruction) {
    //fall through to instruction types
  }

  protected void processArithmeticTwoStackOperations(ArithmeticType type) {
    Expression right = context.getExpressions().pop();
    Expression left = context.getExpressions().pop();
   
    Expression addExp = new Arithmetic(context.getCurrentInstruction(), left, right, type);
    context.getExpressions().push(addExp);
  }
View Full Code Here

 
  //negate operations
  protected void processNegation(Type type) {
    //negation is the same as multiplying by negative 1; more readable.
    //push a negative 1 to the stack.
    Expression negativeOne = new Resolved(context.getCurrentInstruction(), type, "-1");
    context.getExpressions().push(negativeOne);
   
    processArithmeticTwoStackOperations(ArithmeticType.MULTIPLY);
  }
View Full Code Here

  public void visitArrayInstruction(ArrayInstruction instruction) {
    // TODO Auto-generated method stub
  }
 
  protected void processArrayStore() {
    Expression value = context.getExpressions().pop();
    Expression arrayPosition = context.getExpressions().pop();
    Expression arrayReference = context.getExpressions().pop();
   
    ArrayAccess arrayPositionReference = new ArrayAccess(context.getCurrentInstruction(), arrayReference, arrayPosition);
    Assignment assignment = new Assignment(context.getCurrentInstruction(), arrayPositionReference, value);
   
    StatementIntermediate si = new StatementIntermediate(context.getCurrentInstruction(), assignment);
View Full Code Here

    context.pushIntermediateToInstruction(si);
  }

  //array length instruction
  public void visitARRAYLENGTH(ARRAYLENGTH instruction) {
    Expression target = context.getExpressions().pop();
    ArrayLength arrayLength = new ArrayLength(context.getCurrentInstruction(), target);
   
    context.getExpressions().push(arrayLength);
  }
View Full Code Here

   * Decompiles "new primitive array" operations.
   */
  public void visitNEWARRAY(NEWARRAY instruction) {
    //first, check to see if the next instruction is a DUP.  If so,
    //this is probably a constant array value.
    Expression count = context.getExpressions().pop();
    ArrayCreation nai = null;
   
    if(context.getCurrentInstruction().getNext().getInstruction() instanceof DUP) {
      nai = new NewConstantArrayInstance(context.getCurrentInstruction(), instruction.getType(), count);
    }
View Full Code Here

TOP

Related Classes of org.candle.decompiler.intermediate.expression.Expression

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.