Package soot.jimple

Examples of soot.jimple.Stmt


  @Override
  protected void flowThrough(
      Map<Local, ArrayConstantInfo> src,
      Unit unit,
      Map<Local, ArrayConstantInfo> dest) {
    Stmt stmt = (Stmt)unit;
    final Set<Local> dead = new HashSet<Local>();
    srcloop:
    for (Local local : src.keySet()) {
      ArrayConstantInfo info = src.get(local);
      if (info.contents == null) {
          dead.add(local);
        continue;
      }
      ValueBox allowedBox = null; // the only place the statement is allowed to reference an array without breaking it
      boolean affected = false;
      if (stmt instanceof DefinitionStmt) {
        DefinitionStmt def = (DefinitionStmt)stmt;
        if (def.getLeftOp() instanceof ArrayRef) {
          ArrayRef array = (ArrayRef)def.getLeftOp();
          allowedBox = array.getBaseBox();
          if (array.getBase() == local) {
            // assignment into interesting array
            if (array.getIndex() instanceof IntConstant) {
              IntConstant index = (IntConstant)array.getIndex();
              if (index.value >= 0 && index.value < info.contents.length) {
                ArrayConstantInfo out = info.clone();
                out.contents[index.value] = def.getRightOpBox();
                dest.put(local, out);
              } else {
                // definitely ArrayIndexOutOfBoundsException
                // let's just map it to BOTTOM by not adding the array
                dest.clear();
                return;
              }
            } else {
              // unknown index, information is lost
              dead.add(local);
            }
            affected = true;
          }
        }
        else if (def.getLeftOp() instanceof Local) {
            for (int i=0; i<info.contents.length; i++) {
                if (info.contents[i] == def.getLeftOp()) {
                    dead.add(local);
                    continue srcloop;
                }
            }
        }
      }
      if (!affected) {
        dest.put(local, src.get(local));
      }
      for (ValueBox used : stmt.getUseBoxes()) {
        if (used.getValue() == local && used != allowedBox) {
          dead.add(local);
          break;
        }
      }
View Full Code Here


        Set<SootClass> webapps = new HashSet<SootClass>();
        ExceptionalUnitGraph graph = new ExceptionalUnitGraph(
                initMethod.retrieveActiveBody());
        for (Unit aGraph : graph) {
            assert aGraph instanceof Stmt;
            Stmt st = (Stmt) aGraph;
            if (st instanceof JAssignStmt) {
                JAssignStmt jAssignStmt = (JAssignStmt) st;
                Value right = jAssignStmt.getRightOp();
                if (right instanceof JNewExpr) {
                    JNewExpr newInstance = (JNewExpr) right;
View Full Code Here

            CompleteUnitGraph cug = new CompleteUnitGraph(
                    calledMethod.retrieveActiveBody());
            // check every statement for a next() invocation
            for (Unit aCug : cug) {
                assert aCug instanceof Stmt;
                final Stmt stmt = (Stmt) aCug;
                if (stmt.containsInvokeExpr()) {
                    if (isNext(stmt.getInvokeExpr().getMethod())) {
                        return true;
                    }
                }
            }
        }
View Full Code Here

                SootMethod sm = (SootMethod) mi.next();
                if (sm.isConcrete()) {
                    CompleteUnitGraph cug = new CompleteUnitGraph(sm.retrieveActiveBody());
                    Iterator si = cug.iterator();
                    while (si.hasNext()) {
                        Stmt stmt = (Stmt) si.next();
                        if (stmt.containsInvokeExpr()) {
                            InvokeExpr expr = stmt.getInvokeExpr();
                            if (expr.getMethodRef().getSignature().equals(sig)) {
                                ValueBox box = expr.getArgBox(argnum);
                                list.add(box);
                            }
                        }
View Full Code Here

        LiveLocals liveness = new SimpleLiveLocals(exceptionalFlow);
        LocalDefs definitions = new SmartLocalDefs(exceptionalFlow, liveness);
       
        // translate each statement in isolation
        for (Unit unit : body.getUnits()) {
          Stmt stmt = (Stmt) unit;
          translateStmt(stmt);
        }
   
    // create intermediate Catch statements for every catch block
    for (Trap trap : body.getTraps()) {
      Catch ct = new Catch();
      method.addStatement(ct);
     
      // remember the Catch statement associated with the trap
      catchers.put(trap, ct);
     
      // add the catch block as successor
      ct.addSucc(translations.get(trap.getHandlerUnit()).getFirst());
    }
       
        // connect according to normal flow
        AssertionContext assertionContext = new AssertionContext(jt, definitions, translations, sootMethod);
        BriefUnitGraph normalFlow = new BriefUnitGraph(body);
        for (Unit stmt : body.getUnits()) {
            Statement tail = translations.get(stmt).getLast();
           
            if (stmt instanceof IfStmt) {
                // branching statement: link assertion in-between its successors
                IfStmt ifstmt = (IfStmt)stmt;
               
                Stmt trueSuccessor = ifstmt.getTarget();
                Stmt falseSuccessor = (Stmt)body.getUnits().getSuccOf(ifstmt);
                AssertionBranches assertions = assertionCreator.createAssertions(ifstmt, assertionContext);
               
                tail.addSucc(assertions.getWhenFalse().getFirst());
                tail.addSucc(assertions.getWhenTrue().getFirst());
               
                assertions.getWhenFalse().getLast().addSucc(translations.get(falseSuccessor).getFirst());
                assertions.getWhenTrue().getLast().addSucc(translations.get(trueSuccessor).getFirst());
            }
            else if (stmt instanceof LookupSwitchStmt) {
              LookupSwitchStmt sw = (LookupSwitchStmt)stmt;
             
              // add cases
              List<Integer> values = new ArrayList<Integer>();
              for (int i=0; i<sw.getTargetCount(); i++) {
                Stmt succ = (Stmt)sw.getTarget(i);
                AssertionBranch assertion = assertionCreator.createSwitchAssertions(sw.getKeyBox(), sw.getLookupValue(i), sw, assertionContext);
               
                tail.addSucc(assertion.getFirst());
                assertion.getLast().addSucc(translations.get(succ).getFirst());
               
View Full Code Here

  @Override
  protected void flowThrough(Set<Local> in, Unit node, Set<Local> out) {
    out.clear();
    out.addAll(in);
   
    Stmt stmt = (Stmt)node;
    if (!(stmt instanceof DefinitionStmt)) {
      return;
    }
   
    DefinitionStmt def = (DefinitionStmt)stmt;
View Full Code Here

            while (mi.hasNext()) {
                SootMethod sm = (SootMethod) mi.next();
                if (sm.isConcrete()) {
                   
                    for (Unit unit : sm.getActiveBody().getUnits()) {
                        Stmt stmt = (Stmt) unit;
                        if (stmt.containsInvokeExpr()) {
                            InvokeExpr expr = stmt.getInvokeExpr();
                            if (expr.getMethod().getSignature().equals("<dk.brics.string.runtime.Strings: java.lang.String analyze(java.lang.String,java.lang.String)>")) {
                                ValueBox spot = expr.getArgBox(0);
                                Automaton expected = getRegExp(expr).toAutomaton(bindings);
                                hotspots.add(new RuntimeHotspot(spot, expected, HotspotKind.ANALYZE));
                            } else
View Full Code Here

            SootMethod method = queue.removeFirst();
            final Body body = method.retrieveActiveBody();
            CompleteUnitGraph cug = new CompleteUnitGraph(body);
            for (Unit aCug : cug) {
                assert aCug instanceof Stmt;
                Stmt st = (Stmt) aCug;
                if (st.containsInvokeExpr()) {
                    handlePlug(st, body, stateMachine);
                    queue.addAll(handleInvocation(stateMachine, method, st));
                } else if (st instanceof AssignStmt) {
                    // will not alter control flow, but an unanalyzable rhs
                    // might pop up
View Full Code Here

                    final WebMethodTransition webMethodTransition = (WebMethodTransition) t;
                    final InvokeExpr expr = webMethodTransition.getExpr();
                    MethodStatementContainer container = machine
                            .getMakeURLLocation(expr);
                    SootMethod enclosingMethod = container.getMethod();
                    Stmt enclosingStatement = container.getStatement();

                    typeCheckWebMethodInvocation(webMethodTransition,
                            enclosingMethod, enclosingStatement);

                    final Set<SootClass> possibleContexts = InterfaceInvocationLinker
View Full Code Here

        // to makeURL. It is assumed that the varargs array is generated by
        // soot.
        boolean skipAnalysis = false;
        for (Unit unit : graph) {
            assert unit instanceof Stmt;
            Stmt statement = (Stmt) unit;
            if (statement instanceof JAssignStmt) {
                JAssignStmt jAssignStmt = (JAssignStmt) statement;
                if (jAssignStmt.getLeftOp().equals(varArgs)) {
                    // assigning to the varArgs variable
                    log.debug("Found varargs instantiation");
View Full Code Here

TOP

Related Classes of soot.jimple.Stmt

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.