|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.visit.NodeVisitor
polyglot.visit.HaltingVisitor
polyglot.visit.ErrorHandlingVisitor
polyglot.visit.DataFlow
polyglot.visit.DeadCodeEliminator
public class DeadCodeEliminator
Visitor which performs dead code elimination.
Nested Class Summary | |
---|---|
protected static class |
DeadCodeEliminator.DataFlowItem
|
protected static class |
DeadCodeEliminator.DefUseFinder
|
Nested classes/interfaces inherited from class polyglot.visit.DataFlow |
---|
DataFlow.BoolItem, DataFlow.ConditionNavigator, DataFlow.FlowGraphSource, DataFlow.Item |
Field Summary |
---|
Fields inherited from class polyglot.visit.DataFlow |
---|
dataflowOnEntry, flowCounter, flowgraphStack, forward |
Fields inherited from class polyglot.visit.ErrorHandlingVisitor |
---|
error, job, nf, ts |
Constructor Summary | |
---|---|
DeadCodeEliminator(Job job,
TypeSystem ts,
NodeFactory nf)
|
Method Summary | |
---|---|
void |
check(FlowGraph graph,
Term n,
DataFlow.Item inItem,
java.util.Map outItems)
Check that the term n satisfies whatever properties this dataflow is checking for. |
DataFlow.Item |
confluence(java.util.List inItems,
Term node,
FlowGraph graph)
The confluence operator for many flows. |
protected NodeVisitor |
createDefUseFinder(java.util.Set def,
java.util.Set use)
|
DataFlow.Item |
createInitialItem(FlowGraph graph,
Term node)
Create an initial Item for the term node. |
protected DeadCodeEliminator.DataFlowItem |
flow(DataFlow.Item in,
FlowGraph graph,
Term t)
|
java.util.Map |
flow(DataFlow.Item in,
FlowGraph graph,
Term t,
java.util.Set succEdgeKeys)
Produce new Item s as appropriate for the
Term n and the input Item in . |
protected java.util.Set[] |
getDefUse(Node n)
Returns array of sets of local instances. |
protected Stmt |
getEffects(Expr expr)
Returns a statement that is side-effect-equivalent to the given expression. |
Node |
leaveCall(Node old,
Node n,
NodeVisitor v)
Contains all of the functionality that can be done in the leave
method, but allows SemanticExceptions to be
thrown. |
void |
post(FlowGraph graph,
Term root)
Check all of the Peers in the graph, after the dataflow analysis has been performed. |
Methods inherited from class polyglot.visit.DataFlow |
---|
confluence, constructItemsFromCondition, createCFGBuilder, currentFlowGraph, dataflow, dataflow, dumpFlowGraph, enterCall, filterItems, filterItemsExceptionSubclass, filterItemsNonError, filterItemsNonException, findSCCs, flow, flow, flowBooleanConditions, flowToBooleanFlow, hasTrueFalseBranches, initGraph, itemsToMap, itemToMap, leave, leaveCall, safeConfluence, safeConfluence, safeConfluence |
Methods inherited from class polyglot.visit.ErrorHandlingVisitor |
---|
begin, catchErrors, enter, enterCall, enterError, errorQueue, job, nodeFactory, typeSystem |
Methods inherited from class polyglot.visit.HaltingVisitor |
---|
bypass, bypass, bypassChildren, copy, override, visitChildren |
Methods inherited from class polyglot.visit.NodeVisitor |
---|
enter, finish, finish, leave, override, toString, visitEdge |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DeadCodeEliminator(Job job, TypeSystem ts, NodeFactory nf)
Method Detail |
---|
public DataFlow.Item createInitialItem(FlowGraph graph, Term node)
DataFlow
createInitialItem
in class DataFlow
public DataFlow.Item confluence(java.util.List inItems, Term node, FlowGraph graph)
DataFlow
confluence
in class DataFlow
inItems
- List of Item
s that flow into node
.
this method will only be called if the list has at least 2
elements.node
- Term
for which the items
are
flowing into.
public java.util.Map flow(DataFlow.Item in, FlowGraph graph, Term t, java.util.Set succEdgeKeys)
DataFlow
Item
s as appropriate for the
Term n
and the input Item in
.
flow
in class DataFlow
in
- the Item flowing into the node. Note that if the Term n
has many flows going into it, the Item in may be the result
of a call to confluence(List, List, Term)graph
- the FlowGraph which the dataflow is operating ont
- the Term which this method must calculate the flow for.succEdgeKeys
- a set of FlowGraph.EdgeKeys, being all the
EdgeKeys of the edges leaving this node. The
returned Map must have mappings for all objects in this set.
protected DeadCodeEliminator.DataFlowItem flow(DataFlow.Item in, FlowGraph graph, Term t)
public void post(FlowGraph graph, Term root) throws SemanticException
DataFlow
post
in class DataFlow
SemanticException
public void check(FlowGraph graph, Term n, DataFlow.Item inItem, java.util.Map outItems) throws SemanticException
DataFlow
check
in class DataFlow
SemanticException
public Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException
ErrorHandlingVisitor
leave
method, but allows SemanticExceptions
to be
thrown.
This method is in addition to the leave
method,
and allows the compiler writer to write code that can throw errors
and let the polyglot infrastructure handle the exceptions.
leaveCall
in class ErrorHandlingVisitor
old
- The original state of root of the current subtree.n
- The current state of the root of the current subtree.v
- The NodeVisitor
object used to visit the children.
n
.
SemanticException
NodeVisitor.leave(Node, Node, NodeVisitor)
protected java.util.Set[] getDefUse(Node n)
protected NodeVisitor createDefUseFinder(java.util.Set def, java.util.Set use)
protected Stmt getEffects(Expr expr)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |