polyglot.visit
Class CodeCleaner

java.lang.Object
  extended bypolyglot.visit.NodeVisitor
      extended bypolyglot.visit.CodeCleaner

public class CodeCleaner
extends NodeVisitor

The CodeCleaner runs over the AST and performs some trivial dead code elimination, while flattening blocks wherever possible.


Field Summary
protected  AlphaRenamer alphaRen
           
protected  NodeFactory nf
           
 
Constructor Summary
CodeCleaner(NodeFactory nf)
          Creates a visitor for cleaning code.
 
Method Summary
protected  java.util.List clean(java.util.List l)
          Performs some trivial dead code elimination on a list of statements.
protected  java.util.List flattenBlock(Block b)
          Turns a Block into a list of Stmts.
protected  java.util.Set labelRefs(Block b)
          Traverses a Block and determines the set of label references.
 Node leave(Node old, Node n, NodeVisitor v)
           
 
Methods inherited from class polyglot.visit.NodeVisitor
begin, enter, enter, finish, finish, leave, override, override, toString, visitEdge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nf

protected NodeFactory nf

alphaRen

protected AlphaRenamer alphaRen
Constructor Detail

CodeCleaner

public CodeCleaner(NodeFactory nf)
Creates a visitor for cleaning code.

Parameters:
nf - The node factory to be used when generating new nodes.
Method Detail

leave

public Node leave(Node old,
                  Node n,
                  NodeVisitor v)
Overrides:
leave in class NodeVisitor

flattenBlock

protected java.util.List flattenBlock(Block b)
Turns a Block into a list of Stmts.


clean

protected java.util.List clean(java.util.List l)
Performs some trivial dead code elimination on a list of statements.


labelRefs

protected java.util.Set labelRefs(Block b)
Traverses a Block and determines the set of label references.