示例#1
0
 protected ReferenceVariable arrayElementOfImpl(ReferenceVariable base) {
   VarNode l;
   if (base instanceof VarNode) {
     l = (VarNode) base;
   } else {
     FieldRefNode b = (FieldRefNode) base;
     l = pag.makeGlobalVarNode(b, b.getType());
     pag.addEdge(b, l);
   }
   return pag.makeFieldRefNode(l, ArrayElement.v());
 }
示例#2
0
 /** constructor, add edges to maps */
 public MatchEdges(PAG pag) {
   Iterator<VarNode> store_it = pag.storeSourcesIterator();
   // storeMap: store_src(VarNode) ----> store_targets(FieldRefNode)
   while (store_it.hasNext()) {
     // get the representative of the union
     VarNode from = ((VarNode) store_it.next()); // storeSrc, a
     Node[] storeTargets = pag.storeLookup(from);
     for (int i = 0; i < storeTargets.length; i++) {
       FieldRefNode storeTarget = (FieldRefNode) storeTargets[i]; // x.f
       VarNode storeTargetBase = storeTarget.getBase(); // x
       SparkField storeTargetField = storeTarget.getField(); // f
       String storeTargetFieldSig = ((SootField) storeTargetField).getSignature(); // f's signature
       // three inheritances of SparkField:
       // ArrayElement, Parm, and SootField
       if (storeTargetField instanceof SootField) {
         Iterator<FieldRefNode> load_it = pag.loadSourcesIterator();
         while (load_it.hasNext()) {
           FieldRefNode loadSrc = (FieldRefNode) load_it.next(); // y.f
           VarNode loadSrcBase = loadSrc.getBase(); // y
           SparkField loadSrcField = loadSrc.getField(); // f
           if (loadSrcField instanceof SootField) {
             // see whether x.f and y.f has the same offset of
             // the field
             String loadSrcFieldSig = ((SootField) loadSrcField).getSignature(); // f's signature
             if (loadSrcFieldSig.equals(storeTargetFieldSig)) {
               Node[] to = pag.loadLookup(loadSrc); // loadTargets
               for (int j = 0; j < to.length; j++) {
                 addMatchEdge(from, (VarNode) to[j]);
               }
             }
           }
         }
       }
     }
   }
 }