Change debugger init signature.

This commit is contained in:
Stephen Chung
2022-11-25 13:20:03 +08:00
parent 6db9870fb1
commit fbe30b8d0e
6 changed files with 25 additions and 12 deletions

View File

@@ -10,10 +10,10 @@ use std::{fmt, iter::repeat, mem};
/// Callback function to initialize the debugger.
#[cfg(not(feature = "sync"))]
pub type OnDebuggingInit = dyn Fn(&Engine) -> Dynamic;
pub type OnDebuggingInit = dyn Fn(&Engine, Debugger) -> Debugger;
/// Callback function to initialize the debugger.
#[cfg(feature = "sync")]
pub type OnDebuggingInit = dyn Fn(&Engine) -> Dynamic + Send + Sync;
pub type OnDebuggingInit = dyn Fn(&Engine, Debugger) -> Debugger + Send + Sync;
/// Callback function for debugging.
#[cfg(not(feature = "sync"))]
@@ -268,12 +268,12 @@ impl Debugger {
/// Create a new [`Debugger`].
#[inline(always)]
#[must_use]
pub const fn new(status: DebuggerStatus, state: Dynamic) -> Self {
pub const fn new(status: DebuggerStatus) -> Self {
Self {
status,
break_points: Vec::new(),
call_stack: Vec::new(),
state,
state: Dynamic::UNIT,
}
}
/// Get the current call stack.

View File

@@ -104,7 +104,8 @@ impl GlobalRuntimeState {
#[cfg(feature = "debugging")]
debugger: engine.debugger.as_ref().map(|x| {
crate::eval::Debugger::new(crate::eval::DebuggerStatus::Init, (x.0)(engine))
let dbg = crate::eval::Debugger::new(crate::eval::DebuggerStatus::Init);
(x.0)(engine, dbg)
}),
}
}