Skip to main content

runmat_mir/
terminator.rs

1use crate::{BasicBlockId, MirLocalId, MirOperand, MirPlace, MirRvalue};
2use runmat_hir::Span;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct MirTerminator {
7    pub kind: MirTerminatorKind,
8    pub span: Span,
9}
10
11#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12pub enum MirTerminatorKind {
13    Goto(BasicBlockId),
14    Branch {
15        cond: MirOperand,
16        then_block: BasicBlockId,
17        else_block: BasicBlockId,
18    },
19    Switch {
20        discr: MirOperand,
21        cases: Vec<(MirOperand, BasicBlockId)>,
22        otherwise: BasicBlockId,
23    },
24    For {
25        binding: MirLocalId,
26        iterable: MirRvalue,
27        body_block: BasicBlockId,
28        exit_block: BasicBlockId,
29    },
30    TryCatch {
31        try_block: BasicBlockId,
32        catch_block: BasicBlockId,
33        catch_binding: Option<MirLocalId>,
34    },
35    Return(Vec<MirOperand>),
36    Await {
37        future: MirOperand,
38        result: Option<MirPlace>,
39        resume: BasicBlockId,
40    },
41    Unreachable,
42}