polyglot.visit
Class CodeCleaner
java.lang.Object
polyglot.visit.NodeVisitor
polyglot.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.
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
nf
protected NodeFactory nf
alphaRen
protected AlphaRenamer alphaRen
CodeCleaner
public CodeCleaner(NodeFactory nf)
- Creates a visitor for cleaning code.
- Parameters:
nf
- The node factory to be used when generating new nodes.
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.