jif.visit
Class PreciseClassChecker

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 jif.visit.PreciseClassChecker
All Implemented Interfaces:
java.lang.Cloneable, polyglot.util.Copy

public class PreciseClassChecker
extends polyglot.visit.DataFlow

Visitor which determines at which program points more precise information is known about the runtime class of local variables and final access paths. This information is then stored in the appropriate delegates.


Nested Class Summary
 
Nested classes/interfaces inherited from class polyglot.visit.DataFlow
polyglot.visit.DataFlow.BoolItem, polyglot.visit.DataFlow.ConditionNavigator, polyglot.visit.DataFlow.FlowGraphSource, polyglot.visit.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
 
Fields inherited from class polyglot.visit.HaltingVisitor
bypass, bypassParent
 
Constructor Summary
PreciseClassChecker(polyglot.frontend.Job job)
           
PreciseClassChecker(polyglot.frontend.Job job, polyglot.types.TypeSystem ts, polyglot.ast.NodeFactory nf)
           
 
Method Summary
 polyglot.visit.NodeVisitor begin()
           
protected  void check(polyglot.visit.FlowGraph graph, polyglot.ast.Term n, boolean entry, polyglot.visit.DataFlow.Item inItem, java.util.Map outItems)
          "Check" the nodes of the graph for the precise class analysis.
protected  polyglot.visit.DataFlow.Item confluence(java.util.List items, polyglot.ast.Term node, boolean entry, polyglot.visit.FlowGraph graph)
          The confluence operator is intersection: a variable is not null only if it is not null on all paths flowing in.
protected  polyglot.visit.DataFlow.Item createInitialItem(polyglot.visit.FlowGraph graph, polyglot.ast.Term node, boolean entry)
          Create an initial Item for the dataflow analysis.
 polyglot.visit.DataFlow.Item createItem(polyglot.visit.FlowGraph graph, polyglot.ast.Term n)
           
 java.util.Map flow(polyglot.visit.DataFlow.Item trueItem, polyglot.visit.DataFlow.Item falseItem, polyglot.visit.DataFlow.Item otherItem, polyglot.visit.FlowGraph graph, polyglot.ast.Term n, boolean entry, java.util.Set succEdgeKeys)
          If a local variable is initialized with a non-null expression, then the variable is not null.
protected  java.util.Map flow(java.util.List inItems, java.util.List inItemKeys, polyglot.visit.FlowGraph graph, polyglot.ast.Term n, boolean entry, java.util.Set edgeKeys)
           
 
Methods inherited from class polyglot.visit.DataFlow
confluence, constructItemsFromCondition, createCFGBuilder, currentFlowGraph, dataflow, dataflow, dataflow, dumpFlowGraph, enterCall, filterItems, filterItemsExceptionSubclass, filterItemsNonError, filterItemsNonException, findSCCs, flow, flowBooleanConditions, flowToBooleanFlow, hasTrueFalseBranches, initGraph, initGraph, itemsToMap, itemToMap, leave, leaveCall, post, safeConfluence, safeConfluence, safeConfluence
 
Methods inherited from class polyglot.visit.ErrorHandlingVisitor
catchErrors, enter, enterCall, enterError, errorQueue, hasErrors, job, leaveCall, leaveCall, nodeFactory, typeSystem
 
Methods inherited from class polyglot.visit.HaltingVisitor
bypass, bypass, bypassChildren, override, visitChildren
 
Methods inherited from class polyglot.visit.NodeVisitor
copy, enter, finish, finish, leave, override, toString, visitEdge, visitEdgeNoOverride
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PreciseClassChecker

public PreciseClassChecker(polyglot.frontend.Job job,
                           polyglot.types.TypeSystem ts,
                           polyglot.ast.NodeFactory nf)

PreciseClassChecker

public PreciseClassChecker(polyglot.frontend.Job job)
Method Detail

begin

public polyglot.visit.NodeVisitor begin()
Overrides:
begin in class polyglot.visit.ErrorHandlingVisitor

createItem

public polyglot.visit.DataFlow.Item createItem(polyglot.visit.FlowGraph graph,
                                               polyglot.ast.Term n)

createInitialItem

protected polyglot.visit.DataFlow.Item createInitialItem(polyglot.visit.FlowGraph graph,
                                                         polyglot.ast.Term node,
                                                         boolean entry)
Create an initial Item for the dataflow analysis. By default, the set of not null variables is empty.

Specified by:
createInitialItem in class polyglot.visit.DataFlow

flow

protected java.util.Map flow(java.util.List inItems,
                             java.util.List inItemKeys,
                             polyglot.visit.FlowGraph graph,
                             polyglot.ast.Term n,
                             boolean entry,
                             java.util.Set edgeKeys)
Overrides:
flow in class polyglot.visit.DataFlow

flow

public java.util.Map flow(polyglot.visit.DataFlow.Item trueItem,
                          polyglot.visit.DataFlow.Item falseItem,
                          polyglot.visit.DataFlow.Item otherItem,
                          polyglot.visit.FlowGraph graph,
                          polyglot.ast.Term n,
                          boolean entry,
                          java.util.Set succEdgeKeys)
If a local variable is initialized with a non-null expression, then the variable is not null. If a local variable is assigned non-null expression then the variable is not null; if a local variable is assigned a possibly null expression, then the local variable is possibly null.

Overrides:
flow in class polyglot.visit.DataFlow

confluence

protected polyglot.visit.DataFlow.Item confluence(java.util.List items,
                                                  polyglot.ast.Term node,
                                                  boolean entry,
                                                  polyglot.visit.FlowGraph graph)
The confluence operator is intersection: a variable is not null only if it is not null on all paths flowing in.

Specified by:
confluence in class polyglot.visit.DataFlow

check

protected void check(polyglot.visit.FlowGraph graph,
                     polyglot.ast.Term n,
                     boolean entry,
                     polyglot.visit.DataFlow.Item inItem,
                     java.util.Map outItems)
              throws polyglot.types.SemanticException
"Check" the nodes of the graph for the precise class analysis. This actually consists of setting the preciseClass field in the Jif extensions to nodes, so that their exceptionCheck methods can decide whether to suppress the ClassCastExceptions that they would otherwise declare would be thrown.

Specified by:
check in class polyglot.visit.DataFlow
Throws:
polyglot.types.SemanticException