CS 536 Fall 2007, Project 5

Class LiteralNode

Object
  extended by ASTNode
      extended by ExprNode
          extended by LiteralNode

public class LiteralNode
extends ExprNode

An AST node representing an integer, string, or Boolean literal (constant).


Nested Class Summary
 
Nested classes/interfaces inherited from class ASTNode
ASTNode.Opcode
 
Field Summary
 
Fields inherited from class ExprNode
column, line, type
 
Constructor Summary
LiteralNode(Object value, int line, int column)
          Creates a new LiteralNode.
 
Method Summary
 void codeGen(int reg)
          Generates code to load the value of this literal into a register.
 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
 
Methods inherited from class ASTNode
indent, toString
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiteralNode

public LiteralNode(Object value,
                   int line,
                   int column)
Creates a new LiteralNode.

Parameters:
value - the value of the literal. May be an Integer, a String, or a Boolean.
line - the line where the literal occurs in the input.
column - the first column of the literal in the input.
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(int reg)
Generates code to load the value of this literal into a register.

Overrides:
codeGen in class ExprNode
Parameters:
reg - the number of the s register where the result should be placed.

CS 536 Fall 2007, Project 5