46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
package ch.usi.inf.sp.callgraph;
|
|
|
|
import java.util.List;
|
|
|
|
import ch.usi.inf.sp.framework.ClassAnalyzer;
|
|
import org.objectweb.asm.tree.ClassNode;
|
|
import org.objectweb.asm.tree.InsnList;
|
|
import org.objectweb.asm.tree.MethodNode;
|
|
|
|
|
|
/**
|
|
* Build a call graph (as part of the class hierarchy)
|
|
* consisting of CallSite nodes pointing to Method nodes.
|
|
*
|
|
* @author ?
|
|
* @author Matthias.Hauswirth@usi.ch
|
|
*/
|
|
public final class CallGraphBuilder implements ClassAnalyzer {
|
|
|
|
private final ClassHierarchy hierarchy;
|
|
|
|
|
|
public CallGraphBuilder(final ClassHierarchy hierarchy) {
|
|
this.hierarchy = hierarchy;
|
|
}
|
|
|
|
public void analyze(final String location, final ClassNode classNode) {
|
|
try {
|
|
final ClassType type = hierarchy.getOrCreateClass(classNode.name);
|
|
final List<MethodNode> methodNodes = (List<MethodNode>)classNode.methods;
|
|
for (final MethodNode methodNode : methodNodes) {
|
|
final Method method = type.getMethod(methodNode.name, methodNode.desc);
|
|
final InsnList instructions = methodNode.instructions;
|
|
for (int i=0; i<instructions.size(); i++) {
|
|
|
|
// TODO implement this
|
|
|
|
}
|
|
}
|
|
} catch (final TypeInconsistencyException ex) {
|
|
System.err.println(ex);
|
|
}
|
|
}
|
|
|
|
}
|