Package soot

Examples of soot.Value


        for (Iterator uses = useList.iterator(); uses.hasNext();) {
            UnitValueBoxPair pair = (UnitValueBoxPair) uses.next();
            Stmt defStmt = (Stmt) pair.getUnit();

            if (defStmt instanceof DefinitionStmt) {
                Value value = ((DefinitionStmt) defStmt).getLeftOp();

                if (PtolemyUtilities.isTokenType(value.getType())) {
                    set.add(value);
                    set.addAll(_computeTokenLocalsDefinedFrom(localUses,
                            defStmt));
                }
            }
View Full Code Here


                    Local replacementLocal = (Local) fieldToReplacementLeftLocal
                            .get(tokenField);

                    // FIXME: ??
                    Value replacementValue = _getNullValueForType(replacementLocal
                            .getType());
                    body.getUnits().insertBefore(
                            Jimple.v().newAssignStmt(replacementLocal,
                                    replacementValue), stmt);
                }
View Full Code Here

                    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) {
                            CastExpr expr = (CastExpr) value;
                            Type castType = expr.getCastType();
View Full Code Here

                    Stmt stmt = (Stmt) stmts.next();

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

                        if (value instanceof FieldRef) {
                            Object field = ((FieldRef) value).getField();
                            unusedFieldSet.remove(field);
                        }
                    }
                }
            }
        }

        // Loop through the methods again, and kill the statements
        // that write to an unused field.
        for (Iterator i = Scene.v().getApplicationClasses().iterator(); i
                .hasNext();) {
            SootClass entityClass = (SootClass) i.next();

            for (Iterator methods = entityClass.getMethods().iterator(); methods
                    .hasNext();) {
                SootMethod method = (SootMethod) methods.next();
                JimpleBody body = (JimpleBody) method.retrieveActiveBody();

                for (Iterator stmts = body.getUnits().snapshotIterator(); stmts
                        .hasNext();) {
                    Stmt stmt = (Stmt) stmts.next();

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

                        if (value instanceof FieldRef) {
                            Object field = ((FieldRef) value).getField();

                            if (unusedFieldSet.contains(field)) {
View Full Code Here

            // Determine the loop increment.
            int increment = 0;

            if (counterStmt.getRightOp() instanceof AddExpr) {
                AddExpr addExpr = (AddExpr) counterStmt.getRightOp();
                Value incrementValue;

                if (addExpr.getOp1().equals(counterLocal)) {
                    incrementValue = addExpr.getOp2();
                } else {
                    incrementValue = addExpr.getOp1();
                }

                if (!Evaluator.isValueConstantValued(incrementValue)) {
                    continue;
                }

                increment = ((IntConstant) Evaluator
                        .getConstantValueOf(incrementValue)).value;
                System.out.println("increment = " + increment);
            } else {
                continue;
            }

            BinopExpr conditionalExpr = (BinopExpr) jumpStmt.getCondition();

            // Now determine the loop limit from the conditional block.
            Value limitValue;

            if (conditionalExpr.getOp1().equals(counterLocal)) {
                limitValue = conditionalExpr.getOp2();
            } else {
                limitValue = conditionalExpr.getOp1();
View Full Code Here

                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) {
                        SootField field = ((FieldRef) value).getField();
                        SootClass refClass = field.getDeclaringClass();
View Full Code Here

            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
                // variables are verifiable types.
                // This is not ensured by Soot, unless
                // you run the TypeAssigner before this
                // transformation.
                if (value instanceof CastExpr) {
                    // If the cast is to the same type as the
                    // operand already is, then replace with
                    // simple assignment.
                    CastExpr expr = (CastExpr) value;
                    Type castType = expr.getCastType();
                    Value op = expr.getOp();
                    Type opType = op.getType();

                    //                     // Skip locals that are unsafe.
                    //                     if (castType.equals(opType) &&
                    //                             !unsafeLocalSet.contains(op)) {
                    //                         box.setValue(op);
                    //                     }
                    if (unsafeLocalSet.contains(op)) {
                        continue;
                    }

                    Hierarchy hierarchy = Scene.v().getActiveHierarchy();

                    //   if (debug) System.out.println("checking cast in " + unit);
                    //                     if (debug) System.out.println("op = " + op);
                    //                     if (debug) System.out.println("opType = " + opType);
                    replaceCast(box, hierarchy, castType, op, opType, debug);
                } else if (value instanceof InstanceOfExpr) {
                    // If the operand of the expression is
                    // declared to be of a type that implies
                    // the instanceof is true, then replace
                    // with true.
                    InstanceOfExpr expr = (InstanceOfExpr) value;
                    Type checkType = expr.getCheckType();
                    Value op = expr.getOp();
                    Type opType = op.getType();

                    // Skip locals that are unsafe.
                    if (unsafeLocalSet.contains(op)) {
                        continue;
                    }
View Full Code Here

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

                    if (value instanceof InstanceOfExpr) {
                        InstanceOfExpr expr = (InstanceOfExpr) value;
                        Type checkType = expr.getCheckType();
View Full Code Here

                Jimple.v().newAssignStmt(
                        indexArrayLocal,
                        Jimple.v().newInstanceFieldRef(body.getThisLocal(),
                                indexArrayField.makeRef())), stmt);

        Value bufferSizeValue = null;

        // Refer directly to the buffer in the _model
        int channel = 0;

        for (Iterator relations = port.linkedRelationList().iterator(); relations
                .hasNext();) {
            TypedIORelation relation = (TypedIORelation) relations.next();

            int bufferSize = _getBufferSize(relation);

            // remember the size of the buffer.
            bufferSizeValue = IntConstant.v(bufferSize);

            for (int i = 0; i < relation.getWidth(); i++, channel++) {
                Value channelValue = IntConstant.v(channel);

                // Load the correct index into indexLocal
                body.getUnits().insertBefore(
                        Jimple.v().newAssignStmt(
                                indexLocal,
View Full Code Here

        Local returnLocal = Jimple.v().newLocal("return",
                PtolemyUtilities.tokenType);
        body.getLocals().add(returnLocal);

        Value channelValue = expr.getArg(0);

        Value bufferSizeValue = _getBufferAndSize(body, stmt, port, port
                .getType(), channelValue, bufferLocal,
                _portToTypeNameToBufferField, false);

        _getCorrectIndex(body, stmt, port, indexLocal, indexArrayLocal,
                channelValue, bufferSizeValue, _portToIndexArrayField);

        // If we are calling with just a channel, then read the value.
        if (expr.getArgCount() == 1) {
            body.getUnits().insertAfter(
                    _createIndexUpdateInstructions(indexLocal, indexArrayLocal,
                            channelValue, bufferSizeValue), stmt);

            // We may be calling get without setting the return value
            // to anything.
            if (stmt instanceof DefinitionStmt) {
                // Replace the get() with an array read.
                box.setValue(Jimple.v().newArrayRef(bufferLocal, indexLocal));
            } else {
                body.getUnits().remove(stmt);
            }
        } else {
            // We must return an array of tokens.
            // Create an array of the appropriate length.
            body.getUnits().insertBefore(
                    Jimple.v()
                            .newAssignStmt(
                                    returnArrayLocal,
                                    Jimple.v().newNewArrayExpr(
                                            PtolemyUtilities.tokenType,
                                            expr.getArg(1))), stmt);

            Value countValue = expr.getArg(1);

            // If the count is specified statically
            // FIXME: constant loop unroller should take care of this.
            if (Evaluator.isValueConstantValued(countValue)) {
                int argCount = ((IntConstant) Evaluator
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.