Package soot

Examples of soot.Value


                        // If the statement is a call to the next() method,
                        // then inline it with the next value of the iterator.
                        for (Iterator boxes = clone.getUseBoxes().iterator(); boxes
                                .hasNext();) {
                            ValueBox box = (ValueBox) boxes.next();
                            Value value = box.getValue();

                            if (value instanceof InvokeExpr) {
                                InvokeExpr r = (InvokeExpr) value;

                                if (r.getMethod() == iteratorNextMethod) {
View Full Code Here


                    localName, unsignedByteTokenClass,
                    unsignedByteTokenConstructor, IntConstant
                            .v(((UnsignedByteToken) token).byteValue()));
            return tokenLocal;
        } else if (token instanceof BooleanToken) {
            Value value;

            if (((BooleanToken) token).booleanValue()) {
                value = IntConstant.v(1);
            } else {
                value = IntConstant.v(0);
View Full Code Here

            Local local, Unit location, LocalDefs localDefs, LocalUses localUses) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = (Value) stmt.getRightOp();

            if (value instanceof Local) {
                return getTypeValue(method, (Local) value, stmt, localDefs,
                        localUses);
            } else if (value instanceof CastExpr) {
View Full Code Here

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

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

                if (value instanceof BinopExpr) {
                    BinopExpr binop = (BinopExpr) value;
                    Value left = binop.getOp1();
                    Value right = binop.getOp2();

                    // handle nulls
                    NamedObj leftObject = null;
                    NamedObj rightObject = null;

                    if (left.getType() instanceof NullType) {
                        leftObject = null;
                    } else if (left.getType() instanceof RefType) {
                        RefType leftType = (RefType) left.getType();
                        SootClass leftClass = leftType.getSootClass();

                        if (SootUtilities.derivesFrom(leftClass,
                                PtolemyUtilities.namedObjClass)) {
                            try {
                                leftObject = getNamedObjValue(method,
                                        (Local) left, stmt, localDefs,
                                        localUses);
                            } catch (Exception ex) {
                                // Ignore... We cannot determine the
                                // value of the object.
                                continue;
                            }
                        } else {
                            continue;
                        }
                    } else {
                        continue;
                    }

                    if (right.getType() instanceof NullType) {
                        rightObject = null;
                    } else if (right.getType() instanceof RefType) {
                        RefType rightType = (RefType) right.getType();
                        SootClass rightClass = rightType.getSootClass();

                        if (SootUtilities.derivesFrom(rightClass,
                                PtolemyUtilities.namedObjClass)) {
                            try {
View Full Code Here

            Unit location, LocalDefs localDefs, LocalUses localUses) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof Local) {
                return getNamedObjValue(method, (Local) value, stmt, localDefs,
                        localUses);
            } else if (value instanceof CastExpr) {
View Full Code Here

            if (!stmt.containsInvokeExpr()) {
                continue;
            }

            ValueBox box = stmt.getInvokeExprBox();
            Value value = box.getValue();

            if (value instanceof SpecialInvokeExpr) {
                SpecialInvokeExpr r = (SpecialInvokeExpr) value;

                //      System.out.println("compare " + r.getMethod().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();

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

                    if (!PtolemyUtilities.isTokenType(op.getType())) {
                        continue;
                    }

                    // Use the token type inference to get the actual
                    // type of the argument.
                    ptolemy.data.type.Type type = tokenTypes.getTypeOfBefore(
                            (Local) op, unit);

                    if (debug) {
                        System.out.println("checking cast in " + unit);
                    }

                    if (debug) {
                        System.out.println("op = " + op);
                    }

                    if (debug) {
                        System.out.println("type = " + type);
                    }

                    // Don't try to replace non-instantiable types, since they
                    // might be more refined later.
                    // General, is unfortuantely, considered instantiable.
                    if (type.equals(BaseType.UNKNOWN) //!type.isInstantiable() ||
                            || type.equals(BaseType.GENERAL)) {
                        continue;
                    }

                    Type opType = PtolemyUtilities
                            .getSootTypeForTokenType(type);

                    //                     // 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("opType = " + opType);
                    }

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

                    if (!PtolemyUtilities.isTokenType(op.getType())) {
                        continue;
                    }

                    // Use the token type inference to get the actual
                    // type of the argument.
View Full Code Here

                if (debug) {
                    System.out.println("stmt = " + stmt);
                }

                if (stmt instanceof AssignStmt) {
                    Value leftOp = ((AssignStmt) stmt).getLeftOp();
                    Value rightOp = ((AssignStmt) stmt).getRightOp();

                    // Note that the only real possibilities on the
                    // left side are a local or a fieldRef.
                    InequalityTerm leftOpTerm = _getInequalityTerm(method,
                            debug, leftOp, _solver, _objectToInequalityTerm,
View Full Code Here

        //NewExpr newExpr = null;
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof NewExpr) {
                return stmt;
            } else {
                throw new RuntimeException("Found something other"
View Full Code Here

            if (!stmt.containsInvokeExpr()) {
                continue;
            }

            ValueBox box = stmt.getInvokeExprBox();
            Value value = stmt.getInvokeExpr();

            if (value instanceof InstanceInvokeExpr) {
                InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                if (r.getBase().getType() instanceof RefType) {
                    RefType type = (RefType) r.getBase().getType();

                    // Inline calls to connections changed.
                    if (r.getMethod().equals(
                            PtolemyUtilities.connectionsChangedMethod)) {
                        // If we are calling connections changed on one of the classes
                        // we are generating code for, then inline it.
                        if (type.getSootClass().isApplicationClass()) {
                            SootMethod inlinee = null;

                            if (r instanceof VirtualInvokeExpr) {
                                // Now inline the resulting call.
                                List methodList = Scene
                                        .v()
                                        .getActiveHierarchy()
                                        .resolveAbstractDispatch(
                                                type.getSootClass(),
                                                PtolemyUtilities.connectionsChangedMethod);

                                if (methodList.size() == 1) {
                                    // Inline the method.
                                    inlinee = (SootMethod) methodList.get(0);
                                } else {
                                    String string = "Can't inline " + stmt
                                            + " in method " + method + "\n";

                                    for (int i = 0; i < methodList.size(); i++) {
                                        string += ("target = "
                                                + methodList.get(i) + "\n");
                                    }

                                    System.out.println(string);
                                }
                            } else if (r instanceof SpecialInvokeExpr) {
                                inlinee = Scene.v().getActiveHierarchy()
                                        .resolveSpecialDispatch(
                                                (SpecialInvokeExpr) r, method);
                            }

                            if (inlinee != null
                                    && !inlinee.getDeclaringClass()
                                            .isApplicationClass()) {
                                inlinee.getDeclaringClass().setLibraryClass();
                            }

                            inlinee.retrieveActiveBody();

                            if (debug) {
                                System.out
                                        .println("Inlining method call: " + r);
                            }

                            SiteInliner.inlineSite(inlinee, stmt, method);

                            doneSomething = true;
                        } else {
                            // FIXME: this is a bit of a hack, but
                            // for right now it seems to work.
                            // How many things that aren't
                            // the actors we are generating
                            // code for do we really care about here?
                            // Can we do this without having to create
                            // a class for the port too????
                            body.getUnits().remove(stmt);
                            doneSomething = true;
                        }
                    }

                    // Statically evaluate constant arguments.
                    Value[] argValues = new Value[r.getArgCount()];
                    int constantArgCount = 0;

                    for (Iterator args = r.getArgs().iterator(); args.hasNext();) {
                        Value arg = (Value) args.next();

                        //System.out.println("arg = " + arg);
                        if (Evaluator.isValueConstantValued(arg)) {
                            argValues[constantArgCount++] = Evaluator
                                    .getConstantValueOf(arg);
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.