Package soot

Examples of soot.SootFieldRef


                AssignStmt assignStmt = (AssignStmt) unit;

                // Ignore anything that isn't an assignment to a field.
                if (assignStmt.getRightOp() instanceof FieldRef) {
                    FieldRef ref = (FieldRef) assignStmt.getRightOp();
                    SootFieldRef fieldRef = ref.getFieldRef();
                    SootField field = ref.getField();

                    Type type = field.getType();

                    if (!PtolemyUtilities.isTokenType(type)) {
                        continue;
                    }
                    // Things that aren't token types are ignored.
                    // Things that are already the same type are ignored.
                    Type newType = typeAnalysis.getSpecializedSootType(field);
                    if ((newType != null) && !newType.equals(type)) {

                        ref.setFieldRef(Scene.v().makeFieldRef(
                                fieldRef.declaringClass(), fieldRef.name(),
                                newType, fieldRef.isStatic()));
                    }
                    continue;
                }
                if (!(assignStmt.getLeftOp() instanceof FieldRef)) {
                    continue;
                }

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

                if (debug) {
                    System.out.println("checking assignment " + assignStmt);
                }

                // FIXME: We need to figure out a way to insert casts where appropriate.
                // See RampFiringLimitSDF
                //                 ptolemy.data.type.Type leftType, rightType;
                //                 leftType = _getReplacementTokenType(
                //                         assignStmt.getLeftOp(), typeAnalysis);
                //                 rightType = _getReplacementTokenType(
                //                         assignStmt.getRightOp(), typeAnalysis);
                //                 if (leftType != null && rightType != null && !leftType.equals(rightType)) {
                //                     if (debug) System.out.println("inserting conversion: leftType = " +
                //                             leftType + ", rightType = " + rightType);
                //                     // insert a call to convert(), and a cast.
                //                     FieldRef ref = (FieldRef)assignStmt.getLeftOp();
                //                     SootField field = ref.getField();
                //                     Type newType =
                //                         typeAnalysis.getSpecializedSootType(field);
                //                     Local tempLocal =
                //                         Jimple.v().newLocal("fieldUpdateLocal", newType);
                //                     body.getLocals().add(tempLocal);
                //                     Local tokenLocal =
                //                         Jimple.v().newLocal("tokenLocal", PtolemyUtilities.tokenType);
                //                     body.getLocals().add(tokenLocal);
                //                     Local typeLocal =
                //                         PtolemyUtilities.buildConstantTypeLocal(body, unit, leftType);
                //                     body.getUnits().insertBefore(
                //                             Jimple.v().newAssignStmt(tokenLocal,
                //                                     Jimple.v().newVirtualInvokeExpr(
                //                                             typeLocal,
                //                                             PtolemyUtilities.typeConvertMethod,
                //                                             assignStmt.getRightOp())),
                //                             unit);
                //                     body.getUnits().insertBefore(
                //                             Jimple.v().newAssignStmt(tempLocal,
                //                                     Jimple.v().newCastExpr(
                //                                             tokenLocal,
                //                                             newType)),
                //                             unit);
                //                     assignStmt.setRightOp(tempLocal);
                //                 } else {
                FieldRef ref = (FieldRef) assignStmt.getLeftOp();
                SootFieldRef fieldRef = ref.getFieldRef();
                SootField field = ref.getField();

                Type type = field.getType();

                // Things that aren't token types are ignored.
                // Things that are already the same type are ignored.
                Type newType = typeAnalysis.getSpecializedSootType(field);

                if ((newType != null) && !newType.equals(type)) {
                    if (debug) {
                        System.out.println("inserting cast");
                    }

                    Local tempLocal = Jimple.v().newLocal("fieldUpdateLocal",
                            newType);
                    body.getLocals().add(tempLocal);
                    body.getUnits().insertBefore(
                            Jimple.v().newAssignStmt(
                                    tempLocal,
                                    Jimple.v().newCastExpr(
                                            assignStmt.getRightOp(), newType)),
                            unit);
                    assignStmt.setRightOp(tempLocal);
                    ref.setFieldRef(Scene.v().makeFieldRef(
                            fieldRef.declaringClass(), fieldRef.name(),
                            newType, fieldRef.isStatic()));
                }

                //     }
            }
        }
View Full Code Here


                    Value value = box.getValue();

                    if (value instanceof FieldRef) {
                        // Fix references to fields
                        FieldRef r = (FieldRef) value;
                        SootFieldRef fieldRef = r.getFieldRef();
                        if (fieldRef.type() instanceof RefType) {
                            RefType fieldType = (RefType) fieldRef.type();
                            SootClass fieldClass = fieldType.getSootClass();
                            if (fieldClass == oldClass) {
                                r.setFieldRef(Scene.v().makeFieldRef(
                                        fieldRef.declaringClass(),
                                        fieldRef.name(), RefType.v(newClass),
                                        fieldRef.isStatic()));
                            }
                            fieldRef = r.getFieldRef();
                        }

                        if (fieldRef.declaringClass() == oldClass) {
                            // We might also have a reference to a field
                            // which is not actually declared in the
                            // oldclass, in which case, we just fix up
                            // the ref to point to the new super class
                            r.setFieldRef(Scene.v().makeFieldRef(newClass,
                                    fieldRef.name(), fieldRef.type(),
                                    fieldRef.isStatic()));
                        } else if (fieldRef.declaringClass().getName()
                                .startsWith(oldClass.getName())) {
                            SootClass changeClass = _getInnerClassCopy(
                                    oldClass, r.getField().getDeclaringClass(),
                                    newClass);
                            r.setFieldRef(changeClass.getFieldByName(
View Full Code Here

                    Value value = box.getValue();

                    if (value instanceof FieldRef) {
                        // Fix references to fields
                        FieldRef r = (FieldRef) value;
                        SootFieldRef fieldRef = r.getFieldRef();

                        if (r.getField().getDeclaringClass() != superClass
                                && fieldRef.declaringClass() == superClass) {
                            // We might also have a reference to a method
                            // which is not actually declared in the
                            // superclass, in which case, we just fix up
                            // the ref to point to the new super class
                            r.setFieldRef(Scene.v().makeFieldRef(
                                    superClass.getSuperclass(),
                                    fieldRef.name(), fieldRef.type(),
                                    fieldRef.isStatic()));
                        }
                    }
                }
                if (stmt.containsInvokeExpr()) {
                    InvokeExpr invoke = stmt.getInvokeExpr();
View Full Code Here

TOP

Related Classes of soot.SootFieldRef

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.