public final class Procedure extends Declaration implements SymbolTable, Symbol
| Constructor and Description |
|---|
Procedure(Declarator declarator,
CompoundStatement body)
Creates a constructor definition (declaration plus body).
|
Procedure(java.util.List leading_specs,
Declarator declarator,
CompoundStatement body)
Creates a procedure definition (declaration plus body).
|
Procedure(java.util.List leading_specs,
Declarator declarator,
CompoundStatement body,
boolean is_old_style_function)
Constructor that can preserve the old style of the declaration
|
Procedure(Specifier spec,
Declarator declarator,
CompoundStatement body)
Creates a procedure definition (declaration plus body).
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDeclaration(Declaration decl)
Adds a parameter declaration to the procedure.
|
void |
addDeclarationAfter(Declaration ref,
Declaration decl)
Adds a new parameter declaration after the reference declaration.
|
void |
addDeclarationBefore(Declaration ref,
Declaration decl)
Adds a new parameter declaration before the reference declaration.
|
Procedure |
clone()
Returns a clone of the procedure.
|
boolean |
containsDeclaration(Declaration decl)
Checks if the symbol table contains the specified declaration.
|
boolean |
containsSymbol(Symbol symbol)
Checks if the symbol table contains the specified symbol.
|
static void |
defaultPrint(Procedure p,
java.io.PrintWriter o)
Prints a procedure to a stream.
|
Declaration |
findSymbol(IDExpression name)
Retrieves the declaration for a symbol, possibly searching
through parent symbol tables.
|
java.util.List |
getArraySpecifiers()
Not used in a procedure; it just returns null
|
CompoundStatement |
getBody()
Returns the body compound statement of this procedure.
|
Declaration |
getDeclaration()
Returns the parent declaration containing the symbol object.
|
java.util.Set<Declaration> |
getDeclarations()
Returns the set of declarations declared within the symbol table object.
|
Declarator |
getDeclarator()
Returns the procedure declarator of the procedure.
|
java.util.List<IDExpression> |
getDeclaredIDs()
Returns the list of declared name IDs in the procedure.
|
IDExpression |
getName()
Returns the name ID of the procedure.
|
int |
getNumParameters()
Returns the number of parameters of the procedure.
|
Declaration |
getParameter(int index)
returns the parameter at specified index
|
java.util.List |
getParameters()
Returs the list of procedure parameters.
|
java.util.List<SymbolTable> |
getParentTables()
Returns a list of symbol tables that are parents
of this table in the distributed symbol table graph.
|
java.util.List |
getReturnType()
Returns the list of type specifiers of the procedure.
|
java.lang.String |
getSymbolName()
Returns the name of the symbol.
|
java.util.Set<Symbol> |
getSymbols()
Returns the set of declared symbols in the symbol table object.
|
java.util.List |
getTypeSpecifiers()
Returns a list of type specifiers.
|
void |
setBody(CompoundStatement body)
Assigns a new procedure body for the procedure.
|
static void |
setClassPrintMethod(java.lang.reflect.Method m)
Overrides the class print method, so that all subsequently
created objects will use the supplied method.
|
void |
setConstructorInitializers(java.util.List list)
Sets the list of initializers - not used in a C program.
|
void |
setName(IDExpression name)
Modifies the name of the procedure.
|
void |
setName(java.lang.String name)
Modify the name of the symbol.
|
annotate, annotateAfter, annotateBefore, containsAnnotation, detach, equals, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getChildren, getParent, hashCode, print, removeAnnotations, removeAnnotations, removeChild, setChild, setParent, setPrintMethod, setSemiColon, toString, verifygetChildren, getParent, removeChild, setChild, setParentpublic Procedure(Declarator declarator, CompoundStatement body)
declarator - The name and parameter list of the procedure.
Must not be null.body - The body of the procedure.NotAnOrphanException - If body has a parent object.public Procedure(java.util.List leading_specs,
Declarator declarator,
CompoundStatement body)
leading_specs - A list of specifiers describing the return type of
the procedure. May be null.declarator - The name and parameter list of the procedure.
Must not be null.body - The body of the procedure.NotAnOrphanException - If body has a parent object.public Procedure(java.util.List leading_specs,
Declarator declarator,
CompoundStatement body,
boolean is_old_style_function)
public Procedure(Specifier spec, Declarator declarator, CompoundStatement body)
spec - A specifier describing the return type of the procedure.declarator - The name and parameter list of the procedure.
Must not be null.body - The body of the procedure.NotAnOrphanException - If body has a parent object.public void addDeclaration(Declaration decl)
addDeclaration in interface SymbolTabledecl - the new parameter declaration to be added.public void addDeclarationBefore(Declaration ref, Declaration decl)
addDeclarationBefore in interface SymbolTableref - the reference parameter declaration.decl - the new parameter declaration to be added.public void addDeclarationAfter(Declaration ref, Declaration decl)
addDeclarationAfter in interface SymbolTableref - the reference parameter declaration.decl - the new parameter declaration to be added.public Declarator getDeclarator()
public static void defaultPrint(Procedure p, java.io.PrintWriter o)
p - The procedure to print.o - The writer on which to print the procedure.public Declaration findSymbol(IDExpression name)
SymbolTablefindSymbol in interface SymbolTablename - The name of the symbol.public CompoundStatement getBody()
public java.util.List<IDExpression> getDeclaredIDs()
getDeclaredIDs in class Declarationpublic IDExpression getName()
public int getNumParameters()
public java.util.List getParameters()
public Declaration getParameter(int index)
index - - zero-based index of the required parameterpublic java.util.List<SymbolTable> getParentTables()
SymbolTablegetParentTables in interface SymbolTablepublic java.util.List getReturnType()
public void setBody(CompoundStatement body)
body - the new procedure body to be added.NotAnOrphanException - if body has a parent object.public static void setClassPrintMethod(java.lang.reflect.Method m)
m - The new print method.public void setConstructorInitializers(java.util.List list)
public void setName(IDExpression name)
public void setName(java.lang.String name)
Symbolextern variables and
procedure names are not automatically handled.public java.lang.String getSymbolName()
SymbolgetSymbolName in interface Symbolpublic java.util.List getTypeSpecifiers()
SymbolgetTypeSpecifiers in interface Symbolpublic java.util.List getArraySpecifiers()
getArraySpecifiers in interface Symbolpublic Procedure clone()
clone in class Declarationpublic java.util.Set<Symbol> getSymbols()
SymbolTablegetSymbols in interface SymbolTablepublic java.util.Set<Declaration> getDeclarations()
SymbolTablegetDeclarations in interface SymbolTablepublic Declaration getDeclaration()
SymbolgetDeclaration in interface Symbolpublic boolean containsSymbol(Symbol symbol)
SymbolTablecontainsSymbol in interface SymbolTablepublic boolean containsDeclaration(Declaration decl)
SymbolTablecontainsDeclaration in interface SymbolTable