Skip to content

Commit

Permalink
feat: Swappable pause (#414) (#415)
Browse files Browse the repository at this point in the history
Co-authored-by: Xuejie Xiao <xxuejie@gmail.com>
  • Loading branch information
mohanson and xxuejie authored Mar 14, 2024
1 parent 82bcf07 commit bd848a6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@ impl<Inner: SupportMachine> DefaultMachine<Inner> {
self.pause.clone()
}

pub fn set_pause(&mut self, pause: Pause) {
self.pause = pause;
}

pub fn exit_code(&self) -> i8 {
self.exit_code
}
Expand Down Expand Up @@ -651,6 +655,7 @@ pub struct DefaultMachineBuilder<Inner> {
instruction_cycle_func: Box<InstructionCycleFunc>,
debugger: Option<Box<dyn Debugger<Inner>>>,
syscalls: Vec<Box<dyn Syscalls<Inner>>>,
pause: Pause,
}

impl<Inner> DefaultMachineBuilder<Inner> {
Expand All @@ -660,6 +665,7 @@ impl<Inner> DefaultMachineBuilder<Inner> {
instruction_cycle_func: Box::new(|_| 0),
debugger: None,
syscalls: vec![],
pause: Pause::new(),
}
}

Expand All @@ -676,6 +682,11 @@ impl<Inner> DefaultMachineBuilder<Inner> {
self
}

pub fn pause(mut self, pause: Pause) -> Self {
self.pause = pause;
self
}

pub fn debugger(mut self, debugger: Box<dyn Debugger<Inner>>) -> Self {
self.debugger = Some(debugger);
self
Expand All @@ -684,7 +695,7 @@ impl<Inner> DefaultMachineBuilder<Inner> {
pub fn build(self) -> DefaultMachine<Inner> {
DefaultMachine {
inner: self.inner,
pause: Pause::new(),
pause: self.pause,
instruction_cycle_func: self.instruction_cycle_func,
debugger: self.debugger,
syscalls: self.syscalls,
Expand Down

0 comments on commit bd848a6

Please sign in to comment.