mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Remove statement/block concept from mono_ir
This commit is contained in:
parent
0585f32039
commit
8156272438
1 changed files with 0 additions and 88 deletions
|
@ -203,82 +203,6 @@ impl MonoExprId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
||||||
pub struct MonoStmtId {
|
|
||||||
inner: Index<MonoStmt>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MonoStmtId {
|
|
||||||
pub(crate) unsafe fn new_unchecked(inner: Index<MonoStmt>) -> Self {
|
|
||||||
Self { inner }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
||||||
pub enum MonoStmt {
|
|
||||||
/// Assign to a variable.
|
|
||||||
Assign(IdentId, MonoExprId),
|
|
||||||
AssignRec(IdentId, MonoExprId),
|
|
||||||
|
|
||||||
/// Introduce a variable, e.g. `var foo_` (we'll MonoStmt::Assign to it later.)
|
|
||||||
Declare(IdentId),
|
|
||||||
|
|
||||||
/// The `return` statement
|
|
||||||
Return(MonoExprId),
|
|
||||||
|
|
||||||
/// The "crash" keyword. Importantly, during code gen we must mark this as "nothing happens after this"
|
|
||||||
Crash {
|
|
||||||
msg: MonoExprId,
|
|
||||||
/// The type of the `crash` expression (which will have unified to whatever's around it)
|
|
||||||
expr_type: MonoTypeId,
|
|
||||||
},
|
|
||||||
|
|
||||||
Expect {
|
|
||||||
condition: MonoExprId,
|
|
||||||
/// If the expectation fails, we print the values of all the named variables
|
|
||||||
/// in the final expr. These are those values.
|
|
||||||
lookups_in_cond: Slice2<MonoTypeId, IdentId>,
|
|
||||||
},
|
|
||||||
|
|
||||||
Dbg {
|
|
||||||
source_location: InternedStrId,
|
|
||||||
source: InternedStrId,
|
|
||||||
expr: MonoExprId,
|
|
||||||
expr_type: MonoTypeId,
|
|
||||||
name: IdentId,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Call a function that has no return value (or which we are discarding due to an underscore pattern).
|
|
||||||
CallVoid {
|
|
||||||
fn_type: MonoTypeId,
|
|
||||||
fn_expr: MonoExprId,
|
|
||||||
args: Slice2<MonoTypeId, MonoExprId>,
|
|
||||||
/// This is the type of the closure based only on canonical IR info,
|
|
||||||
/// not considering what other closures might later influence it.
|
|
||||||
/// Lambda set specialization may change this type later!
|
|
||||||
capture_type: MonoTypeId,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Branching
|
|
||||||
When {
|
|
||||||
/// The actual condition of the when expression.
|
|
||||||
cond: MonoExprId,
|
|
||||||
cond_type: MonoTypeId,
|
|
||||||
/// Type of each branch (and therefore the type of the entire `when` expression)
|
|
||||||
branch_type: MonoTypeId,
|
|
||||||
/// Note: if the branches weren't exhaustive, we will have already generated a default
|
|
||||||
/// branch which crashes if it's reached. (The compiler will have reported an error already;
|
|
||||||
/// this is for if you want to run anyway.)
|
|
||||||
branches: NonEmptySlice<WhenBranch>,
|
|
||||||
},
|
|
||||||
If {
|
|
||||||
/// Type of each branch (and therefore the type of the entire `if` expression)
|
|
||||||
branch_type: MonoTypeId,
|
|
||||||
branches: Slice<(MonoStmtId, MonoStmtId)>,
|
|
||||||
final_else: Option<MonoTypeId>,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum MonoExpr {
|
pub enum MonoExpr {
|
||||||
Str(InternedStrId),
|
Str(InternedStrId),
|
||||||
|
@ -368,11 +292,6 @@ pub enum MonoExpr {
|
||||||
args: Slice2<MonoTypeId, MonoExprId>,
|
args: Slice2<MonoTypeId, MonoExprId>,
|
||||||
},
|
},
|
||||||
|
|
||||||
Block {
|
|
||||||
stmts: Slice<MonoStmtId>,
|
|
||||||
final_expr: MonoExprId,
|
|
||||||
},
|
|
||||||
|
|
||||||
If {
|
If {
|
||||||
branch_type: MonoTypeId,
|
branch_type: MonoTypeId,
|
||||||
branches: PairSlice<MonoExpr>,
|
branches: PairSlice<MonoExpr>,
|
||||||
|
@ -382,13 +301,6 @@ pub enum MonoExpr {
|
||||||
CompilerBug(Problem),
|
CompilerBug(Problem),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
||||||
pub struct WhenBranch {
|
|
||||||
pub patterns: Slice<MonoPatternId>,
|
|
||||||
pub body: Slice<MonoStmtId>,
|
|
||||||
pub guard: Option<MonoExprId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum MonoPattern {
|
pub enum MonoPattern {
|
||||||
Identifier(IdentId),
|
Identifier(IdentId),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue