use of soot.SootMethod in project soot by Sable.
the class PointsToAnalysis method getLocals.
private static Map getLocals(SootClass sc, String methodname, String typename) {
Map res = new HashMap();
Iterator mi = sc.getMethods().iterator();
while (mi.hasNext()) {
SootMethod sm = (SootMethod) mi.next();
System.err.println(sm.getName());
if (true && sm.getName().equals(methodname) && sm.isConcrete()) {
JimpleBody jb = (JimpleBody) sm.retrieveActiveBody();
Iterator ui = jb.getUnits().iterator();
while (ui.hasNext()) {
Stmt s = (Stmt) ui.next();
int line = getLineNumber(s);
// find definitions
Iterator bi = s.getDefBoxes().iterator();
while (bi.hasNext()) {
Object o = bi.next();
if (o instanceof ValueBox) {
Value v = ((ValueBox) o).getValue();
if (v.getType().toString().equals(typename) && v instanceof Local)
res.put(new Integer(line), v);
}
}
}
}
}
return res;
}
use of soot.SootMethod in project soot by Sable.
the class ExprTranslator method handleSpecialCall.
// any type
boolean handleSpecialCall(InstanceInvokeExpr expr, SootMethod target) {
String mn = target.getName();
int np = target.getParameterCount();
SootClass dc = target.getDeclaringClass();
// Is it a method in a Foo object?
if (isFoo(dc)) {
if (mn.equals("foo") && np == 1) {
Variable lvar = new Variable(Variable.Type.FOO);
Method foo = new Method("foo", new Variable[0]);
FooMethodCall fmc = new FooMethodCall(foo);
fmc.setAssignmentTarget(lvar);
st.addStatement(fmc);
return true;
}
// Unknown Foo method
return false;
}
// Not a special call
return false;
}
use of soot.SootMethod in project soot by Sable.
the class ExprTranslator method caseSpecialInvokeExpr.
public void caseSpecialInvokeExpr(SpecialInvokeExpr expr) {
// Constructor calls, maybe
Variable bvar = st.getLocalVariable((Local) expr.getBase());
SootMethod m = expr.getMethod();
if (m.getName().equals("<init>")) {
SootClass dc = m.getDeclaringClass();
if (isFoo(dc)) {
FooInit fi = new FooInit();
fi.setAssignmentTarget(bvar);
st.addStatement(fi);
return;
}
}
handleCall(expr, expr.getMethod());
}
use of soot.SootMethod in project soot by Sable.
the class CallGraphExample method main.
public static void main(String[] args) {
List<String> argsList = new ArrayList<String>(Arrays.asList(args));
argsList.addAll(Arrays.asList(new String[] { "-w", "-main-class", // main-class
"testers.CallGraphs", // argument classes
"testers.CallGraphs", //
"testers.A" }));
PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new SceneTransformer() {
@Override
protected void internalTransform(String phaseName, Map options) {
CHATransformer.v().transform();
SootClass a = Scene.v().getSootClass("testers.A");
SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");
CallGraph cg = Scene.v().getCallGraph();
Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(src));
while (targets.hasNext()) {
SootMethod tgt = (SootMethod) targets.next();
System.out.println(src + " may call " + tgt);
}
}
}));
args = argsList.toArray(new String[0]);
soot.Main.main(args);
}
use of soot.SootMethod in project soot by Sable.
the class Foonalasys method loadClass.
/**
* Loads the named class into the Soot scene,
* marks it as an application class, and generates bodies
* for all of its concrete methods.
* @param name the fully qualified name of the class to be loaded.
*/
public static void loadClass(String name) {
SootClass c = Scene.v().loadClassAndSupport(name);
c.setApplicationClass();
Iterator mi = c.getMethods().iterator();
while (mi.hasNext()) {
SootMethod sm = (SootMethod) mi.next();
if (sm.isConcrete()) {
sm.retrieveActiveBody();
}
}
}
Aggregations