TranslatorContext context = new TranslatorContext(graph, errors);
Translator translator = new Translator(context, config);
// create methods and parse field annotations
for (SootClass c : Scene.v().getApplicationClasses()) {
for (SootMethod m : c.getMethods()) {
Origin origin = new Origin(c.getName() + "." + m.getName(), 0, 0);
Statement methodentry, methodexit;
Variable returnVar;
Variable[] parameters = new Variable[m.getParameterCount()];
if (m.isConcrete()) {
// entry
methodentry = new NopStm(origin, "method entry");
graph.addNode(methodentry);
// exit
methodexit = new NopStm(origin, "method exit");
graph.addNode(methodexit);
// parameters
for (int i=0; i<m.getParameterCount(); i++) {
parameters[i] = new Variable(context.getNextVarID(), false);
}
// return var
returnVar = new Variable(context.getNextVarID(), false);
// externally callable
if (config.isExternallyCallable(m)) {
graph.addEntry(methodentry);
}
} else {
// non-concrete method. it must still be created for annotations to
// be visible.
methodentry = methodexit = null;
returnVar = null;
}
// parse annotations
SchemaType returnType;
if (context.isAnnotatableType(m.getReturnType())) {
returnType = context.parseSchemaType(config.getMethodReturnType(m, context.getTypeAnnotation(m)), origin);
} else {
returnType = null;
}
SchemaType[] paramTypes = new SchemaType[m.getParameterCount()];
for (int i=0; i<m.getParameterCount(); i++) {
if (context.isAnnotatableType(m.getParameterType(i))) {
paramTypes[i] = context.parseSchemaType(config.getMethodParameterType(m, i, context.getTypeAnnotationForParameter(m, i)), origin);
}
}
// make the method
Method method = new Method(m.getName(), methodentry, methodexit, parameters, returnVar, returnType, paramTypes);
context.setMethod(m, method);
}
for (SootField f : c.getFields()) {
// parse annotations
if (context.isAnnotatableType(f.getType())) {
Origin origin = new Origin(c.getName() + "." + f.getName(), 0, 0);
context.setFieldSchemaType(f, context.parseSchemaType(config.getFieldType(f, context.getTypeAnnotation(f)), origin));
}
}
}
// translate!