CS 536 Fall 2007, Project 5

Class BlockNode

Object
  extended by ASTNode
      extended by BlockNode

public class BlockNode
extends ASTNode

An AST node representing a block (procedure or function body): "decls BEGIN stmts END".


Nested Class Summary
 
Nested classes/interfaces inherited from class ASTNode
ASTNode.Opcode
 
Field Summary
 List<DeclNode> decls
          List of variables, functions, and procedures declared locally in the block.
 List<StmtNode> stmts
          List of statements in the block.
 
Constructor Summary
BlockNode()
           
 
Method Summary
 void codeGen(StmtNode loop)
          Generates code for this block and all its contents.
 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

decls

public List<DeclNode> decls
List of variables, functions, and procedures declared locally in the block. May be a zero-length list, but must not be null.


stmts

public List<StmtNode> stmts
List of statements in the block. Must be a non-empty list.

Constructor Detail

BlockNode

public BlockNode()
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 block and all its contents.

Parameters:
loop - the smallest enclosing ForStmtNode or WhileStmtNode, if any.

CS 536 Fall 2007, Project 5