Exemplo n.º 1
0
  @Override
  public void see(Implementation implementation, Signature sig, Body body, Declaration tail) {
    // initialize graph
    currentFlowGraph = new SimpleGraph<Block>();
    flowGraphs.put(implementation, currentFlowGraph);

    // get blocks by name
    blocksByName = new HashMap<String, Block>();
    Block b = body.getBlocks();
    while (b != null) {
      blocksByName.put(b.getName(), b);
      currentFlowGraph.node(b);
      b = b.getTail();
    }

    // build graph
    body.eval(this);

    // check for reachability
    seenBlocks = new HashSet<Block>();
    b = body.getBlocks();
    if (b == null) return;
    dfs(b);
    while (b != null) {
      if (!seenBlocks.contains(b))
        Err.warning("" + b.loc() + ": Block " + b.getName() + " is unreachable.");
      b = b.getTail();
    }

    if (tail != null) tail.eval(this);
  }
Exemplo n.º 2
0
 @Override
 public void see(AtomId atomId, String id) {
   if (currentBlock == null) return;
   Block target = blocksByName.get(id);
   if (target == null) {
     Err.error("" + atomId.loc() + ": Inexistent block " + id + ".");
     errors = true;
   } else currentFlowGraph.edge(currentBlock, target);
 }