use of soot.MethodOrMethodContext in project soot by Sable.
the class CallGraphBuilder method build.
public void build() {
QueueReader<MethodOrMethodContext> worklist = reachables.listener();
while (true) {
ofcgb.processReachables();
reachables.update();
if (!worklist.hasNext())
break;
final MethodOrMethodContext momc = worklist.next();
List<Local> receivers = ofcgb.methodToReceivers().get(momc.method());
if (receivers != null)
for (Iterator<Local> receiverIt = receivers.iterator(); receiverIt.hasNext(); ) {
final Local receiver = receiverIt.next();
final PointsToSet p2set = pa.reachingObjects(receiver);
for (Iterator<Type> typeIt = p2set.possibleTypes().iterator(); typeIt.hasNext(); ) {
final Type type = typeIt.next();
ofcgb.addType(receiver, momc.context(), type, null);
}
}
List<Local> bases = ofcgb.methodToInvokeArgs().get(momc.method());
if (bases != null) {
for (Local base : bases) {
PointsToSet pts = pa.reachingObjects(base);
for (Type ty : pts.possibleTypes()) {
ofcgb.addBaseType(base, momc.context(), ty);
}
}
}
List<Local> argArrays = ofcgb.methodToInvokeBases().get(momc.method());
if (argArrays != null) {
for (final Local argArray : argArrays) {
PointsToSet pts = pa.reachingObjects(argArray);
if (pts instanceof PointsToSetInternal) {
PointsToSetInternal ptsi = (PointsToSetInternal) pts;
ptsi.forall(new P2SetVisitor() {
@Override
public void visit(Node n) {
assert n instanceof AllocNode;
AllocNode an = (AllocNode) n;
Object newExpr = an.getNewExpr();
ofcgb.addInvokeArgDotField(argArray, an.dot(ArrayElement.v()));
if (newExpr instanceof NewArrayExpr) {
NewArrayExpr nae = (NewArrayExpr) newExpr;
Value size = nae.getSize();
if (size instanceof IntConstant) {
IntConstant arrSize = (IntConstant) size;
ofcgb.addPossibleArgArraySize(argArray, arrSize.value, momc.context());
} else {
ofcgb.setArgArrayNonDetSize(argArray, momc.context());
}
}
}
});
}
for (Type t : pa.reachingObjectsOfArrayElement(pts).possibleTypes()) {
ofcgb.addInvokeArgType(argArray, momc.context(), t);
}
}
}
List<Local> stringConstants = ofcgb.methodToStringConstants().get(momc.method());
if (stringConstants != null)
for (Iterator<Local> stringConstantIt = stringConstants.iterator(); stringConstantIt.hasNext(); ) {
final Local stringConstant = stringConstantIt.next();
PointsToSet p2set = pa.reachingObjects(stringConstant);
Collection<String> possibleStringConstants = p2set.possibleStringConstants();
if (possibleStringConstants == null) {
ofcgb.addStringConstant(stringConstant, momc.context(), null);
} else {
for (Iterator<String> constantIt = possibleStringConstants.iterator(); constantIt.hasNext(); ) {
final String constant = constantIt.next();
ofcgb.addStringConstant(stringConstant, momc.context(), constant);
}
}
}
}
}
use of soot.MethodOrMethodContext in project soot by Sable.
the class JimpleBasedInterproceduralCFG method initializeUnitToOwner.
protected void initializeUnitToOwner() {
for (Iterator<MethodOrMethodContext> iter = Scene.v().getReachableMethods().listener(); iter.hasNext(); ) {
SootMethod m = iter.next().method();
initializeUnitToOwner(m);
}
}
use of soot.MethodOrMethodContext in project soot by Sable.
the class OnFlyCallGraphBuilder method processReachables.
public void processReachables() {
while (true) {
if (!worklist.hasNext()) {
rm.update();
if (!worklist.hasNext())
break;
}
MethodOrMethodContext momc = worklist.next();
SootMethod m = momc.method();
if (appOnly && !m.getDeclaringClass().isApplicationClass())
continue;
if (analyzedMethods.add(m))
processNewMethod(m);
processNewMethodContext(momc);
}
}
use of soot.MethodOrMethodContext in project soot by Sable.
the class ReachableMethods method update.
/**
* Causes the QueueReader objects to be filled up with any methods that have
* become reachable since the last call.
*/
public void update() {
while (edgeSource.hasNext()) {
Edge e = edgeSource.next();
if (set.contains(e.getSrc()))
addMethod(e.getTgt());
}
while (unprocessedMethods.hasNext()) {
MethodOrMethodContext m = unprocessedMethods.next();
Iterator<Edge> targets = cg.edgesOutOf(m);
if (filter != null)
targets = filter.wrap(targets);
addMethods(new Targets(targets));
}
}
use of soot.MethodOrMethodContext in project soot by Sable.
the class SideEffectAnalysis method readSet.
public RWSet readSet(SootMethod method, Stmt stmt) {
RWSet ret = null;
Iterator<MethodOrMethodContext> targets = tt.iterator(stmt);
while (targets.hasNext()) {
SootMethod target = (SootMethod) targets.next();
if (target.isNative()) {
if (ret == null)
ret = new SiteRWSet();
ret.setCallsNative();
} else if (target.isConcrete()) {
RWSet ntr = nonTransitiveReadSet(target);
if (ntr != null) {
if (ret == null)
ret = new SiteRWSet();
ret.union(ntr);
}
}
}
if (ret == null)
return ntReadSet(method, stmt);
ret.union(ntReadSet(method, stmt));
return ret;
}
Aggregations