polyglot.ast
Class Formal_c

java.lang.Object
  extended by polyglot.ast.Node_c
      extended by polyglot.ast.Term_c
          extended by polyglot.ast.Formal_c
All Implemented Interfaces:
java.lang.Cloneable, Formal, JL, Node, NodeOps, Term, VarDecl, Copy

public class Formal_c
extends Term_c
implements Formal

A Formal represents a formal parameter for a procedure or catch block. It consists of a type and a variable identifier.


Field Summary
protected  Flags flags
           
protected  LocalInstance li
           
protected  Id name
           
protected  TypeNode type
           
 
Fields inherited from class polyglot.ast.Term_c
exceptions, reachable
 
Fields inherited from class polyglot.ast.Node_c
del, error, ext, position
 
Fields inherited from interface polyglot.ast.Term
ENTRY, EXIT
 
Constructor Summary
Formal_c(Position pos, Flags flags, TypeNode type, Id name)
           
 
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)
          Build type objects for the formal.
 Node copy(NodeFactory nf)
          Produce a copy of this node using the given NodeFactory.
 Type declType()
          Get the type of the formal.
 Node disambiguate(AmbiguityRemover ar)
          Remove any remaining ambiguities from the AST.
 void dump(CodeWriter w)
          Dump the AST node for debugging purposes.
 Term firstChild()
          Return the first direct subterm performed when evaluating this term.
 Flags flags()
          Get the flags of the formal.
 Formal flags(Flags flags)
          Set the flags of the formal.
 Id id()
          Get the name of the formal.
 Formal id(Id name)
          Set the name of the formal.
 boolean isDisambiguated()
           
 LocalInstance localInstance()
          Get the local instance of the formal.
 Formal localInstance(LocalInstance li)
          Set the local instance of the formal.
 java.lang.String name()
          Get the name of the formal.
 Formal name(java.lang.String name)
          Set the name of the formal.
 void prettyPrint(CodeWriter w, PrettyPrinter tr)
          Write the formal to an output file.
protected  Formal_c reconstruct(TypeNode type, Id name)
          Reconstruct the formal.
 java.lang.String toString()
           
 TypeNode type()
          Get the type node of the formal.
 Formal type(TypeNode type)
          Set the type node of the formal.
 Node typeCheck(TypeChecker tc)
          Type check the formal.
 Node visitChildren(NodeVisitor v)
          Visit the children of the formal.
 
Methods inherited from class polyglot.ast.Term_c
exceptionCheck, exceptions, exceptions, listChild, reachable, reachable
 
Methods inherited from class polyglot.ast.Node_c
buildTypesEnter, checkConstants, childExpectedType, copy, copy, del, del, disambiguateEnter, disambiguateOverride, dump, dump, enterChildScope, enterScope, error, error, exceptionCheckEnter, ext, ext, ext, ext, init, isTypeChecked, node, position, position, prettyPrint, prettyPrint, print, printBlock, printSubStmt, throwTypes, translate, typeCheckEnter, 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
childExpectedType, del, del, error, error, ext, ext, ext, ext, isTypeChecked, position, position, visit, visitChild, visitEdge, visitList
 
Methods inherited from interface polyglot.ast.JL
init, node
 
Methods inherited from interface polyglot.ast.NodeOps
buildTypesEnter, checkConstants, copy, disambiguateEnter, disambiguateOverride, dump, dump, enterChildScope, enterScope, exceptionCheck, exceptionCheckEnter, prettyPrint, prettyPrint, throwTypes, translate, typeCheckEnter, typeCheckOverride
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

li

protected LocalInstance li

flags

protected Flags flags

type

protected TypeNode type

name

protected Id name
Constructor Detail

Formal_c

public Formal_c(Position pos,
                Flags flags,
                TypeNode type,
                Id name)
Method Detail

isDisambiguated

