Examples of FieldRef


Examples of soot.jimple.FieldRef

                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

Examples of soot.jimple.FieldRef

            }

            // Otherwise there is nothing to be done.
            return null;
        } else if (value instanceof FieldRef) {
            FieldRef r = (FieldRef) value;

            // Field references have the type of the field.
            SootField field = r.getField();

            // FIXME: UGH: This is the same as elementType...
            if (field.getSignature().equals(
                    "<ptolemy.data.ArrayToken: ptolemy.data.Token[] _value>")
                    || field
View Full Code Here

Examples of soot.jimple.FieldRef

                            theClass.getFieldByName(
                                    ModelTransformer.getContainerFieldName())
                                    .makeRef());
        } else {
            DefinitionStmt stmt = _getFieldDef(baseLocal, unit, localDefs);
            FieldRef ref = (FieldRef) stmt.getRightOp();
            SootField field = ref.getField();
            Entity entity = ModelTransformer.getEntityForField(field);
            Entity container = (Entity) entity.getContainer();
            return getLocalReferenceForEntity(container, sourceClass, body
                    .getThisLocal(), body, unit, _options);
        }
View Full Code Here

Examples of soot.jimple.FieldRef

            // Then we are dealing with a getEntity call on one of the
            // classes we are generating.
            entity = ((CompositeEntity) object).getEntity(name);
        } else {
            DefinitionStmt stmt = _getFieldDef(baseLocal, unit, localDefs);
            FieldRef ref = (FieldRef) stmt.getRightOp();
            SootField field = ref.getField();
            CompositeEntity container = (CompositeEntity) ModelTransformer
                    .getEntityForField(field);
            entity = container.getEntity(name);
        }
View Full Code Here

Examples of soot.jimple.FieldRef

                    modelClass, "<init>", args);
            units.insertBefore(Jimple.v().newInvokeStmt(
                    Jimple.v().newSpecialInvokeExpr(modelLocal,
                            constructor.makeRef(), args)), insertPoint);

            FieldRef fieldRef = Jimple.v().newInstanceFieldRef(
                    body.getThisLocal(), modelField.makeRef());
            units.insertBefore(Jimple.v().newAssignStmt(fieldRef, modelLocal),
                    insertPoint);

            // Set the name.
View Full Code Here

Examples of soot.jimple.FieldRef

      Value lhs = assign.getLeftOp();
     
      if(lhs instanceof FieldRef == false)
        continue;
       
      FieldRef ref = (FieldRef) lhs;
      SootField field = ref.getField();
      String name = field.getDeclaringClass().getName();
      if(m_WrittenClasses.contains(name) == false)
        m_WrittenClasses.add(name);
    }
  }
View Full Code Here

Examples of soot.jimple.FieldRef

      Variable lefthandSide = factory.getLocal((Local)stmt.getLeftOp());
      assignValue(lefthandSide, result);
   
    // assign to a field?
    } else if (stmt.getLeftOp() instanceof FieldRef) {
      FieldRef ref = (FieldRef)stmt.getLeftOp();
     
      // delegate the translation
      fieldReferenceTranslator.translateFieldAssignment(ref, result, factory);
   
    // assign into an array slot?
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.