|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface NodeOps
A Node
represents an AST node. All AST nodes must implement
this interface. Nodes should be immutable: methods which set fields
of the node should copy the node, set the field in the copy, and then
return the copy.
Method Summary | |
---|---|
void |
addDecls(Context c)
Add any declarations to the context that should be in scope when visiting later sibling nodes. |
Node |
buildTypes(TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these. |
NodeVisitor |
buildTypesEnter(TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node and constructs type objects for these. |
Node |
checkConstants(ConstantChecker cc)
|
Node |
disambiguate(AmbiguityRemover ar)
Remove any remaining ambiguities from the AST. |
NodeVisitor |
disambiguateEnter(AmbiguityRemover ar)
|
Node |
disambiguateOverride(Node parent,
AmbiguityRemover ar)
Remove any remaining ambiguities from the AST. |
void |
dump(java.io.OutputStream os)
Dump the AST for debugging. |
void |
dump(java.io.Writer w)
Dump the AST for debugging. |
Context |
enterChildScope(Node child,
Context c)
Push a new scope for visiting the child node child . |
Context |
enterScope(Context c)
Push a new scope upon entering this node, and add any declarations to the context that should be in scope when visiting children of this node. |
Node |
exceptionCheck(ExceptionChecker ec)
Check that exceptions are properly propagated throughout the AST. |
NodeVisitor |
exceptionCheckEnter(ExceptionChecker ec)
Check that exceptions are properly propagated throughout the AST. |
void |
prettyPrint(CodeWriter w,
PrettyPrinter pp)
Pretty-print the AST using the given code writer. |
void |
prettyPrint(java.io.OutputStream os)
Pretty-print the AST for debugging. |
void |
prettyPrint(java.io.Writer w)
Pretty-print the AST for debugging. |
java.util.List |
throwTypes(TypeSystem ts)
List of Types of exceptions that might get thrown. |
void |
translate(CodeWriter w,
Translator tr)
Translate the AST using the given code writer. |
Node |
typeCheck(TypeChecker tc)
|
NodeVisitor |
typeCheckEnter(TypeChecker tc)
Type check the AST. |
Node |
typeCheckOverride(Node parent,
TypeChecker tc)
Type check the AST. |
Node |
visitChildren(NodeVisitor v)
Visit the children of the node. |
Method Detail |
---|
Node visitChildren(NodeVisitor v)
v
- The visitor that will traverse/rewrite the AST.
this
.Context enterScope(Context c)
addDecls
when leaving the node
for that.
c
- the current Context
Context
to be used for visiting this node.Context enterChildScope(Node child, Context c)
child
.
The default behavior is to delegate the call to the child node, and let
it add appropriate declarations that should be in scope. However,
this method gives parent nodes have the ability to modify this behavior.
child
- The child node about to be entered.c
- The current Context
Context
to be used for visiting node
child
void addDecls(Context c)
c
- The context to which to add declarations.NodeVisitor buildTypesEnter(TypeBuilder tb) throws SemanticException
TypeSystem
.
This method is called by the enter()
method of the
visitor. The * method should perform work that should be done
before visiting the children of the node. The method may return
this
or a new copy of the node on which
visitChildren()
and leave()
will be
invoked.
tb
- The visitor which adds new type objects to the
TypeSystem
.
SemanticException
Node buildTypes(TypeBuilder tb) throws SemanticException
TypeSystem
.
This method is called by the leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.
tb
- The visitor which adds new type objects to the
TypeSystem
.
SemanticException
Node disambiguateOverride(Node parent, AmbiguityRemover ar) throws SemanticException
enter()
method of the
visitor. The * method should perform work that should be done
before visiting the children of the node. The method may return
this
or a new copy of the node on which
visitChildren()
and leave()
will be
invoked.
ar
- The visitor which disambiguates.
SemanticException
NodeVisitor disambiguateEnter(AmbiguityRemover ar) throws SemanticException
SemanticException
Node disambiguate(AmbiguityRemover ar) throws SemanticException
leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.
The node should not assume that its children have been disambiguated.
If it depends on a child being disambiguated,
it may just return this
without doing any work.
ar
- The visitor which disambiguates.
SemanticException
NodeVisitor typeCheckEnter(TypeChecker tc) throws SemanticException
enter()
method of the
visitor. The * method should perform work that should be done
before visiting the children of the node. The method may return
this
or a new copy of the node on which
visitChildren()
and leave()
will be
invoked.
tc
- The type checking visitor.
SemanticException
Node typeCheckOverride(Node parent, TypeChecker tc) throws SemanticException
leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.
tc
- The type checking visitor.
SemanticException
Node typeCheck(TypeChecker tc) throws SemanticException
SemanticException
Node checkConstants(ConstantChecker cc) throws SemanticException
SemanticException
NodeVisitor exceptionCheckEnter(ExceptionChecker ec) throws SemanticException
enter()
method of the
visitor. The * method should perform work that should be done
before visiting the children of the node. The method may return
this
or a new copy of the node on which
visitChildren()
and leave()
will be
invoked.
ec
- The visitor.
SemanticException
Node exceptionCheck(ExceptionChecker ec) throws SemanticException
leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.
ec
- The visitor.
SemanticException
java.util.List throwTypes(TypeSystem ts)
void dump(java.io.OutputStream os)
void dump(java.io.Writer w)
void prettyPrint(java.io.OutputStream os)
void prettyPrint(java.io.Writer w)
void prettyPrint(CodeWriter w, PrettyPrinter pp)
w
- The code writer to which to write.pp
- The pretty printer. This is not a visitor.void translate(CodeWriter w, Translator tr)
w
- The code writer to which to write.tr
- The translation pass. This is not a visitor.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |