|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectpolyglot.ast.Node_c
public abstract class Node_c
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.
| Field Summary | |
|---|---|
protected JL |
del
|
protected boolean |
error
|
protected Ext |
ext
|
protected Position |
position
|
| Constructor Summary | |
|---|---|
Node_c(Position pos)
|
|
| 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)
|
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of this. |
java.lang.Object |
copy()
|
JL |
del()
Get the node's delegate. |
Node |
del(JL del)
Set the delegate of the node. |
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(CodeWriter w)
Dump the AST node for debugging purposes. |
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. |
boolean |
error()
Return true if there an error in this node or its children. |
Node |
error(boolean flag)
|
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. |
Ext |
ext()
Get the node's extension. |
Node |
ext(Ext ext)
Set the extension of the node. |
Ext |
ext(int n)
Get the node's nth extension, n >= 1. |
Node |
ext(int n,
Ext ext)
Set the node's nth extension, n >= 1. |
void |
init(Node node)
Initialize the back pointer to the node. |
boolean |
isDisambiguated()
|
boolean |
isTypeChecked()
|
Node |
node()
Pointer back to the node we are delegating for, possibly this. |
Position |
position()
Get the position of the node in the source file. |
Node |
position(Position position)
Create a copy of the node with a new position. |
void |
prettyPrint(CodeWriter w,
PrettyPrinter pp)
Pretty-print the AST using the given CodeWriter. |
void |
prettyPrint(java.io.OutputStream os)
Pretty-print the AST for debugging. |
void |
prettyPrint(java.io.Writer w)
Pretty-print the AST for debugging. |
void |
print(Node child,
CodeWriter w,
PrettyPrinter pp)
|
void |
printBlock(Node n,
CodeWriter w,
PrettyPrinter pp)
|
void |
printSubStmt(Stmt stmt,
CodeWriter w,
PrettyPrinter pp)
|
java.util.List |
throwTypes(TypeSystem ts)
List of Types of exceptions that might get thrown. |
java.lang.String |
toString()
|
void |
translate(CodeWriter w,
Translator tr)
Translate the AST using the given CodeWriter. |
Node |
typeCheck(TypeChecker tc)
|
NodeVisitor |
typeCheckEnter(TypeChecker tc)
Type check the AST. |
Node |
typeCheckOverride(Node parent,
TypeChecker tc)
Type check the AST. |
Node |
visit(NodeVisitor v)
Visit the node. |
Node |
visitChild(Node n,
NodeVisitor v)
Visit a single child of the node. |
Node |
visitChildren(NodeVisitor v)
Visit the children of the node. |
Node |
visitEdge(Node parent,
NodeVisitor v)
Visit the node, passing in the node's parent. |
java.util.List |
visitList(java.util.List l,
NodeVisitor v)
Visit all the elements of a list. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Position position
protected JL del
protected Ext ext
protected boolean error
| Constructor Detail |
|---|
public Node_c(Position pos)
| Method Detail |
|---|
public void init(Node node)
JL
init in interface JLpublic Node node()
JL
node in interface JLpublic JL del()
Node
del in interface Nodepublic Node del(JL del)
Node
del in interface Nodepublic Ext ext(int n)
Node
ext in interface Node
public Node ext(int n,
Ext ext)
Node
ext in interface Nodepublic Ext ext()
Node
ext in interface Nodepublic Node ext(Ext ext)
Node
ext in interface Nodepublic java.lang.Object copy()
copy in interface Copypublic Position position()
Node
position in interface Nodepublic Node position(Position position)
Node
position in interface Nodepublic boolean isDisambiguated()
isDisambiguated in interface Nodepublic boolean isTypeChecked()
isTypeChecked in interface Nodepublic boolean error()
Node
error in interface Nodepublic Node error(boolean flag)
error in interface Node
public Node visitChild(Node n,
NodeVisitor v)
Node
visitChild in interface Noden - The child to visit.v - The visitor which will traverse/rewrite the AST.
child.visit(v), or null
if child was null.public Node visit(NodeVisitor v)
NodevisitEdge(null, v).
visit in interface Nodev - The visitor which will traverse/rewrite the AST.
this.
public Node visitEdge(Node parent,
NodeVisitor v)
NodeNodeVisitor to traverse the AST starting at this node.
This method should call the override, enter,
and leave methods of the visitor. The method may return a
new version of the node.
- Specified by:
visitEdge in interface Node
- Parameters:
parent - The parent of this in the AST.v - The visitor which will traverse/rewrite the AST.
- Returns:
- A new AST if a change was made, or
this.
public java.util.List visitList(java.util.List l,
NodeVisitor v)
visitList in interface Nodel - The list to visit.v - The visitor to use.
l is a TypedList, the
new list will also be typed with the same type as
l. If l is null,
null is returned.public Node visitChildren(NodeVisitor v)
NodeOps
visitChildren in interface NodeOpsv - The visitor that will traverse/rewrite the AST.
this.public Context enterScope(Context c)
enterScope in interface NodeOpsc - the current Context
Context to be used for visiting this node.
public 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.
enterChildScope in interface NodeOpschild - the child node about to be entered.c - the current Context
Context to be used for visiting node
childpublic void addDecls(Context c)
addDecls in interface NodeOpsc - The context to which to add declarations.
public NodeVisitor buildTypesEnter(TypeBuilder tb)
throws SemanticException
NodeOpsTypeSystem.
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.
buildTypesEnter in interface NodeOpstb - The visitor which adds new type objects to the
TypeSystem.
SemanticException
public Node buildTypes(TypeBuilder tb)
throws SemanticException
NodeOpsTypeSystem.
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.
buildTypes in interface NodeOpstb - The visitor which adds new type objects to the
TypeSystem.
SemanticException
public Node disambiguateOverride(Node parent,
AmbiguityRemover ar)
throws SemanticException
NodeOpsenter() 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.
disambiguateOverride in interface NodeOpsar - The visitor which disambiguates.
SemanticException
public NodeVisitor disambiguateEnter(AmbiguityRemover ar)
throws SemanticException
disambiguateEnter in interface NodeOpsSemanticException
public Node disambiguate(AmbiguityRemover ar)
throws SemanticException
NodeOpsleave() 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.
disambiguate in interface NodeOpsar - The visitor which disambiguates.
SemanticException
public Node typeCheckOverride(Node parent,
TypeChecker tc)
throws SemanticException
typeCheckOverride in interface NodeOpstc - The type checking visitor.
SemanticException
public NodeVisitor typeCheckEnter(TypeChecker tc)
throws SemanticException
NodeOpsenter() 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.
typeCheckEnter in interface NodeOpstc - The type checking visitor.
SemanticException
public Node typeCheck(TypeChecker tc)
throws SemanticException
typeCheck in interface NodeOpsSemanticException
public Node checkConstants(ConstantChecker cc)
throws SemanticException
checkConstants in interface NodeOpsSemanticException
public Type childExpectedType(Expr child,
AscriptionVisitor av)
Nodethis.
The expected type is determined by the context in that the child occurs
(e.g., for x = e, the expected type of e is
the declared type of x.
The expected type should impose the least constraints on the child's
type that are allowed by the parent node.
childExpectedType in interface Nodechild - A child expression of this node.av - An ascription visitor.
child.
public NodeVisitor exceptionCheckEnter(ExceptionChecker ec)
throws SemanticException
NodeOpsenter() 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.
exceptionCheckEnter in interface NodeOpsec - The visitor.
SemanticException
public Node exceptionCheck(ExceptionChecker ec)
throws SemanticException
NodeOpsleave() 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.
exceptionCheck in interface NodeOpsec - The visitor.
SemanticExceptionpublic java.util.List throwTypes(TypeSystem ts)
NodeOps
throwTypes in interface NodeOpspublic void dump(java.io.OutputStream os)
dump in interface NodeOpspublic void dump(java.io.Writer w)
dump in interface NodeOpspublic void prettyPrint(java.io.OutputStream os)
prettyPrint in interface NodeOpspublic void prettyPrint(java.io.Writer w)
prettyPrint in interface NodeOps
public void prettyPrint(CodeWriter w,
PrettyPrinter pp)
CodeWriter.
prettyPrint in interface NodeOpsw - The code writer to which to write.pp - The pretty printer. This is not a visitor.
public void printBlock(Node n,
CodeWriter w,
PrettyPrinter pp)
public void printSubStmt(Stmt stmt,
CodeWriter w,
PrettyPrinter pp)
public void print(Node child,
CodeWriter w,
PrettyPrinter pp)
public void translate(CodeWriter w,
Translator tr)
CodeWriter.
translate in interface NodeOpsw - The code writer to which to write.tr - The translation pass. This is not a visitor.public void dump(CodeWriter w)
Node
dump in interface Nodepublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||