// Mike Maxim
// IRTree for conditional jumps

package edu.cmu.cs.l3.tree;

public class IRCJump extends IRStatement {

    public final static int EQ=20,NE=21,LT=22,GT=23,LE=24,GE=25;

    public IRCJump(int ro, IRExpression l , IRExpression r, IRLabel t, IRLabel f) {
	m_relop = ro;
	m_left = l; m_right = r;
	m_iftrue = t; m_iffalse = f;

	m_classname = "IRCJump";
    }

    public int getRelationOperator() {
	return m_relop;
    }

    public IRExpression getLeft() {
	return m_left;
    }

    public IRExpression getRight() {
	return m_right;
    }

    public void setLeft(IRExpression left) {
	m_left = left;
    }

    public void setRight(IRExpression right) {
	m_right = right;
    }

    public IRLabel getTrueLabel() {
	return m_iftrue;
    }

    public void setTrueLabel(IRLabel t) {
	m_iftrue = t;
    }

    public IRLabel getFalseLabel() {
	return m_iffalse;
    }

    public void setFalseLabel(IRLabel f) {
	m_iffalse = f;
    }

    public IRExpressionList getComponents() {
	IRExpressionList comps = new IRExpressionList();
	return comps.prepend(m_right).prepend(m_left);
    }

    public IRStatement build(IRExpressionList comps) {
	return new IRCJump(m_relop,comps.getExpression(0),comps.getExpression(1),m_iftrue,m_iffalse);
    }

    public String toString() {
	return super.toString() + m_left + " " + m_relop + " " + m_right + " (T: " + m_iftrue.toString() + " F: " + m_iffalse.toString() + ")";
    }

    private int m_relop;
    private IRExpression m_left,m_right;
    private IRLabel m_iftrue,m_iffalse;

}

