Skip to content

Commit

Permalink
make conditions only a part of if, when jump/call/return needs to b…
Browse files Browse the repository at this point in the history
…e conditional they should be contained in if
  • Loading branch information
Lokathor committed Dec 30, 2024
1 parent 11a4218 commit aa70a61
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pub enum Mir {
/// standard looping over a body of "inner" steps
Loop(MirLoop),

/// when a condition holds, do this
If(MirIf),

/// both break and continue are just "jump"
///
/// * if necessary, you can tell if it was break or continue by the tail of
Expand All @@ -18,10 +21,7 @@ pub enum Mir {
Call(MirCall),

/// go back to the caller
Return(MirReturn),

/// when a condition holds, do this
If(MirIf),
Return,

/// `inc reg16`
///
Expand Down Expand Up @@ -58,15 +58,21 @@ pub struct MirLoop {
pub canonical_end: StrID,
}

#[derive(Debug, Clone)]
pub struct MirIf {
pub condition: Condition,
pub steps: Vec<Mir>,
pub canonical_name: StrID,
pub canonical_end: StrID,
}

#[derive(Debug, Clone, Copy)]
pub struct MirJump {
pub condition: Condition,
pub target: StrID,
}

#[derive(Debug, Clone, Copy)]
pub struct MirCall {
pub condition: Condition,
pub target: StrID,
pub abi: Abi,
}
Expand All @@ -75,16 +81,3 @@ pub struct MirCall {
pub struct Abi {
// todo: an ABI system
}

#[derive(Debug, Clone, Copy)]
pub struct MirReturn {
pub condition: Condition,
}

#[derive(Debug, Clone)]
pub struct MirIf {
pub condition: Condition,
pub steps: Vec<Mir>,
pub canonical_name: StrID,
pub canonical_end: StrID,
}

0 comments on commit aa70a61

Please sign in to comment.