private void createInitalNodesAndFlow( final Map<PDGNode, Node> pdg2cfg, final ModRefCandidates modref, final PDG pdg) { final Node nEntry = createNOPNode(pdg.entry); this.entry = nEntry; pdg2cfg.put(pdg.entry, nEntry); final Node nExit = createNOPNode(pdg.exit); this.exit = nExit; pdg2cfg.put(pdg.exit, nExit); for (final PDGField fref : pdg.getFieldReads()) { if (!fref.field.isStatic()) { final SSAInstruction instr = pdg.getInstruction(fref.node); final ModRefFieldCandidate refCand = modref.createRefCandidate(pdg.cgNode, instr); final Node n = createNode(refCand, fref.accfield, Node.Kind.READ); pdg2cfg.put(fref.accfield, n); } } for (final PDGField fmod : pdg.getFieldWrites()) { if (!fmod.field.isStatic()) { final SSAInstruction instr = pdg.getInstruction(fmod.node); final ModRefFieldCandidate refCand = modref.createModCandidate(pdg.cgNode, instr); final Node n = createNode(refCand, fmod.accfield, Node.Kind.WRITE); pdg2cfg.put(fmod.accfield, n); } } for (final PDGNode pn : pdg.vertexSet()) { if (pn.getPdgId() == pdg.getId() && !pdg2cfg.containsKey(pn)) { final Node n = createNOPNode(pn); pdg2cfg.put(pn, n); } } for (final PDGEdge e : pdg.edgeSet()) { if (e.kind == PDGEdge.Kind.CONTROL_FLOW || e.kind == PDGEdge.Kind.CONTROL_FLOW_EXC) { final Node from = pdg2cfg.get(e.from); final Node to = pdg2cfg.get(e.to); addEdge(from, to); } } }
private void createActualInAndOut( final Map<PDGNode, Node> pdg2cfg, final ModRefCandidates modref, final PDG pdg, final CallGraph cg) { for (final PDGNode call : pdg.getCalls()) { final Node cn = pdg2cfg.get(call); final SSAInvokeInstruction invk = (SSAInvokeInstruction) pdg.getInstruction(call); final CallSiteReference site = invk.getCallSite(); final Set<ModRefFieldCandidate> modRefCands = new HashSet<ModRefFieldCandidate>(); for (final CGNode tgt : cg.getPossibleTargets(pdg.cgNode, site)) { final InterProcCandidateModel tgtModRef = modref.getCandidates(tgt); if (tgtModRef == null) { continue; } for (final ModRefFieldCandidate c : tgtModRef) { modRefCands.add(c); } } final List<ModRefFieldCandidate> refs = new LinkedList<ModRefFieldCandidate>(); final List<ModRefFieldCandidate> mods = new LinkedList<ModRefFieldCandidate>(); for (final ModRefFieldCandidate c : modRefCands) { if (c.isMod()) { mods.add(c); } if (c.isRef()) { refs.add(c); } } addNodesBefore(cn, refs, Node.Kind.ACTUAL_IN); addNodesAfter(cn, mods, Node.Kind.ACTUAL_OUT); } }
private void createFormalInAndOut( final Map<PDGNode, Node> pdg2cfg, final ModRefCandidates modref, final PDG pdg) { final InterProcCandidateModel pdgModRef = modref.getCandidates(pdg.cgNode); if (pdgModRef == null) { return; } final List<ModRefFieldCandidate> ref = new LinkedList<ModRefFieldCandidate>(); final List<ModRefFieldCandidate> mod = new LinkedList<ModRefFieldCandidate>(); for (final ModRefFieldCandidate c : pdgModRef) { if (c.isMod()) { mod.add(c); } if (c.isRef()) { ref.add(c); } } addNodesAfter(entry, ref, Node.Kind.FORMAL_IN); addNodesBefore(exit, mod, Node.Kind.FORMAL_OUT); }