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
 /**
  * Constructs flow graphs for {@code ast}. It also prints warnings if there are syntactically
  * unreachable blocks.
  *
  * @param ast the AST for which to build flow graphs
  * @return whether there were missing blocks
  */
 public boolean process(Declaration ast) {
   currentBlock = null;
   errors = false;
   flowGraphs = new HashMap<Implementation, SimpleGraph<Block>>();
   ast.eval(this);
   return errors;
 }