Skip to content

Commit

Permalink
feat: Swappable pause (#414)
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 committed Mar 14, 2024
1 parent ef592b1 commit 6c97927
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 @@ -602,6 +602,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 @@ -658,6 +662,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 @@ -667,6 +672,7 @@ impl<Inner> DefaultMachineBuilder<Inner> {
instruction_cycle_func: Box::new(|_| 0),
debugger: None,
syscalls: vec![],
pause: Pause::new(),
}
}

Expand All @@ -683,6 +689,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 @@ -691,7 +702,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 6c97927

Please sign in to comment.