Skip to content

Commit

Permalink
Add more control words
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Jul 29, 2023
1 parent 37e2840 commit 29bfed8
Show file tree
Hide file tree
Showing 13 changed files with 767 additions and 549 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 3 additions & 18 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,17 @@ impl<'a> Context<'a> {
}
}

pub fn interpret(&mut self) -> FiftResult<u8> {
self.run(Rc::new(InterpretCont))
}

pub fn run(&mut self, cont: Continuation) -> FiftResult<u8> {
let mut current = Some(cont);
pub fn run(&mut self) -> FiftResult<u8> {
let mut current = Some(Rc::new(InterpretCont) as Continuation);
while let Some(cont) = current.take() {
current = cont.run_tail(self)?;
current = cont.run(self)?;
if current.is_none() {
current = self.next.take();
}
}

Ok(self.exit_code)
}

pub fn interpret_execute(&mut self) -> FiftResult<Option<Continuation>> {
let cont = self.stack.pop()?.into_cont()?;
let count = self.stack.pop_smallint_range(0, 255)? as usize;
self.stack.check_underflow(count)?;
Ok(Some(*cont))
}

pub fn interpret_compile(&mut self) -> FiftResult<()> {
todo!()
}
}

#[derive(Debug, Default)]
Expand Down
Loading

0 comments on commit 29bfed8

Please sign in to comment.