예제 #1
0
 public boolean isRef() {
   if (kind == Kind.FORMAL_IN || kind == Kind.ACTUAL_OUT) {
     return false;
   } else if (kind == Kind.FORMAL_OUT || kind == Kind.ACTUAL_IN) {
     return true;
   } else {
     return (cand != null ? cand.isRef() : false);
   }
 }
예제 #2
0
  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);
    }
  }
예제 #3
0
  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);
  }
예제 #4
0
 public String toString() {
   return (cand == null ? node.toString() : cand.toString());
 }