CS 536 Fall 2007, Project 5

Class ExprNode

Object
  extended by ASTNode
      extended by ExprNode
Direct Known Subclasses:
IdNode, LiteralNode, OpExprNode, SimpleExprNode

public abstract class ExprNode
extends ASTNode

An AST node representing an expression.


Nested Class Summary
 
Nested classes/interfaces inherited from class ASTNode
ASTNode.Opcode
 
Field Summary
protected  int column
          The column number of the first identifier or literal in this expression.
protected  int line
          The line number of the first identifier or literal in this expression.
protected  Type type
          The type of this expression.
 
Constructor Summary
ExprNode()
           
 
Method Summary
 void codeGen(int reg)
          Generates code to load the value of this expression into a register.
 void codeGen(String trueLabel, String falseLabel)
          Generates jump code for this expression and all sub-expressions.
 
Methods inherited from class ASTNode
indent, resolveNames, resolveTypes, toString, unparse
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected Type type
The type of this expression.


line

protected int line
The line number of the first identifier or literal in this expression.


column

protected int column
The column number of the first identifier or literal in this expression.

Constructor Detail

ExprNode

public ExprNode()
Method Detail

codeGen

public void codeGen(String trueLabel,
                    String falseLabel)
Generates jump code for this expression and all sub-expressions. Only valid for expressions of type BOOL.

Parameters:
trueLabel - the label to jump to if the expression is true.
falseLabel - the label to jump to if the expression is false.

codeGen

public void codeGen(int reg)
Generates code to load the value of this expression into a register.

Parameters:
reg - the number of the s register where the result should be placed.

CS 536 Fall 2007, Project 5