2 import IR.TypeDescriptor;
4 public class TertiaryNode extends ExpressionNode {
6 ExpressionNode trueExpr;
7 ExpressionNode falseExpr;
9 public TertiaryNode(ExpressionNode cond,
10 ExpressionNode trueExpr,
11 ExpressionNode falseExpr) {
13 this.trueExpr = trueExpr;
14 this.falseExpr = falseExpr;
17 public ExpressionNode getCond() {
21 public ExpressionNode getTrueExpr() {
25 public ExpressionNode getFalseExpr() {
29 public String printNode(int indent) {
30 return cond.printNode(indent)+" ? "+trueExpr.printNode(indent)+" : "+falseExpr.printNode(indent);
33 public TypeDescriptor getType() {
34 return trueExpr.getType();
38 return Kind.TertiaryNode;
41 public Long evaluate() {
43 Long c = this.cond.evaluate();
45 Long t = this.trueExpr.evaluate();
47 Long f = this.falseExpr.evaluate();
49 if(c.intValue() > 0) {