public boolean isDisambiguated()
Specified by:
isDisambiguated in interface Node
Overrides:
isDisambiguated in class Node_c
Returns:
true if the all type information for the node (but not necessarily for the node's children) is unambiguous.

declType

public Type declType()
Get the type of the formal.

Specified by:
declType in interface VarDecl

flags

public Flags flags()
Get the flags of the formal.

Specified by:
flags in interface Formal
Specified by:
flags in interface VarDecl

flags

public Formal flags(Flags flags)
Set the flags of the formal.

Specified by:
flags in interface Formal

type

public TypeNode type()
Get the type node of the formal.

Specified by:
type in interface Formal
Specified by:
type in interface VarDecl

type

public Formal type(TypeNode type)
Set the type node of the formal.

Specified by:
type in interface Formal

id

public Id id()
Get the name of the formal.

Specified by:
id in interface Formal
Specified by:
id in interface VarDecl

id

public Formal id(Id name)
Set the name of the formal.

Specified by:
id in interface Formal

name

public java.lang.String name()
Get the name of the formal.

Specified by:
name in interface Formal
Specified by:
name in interface VarDecl

name

public Formal name(java.lang.String name)
Set the name of the formal.

Specified by:
name in interface Formal

localInstance

public LocalInstance localInstance()
Get the local instance of the formal.

Specified by:
localInstance in interface Formal
Specified by:
localInstance in interface VarDecl

localInstance

public Formal localInstance(LocalInstance li)
Set the local instance of the formal.

Specified by:
localInstance in interface Formal

reconstruct

protected Formal_c reconstruct(TypeNode type,
                               Id name)
Reconstruct the formal.


visitChildren

public Node visitChildren(NodeVisitor v)
Visit the children of the formal.

Specified by:
visitChildren in interface NodeOps
Overrides:
visitChildren in class Node_c
Parameters:
v - The visitor that will traverse/rewrite the AST.
Returns:
A new AST if a change was made, or this.

addDecls

public void addDecls(Context c)
Description copied from class: Node_c
Add any declarations to the context that should be in scope when visiting later sibling nodes.

Specified by:
addDecls in interface NodeOps
Overrides:
addDecls in class Node_c
Parameters:
c - The context to which to add declarations.

prettyPrint

public void prettyPrint(CodeWriter w,
                        PrettyPrinter tr)
Write the formal to an output file.

Specified by:
prettyPrint in interface NodeOps
Overrides:
prettyPrint in class Node_c
Parameters:
w - The code writer to which to write.
tr - The pretty printer. This is not a visitor.

buildTypes

public Node buildTypes(TypeBuilder tb)
                throws SemanticException
Build type objects for the formal.

Specified by:
buildTypes in interface NodeOps
Overrides:
buildTypes in class Node_c
Parameters:
tb - The visitor which adds new type objects to the TypeSystem.
Throws:
SemanticException

disambiguate

public Node disambiguate(AmbiguityRemover ar)
                  throws SemanticException
Description copied from interface: NodeOps
Remove any remaining ambiguities from the AST. 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. 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.

Specified by:
disambiguate in interface NodeOps
Overrides:
disambiguate in class Node_c
Parameters:
ar - The visitor which disambiguates.
Throws:
SemanticException

typeCheck

public Node typeCheck(TypeChecker tc)
               throws SemanticException
Type check the formal.

Specified by:
typeCheck in interface NodeOps
Overrides:
typeCheck in class Node_c
Parameters:
tc - The type checking visitor.
Throws:
SemanticException

firstChild

public Term firstChild()
Description copied from interface: Term
Return the first direct subterm performed when evaluating this term. If this term has no subterms, this should return null. This method is similar to the deprecated entry(), but it should *not* recursively drill down to the innermost subterm. The direct child visited first in this term's dataflow should be returned.

Specified by:
firstChild in interface Term

acceptCFG

public java.util.List acceptCFG(CFGBuilder v,
                                java.util.List succs)
Description copied from class: Term_c
Visit this term in evaluation order.

Specified by:
acceptCFG in interface Term
Specified by:
acceptCFG in class Term_c

dump

public void dump(CodeWriter w)
Description copied from interface: Node
Dump the AST node for debugging purposes.

Specified by:
dump in interface Node
Overrides:
dump in class Node_c

toString

public java.lang.String toString()
Overrides:
toString in class Node_c

copy

public Node copy(NodeFactory nf)
Description copied from interface: NodeOps
Produce a copy of this node using the given NodeFactory.

Specified by:
copy in interface NodeOps
Overrides:
copy in class Node_c