|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object polyglot.ext.jl.ast.Node_c polyglot.ext.jl.ast.Term_c polyglot.ext.jl.ast.Stmt_c polyglot.ext.jl.ast.LocalDecl_c
public class LocalDecl_c
A LocalDecl
is an immutable representation of the declaration
of a local variable.
Field Summary | |
---|---|
protected Flags |
flags
|
protected Expr |
init
|
protected LocalInstance |
li
|
protected java.lang.String |
name
|
protected TypeNode |
type
|
Fields inherited from class polyglot.ext.jl.ast.Term_c |
---|
exceptions, reachable |
Fields inherited from class polyglot.ext.jl.ast.Node_c |
---|
del, ext, position |
Constructor Summary | |
---|---|
LocalDecl_c(Position pos,
Flags flags,
TypeNode type,
java.lang.String name,
Expr init)
|
Method Summary | |
---|---|
java.util.List |
acceptCFG(CFGBuilder v,
java.util.List succs)
Visit this term in evaluation order. |
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. |
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of this . |
Type |
declType()
Get the type of the declaration. |
Node |
disambiguate(AmbiguityRemover ar)
Remove any remaining ambiguities from the AST. |
void |
dump(CodeWriter w)
Dump the AST node for debugging purposes. |
Context |
enterScope(Node child,
Context c)
Add the declaration of the variable as we enter the scope of the intializer |
Term |
entry()
Return the first (sub)term performed when evaluating this term. |
Flags |
flags()
Get the flags of the declaration. |
LocalDecl |
flags(Flags flags)
Set the flags of the declaration. |
Expr |
init()
Get the initializer of the declaration. |
LocalDecl |
init(Expr init)
Set the initializer of the declaration. |
LocalInstance |
localInstance()
Get the local instance of the declaration. |
LocalDecl |
localInstance(LocalInstance li)
Set the local instance of the declaration. |
java.lang.String |
name()
Get the name of the declaration. |
LocalDecl |
name(java.lang.String name)
Set the name of the declaration. |
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given CodeWriter . |
protected LocalDecl_c |
reconstruct(TypeNode type,
Expr init)
Reconstruct the declaration. |
java.lang.String |
toString()
|
TypeNode |
type()
Get the type node of the declaration. |
LocalDecl |
type(TypeNode type)
Set the type of the declaration. |
Node |
typeCheck(TypeChecker tc)
Type check the declaration. |
NodeVisitor |
typeCheckEnter(TypeChecker tc)
Override superclass behaviour to check if the variable is multiply defined. |
Node |
visitChildren(NodeVisitor v)
Visit the children of the declaration. |
Methods inherited from class polyglot.ext.jl.ast.Term_c |
---|
exceptionCheck, exceptions, exceptions, listEntry, reachable, reachable |
Methods inherited from class polyglot.ext.jl.ast.Node_c |
---|
addMembers, addMembersEnter, addMembersOverride, buildTypesEnter, buildTypesOverride, copy, del, del, disambiguateEnter, disambiguateOverride, enterScope, exceptionCheckEnter, exceptionCheckOverride, ext, ext, ext, ext, init, node, position, position, print, printBlock, printSubStmt, throwTypes, translate, typeCheckOverride, visit, visitChild, visitEdge, visitList |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface polyglot.ast.Term |
---|
exceptions, exceptions, reachable, reachable |
Methods inherited from interface polyglot.ast.Node |
---|
del, del, ext, ext, ext, ext, position, position, visit, visitChild, visitEdge, visitList |
Methods inherited from interface polyglot.ast.JL |
---|
init, node |
Methods inherited from interface polyglot.ast.NodeOps |
---|
addMembers, addMembersEnter, buildTypesEnter, disambiguateEnter, enterScope, exceptionCheck, exceptionCheckEnter, throwTypes, translate |
Methods inherited from interface polyglot.util.Copy |
---|
copy |
Field Detail |
---|
protected Flags flags
protected TypeNode type
protected java.lang.String name
protected Expr init
protected LocalInstance li
Constructor Detail |
---|
public LocalDecl_c(Position pos, Flags flags, TypeNode type, java.lang.String name, Expr init)
Method Detail |
---|
public Type declType()
declType
in interface VarDecl
public Flags flags()
flags
in interface VarDecl
public LocalDecl flags(Flags flags)
flags
in interface LocalDecl
public TypeNode type()
type
in interface VarDecl
public LocalDecl type(TypeNode type)
type
in interface LocalDecl
public java.lang.String name()
name
in interface VarDecl
public LocalDecl name(java.lang.String name)
name
in interface LocalDecl
public Expr init()
init
in interface LocalDecl
public LocalDecl init(Expr init)
init
in interface LocalDecl
public LocalDecl localInstance(LocalInstance li)
localInstance
in interface LocalDecl
public LocalInstance localInstance()
localInstance
in interface VarDecl
protected LocalDecl_c reconstruct(TypeNode type, Expr init)
public Node visitChildren(NodeVisitor v)
visitChildren
in interface NodeOps
visitChildren
in class Node_c
v
- The visitor that will traverse/rewrite the AST.
this
.public Context enterScope(Node child, Context c)
enterScope
in interface NodeOps
enterScope
in class Node_c
child
- the child node about to be entered.c
- the current Context
Context
to be used for visiting node
child
public void addDecls(Context c)
Node_c
addDecls
in interface NodeOps
addDecls
in class Node_c
c
- The context to which to add declarations.public Node buildTypes(TypeBuilder tb) throws SemanticException
NodeOps
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.
buildTypes
in interface NodeOps
buildTypes
in class Node_c
tb
- The visitor which adds new type objects to the
TypeSystem
.
SemanticException
public Node disambiguate(AmbiguityRemover ar) throws SemanticException
NodeOps
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.
disambiguate
in interface NodeOps
disambiguate
in class Node_c
ar
- The visitor which disambiguates.
SemanticException
public NodeVisitor typeCheckEnter(TypeChecker tc) throws SemanticException
typeCheckEnter
in interface NodeOps
typeCheckEnter
in class Node_c
tc
- The type checking visitor.
SemanticException
public Node typeCheck(TypeChecker tc) throws SemanticException
typeCheck
in interface NodeOps
typeCheck
in class Node_c
tc
- The type checking visitor.
SemanticException
public Type childExpectedType(Expr child, AscriptionVisitor av)
Node
this
.
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 Node
childExpectedType
in class Node_c
child
- A child expression of this node.av
- An ascription visitor.
child
.public java.lang.String toString()
toString
in class Node_c
public void prettyPrint(CodeWriter w, PrettyPrinter tr)
Node_c
CodeWriter
.
prettyPrint
in interface NodeOps
prettyPrint
in class Node_c
w
- The code writer to which to write.tr
- The pretty printer. This is not a visitor.public void dump(CodeWriter w)
Node
dump
in interface Node
dump
in class Node_c
public Term entry()
Term_c
entry
in interface Term
entry
in class Term_c
public java.util.List acceptCFG(CFGBuilder v, java.util.List succs)
Term_c
acceptCFG
in interface Term
acceptCFG
in class Term_c
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |