1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use cranelift_entity::entity_impl;

use super::{expressions::ExpressionId, types::TypeId, Call, NameId};

#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct StatementId(u32);
entity_impl!(StatementId, "name");

#[derive(Debug, PartialEq, Clone)]
pub enum Statement {
    Let(Let),
    Assign(Assign),
    Call(Call),
    If(If),
    Return(Return),
}

#[derive(Debug, PartialEq, Clone)]
pub struct Let {
    pub mutable: bool,
    pub ident: NameId,
    pub annotation: Option<TypeId>,
    pub expression: ExpressionId,
}

#[derive(Debug, PartialEq, Clone)]
pub struct Assign {
    pub ident: NameId,
    pub expression: ExpressionId,
}

#[derive(Debug, PartialEq, Clone)]
pub struct If {
    pub condition: ExpressionId,
    pub block: Vec<StatementId>,
}

#[derive(Debug, PartialEq, Clone)]
pub struct Return {
    pub expression: Option<ExpressionId>,
}