示例#1
0
  /* Processing assignments of actuals to formals at a call
  site. The first parameter is the call instruction. The second
  is the formal parameter. The last two represent the variable or
  the field being passed.

  For return values, the second parameter is the formal return
  variable in the callee, and the last two parameters are the
  variable/field that the call is assigned to. */
  public void assignParams(Call call, Var p, Var x, Field f, boolean isBasic) {

    if (!isBasic) {
      Method callee = call.getCallee();
      Graph gcallee = PointsToAnalysis.v().getGraph(callee);

      Node nodeL = gcallee.getNode(p, null);
      Node nodeR = this.getNode(x, f);
      if (Options.mergeGraphs.value && this == gcallee) {
        if (p.isReturn()) w.addFirst(new UnifyConstraint(nodeR, nodeL));
        else w.addFirst(new UnifyConstraint(nodeL, nodeR));
      }
      callsites.add(call);
      callees.add(callee);
      gcallee.callers.add(method);
      gcallee.w.add(new CallConstraint(nodeR, nodeL, call));
    }

    if (f != null) setTouched(x);
  }
示例#2
0
  /** Is tag reachable from node on paths with no visited nodes? */
  private Node reachesTag(Node node, UniqueTag tag, Set<Node> visited) {
    assert (node.isRep());
    if (visited.contains(node)) return null;
    if (tag.mergeable(node.tag)) return node;

    visited.add(node);

    if (secondary_index[2]) {
      for (Field f : node.infields.keySet())
        for (FieldEdge e : node.infields.get(f)) {
          assert (e.dst == node);
          Node result = reachesTag(e.src.getRep(), tag, visited);
          if (result != null) return result;
        }
    } else {
      for (Field f : fedges.keySet())
        for (FieldEdge e : fedges.get(f)) {
          if (e.dst != node) continue;
          Node result = reachesTag(e.src, tag, visited);
          if (result != null) return result;
        }
    }
    return null;
  }