Modifier and Type | Method and Description |
---|---|
void |
addDecls(Node n,
Context c)
Add any declarations to the context that should be in scope when
visiting later sibling nodes.
|
Node |
buildTypes(Node n,
TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node
and constructs type objects for these.
|
NodeVisitor |
buildTypesEnter(Node n,
TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node
and constructs type objects for these.
|
java.lang.Object |
constantValue(Expr n,
Lang lang)
Return the constant value of the expression, if any.
|
boolean |
constantValueSet(Expr n,
Lang lang)
Return true iff the compiler has determined whether this expression has a
constant value.
|
Node |
copy(Node n,
ExtensionInfo extInfo)
Produce a copy of this node using the given ExtensionInfo.
|
Node |
copy(Node n,
NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
void |
dump(Node n,
Lang lang,
java.io.OutputStream os)
Dump the AST for debugging.
|
void |
dump(Node n,
Lang lang,
java.io.Writer w)
Dump the AST for debugging.
|
Context |
enterChildScope(Node n,
Node child,
Context c)
Push a new scope for visiting the child node
child . |
Context |
enterScope(Node n,
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 |
extRewrite(Node n,
ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
NodeVisitor |
extRewriteEnter(Node n,
ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
boolean |
isConstant(Expr n,
Lang lang)
Return whether the expression evaluates to a constant.
|
void |
prettyPrint(Node n,
CodeWriter w,
PrettyPrinter pp)
Pretty-print the AST using the given code writer.
|
void |
prettyPrint(Node n,
Lang lang,
java.io.OutputStream os)
Pretty-print the AST for debugging.
|
void |
prettyPrint(Node n,
Lang lang,
java.io.Writer w)
Pretty-print the AST for debugging.
|
void |
translate(Node n,
CodeWriter w,
Translator tr)
Translate the AST using the given code writer.
|
Node |
typeCheck(Node n,
TypeChecker tc)
Type check the AST.
|
NodeVisitor |
typeCheckEnter(Node n,
TypeChecker tc)
Type check the AST.
|
Node |
typeCheckOverride(Node n,
Node parent,
TypeChecker tc)
Type check the AST.
|
Node |
visitChildren(Node n,
NodeVisitor v)
Visit the children of the node.
|
Node visitChildren(Node n, NodeVisitor v)
v
- The visitor that will traverse/rewrite the AST.this
.Context enterScope(Node n, Context c)
addDecls
when leaving the node
for that.c
- the current Context
Context
to be used for visiting this node.Context enterChildScope(Node n, 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(Node n, Context c)
c
- The context to which to add declarations.NodeVisitor buildTypesEnter(Node n, 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(Node n, 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
NodeVisitor typeCheckEnter(Node n, 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 n, Node parent, TypeChecker tc) throws SemanticException
override()
method of the
visitor. If this method returns non-null, the node's children
will not be visited automatically. Thus, the method should check
both the node this
and it's children, usually by
invoking visitChildren
with tc
or
with another visitor, returning a non-null node. OR, the method
should do nothing and simply return null
to allow
enter
, visitChildren
, and leave
to be invoked on the node.
The default implementation returns null
.
Overriding of this method is discouraged, but sometimes necessary.tc
- The type checking visitor.SemanticException
Node typeCheck(Node n, 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
NodeVisitor extRewriteEnter(Node n, ExtensionRewriter rw) 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.rw
- The visitor.SemanticException
Node extRewrite(Node n, ExtensionRewriter rw) 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.rw
- The visitor.SemanticException
void prettyPrint(Node n, Lang lang, java.io.OutputStream os)
void prettyPrint(Node n, Lang lang, java.io.Writer w)
void prettyPrint(Node n, CodeWriter w, PrettyPrinter pp)
w
- The code writer to which to write.pp
- The pretty printer. This is not a visitor.void translate(Node n, CodeWriter w, Translator tr)
w
- The code writer to which to write.tr
- The translation pass. This is not a visitor.Node copy(Node n, NodeFactory nf)
Node copy(Node n, ExtensionInfo extInfo) throws SemanticException
SemanticException
- If the type information cannot be copied.boolean constantValueSet(Expr n, Lang lang)
isConstant()
is valid only if
constantValueSet()
is true.boolean isConstant(Expr n, Lang lang)
constantValueSet()
is true.