/** Returns the size of this Chain. */ @Override public int size() { return innerChain.size(); }
/** Returns the number of locals declared in this body. */ public int getLocalCount() { return localChain.size(); }
public int size() { return chain.size(); }
public int size() { return unitChain.size(); }
/** * Returns the number of fields in this class. */ public int getFieldCount() { checkLevel(SIGNATURES); return fields == null ? 0 : fields.size(); }
/** * Returns the number of interfaces being directly implemented by this class. Note that direct implementation corresponds * to an "implements" keyword in the Java class file and that this class may still be implementing additional interfaces in * the usual sense by being a subclass of a class which directly implements some interfaces. */ public int getInterfaceCount() { checkLevel(HIERARCHY); return interfaces == null ? 0 : interfaces.size(); }
/** Constructs a hierarchy from the current scene. */ public Hierarchy() { this.sc = Scene.v(); state = sc.getState(); // Well, this used to be describable by 'Duh'. // Construct the subclasses hierarchy and the subinterfaces hierarchy. { Chain<SootClass> allClasses = sc.getClasses(); classToSubclasses = new HashMap<SootClass, List<SootClass>>(allClasses.size() * 2 + 1, 0.7f); interfaceToSubinterfaces = new HashMap<SootClass, List<SootClass>>(allClasses.size() * 2 + 1, 0.7f); interfaceToSuperinterfaces = new HashMap<SootClass, List<SootClass>>(allClasses.size() * 2 + 1, 0.7f); classToDirSubclasses = new HashMap<SootClass, List<SootClass>>(allClasses.size() * 2 + 1, 0.7f); interfaceToDirSubinterfaces = new HashMap<SootClass, List<SootClass>>(allClasses.size() * 2 + 1, 0.7f); interfaceToDirSuperinterfaces = new HashMap<SootClass, List<SootClass>>(allClasses.size() * 2 + 1, 0.7f); interfaceToDirImplementers = new HashMap<SootClass, List<SootClass>>(allClasses.size() * 2 + 1, 0.7f); initializeHierarchy(allClasses); } }
/** * @param body */ public SimpleExceptionalGraph(Body body) { super(body); int size = unitChain.size(); unitToSuccs = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); unitToPreds = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); buildUnexceptionalEdges(unitToSuccs, unitToPreds); buildSimpleExceptionalEdges(unitToSuccs, unitToPreds); buildHeadsAndTails(); }
private List<Trap> getTrapsForUnit(Object o, Body b) { ArrayList<Trap> list = new ArrayList<Trap>(); Chain<Trap> traps = b.getTraps(); if (traps.size() != 0) { PatchingChain<Unit> units = b.getUnits(); Iterator<Trap> it = traps.iterator(); while (it.hasNext()) { Trap t = it.next(); Iterator<Unit> tit = units.iterator(t.getBeginUnit(), t.getEndUnit()); while (tit.hasNext()) { if (tit.next() == o) { list.add(t); break; } } } } return list; }
localToDefs = new HashMap<Value, List<Unit>>(unitsChain.size() * 2 + 1, 0.7f);
private void printStatementsInBody(Body body, java.io.PrintWriter out) { if (Options.v().verbose()) { System.out.println("Printing " + body.getMethod().getName()); } Chain<Unit> units = ((DavaBody) body).getUnits(); if (units.size() != 1) { throw new RuntimeException("DavaBody AST doesn't have single root."); } UnitPrinter up = new DavaUnitPrinter((DavaBody) body); ((ASTNode) units.getFirst()).toString(up); out.print(up.toString()); }
public EnhancedUnitGraph(Body body) { super(body); // try2nop = new Hashtable<GuardedBlock, Unit>(); try2nop = new Hashtable<Unit, Unit>(); handler2header = new Hashtable<Unit, Unit>(); // there could be a maximum of traps.size() of nop // units added to the CFG plus potentially START/STOP nodes. int size = unitChain.size() + body.getTraps().size() + 2; unitToSuccs = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); unitToPreds = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); /* * Compute the head and tails at each phase because other phases might rely on them. */ buildUnexceptionalEdges(unitToSuccs, unitToPreds); addAuxiliaryExceptionalEdges(); buildHeadsAndTails(); handleExplicitThrowEdges(); buildHeadsAndTails(); handleMultipleReturns(); buildHeadsAndTails(); /** * Remove bogus heads (these are useless goto's) */ removeBogusHeads(); buildHeadsAndTails(); }
public void staticBlockInlining(SootClass sootClass) { this.sootClass = sootClass; // retrieve the clinit method if any for sootClass // the clinit method gets converted into the static block which could initialize the final variable if (!sootClass.declaresMethod("void <clinit>()")) { // System.out.println("no clinit"); return; } SootMethod clinit = sootClass.getMethod("void <clinit>()"); // System.out.println(clinit); // retireve the active body if (!clinit.hasActiveBody()) { throw new RuntimeException("method " + clinit.getName() + " has no active body!"); } Body clinitBody = clinit.getActiveBody(); Chain units = ((DavaBody) clinitBody).getUnits(); if (units.size() != 1) { throw new RuntimeException("DavaBody AST doesn't have single root."); } ASTNode AST = (ASTNode) units.getFirst(); if (!(AST instanceof ASTMethodNode)) { throw new RuntimeException("Starting node of DavaBody AST is not an ASTMethodNode"); } // running methodCallFinder on the Clinit method AST.apply(new MethodCallFinder(this)); }
if (units.size() != 1) { throw new RuntimeException("DavaBody AST doesn't have single root.");
/** * Constructs a BriefUnitGraph given a Body instance. * * @param body * The underlying body we want to make a graph for. */ public BriefUnitGraph(Body body) { super(body); int size = unitChain.size(); if (Options.v().time()) { Timers.v().graphTimer.start(); } unitToSuccs = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); unitToPreds = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); buildUnexceptionalEdges(unitToSuccs, unitToPreds); buildHeadsAndTails(); if (Options.v().time()) { Timers.v().graphTimer.end(); } soot.util.PhaseDumper.v().dumpGraph(this, body); }
/** * Constructs the graph from a given Body instance. * * @param the * Body instance from which the graph is built. */ public TrapUnitGraph(Body body) { super(body); int size = unitChain.size(); if (Options.v().time()) { Timers.v().graphTimer.start(); } unitToSuccs = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); unitToPreds = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f); buildUnexceptionalEdges(unitToSuccs, unitToPreds); buildExceptionalEdges(unitToSuccs, unitToPreds); buildHeadsAndTails(); if (Options.v().time()) { Timers.v().graphTimer.end(); } soot.util.PhaseDumper.v().dumpGraph(this, body); }
public static void updateTraps(Unit oldu, Unit newu, Chain<Trap> traps) { int size = traps.size(); if (size == 0) { return; } Trap t = traps.getFirst(); do { if (t.getBeginUnit() == oldu) { t.setBeginUnit(newu); } if (t.getEndUnit() == oldu) { t.setEndUnit(newu); } if (t.getHandlerUnit() == oldu) { t.setHandlerUnit(newu); } } while ((--size > 0) && (t = traps.getSuccOf(t)) != null); }
for (Unit stmt : units.toArray(new Unit[units.size()])) { if (stmt instanceof IfStmt) { IfStmt ifs = (IfStmt) stmt;