Package soot

Examples of soot.Unit


        _trapsForEachEpc = new LinkedList();

        while (i.hasNext()) {
            Trap CurrentTrap = (Trap) i.next();

            Unit BeginUnit = CurrentTrap.getBeginUnit();
            Unit EndUnit = CurrentTrap.getEndUnit();
            Unit HandlerUnit = CurrentTrap.getHandlerUnit();

            _beginUnitList.add(BeginUnit);
            _endUnitList.add(EndUnit);
            _handlerUnitList.add(HandlerUnit);
        }
View Full Code Here


            }

            // Grab the classes of all referenced fields, invoked
            // methods, and created classes.
            for (Iterator units = body.getUnits().iterator(); units.hasNext();) {
                Unit unit = (Unit) units.next();

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

                    if (value instanceof FieldRef) {
View Full Code Here

            Set unsafeLocalSet, boolean debug) {
        Scene.v().setActiveHierarchy(new Hierarchy());
        Scene.v().setFastHierarchy(new FastHierarchy());

        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();

                // This assumes that the types of local
View Full Code Here

            }

            if (method.isConcrete()) {
                for (Iterator units = method.retrieveActiveBody().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

            boolean leaf = _isLeaf(method);

            Iterator units = method.retrieveActiveBody().getUnits().iterator();

            while (units.hasNext()) {
                Unit unit = (Unit) units.next();

                if (unit instanceof Stmt) {
                    Stmt stmt = (Stmt) unit;

                    // Add accessed fields.
                    if (stmt.containsFieldRef()) {
                        FieldRef fieldRef = stmt.getFieldRef();
                        SootField field = fieldRef.getField();
                        nodes.add(field);
                    }

                    // Add directly called methods.
                    if (!leaf && stmt.containsInvokeExpr()) {
                        SootMethod m = stmt.getInvokeExpr().getMethod();
                        nodes.add(m);
                        nodes.add(m.getDeclaringClass());
                    }
                }

                // Get all classes used in all "instanceof" expressions.
                Iterator boxes = unit.getUseAndDefBoxes().iterator();

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

        // A method has side effects if it sets the values of any fields.
        Body body = method.retrieveActiveBody();
        Scene.v().releaseActiveHierarchy();

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

            if (_debug) {
                System.out.println("unit = " + unit);
            }

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

                if (value instanceof FieldRef) {
                    if (_debug) {
                        System.out
                                .println("SideEffectAnalysis: assigns to field");
                    }

                    out.addSideEffect(((FieldRef) value).getField());
                }

                if (value instanceof ArrayRef) {
                    if (_debug) {
                        System.out
                                .println("SideEffectAnalysis: assigns to array.");
                    }

                    // Escape analysis might help in this case.
                    out.setUnknownSideEffects();
                    return out;
                }
            }

            // Method calls that are in the invokeGraph
            // have already been checked.
            // However, it turns out that context classes
            // are not included in the
            // invokeGraph!  This checks to see if there
            // are any invocations of
            // methods that are not in the invoke graph.  Conservatively
            // assume that they have side effects.
            for (Iterator boxes = unit.getUseBoxes().iterator(); boxes
                    .hasNext();) {
                ValueBox box = (ValueBox) boxes.next();
                Value expr = box.getValue();

                if (expr instanceof InvokeExpr) {
View Full Code Here

        /*SimpleLocalDefs localDefs = */new SimpleLocalDefs(unitGraph);
        SimpleLiveLocals liveLocals = new SimpleLiveLocals(unitGraph);

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

            // Find a method invocation that doesn't have a return
            // value, or whose return value is dead.
            if (unit instanceof DefinitionStmt) {
View Full Code Here

        Iterator units = body.getUnits().iterator();
        boolean handle_exceptions = tracker.trapsExist()
                && (!Context.getSingleClassMode());

        while (units.hasNext()) {
            Unit unit = (Unit) (units.next());

            if (visitor.isTarget(unit)) {
                code.append(visitor.getLabel(unit) + ":\n");
            }

            //Code for begin Unit in exceptions.
            if (handle_exceptions && tracker.isBeginUnit(unit)) {
                tracker.beginUnitEncountered(unit);
                code.append(_indent(2) + "epc = " + tracker.getEpc() + ";\n");
                code.append(_indent(2) + "/*Trap " + tracker.beginIndexOf(unit)
                        + " begins. */\n");
            }

            //Actual unit code.
            unit.apply(visitor);

            StringBuffer newCode = visitor.getCode();

            if (newCode.length() > 0) {
                code.append(_indent(indentLevel)).append(newCode + ";");
                code.append("/* " + unit.toString().replace('/', '@') + " */");
                code.append("\n");
            }

            //Code for end unit in exceptions.
            if (handle_exceptions && tracker.isEndUnit(unit)) {
View Full Code Here

            SootMethod method) {
        JimpleBody body = (JimpleBody) method.retrieveActiveBody();
        Iterator units = body.getUnits().iterator();

        while (units.hasNext()) {
            Unit unit = (Unit) (units.next());
            Unit target = null;

            // Direct "goto".
            if (unit instanceof GotoStmt) {
                target = ((GotoStmt) unit).getTarget();
View Full Code Here

            }

            Iterator j = newBody.getUnits().iterator();

            while (j.hasNext()) {
                Unit unit = (Unit) j.next();
                Iterator boxes = unit.getUseAndDefBoxes().iterator();
                //  System.out.println("unit = " + unit);

                while (boxes.hasNext()) {
                    ValueBox box = (ValueBox) boxes.next();
                    Value value = box.getValue();
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.