polyglot.visit
Class CopyPropagator
java.lang.Object
polyglot.visit.NodeVisitor
polyglot.visit.HaltingVisitor
polyglot.visit.ErrorHandlingVisitor
polyglot.visit.DataFlow
polyglot.visit.CopyPropagator
- All Implemented Interfaces:
- java.lang.Cloneable, Copy
public class CopyPropagator
- extends DataFlow
Visitor which performs copy propagation.
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. |
DataFlow.Item |
createInitialItem(FlowGraph graph,
Term node)
Create an initial Item for the term node. |
protected CopyPropagator.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 . |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
CopyPropagator
public CopyPropagator(Job job,
TypeSystem ts,
NodeFactory nf)
createInitialItem
public DataFlow.Item createInitialItem(FlowGraph graph,
Term node)
- Description copied from class:
DataFlow
- Create an initial Item for the term node. This is generally how the Item that will be given
to the start node of a graph is created, although this method may also be called for other
(non-start) nodes.
- Specified by:
createInitialItem
in class DataFlow
- Returns:
- a (possibly null) Item.
confluence
public DataFlow.Item confluence(java.util.List inItems,
Term node,
FlowGraph graph)
- Description copied from class:
DataFlow
- The confluence operator for many flows. This method produces a single
Item from a List of Items, for the confluence just before flow enters
node.
- Specified by:
confluence
in class DataFlow
- Parameters:
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.
- Returns:
- a non-null Item.
flow
protected CopyPropagator.DataFlowItem flow(DataFlow.Item in,
FlowGraph graph,
Term t)
flow
public java.util.Map flow(DataFlow.Item in,
FlowGraph graph,
Term t,
java.util.Set succEdgeKeys)
- Description copied from class:
DataFlow
- Produce new
Item
s as appropriate for the
Term n
and the input Item in
.
- Overrides:
flow
in class DataFlow
- Parameters:
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.
- Returns:
- a Map from FlowGraph.EdgeKeys to Items. The map must have
entries for all EdgeKeys in edgeKeys.
post
public void post(FlowGraph graph,
Term root)
throws SemanticException
- Description copied from class:
DataFlow
- Check all of the Peers in the graph, after the dataflow analysis has
been performed.
- Overrides:
post
in class DataFlow
- Throws:
SemanticException
check
public void check(FlowGraph graph,
Term n,
DataFlow.Item inItem,
java.util.Map outItems)
throws SemanticException
- Description copied from class:
DataFlow
- Check that the term n satisfies whatever properties this
dataflow is checking for. This method is called for each term
in a code declaration block after the dataflow for that block of code
has been performed.
- Specified by:
check
in class DataFlow
- Throws:
SemanticException
leaveCall
public Node leaveCall(Node old,
Node n,
NodeVisitor v)
throws SemanticException
- Description copied from class:
ErrorHandlingVisitor
- Contains all of the functionality that can be done in the
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.
- Overrides:
leaveCall
in class ErrorHandlingVisitor
- Parameters:
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.
- Returns:
- The final result of the traversal of the tree rooted at
n
.
- Throws:
SemanticException
- See Also:
NodeVisitor.leave(Node, Node, NodeVisitor)