Skip to content

Commit

Permalink
Move MOO-specific stack frame pieces on Activation into their own Fra…
Browse files Browse the repository at this point in the history
…me struct
  • Loading branch information
rdaum committed Jan 27, 2024
1 parent 9584fd0 commit 6182db5
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 374 deletions.
4 changes: 3 additions & 1 deletion crates/kernel/src/builtins/bf_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,10 @@ fn bf_move(bf_args: &mut BfCallState<'_>) -> Result<BfRet, Error> {

// Accept verb has been called, and returned. Check the result. Should be on stack,
// unless short-circuited, in which case we assume *false*
// TODO directly pushing into the stack like this is going to be a problem for
// non-MOO interpreters. we need a more generic way of doing this
let result = if !shortcircuit {
bf_args.exec_state.top().peek_top().clone()
bf_args.exec_state.top().frame.peek_top().clone()
} else {
v_int(0)
};
Expand Down
6 changes: 4 additions & 2 deletions crates/kernel/src/tasks/vm_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl VmHost {
/// Resume what you were doing after suspension.
pub fn resume_execution(&mut self, value: Var) {
// coming back from suspend, we need a return value to feed back to `bf_suspend`
self.vm_exec_state.top_mut().push(value);
self.vm_exec_state.top_mut().frame.push(value);
self.vm_exec_state.start_time = Some(SystemTime::now());
self.vm_exec_state.tick_count = 0;
self.running = true;
Expand All @@ -366,6 +366,7 @@ impl VmHost {
pub fn set_variable(&mut self, task_id_var: &Name, value: Var) {
self.vm_exec_state
.top_mut()
.frame
.set_var_offset(task_id_var, value)
.expect("Could not set forked task id");
}
Expand All @@ -384,7 +385,8 @@ impl VmHost {
pub fn line_number(&self) -> usize {
self.vm_exec_state
.top()
.find_line_no(self.vm_exec_state.top().pc)
.frame
.find_line_no(self.vm_exec_state.top().frame.pc)
.unwrap_or(0)
}

Expand Down
Loading

0 comments on commit 6182db5

Please sign in to comment.