use of dk.brics.soot.intermediate.representation.Method in project soot by Sable.
the class JavaTranslator method makeMethods.
void makeMethods() {
Collection<SootClass> app = Scene.v().getApplicationClasses();
for (SootClass ac : app) {
List<SootMethod> sootMethods = ac.getMethods();
for (SootMethod sm : sootMethods) {
List<Variable> vars = new LinkedList<Variable>();
List<Type> params = sm.getParameterTypes();
for (Type pt : params) {
Variable v = makeVariable(pt);
vars.add(v);
}
Variable[] var_array = (Variable[]) vars.toArray(new Variable[0]);
Method m = new Method(sm.getName(), var_array);
methods.add(m);
methodsignaturToMethod.put(sm.getSignature(), m);
}
}
}
use of dk.brics.soot.intermediate.representation.Method 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 dk.brics.soot.intermediate.representation.Method in project soot by Sable.
the class ExprTranslator method handleCall.
// For a single target, foo-type or not, non-special
void handleCall(InvokeExpr expr, SootMethod target) {
SootClass dc = target.getDeclaringClass();
if (jt.isApplicationClass(dc)) {
if (!dc.isInterface()) {
// Target in an application class.
// Setup call to translated method.
Method method = jt.methodsignaturToMethod.get(target.getSignature());
SomeMethodCall smc = new SomeMethodCall(method, getArgs(target));
st.addStatement(smc);
} else {
// Call to interface method or abstract method as target.
// Only occurs if no implementions are found.
// Arguments are evaluated and nothing is returned.
jt.notSupported("We don't support interface calls");
}
} else {
// Target in non-application class.
// We should Escape all arguments and corrupt result.
// So this might not be what we want.
Method method = new Method(target.getName(), getArgs(target));
SomeMethodCall smc = new SomeMethodCall(method, getArgs(target));
st.addStatement(smc);
return;
}
}
use of dk.brics.soot.intermediate.representation.Method in project soot by Sable.
the class JavaTranslator method translate.
private void translate() {
st = new StmtTranslator(this);
Collection<SootClass> app = Scene.v().getApplicationClasses();
for (SootClass ac : app) {
st.setCurrentClass(ac);
List<SootMethod> sootMethods = ac.getMethods();
for (SootMethod sm : sootMethods) {
if (sm.isConcrete()) {
Method method = methodsignaturToMethod.get(sm.getSignature());
st.setCurrentMethod(sm);
CompleteUnitGraph cug = new CompleteUnitGraph(sm.retrieveActiveBody());
Iterator si = cug.iterator();
while (si.hasNext()) {
Stmt stmt = (Stmt) si.next();
st.translateStmt(stmt);
}
// System.err.println("Setting up link between entry and first stmt of the method...");
si = cug.getHeads().iterator();
while (si.hasNext()) {
Stmt stmt = (Stmt) si.next();
method.getEntry().addSucc(st.getFirst(stmt));
}
si = cug.iterator();
// System.err.println("Setting up link between the last statement and the first statement...");
while (si.hasNext()) {
Stmt stmt = (Stmt) si.next();
Iterator si2 = cug.getSuccsOf(stmt).iterator();
while (si2.hasNext()) {
Stmt stmt2 = (Stmt) si2.next();
st.getLast(stmt).addSucc(st.getFirst(stmt2));
}
}
// System.err.println("!!!!!!!!!!!!!!!!!!"+sm.getName()+"!!!!!!!!!!!!!!!!!!!!");
// si = cug.iterator();
// while (si.hasNext()) {
// Stmt stmt = (Stmt)si.next();
// System.err.println("The stmt: "+stmt+" translates to "+st.getFirst(stmt));
// //System.err.println(st.getFirst(stmt).getSuccs());
// }
// System.err.println("######################################");
}
}
}
}
Aggregations