Example #1
0
 public void visitHeapInst(Quad q) {
   Operator op = q.getOperator();
   if (op instanceof AStore) {
     if (((AStore) op).getType().isReferenceType()) {
       Operand rx = AStore.getValue(q);
       if (rx instanceof RegisterOperand) {
         RegisterOperand ro = (RegisterOperand) rx;
         Register r = ro.getRegister();
         RegisterOperand bo = (RegisterOperand) AStore.getBase(q);
         Register b = bo.getRegister();
         int mIdx = domM.indexOf(ctnrMethod);
         assert (mIdx >= 0);
         int rIdx = domV.indexOf(r);
         assert (rIdx >= 0);
         int bIdx = domV.indexOf(b);
         assert (bIdx >= 0);
         int fIdx = 0;
         add(mIdx, bIdx, fIdx, rIdx);
       }
     }
     return;
   }
   if (op instanceof Putfield) {
     jq_Field f = Putfield.getField(q).getField();
     if (f.getType().isReferenceType()) {
       Operand rx = Putfield.getSrc(q);
       if (rx instanceof RegisterOperand) {
         Operand bx = Putfield.getBase(q);
         if (bx instanceof RegisterOperand) {
           RegisterOperand bo = (RegisterOperand) bx;
           RegisterOperand ro = (RegisterOperand) rx;
           Register b = bo.getRegister();
           Register r = ro.getRegister();
           int mIdx = domM.indexOf(ctnrMethod);
           assert (mIdx >= 0);
           int bIdx = domV.indexOf(b);
           assert (bIdx >= 0);
           int rIdx = domV.indexOf(r);
           assert (rIdx >= 0);
           int fIdx = domF.indexOf(f);
           assert (fIdx >= 0);
           add(mIdx, bIdx, fIdx, rIdx);
         }
       }
     }
   }
 }
 public void visitHeapInst(Quad q) {
   Operator op = q.getOperator();
   if (op instanceof ALoad) {
     if (!((ALoad) op).getType().isReferenceType()) {
       RegisterOperand lo = ALoad.getDest(q);
       Register l = lo.getRegister();
       RegisterOperand bo = (RegisterOperand) ALoad.getBase(q);
       Register b = bo.getRegister();
       int mIdx = domM.indexOf(ctnrMethod);
       assert (mIdx != -1);
       int lIdx = domU.indexOf(l);
       assert (lIdx != -1);
       int bIdx = domV.indexOf(b);
       assert (bIdx != -1);
       int fIdx = 0;
       add(mIdx, lIdx, bIdx, fIdx);
     }
     return;
   }
   if (op instanceof Getfield) {
     FieldOperand fo = Getfield.getField(q);
     fo.resolve();
     jq_Field f = fo.getField();
     if (!f.getType().isReferenceType()) {
       Operand bx = Getfield.getBase(q);
       if (bx instanceof RegisterOperand) {
         RegisterOperand bo = (RegisterOperand) bx;
         Register b = bo.getRegister();
         RegisterOperand lo = Getfield.getDest(q);
         Register l = lo.getRegister();
         int mIdx = domM.indexOf(ctnrMethod);
         assert (mIdx != -1);
         int bIdx = domV.indexOf(b);
         assert (bIdx != -1);
         int lIdx = domU.indexOf(l);
         assert (lIdx != -1);
         int fIdx = domF.indexOf(f);
         if (fIdx == -1) {
           System.out.println("WARNING: MgetInstFldInst: method: " + ctnrMethod + " quad: " + q);
         } else add(mIdx, lIdx, bIdx, fIdx);
       } else assert (bx instanceof AConstOperand);
     }
   }
 }