private static boolean isSimpleCopy(Unit u) { if (!(u instanceof DefinitionStmt)) { return false; } DefinitionStmt defstmt = (DefinitionStmt) u; if (!(defstmt.getRightOp() instanceof Local)) { return false; } if (!(defstmt.getLeftOp() instanceof Local)) { return false; } return true; }
public FlowFunction<Pair<Value, Type>> getNormalFlowFunction(Unit src, Unit dest) { if (src instanceof DefinitionStmt) { DefinitionStmt defnStmt = (DefinitionStmt) src; if (defnStmt.containsInvokeExpr()) { return Identity.v(); final Value right = defnStmt.getRightOp(); final Value left = defnStmt.getLeftOp();
public void caseDefinitionStmt(DefinitionStmt s) { inDefinitionStmt(s); /* * March 18th, 2006 introducing level of indirection decideCaseExprOrRef(s.getRightOp()); * decideCaseExprOrRef(s.getLeftOp()); */ caseExprOrRefValueBox(s.getRightOpBox()); caseExprOrRefValueBox(s.getLeftOpBox()); outDefinitionStmt(s); }
private boolean isConstant(Stmt s) { if (s instanceof DefinitionStmt) { DefinitionStmt ds = (DefinitionStmt) s; if (constants.contains(ds.getLeftOp())) { return true; } } return false; } }
public boolean canRemoveDef(DefinitionStmt ds) { List uses = useDefs.getDUChain(ds); if (uses.size() != 0) { return false; } // there is no use of this def, we can remove it if it is copy stmt or a constant assignment if (ds.getRightOp() instanceof Local || ds.getRightOp() instanceof Constant) { return true; } return false; }
private void translateDefinitionStmt(DefinitionStmt def) { if (def.containsInvokeExpr()) { translateMethodInvokation(def, def.getLeftOp(), def.getInvokeExpr()); return; Value lhs = def.getLeftOp(); Value rhs = def.getRightOp(); if (def.containsFieldRef()) { Verify.verify(lhs instanceof FieldRef || rhs instanceof FieldRef); if (def.getFieldRef().getField().equals(SootTranslationHelpers.v().getExceptionGlobal())) { if (lhs instanceof FieldRef) { Verify.verify(!(rhs instanceof AnyNewExpr)); SootTranslationHelpers.v().getMemoryModel().mkHeapWriteStatement(def, def.getFieldRef(), rhs); } else /* if (rhs instanceof FieldRef) */ { SootTranslationHelpers.v().getMemoryModel().mkHeapReadStatement(def, def.getFieldRef(), lhs); } else if (def.containsArrayRef()) { throw new RuntimeException("Remove Arrays first."); } else if (rhs instanceof LengthExpr) {
DefinitionStmt ds = (DefinitionStmt) s; javafy(ds.getRightOpBox()); javafy(ds.getLeftOpBox()); if (ds.getRightOp() instanceof IntConstant) { ds.getRightOpBox().setValue(DIntConstant.v(((IntConstant) ds.getRightOp()).value, ds.getLeftOp().getType())); Value rightOp = ds.getRightOp(); pMap.put(((ParameterRef) rightOp).getIndex(), ds.getLeftOp());
ValueBox right = ds.getRightOpBox(); Value rightValue = right.getValue(); Stmt augSTwo = augTwo.get_Stmt(); if (!isInSequenceAssignmentPatternTwo(augSOne, augSTwo, ds.getLeftOp(), i)) { DArrayInitExpr tempExpr = new DArrayInitExpr(array, arrayType); DArrayInitValueBox tempValueBox = new DArrayInitValueBox(tempExpr); DAssignStmt newStmt = new DAssignStmt(ds.getLeftOpBox(), tempValueBox); markLocal(ds.getLeftOp());
ValueBox rightBox = ds.getRightOpBox(); OpBox = ((CastExpr) right).getOpBox(); } else { rightType = ds.getLeftOp().getType(); OpBox = rightBox;
Value lhsValue = defStmt.getLeftOp(); ValueBox lhsLocalBox = defStmt.getLeftOpBox(); Local lhsLocal = (Local) lhsValue;
if (defsOfUse.size() == 1) { DefinitionStmt defStmt = (DefinitionStmt) defsOfUse.get(0); Value rhs = defStmt.getRightOp(); if (rhs instanceof NumericConstant || rhs instanceof StringConstant || rhs instanceof NullConstant) { if (useBox.canContainValue(rhs)) { CastExpr ce = (CastExpr) rhs; if (ce.getCastType() instanceof RefType && ce.getOp() instanceof NullConstant) { defStmt.getRightOpBox().setValue(NullConstant.v()); numPropagated++;
ValueBox defSrcBox = stmt.getRightOpBox(); Value defSrc = defSrcBox.getValue();
@Override public FlowFunction<Local> getCallToReturnFlowFunction(Unit callSite, Unit returnSite) { if (callSite instanceof DefinitionStmt) { DefinitionStmt definition = (DefinitionStmt) callSite; if (definition.getLeftOp() instanceof Local) { final Local leftOpLocal = (Local) definition.getLeftOp(); return new Kill<Local>(leftOpLocal); } } return Identity.v(); } };
public void outDefinitionStmt(DefinitionStmt s) { // checking casting here because we want to see if the expr // on the right of def stmt is a cast expr not whether it contains a cast expr if (definedLocal != null && s.getRightOp() instanceof CastExpr) { Type castType = ((CastExpr) s.getRightOp()).getCastType(); info.addCastString(definedLocal, castType.toString()); } inDefinitionStmt = false; definedLocal = null; }
ValueBox right = ds.getRightOpBox(); Value rightValue = right.getValue(); if (!isInSequenceAssignment(augS, ds.getLeftOp(), i)) { array[i] = ((DefinitionStmt) augS).getRightOpBox(); toRemove.add(aug); DArrayInitExpr tempExpr = new DArrayInitExpr(array, arrayType); DArrayInitValueBox tempValueBox = new DArrayInitValueBox(tempExpr); DAssignStmt newStmt = new DAssignStmt(ds.getLeftOpBox(), tempValueBox); markLocal(ds.getLeftOp());
private void convertVarStoreInsn(VarInsnNode insn) { int op = insn.getOpcode(); boolean dword = op == LSTORE || op == DSTORE; StackFrame frame = getFrame(insn); Operand opr = dword ? popDual() : pop(); Local local = getLocal(insn.var); if (!units.containsKey(insn)) { DefinitionStmt as = Jimple.v().newAssignStmt(local, opr.stackOrValue()); opr.addBox(as.getRightOpBox()); frame.boxes(as.getRightOpBox()); frame.in(opr); setUnit(insn, as); } else { frame.mergeIn(opr); } assignReadOps(local); }
public boolean isCopyStmt(Stmt s) { if (!(s instanceof DefinitionStmt)) { // only definition stmts can be copy stmts return false; } // x = expr; // check if expr is a local in which case this is a copy Value leftOp = ((DefinitionStmt) s).getLeftOp(); Value rightOp = ((DefinitionStmt) s).getRightOp(); if (leftOp instanceof Local && rightOp instanceof Local) { // this is a copy statement return true; } return false; }
@Override public List<Unit> getDefsOf(Local l) { Set<Unit> defs = localToDefs.get(l); if (defs == null) { defs = new HashSet<>(); BitSet bs = localToDefsBits[localToNumber.get(l)]; if (bs != null) { for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { Unit u = unitList.get(i); if (u instanceof DefinitionStmt) { if (((DefinitionStmt) u).getLeftOp() == l) { defs.add(u); } } } } localToDefs.put(l, defs); } return new ArrayList<>(defs); }
private void getGenAndKillSetForDefnStmt(DefinitionStmt asstmt, HashMap<Stmt, HashSet<Value>> absgen, HashSet<Object> genset, HashSet<Value> absgenset, HashSet<Value> killset, HashSet<Value> condset) { Value lhs = asstmt.getLeftOp(); Value rhs = asstmt.getRightOp(); if (asstmt.containsInvokeExpr()) { if (asstmt.containsInvokeExpr()) { killallarrayref = true;
if (defStmt.getRightOp() instanceof Local && seenLocals.add((Local) defStmt.getRightOp())) { newLocals.add((Local) defStmt.getRightOp());