Class ExprNode
Object
ASTNode
ExprNode
- Direct Known Subclasses:
- IdNode, LiteralNode, OpExprNode, SimpleExprNode
public abstract class ExprNode
- extends ASTNode
An AST node representing an expression.
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. |
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. |
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.
ExprNode
public ExprNode()
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.