jltools.visit
Class ExceptionChecker

java.lang.Object
  |
  +--jltools.ast.NodeVisitor
        |
        +--jltools.visit.ExceptionChecker

public class ExceptionChecker
extends NodeVisitor

Visitor which checks if exceptions are caught or declared properly.


Field Summary
protected  ErrorQueue eq
           
protected  java.util.LinkedList freelist
           
protected  SubtypeSet thrown
           
protected  TypeSystem ts
           
 
Constructor Summary
  ExceptionChecker(TypeSystem ts, ErrorQueue eq)
           
protected ExceptionChecker(TypeSystem ts, ErrorQueue eq, java.util.LinkedList freelist)
           
 
Method Summary
 ExceptionChecker alloc()
           
 NodeVisitor enter(Node n)
          This method is called when we are to perform a "normal" traversal of a subtree rooted at n.
 Node leave(Node old, Node n, NodeVisitor v)
          Here, we pop the stack frame that we pushed in enter and agregate the exceptions.
 Node override(Node n)
          Given a tree rooted at n, the visitor has the option of overriding all traversal of the children of n.
 void release(ExceptionChecker ec)
           
 void throwsException(Type t)
          The ast nodes will use this callback to notify us that they throw an exception of type t.
 SubtypeSet throwsSet()
          Method to allow the throws clause and method body to inspect and modify the throwsSet.
 TypeSystem typeSystem()
           
 
Methods inherited from class jltools.ast.NodeVisitor
finish, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

thrown

protected SubtypeSet thrown

ts

protected TypeSystem ts

eq

protected ErrorQueue eq

freelist

protected java.util.LinkedList freelist
Constructor Detail

ExceptionChecker

public ExceptionChecker(TypeSystem ts,
                        ErrorQueue eq)

ExceptionChecker

protected ExceptionChecker(TypeSystem ts,
                           ErrorQueue eq,
                           java.util.LinkedList freelist)
Method Detail

typeSystem

public TypeSystem typeSystem()

override

public Node override(Node n)
Description copied from class: NodeVisitor
Given a tree rooted at n, the visitor has the option of overriding all traversal of the children of n. If no changes were made to n and the visitor wishes to prevent further traversal of the tree, then it should return n. If changes were made to the subtree, then the visitor should return a copy of n with appropriate changes. Finally, if the visitor does not wish to override traversal of the subtree rooted at n, then it should return null.
Overrides:
override in class NodeVisitor
Following copied from class: jltools.ast.NodeVisitor
Parameters:
n - The root of the subtree to be traversed.
Returns:
A node if normal traversal is to stop, null if it is to continue.

enter

public NodeVisitor enter(Node n)
This method is called when we are to perform a "normal" traversal of a subtree rooted at n. At every node, we will push a stack frame. Each child node will add the exceptions that it throws to this stack frame. For most nodes ( excdeption for the try / catch) will just aggregate the stack frames.
Overrides:
enter in class NodeVisitor
Parameters:
n - The root of the subtree to be traversed.
Returns:
The NodeVisitor which should be used to visit the children of n.

leave

public Node leave(Node old,
                  Node n,
                  NodeVisitor v)
Here, we pop the stack frame that we pushed in enter and agregate the exceptions.
Overrides:
leave in class NodeVisitor
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.

throwsException

public void throwsException(Type t)
The ast nodes will use this callback to notify us that they throw an exception of type t. This should only be called by MethodExpr node, and throw node, since they are the only node which can generate exceptions.
Parameters:
t - The type of exception that the node throws.

throwsSet

public SubtypeSet throwsSet()
Method to allow the throws clause and method body to inspect and modify the throwsSet.

alloc

public ExceptionChecker alloc()

release

public void release(ExceptionChecker ec)