CS 536 Fall 2007, Project 5

Class IdNode

Object
  extended by ASTNode
      extended by ExprNode
          extended by IdNode

public class IdNode
extends ExprNode

An AST node representing an identifier.


Nested Class Summary
 
Nested classes/interfaces inherited from class ASTNode
ASTNode.Opcode
 
Field Summary
 
Fields inherited from class ExprNode
column, line, type
 
Constructor Summary
IdNode(String name, int line, int column)
          Creates a new IdNode.
 
Method Summary
 String getAddress()
          Generates a SPIM address for this id, either "_id" or "-nnn($fp)" depending on this id's offset.
 String getName()
          Returns the string name of this identifier.
 Symbol getSymbol()
          Returns the Symbol bound to this identifier.
 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 ExprNode
codeGen, codeGen
 
Methods inherited from class ASTNode
indent, toString
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdNode

public IdNode(String name,
              int line,
              int column)
Creates a new IdNode.

Parameters:
name - the name of the identifier.
line - the line on which this identifier appears.
column - the column of the first character of this identifier.
Method Detail

getSymbol

public Symbol getSymbol()
Returns the Symbol bound to this identifier.

Returns:
the symbol.

getName

public String getName()
Returns the string name of this identifier.

Returns:
the name.

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.

getAddress

public String getAddress()
Generates a SPIM address for this id, either "_id" or "-nnn($fp)" depending on this id's offset.

Returns:
the address

CS 536 Fall 2007, Project 5