From b82a3b64cbdb0d53d7248cd734e4c375e97f1b61 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 cd1141f1..18d5c557 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -599,6 +599,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 } @@ -651,6 +655,7 @@ pub struct DefaultMachineBuilder { instruction_cycle_func: Box, debugger: Option>>, syscalls: Vec>>, + pause: Pause, } impl DefaultMachineBuilder { @@ -660,6 +665,7 @@ impl DefaultMachineBuilder { instruction_cycle_func: Box::new(|_| 0), debugger: None, syscalls: vec![], + pause: Pause::new(), } } @@ -676,6 +682,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 @@ -684,7 +695,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,