use crate::lower::ir;
use microcad_lang_base::SrcRef;
use microcad_lang_proc_macros::SrcReferrer;
#[derive(Clone, Debug, SrcReferrer)]
pub struct IfStatement {
pub if_ref: SrcRef,
pub cond: ir::Expression,
pub body: ir::Body,
pub else_ref: Option<SrcRef>,
pub body_else: Option<ir::Body>,
pub next_if_ref: Option<SrcRef>,
pub next_if: Option<Box<IfStatement>>,
pub src_ref: SrcRef,
}
impl std::fmt::Display for IfStatement {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
writeln!(f, "if {cond} {body}", cond = self.cond, body = self.body)?;
if let Some(next) = &self.next_if {
writeln!(f, "else {next}")?;
}
if let Some(body) = &self.body_else {
writeln!(f, "else {body}")?;
}
Ok(())
}
}