protected void flowThrough(Object inValue, Object unit, Object outValue) { FlowSet in = (FlowSet) inValue; FlowSet out = (FlowSet) outValue; Stmt stmt = (Stmt) unit; in.copy(out); // get list of definitions at this unit List<EquivalentValue> newDefs = new ArrayList<EquivalentValue>(); Iterator newDefBoxesIt = stmt.getDefBoxes().iterator(); while (newDefBoxesIt.hasNext()) { newDefs.add(new EquivalentValue(((ValueBox) newDefBoxesIt.next()).getValue())); } // If the local of interest was defined in this statement, then we must // generate a new list of aliases to it starting here if (unitToAliasSet.keySet().contains(stmt)) { out.clear(); List aliases = (List) unitToAliasSet.get(stmt); Iterator aliasIt = aliases.iterator(); while (aliasIt.hasNext()) { out.add(aliasIt.next()); } } else if (stmt instanceof DefinitionStmt) { Iterator<EquivalentValue> newDefsIt = newDefs.iterator(); while (newDefsIt.hasNext()) { out.remove(newDefsIt.next()); // to be smarter, we could also add the right side to the list of aliases... } } // logger.debug(""+stmt + " HAS ALIASES in" + in + " out" + out); }
assert s.getDefBoxes().isEmpty();
Iterator<ValueBox> newDefBoxesIt = stmt.getDefBoxes().iterator(); while (newDefBoxesIt.hasNext()) { newDefs.add(((ValueBox) newDefBoxesIt.next()).getValue());
Iterator defsIt = s.getDefBoxes().iterator(); while (defsIt.hasNext()) { ValueBox def = (ValueBox) defsIt.next();
private static soot.Local getLocalOfType(soot.Body body, soot.Type type) { soot.FastHierarchy fh = InitialResolver.v().hierarchy(); Iterator stmtsIt = body.getUnits().iterator(); soot.Local correctLocal = null; while (stmtsIt.hasNext()) { soot.jimple.Stmt s = (soot.jimple.Stmt) stmtsIt.next(); if (s instanceof soot.jimple.IdentityStmt && (s.hasTag("EnclosingTag") || s.hasTag("QualifyingTag"))) { Iterator it = s.getDefBoxes().iterator(); while (it.hasNext()) { soot.ValueBox vb = (soot.ValueBox) it.next(); if ((vb.getValue() instanceof soot.Local) && (fh.canStoreType(type, vb.getValue().getType()))) { // (vb.getValue().getType().equals(type))){ correctLocal = (soot.Local) vb.getValue(); } } } } return correctLocal; }
logger.debug("s : " + s + " use boxes: " + s.getUseBoxes() + " def boxes: " + s.getDefBoxes()); Iterator defBoxesIt = s.getDefBoxes().iterator(); defs: while (defBoxesIt.hasNext()) { ValueBox vb = (ValueBox) defBoxesIt.next();
private static boolean bodyHasLocal(soot.Body body, soot.Type type) { soot.FastHierarchy fh = InitialResolver.v().hierarchy(); Iterator stmtsIt = body.getUnits().iterator(); while (stmtsIt.hasNext()) { soot.jimple.Stmt s = (soot.jimple.Stmt) stmtsIt.next(); if (s instanceof soot.jimple.IdentityStmt && (s.hasTag("EnclosingTag") || s.hasTag("QualifyingTag"))) { Iterator it = s.getDefBoxes().iterator(); while (it.hasNext()) { soot.ValueBox vb = (soot.ValueBox) it.next(); if ((vb.getValue() instanceof soot.Local) && (fh.canStoreType(type, vb.getValue().getType()))) { // (vb.getValue().getType().equals(type))){ return true; } } } } return false; /* * soot.FastHierarchy fh = InitialResolver.v().hierarchy(); Iterator it = body.getDefBoxes().iterator(); while * (it.hasNext()){ soot.ValueBox vb = (soot.ValueBox)it.next(); if ((vb.getValue() instanceof soot.Local) && * (fh.canStoreType(type, vb.getValue().getType()))){//(vb.getValue().getType().equals(type))){ return true; } } return * false; */ }
Iterator newDefBoxesIt = stmt.getDefBoxes().iterator(); while (newDefBoxesIt.hasNext()) { newDefs.add(new EquivalentValue(((ValueBox) newDefBoxesIt.next()).getValue())); Stmt s = (Stmt) existingDefIt.next(); List sNewDefs = new ArrayList(); Iterator sNewDefBoxesIt = s.getDefBoxes().iterator(); while (sNewDefBoxesIt.hasNext()) { sNewDefs.add(((ValueBox) sNewDefBoxesIt.next()).getValue());
Iterator<ValueBox> defsIt = s.getDefBoxes().iterator(); FlowSet afterSet = (FlowSet) analysis.getFallFlowAfter(s);
for (ValueBox vb : between.getDefBoxes()) { Value v = vb.getValue(); if (localsUsed.contains(v)) {
valBoxIt = s.getDefBoxes().iterator();
b.setValue(Grimp.v().newExpr(b.getValue())); useBoxesIt = newStmt.getDefBoxes().iterator(); while (useBoxesIt.hasNext()) { ValueBox b = (useBoxesIt.next());
for (ValueBox box : nextNextStmt.getDefBoxes()) { if (box.getValue().equivTo(rvalue)) { found = true;
private SootMethod getOrCreateInitializer(SootClass sc, Set<SootField> alreadyInitialized) { SootMethod smInit; // Create a static initializer if we don't already have one smInit = sc.getMethodByNameUnsafe(SootMethod.staticInitializerName); if (smInit == null) { smInit = Scene.v().makeSootMethod(SootMethod.staticInitializerName, Collections.<Type>emptyList(), VoidType.v()); smInit.setActiveBody(Jimple.v().newBody(smInit)); sc.addMethod(smInit); smInit.setModifiers(Modifier.PUBLIC | Modifier.STATIC); } else if (smInit.isPhantom()) { return null; } else { smInit.retrieveActiveBody(); // We need to collect those variables that are already initialized // somewhere for (Unit u : smInit.getActiveBody().getUnits()) { Stmt s = (Stmt) u; for (ValueBox vb : s.getDefBoxes()) { if (vb.getValue() instanceof FieldRef) { alreadyInitialized.add(((FieldRef) vb.getValue()).getField()); } } } } return smInit; }
} else { Iterator<ValueBox> boxIt; boxIt = s.getDefBoxes().iterator(); while (boxIt.hasNext()) { ValueBox vBox = (ValueBox) boxIt.next();
for (Iterator<ValueBox> bIt = stmt.getDefBoxes().iterator(); bIt.hasNext();) { final ValueBox b = (ValueBox) bIt.next(); Value v = b.getValue();
Iterator newDefBoxesIt = stmt.getDefBoxes().iterator(); while( newDefBoxesIt.hasNext() )
assert s.getDefBoxes().isEmpty();
Iterator defsIt = s.getDefBoxes().iterator(); while (defsIt.hasNext()){ ValueBox def = (ValueBox)defsIt.next();
Iterator defsIt = s.getDefBoxes().iterator(); while (defsIt.hasNext()){ ValueBox def = (ValueBox)defsIt.next();