brainfrick/step.rs
1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub(crate) enum Step {
3 Add(i8),
4 Move(isize),
5 Loop(LoopKind, usize),
6 Output,
7 Input,
8 Debug,
9}
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub(crate) enum LoopKind {
13 Begin,
14 End,
15}
16
17impl LoopKind {
18 pub fn should_jump(self, mem: &crate::mem::Memory) -> bool {
19 let c = mem.get_cell() == 0;
20 match self {
21 Self::Begin => c,
22 Self::End => !c,
23 }
24 }
25}