package edu.cmu.cs.l3.translate;

import edu.cmu.cs.l3.absyn.*;
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 class TranslateExpressionValueCx extends TranslateExpressionCx {

    public TranslateExpressionValueCx(Frame curframe, ErrorMsg e, TranslateEnvironment t) {
	super(curframe,e,t);
    }

    public IRStatement asConditional(Label t, Label f) {
	if (m_value)
	    return new IRJump(new IRLabel(t));
	else
	    return new IRJump(new IRLabel(f));
    }

    public void visitResponse(String type, Object obj) {

	if (type.equals("ASBoolConstant"))
	    visitBoolExp(obj);
    }

    public void visitBoolExp(Object e) {

	ASBoolConstant ae = (ASBoolConstant) e;

	m_value = ae.getValue();
    }

    private boolean m_value;

}

