Package soot.jimple

Examples of soot.jimple.BinopExpr


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

                    if (value instanceof BinopExpr) {
                        BinopExpr expr = (BinopExpr) value;
                        boolean op1IsToken = PtolemyUtilities.isTokenType(expr
                                .getOp1().getType());
                        boolean op2IsToken = PtolemyUtilities.isTokenType(expr
                                .getOp2().getType());

                        if (op1IsToken && op2IsToken) {
                            //                             throw new RuntimeException(
                            //                                     "Unable to handle expression"
                            //                                             + " of two token types: " + unit);
                        } else if (op1IsToken
                                && expr.getOp2().getType().equals(NullType.v())) {
                            doneSomething = true;

                            Local isNotNullLocal = (Local) localToIsNotNullLocal
                                    .get(expr.getOp1());

                            if (isNotNullLocal != null) {
                                if (debug) {
                                    System.out
                                            .println("replacing binary expression "
                                                    + expr);
                                }

                                Value nullValue;

                                if (isNotNullLocal.getType().equals(
                                        BooleanType.v())) {
                                    // If the isNotNullLocal is for a regular Object.
                                    nullValue = IntConstant.v(0);
                                } else {
                                    // If the isNotNullLocal is for an Array Object.
                                    nullValue = NullConstant.v();
                                }

                                if (expr instanceof EqExpr) {
                                    box.setValue(Jimple.v().newEqExpr(
                                            isNotNullLocal, nullValue));
                                } else if (expr instanceof NeExpr) {
                                    box.setValue(Jimple.v().newNeExpr(
                                            isNotNullLocal, nullValue));
                                }
                            }
                        } else if (op2IsToken
                                && expr.getOp1().getType().equals(NullType.v())) {
                            doneSomething = true;

                            Local isNotNullLocal = (Local) localToIsNotNullLocal
                                    .get(expr.getOp2());

                            if (isNotNullLocal != null) {
                                Value nullValue;

                                if (isNotNullLocal.getType().equals(
View Full Code Here


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

            int limit;

            if (Evaluator.isValueConstantValued(counterStmt.getRightOp())) {
View Full Code Here

                    .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 {
                                rightObject = getNamedObjValue(method,
                                        (Local) right, stmt, localDefs,
                                        localUses);
                            } catch (Exception ex) {
                                // Ignore... We cannot determine the
                                // value of the object.
                                continue;
                            }
                        } else {
                            continue;
                        }
                    } else {
                        continue;
                    }

                    //   System.out.println("leftObject = "
                    //          + leftObject);
                    //  System.out.println("rightObject = "
                    //        + rightObject);
                    if (leftObject == rightObject) {
                        binop.getOp1Box().setValue(IntConstant.v(0));
                        binop.getOp2Box().setValue(IntConstant.v(0));
                    } else {
                        binop.getOp1Box().setValue(IntConstant.v(0));
                        binop.getOp2Box().setValue(IntConstant.v(1));
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of soot.jimple.BinopExpr

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.