polyglot.visit
Class ReachChecker

java.lang.Object
  extended by polyglot.visit.NodeVisitor
      extended by polyglot.visit.HaltingVisitor
          extended by polyglot.visit.ErrorHandlingVisitor
              extended by polyglot.visit.DataFlow
                  extended by polyglot.visit.ReachChecker
All Implemented Interfaces:
java.lang.Cloneable, Copy

public class ReachChecker
extends DataFlow

Visitor which checks that all statements must be reachable


Nested Class Summary
protected static class ReachChecker.DataFlowItem
           
 
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
ReachChecker(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.
protected  Node checkReachability(Term n)
           
 DataFlow.Item confluence(java.util.List inItems, java.util.List itemKeys, Term node, FlowGraph graph)
          The confluence operator for many flows.
 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.
 java.util.Map flow(DataFlow.Item in, FlowGraph graph, Term n, java.util.Set succEdgeKeys)
          Produce new Items as appropriate for the Term n and the input Item in.
 Node leaveCall(Node n)
          Overridden superclass method, to pop from the stack of FlowGraphs if necessary.
 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
constructItemsFromCondition, createCFGBuilder, currentFlowGraph, dataflow, dataflow, dumpFlowGraph, enterCall, filterItems, filterItemsExceptionSubclass, filterItemsNonError, filterItemsNonException, findSCCs, flow, flow, flowBooleanConditions, flowToBooleanFlow, hasTrueFalseBranches, initGraph, itemsToMap, itemToMap, leave, safeConfluence, safeConfluence, safeConfluence
 
Methods inherited from class polyglot.visit.ErrorHandlingVisitor
begin, catchErrors, enter, enterCall, enterError, errorQueue, job, leaveCall, 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

ReachChecker

public ReachChecker(Job job,
                    TypeSystem ts,
                    NodeFactory nf)
Method Detail

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.

flow

public java.util.Map flow(DataFlow.Item in,
                          FlowGraph graph,
                          Term n,
                          java.util.Set succEdgeKeys)
Description copied from class: DataFlow
Produce new Items 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 on
n - 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.

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 Items 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.

confluence

public DataFlow.Item confluence(java.util.List inItems,
                                java.util.List itemKeys,
                                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.

Overrides:
confluence in class DataFlow
Parameters:
inItems - List of Items that flow into node. This method will only be called if the list has at least 2 elements.
itemKeys - List of FlowGraph.ExceptionEdgeKeys for the edges that the corresponding Items in items flowed from.
node - Term for which the items are flowing into.
Returns:
a non-null Item.

leaveCall

public Node leaveCall(Node n)
               throws SemanticException
Description copied from class: DataFlow
Overridden superclass method, to pop from the stack of FlowGraphs if necessary.

Overrides:
leaveCall in class DataFlow
Throws:
SemanticException

checkReachability

protected Node checkReachability(Term n)
                          throws SemanticException
Throws:
SemanticException

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