use rucc_base::{Idx, IdxRange};
use crate::asm::AsmId;
use crate::decl::DeclList;
use crate::expr::ExprId;
use crate::tast::LabelId;
pub type CaseId = Idx<Case>;
pub type StmtId = Idx<Stmt>;
#[derive(Debug)]
pub struct StmtRef;
pub type StmtList = IdxRange<StmtRef>;
pub type CaseList = IdxRange<Case>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Stmt {
Error,
Empty,
Expr(ExprId),
Block(StmtList),
Decls(DeclList),
If {
cond: ExprId,
then: StmtId,
otherwise: Option<StmtId>,
},
While {
cond: ExprId,
body: StmtId,
},
DoWhile {
body: StmtId,
cond: ExprId,
},
For {
init: Option<StmtId>,
cond: Option<ExprId>,
step: Option<ExprId>,
body: StmtId,
},
Switch {
cond: ExprId,
body: StmtId,
cases: CaseList,
default: Option<StmtId>,
},
Case {
case: CaseId,
body: StmtId,
},
Default {
body: StmtId,
},
Label {
label: LabelId,
body: StmtId,
},
Goto(LabelId),
IndirectGoto(ExprId),
Asm(AsmId),
Break,
Continue,
Return(Option<ExprId>),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Case {
pub low: i128,
pub high: i128,
pub body: StmtId,
}