polyglot.ext.coffer.visit
Class KeyChecker

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.ext.coffer.visit.KeyChecker
All Implemented Interfaces:
java.lang.Cloneable, Copy

public class KeyChecker
extends DataFlow

Data flow analysis to compute and check held key sets.


Nested Class Summary
 
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
KeyChecker(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  DataFlow.Item confluence(java.util.List items, java.util.List itemKeys, Term node, FlowGraph graph)
          The confluence operator for many flows.
protected  DataFlow.Item confluence(java.util.List inItems, Term node, FlowGraph graph)
          The confluence operator for many flows.
protected  DataFlow.Item confluenceExitTerm(java.util.List items, java.util.List itemKeys, FlowGraph graph)
           
 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.
protected  DataFlow.Item safeConfluence(java.util.List items, java.util.List itemKeys, Term node, FlowGraph graph)
          The confluence operator for many flows.
 
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, leaveCall, post, 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

KeyChecker

public KeyChecker(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.

safeConfluence

protected DataFlow.Item safeConfluence(java.util.List items,
                                       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:
safeConfluence in class DataFlow
Parameters:
items - 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.

confluence

protected DataFlow.Item confluence(java.util.List items,
                                   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:
items - 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.

confluenceExitTerm

protected DataFlow.Item confluenceExitTerm(java.util.List items,
                                           java.util.List itemKeys,
                                           FlowGraph graph)

confluence

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

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