Package soot

Examples of soot.Value


  void copyLocals(){
    for(Unit u : m_outputUnits){
      List<ValueBox> boxes = u.getUseAndDefBoxes();
      for(ValueBox box : boxes){
        Value v = box.getValue();
        if(v instanceof Local == false)
          continue;
        Local local = (Local) v.clone();
        if(m_localMap.containsKey(local.toString()) == false){
          m_localMap.put(local.toString(), local);
          m_outputLocals.add(local);
        }
        local = m_localMap.get(local.toString());
View Full Code Here


    Iterator<Unit> iter = chain.iterator();
    while(iter.hasNext()){
      Unit unit = iter.next();
      List<ValueBox> vboxes = unit.getUseAndDefBoxes();
      for(ValueBox vbox : vboxes){
        Value value = vbox.getValue();
        if(value instanceof InvokeExpr == false)
          continue;
        InvokeExpr expr = (InvokeExpr) value;
        SootMethod method = expr.getMethod();
        if(methods.contains(method) == false)
View Full Code Here

      Unit curr = iter.next();
      if(curr instanceof AssignStmt == false)
        continue;
     
      AssignStmt assign = (AssignStmt) curr;
      Value lhs = assign.getLeftOp();
     
      if(lhs instanceof FieldRef == false)
        continue;
       
      FieldRef ref = (FieldRef) lhs;
View Full Code Here

  }
 
  /** Generates code for an if statement. */
  @Override
  public Void visitIfStmt(IfStmt nd) {
    Value cond = ExprCodeGenerator.generate(nd.getExpr(), fcg);
    NopStmt join = j.newNopStmt();
    units.add(j.newIfStmt(j.newEqExpr(cond, IntConstant.v(0)), join));
    nd.getThen().accept(this);
    if(nd.hasElse()) {
      NopStmt els = join;
View Full Code Here

    label1:
     */
    NopStmt label0 = j.newNopStmt();
    this.units.add(label0);
   
    Value cond = ExprCodeGenerator.generate(nd.getExpr(), this.fcg);
    NopStmt label1 = j.newNopStmt();
    this.units.add(
        j.newIfStmt(
            j.newEqExpr(cond, IntConstant.v(0)),
            label1
View Full Code Here

 
  /** Generate code for an assignment. */
  @Override
  public Value visitAssignment(Assignment nd) {
    // note that the left hand side should _not_ be wrapped!
    Value lhs = nd.getLHS().accept(this),
        rhs = wrap(nd.getRHS().accept(this));
    units.add(Jimple.v().newAssignStmt(lhs, rhs));
    return rhs;
  }
View Full Code Here

  /** Generate code for an integer literal. */
  @Override
  public Value visitIntLiteral(IntLiteral nd) {
    /* DONE: return something meaningful here */
    //Value value = ExprCodeGenerator.generate(nd, this.fcg); // recursive, stack overflow
    Value value = IntConstant.v( // no need wrap
            nd.getValue().intValue()
          );
    // why not units.add(...)? because only add statement, not expression
    return value;
  }
View Full Code Here

 
  /** Generate code for a string literal. */
  @Override
  public Value visitStringLiteral(StringLiteral nd) {
    /* DONE: return something meaningful here */
    Value value = StringConstant.v( // no need wrap
            nd.getValue()
          );
    return value;
  }
View Full Code Here

  @Override
  public Value visitBooleanLiteral(BooleanLiteral nd) {
    /* DONE: return something meaningful here (hint: translate 'true' to integer
     *       constant 1, 'false' to integer constant 0) */
    Boolean truthBoolean = nd.getValue();
    Value value;
    if(truthBoolean) {
      value = IntConstant.v(1); // no need wrap
    }
    else {
      value = IntConstant.v(0); // no need wrap
View Full Code Here

  /** Generate code for an array literal. */
  @Override
  public Value visitArrayLiteral(ArrayLiteral nd) {
    Type elttp = SootTypeUtil.getSootType(nd.getElement(0).type());
    // create a new array with the appropriate number of elements
    Value array = wrap(Jimple.v().newNewArrayExpr(elttp, IntConstant.v(nd.getNumElement())));
    for(int i=0;i<nd.getNumElement();++i) {
      // generate code to store the individual expressions into the elements of the array
      Value elt = wrap(nd.getElement(i).accept(this));
      units.add(Jimple.v().newAssignStmt(Jimple.v().newArrayRef(array, IntConstant.v(i)), elt));
    }
    return array;
  }
View Full Code Here

TOP

Related Classes of soot.Value

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.