From 07f1868bf935f4edd8c7f7deaaf079a6750807ec Mon Sep 17 00:00:00 2001 From: Xuejie Xiao Date: Tue, 23 Jan 2024 02:55:48 +0000 Subject: [PATCH] feat: Swappable pause --- src/machine/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/machine/mod.rs b/src/machine/mod.rs index b07ad7f2..be231177 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -602,6 +602,10 @@ impl DefaultMachine { self.pause.clone() } + pub fn set_pause(&mut self, pause: Pause) { + self.pause = pause; + } + pub fn exit_code(&self) -> i8 { self.exit_code } @@ -658,6 +662,7 @@ pub struct DefaultMachineBuilder { instruction_cycle_func: Box, debugger: Option>>, syscalls: Vec>>, + pause: Pause, } impl DefaultMachineBuilder { @@ -667,6 +672,7 @@ impl DefaultMachineBuilder { instruction_cycle_func: Box::new(|_| 0), debugger: None, syscalls: vec![], + pause: Pause::new(), } } @@ -683,6 +689,11 @@ impl DefaultMachineBuilder { self } + pub fn pause(mut self, pause: Pause) -> Self { + self.pause = pause; + self + } + pub fn debugger(mut self, debugger: Box>) -> Self { self.debugger = Some(debugger); self @@ -691,7 +702,7 @@ impl DefaultMachineBuilder { pub fn build(self) -> DefaultMachine { DefaultMachine { inner: self.inner, - pause: Pause::new(), + pause: self.pause, instruction_cycle_func: self.instruction_cycle_func, debugger: self.debugger, syscalls: self.syscalls,