Search in sources :

Example 1 with SiteInvocationEdge

use of org.mapleir.deob.callgraph.CallGraphEdge.SiteInvocationEdge in project maple-ir by LLVM-but-worse.

the class SensitiveCallGraphBuilder method process.

@Override
public void process(Worklist<MethodNode> worklist, MethodNode n) {
    if (worklist != this.worklist) {
        throw new IllegalStateException();
    }
    if (worklist.hasProcessed(n)) {
        throw new UnsupportedOperationException(String.format("Already processed %s", n));
    }
    /* this is not the same as getNode */
    CallGraphNode.CallReceiverNode currentReceiverNode = createNode(n, false);
    ControlFlowGraph cfg = context.getIRCache().get(n);
    if (cfg == null) {
        return;
    }
    for (Stmt stmt : cfg.stmts()) {
        for (Expr e : stmt.enumerateOnlyChildren()) {
            if (e instanceof Invocation) {
                Invocation invoke = (Invocation) e;
                CallGraphNode.CallSiteNode thisCallSiteNode = callGraph.addInvocation(n, invoke);
                /* link the current receiver to this call site. */
                FunctionOwnershipEdge foe = new FunctionOwnershipEdge(currentReceiverNode, thisCallSiteNode);
                callGraph.addEdge(currentReceiverNode, foe);
                Set<MethodNode> targets = invoke.resolveTargets(context.getInvocationResolver());
                for (MethodNode target : targets) {
                    CallGraphNode.CallReceiverNode targetReceiverNode = createNode(target, true);
                    /* link each target to the call site. */
                    SiteInvocationEdge sie = new SiteInvocationEdge(thisCallSiteNode, targetReceiverNode);
                    callGraph.addEdge(thisCallSiteNode, sie);
                }
            }
        }
    }
}
Also used : Invocation(org.mapleir.ir.code.expr.invoke.Invocation) SiteInvocationEdge(org.mapleir.deob.callgraph.CallGraphEdge.SiteInvocationEdge) Stmt(org.mapleir.ir.code.Stmt) Expr(org.mapleir.ir.code.Expr) MethodNode(org.objectweb.asm.tree.MethodNode) ControlFlowGraph(org.mapleir.ir.cfg.ControlFlowGraph) FunctionOwnershipEdge(org.mapleir.deob.callgraph.CallGraphEdge.FunctionOwnershipEdge)

Aggregations

FunctionOwnershipEdge (org.mapleir.deob.callgraph.CallGraphEdge.FunctionOwnershipEdge)1 SiteInvocationEdge (org.mapleir.deob.callgraph.CallGraphEdge.SiteInvocationEdge)1 ControlFlowGraph (org.mapleir.ir.cfg.ControlFlowGraph)1 Expr (org.mapleir.ir.code.Expr)1 Stmt (org.mapleir.ir.code.Stmt)1 Invocation (org.mapleir.ir.code.expr.invoke.Invocation)1 MethodNode (org.objectweb.asm.tree.MethodNode)1