Package soot

Examples of soot.Unit


                if (whilePredecessor == block) {
                    whilePredecessor = (Block) whileCond.getPreds().get(1);
                }

                // System.out.println("whilePredecessor = " + whilePredecessor);
                Unit unit = whilePredecessor.getTail();
                boolean found = false;

                // walk backwards until we find a definition of the iterator.
                while ((unit != whilePredecessor.getHead()) && !found) {
                    if (unit instanceof DefinitionStmt
                            && ((DefinitionStmt) unit).getLeftOp().equals(
                                    iteratorLocal)) {
                        found = true;
                    } else {
                        unit = whilePredecessor.getPredOf(unit);
                    }
                }

                //  System.out.println("iterator def = " + unit);
                DefinitionStmt iteratorDefinition = ((DefinitionStmt) unit);

                if (!(iteratorDefinition.getRightOp() instanceof InterfaceInvokeExpr)
                        || !((InterfaceInvokeExpr) iteratorDefinition
                                .getRightOp()).getMethod().getName().equals(
                                "iterator")) {
                    continue;
                }

                Local collectionLocal = (Local) ((InterfaceInvokeExpr) iteratorDefinition
                        .getRightOp()).getBase();

                //  System.out.println("collection Local = " + collectionLocal);
                found = false;

                // Walk backward again until we reach the definition
                // of the collection.
                while ((unit != whilePredecessor.getHead()) && !found) {
                    if (unit instanceof DefinitionStmt
                            && ((DefinitionStmt) unit).getLeftOp().equals(
                                    collectionLocal)) {
                        found = true;
                    } else {
                        unit = whilePredecessor.getPredOf(unit);
                    }
                }

                //  System.out.println("collection def = " + unit);
                // System.out.println("field = " + field);
                DefinitionStmt collectionDefinition = ((DefinitionStmt) unit);

                if (!(collectionDefinition.getRightOp() instanceof FieldRef)
                        || (((FieldRef) collectionDefinition.getRightOp())
                                .getField() != field)) {
                    continue;
                }

                // FINALLY we know we've found something we can unroll... :)
                // System.out.println("is unrollable...");
                // There should be a jump from the predecessor to the
                // condition.  Redirect this jump to the body.
                whileCond.getHead().redirectJumpsToThisTo(block.getHead());

                Local thisLocal = body.getThisLocal();
                Chain units = body.getUnits();
                List blockStmtList = new LinkedList();

                // pull the statements that we are inlining out of the block
                // so that we can copy them.  Note that this also removes
                // them from the method body.
                Unit insertPoint = (Unit) units.getSuccOf(block.getTail());

                for (Iterator blockStmts = block.iterator(); blockStmts
                        .hasNext();) {
                    Stmt original = (Stmt) blockStmts.next();
                    blockStmtList.add(original);
View Full Code Here


            Body body = method.retrieveActiveBody();

            for (Iterator units = body.getUnits().snapshotIterator(); units
                    .hasNext();) {
                Unit unit = (Unit) units.next();

                //System.out.println("unit = " + unit);
                Iterator boxes = unit.getUseBoxes().iterator();

                while (boxes.hasNext()) {
                    ValueBox box = (ValueBox) boxes.next();
                    /*Value value = */box.getValue();

 
View Full Code Here

                    body.getUnits().remove(stmt);

                    for (Iterator defs = localDefs.getDefsOfAt(
                            (Local) r.getBase(), stmt).iterator(); defs
                            .hasNext();) {
                        Unit defUnit = (Unit) defs.next();

                        if (defUnit instanceof DefinitionStmt) {
                            // If we are keeping a definition, then
                            // set the definition to be null.
                            ((DefinitionStmt) defUnit).getRightOpBox()
View Full Code Here

        // Analyze the types of variables which refer to tokens.
        TokenTypeAnalysis tokenTypes = new TokenTypeAnalysis(body.getMethod(),
                new CompleteUnitGraph(body));

        for (Iterator units = body.getUnits().iterator(); units.hasNext();) {
            Unit unit = (Unit) units.next();

            for (Iterator boxes = unit.getUseBoxes().iterator(); boxes
                    .hasNext();) {
                ValueBox box = (ValueBox) boxes.next();
                Value value = box.getValue();

                if (value instanceof CastExpr) {
View Full Code Here

                if (invokedMethod.getName().equals("<init>")
                        && SootUtilities.isSubtypeOf(invokeExpr.getBase()
                                .getType(), RefType
                                .v(PtolemyUtilities.tokenClass))) {
                    // System.out.println("found token initializer: " + unit);
                    Unit constructor = _findConstructor((Local) invokeExpr
                            .getBase(), unit, localDefs);

                    //  System.out.println("found token constructor: " + constructor);
                    if (constructor == null) {
                        continue;
View Full Code Here

            }

            JimpleBody body = (JimpleBody) method.retrieveActiveBody();
            for (Iterator units = body.getUnits().snapshotIterator(); units
                    .hasNext();) {
                Unit unit = (Unit) units.next();

                if (debug) {
                    System.out.println("ptr unit = " + unit);
                }
View Full Code Here

            SootMethod method = (SootMethod) methods.next();
            JimpleBody body = (JimpleBody) method.retrieveActiveBody();

            for (Iterator units = body.getUnits().snapshotIterator(); units
                    .hasNext();) {
                Unit unit = (Unit) units.next();
                Iterator boxes = unit.getUseBoxes().iterator();

                while (boxes.hasNext()) {
                    ValueBox box = (ValueBox) boxes.next();
                    Value value = box.getValue();
View Full Code Here

    MonitorGroupItem curr_monitor = new MonitorGroupItem();
    ret.add(curr_monitor);
    stack.push(curr_monitor);
    List<Unit> units = getUnits(body);
    for(int i = 0; i < units.size(); ++i){
      Unit curr = units.get(i);
      if(curr instanceof EnterMonitorStmt){
        MonitorGroupItem item = new MonitorGroupItem();
        item.addEnterMonitor(curr);
        stack.top().addGroup(item);
        stack.push(item);
View Full Code Here

 
  private boolean isLastExit(ExitMonitorStmt exit, int index, List<Unit> units){
    Value op = exit.getOp();
    Local op_local = (Local) op;
    for(int j = index + 1; j < units.size(); ++j){
      Unit curr = units.get(j);
      if(curr instanceof EnterMonitorStmt){
        return true;
      } else if(curr instanceof ExitMonitorStmt){
        ExitMonitorStmt exit2 = (ExitMonitorStmt) curr;
        Local op_local2 = (Local) exit2.getOp();
View Full Code Here

 
  private List<Unit> getUnits(Body body){
    List<Unit> ret = new ArrayList<Unit>();
    Iterator<Unit> iter = body.getUnits().iterator();
    while(iter.hasNext()){
      Unit curr = iter.next();
      ret.add(curr);
    }
    return ret;
  }
View Full Code Here

TOP

Related Classes of soot.Unit

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.