package edu.cmu.cs.l3.translate;

import edu.cmu.cs.l3.frame.*;
import edu.cmu.cs.l3.errormsg.*;
import edu.cmu.cs.l3.tree.*;
import edu.cmu.cs.l3.temp.*;

public abstract class TranslateExpressionCx extends TranslateExpression {

    public TranslateExpressionCx(Frame curframe, ErrorMsg m, TranslateEnvironment t) {
	super(curframe,m,t);
    }

    public IRExpression asExpression() {

	Temp r = m_curframe.allocLocalTemp();
	Label t = new Label();
	Label f = new Label();

	return new IRESeq(
                new IRSeq(new IRMove(new IRTemp(r),
                new IRConst(1)),
                new IRSeq(asConditional(t,f),
                new IRSeq(new IRLabel(f),
                new IRSeq(new IRMove(new IRTemp(r),
                new IRConst(0)),
                new IRLabel(t))))),
                new IRTemp(r));

    }

    public IRStatement asStatement() {

	Label l = new Label();
	return new IRSeq(asConditional(l,l), new IRLabel(l));

    }

    private IRStatement m_stm;
}

