Allow initialization of EvalState tag and separate debugger state into separate variable.

This commit is contained in:
Stephen Chung
2022-05-21 21:44:12 +08:00
parent 5435fdb8c8
commit 1abec0a8a8
10 changed files with 86 additions and 25 deletions

View File

@@ -253,17 +253,20 @@ pub struct Debugger {
break_points: Vec<BreakPoint>,
/// The current function call stack.
call_stack: Vec<CallStackFrame>,
/// The current state.
state: Dynamic,
}
impl Debugger {
/// Create a new [`Debugger`].
#[inline(always)]
#[must_use]
pub fn new(status: DebuggerStatus) -> Self {
pub fn new(status: DebuggerStatus, state: Dynamic) -> Self {
Self {
status,
break_points: Vec::new(),
call_stack: Vec::new(),
state,
}
}
/// Get the current call stack.
@@ -374,6 +377,23 @@ impl Debugger {
pub fn break_points_mut(&mut self) -> &mut Vec<BreakPoint> {
&mut self.break_points
}
/// Get the custom state.
#[inline(always)]
#[must_use]
pub fn state(&self) -> &Dynamic {
&self.state
}
/// Get a mutable reference to the custom state.
#[inline(always)]
#[must_use]
pub fn state_mut(&mut self) -> &mut Dynamic {
&mut self.state
}
/// Set the custom state.
#[inline(always)]
pub fn set_state(&mut self, state: impl Into<Dynamic>) {
self.state = state.into();
}
}
impl Engine {