jif.visit
Class ConstChecker
java.lang.Object
polyglot.visit.NodeVisitor
jif.visit.ConstChecker
- All Implemented Interfaces:
- java.lang.Cloneable, polyglot.util.Copy
public class ConstChecker
- extends polyglot.visit.NodeVisitor
Visitor which traverses an expression AST, and determines if the expression
is a constant expression. This visitor should only be used for checking the
initialization expressions of static fields; it is not checking for
compile-time constants.
In general, we prevent static initializers from containing any references,
as such a reference may cause a class to be loaded, and thus leak
information about when a class is first mentioned. However, we allow
literals (e.g. String literals) and array initializers (although if an
element of the array initalizer is not constant, it will be ruled out.)
|
Constructor Summary |
ConstChecker(polyglot.types.ClassType currentClass)
|
|
Method Summary |
boolean |
isConst()
|
polyglot.ast.Node |
leave(polyglot.ast.Node old,
polyglot.ast.Node n,
polyglot.visit.NodeVisitor v)
|
polyglot.ast.Node |
override(polyglot.ast.Node n)
|
| Methods inherited from class polyglot.visit.NodeVisitor |
begin, copy, enter, 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 |
ConstChecker
public ConstChecker(polyglot.types.ClassType currentClass)
isConst
public boolean isConst()
override
public polyglot.ast.Node override(polyglot.ast.Node n)
- Overrides:
override in class polyglot.visit.NodeVisitor
leave
public polyglot.ast.Node leave(polyglot.ast.Node old,
polyglot.ast.Node n,
polyglot.visit.NodeVisitor v)
- Overrides:
leave in class polyglot.visit.NodeVisitor