CS 536 Fall 2007, Project 5

Class ProcDeclNode

Object
  extended by ASTNode
      extended by DeclNode
          extended by ProcDeclNode

public class ProcDeclNode
extends DeclNode

An AST node representing a function or procedure declaration: "FUNCTION name(parameters) RETURN type IS decls BEGIN stmts END;" or "PROCEDURE name(parameters) IS decls BEGIN stmts END;".


Nested Class Summary
(package private) static class ProcDeclNode.Mode
          A parameter mode: IN, OUT, INOUT, or NONE (equivalent to IN).
static class ProcDeclNode.Param
          A formal parameter.
 
Nested classes/interfaces inherited from class ASTNode
ASTNode.Opcode
 
Field Summary
 int frameSize
          The size, in bytes, of a stack frame for this procedure, including formal parameters, return address, control pointer, register save area, and local variables.
 IdNode id
          The name of the procedure.
 Type.BaseType returnType
          The return type of the procedure or function.
 
Fields inherited from class DeclNode
enclosingProc
 
Constructor Summary
ProcDeclNode(IdNode id, List<ProcDeclNode.Param> params, Type.BaseType returnType, BlockNode body)
          Creates a new ProcDeclNode.
 
Method Summary
 void codeGen(StmtNode loop)
          Generates code for this node and all descendants.
 void resolveNames(SymbolTable symtab)
          Resolves all applied uses of identifiers in the tree rooted at this node.
 void resolveTypes(ProcDeclNode proc)
          Fills in types for all Symbols bound to IdNodes.
 void unparse(PrintWriter p, int level)
          Prints a source representation of the tree rooted at this node on output stream p.
 
Methods inherited from class ASTNode
indent, toString
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

public final IdNode id
The name of the procedure.


returnType

public final Type.BaseType returnType
The return type of the procedure or function. Is VOID for procedures.


frameSize

public int frameSize
The size, in bytes, of a stack frame for this procedure, including formal parameters, return address, control pointer, register save area, and local variables.

Constructor Detail

ProcDeclNode

public ProcDeclNode(IdNode id,
                    List<ProcDeclNode.Param> params,
                    Type.BaseType returnType,
                    BlockNode body)
Creates a new ProcDeclNode.

Parameters:
id - the name of the procedure.
returnType - the return type of the procedure.
params - the list of parameters. May be a zero-length list, but must not be null.
body - the procedure body.
Method Detail

unparse

public void unparse(PrintWriter p,
                    int level)
Prints a source representation of the tree rooted at this node on output stream p.

Specified by:
unparse in class ASTNode
Parameters:
p - the place to display the output.
level - the number of levels of indentation to use if the output requires more than one line.

resolveNames

public void resolveNames(SymbolTable symtab)
Resolves all applied uses of identifiers in the tree rooted at this node.

Specified by:
resolveNames in class ASTNode
Parameters:
symtab - the symbol table to be used.

resolveTypes

public void resolveTypes(ProcDeclNode proc)
Fills in types for all Symbols bound to IdNodes. Prints error messages as necessary.

Specified by:
resolveTypes in class ASTNode
Parameters:
proc - the smallest enclosing procedure or function declaration.

codeGen

public void codeGen(StmtNode loop)
Generates code for this node and all descendants.

Overrides:
codeGen in class DeclNode
Parameters:
loop - the smallest enclosing ForStmtNode or WhileStmtNode, if any.

CS 536 Fall 2007, Project 5