Refactor and add state to debugger.
This commit is contained in:
@@ -154,10 +154,7 @@ impl Engine {
|
||||
arg_values: impl AsMut<[Dynamic]>,
|
||||
) -> RhaiResult {
|
||||
let state = &mut EvalState::new();
|
||||
let global = &mut GlobalRuntimeState::new();
|
||||
|
||||
#[cfg(feature = "debugging")]
|
||||
global.debugger.activate(self.debugger.is_some());
|
||||
let global = &mut GlobalRuntimeState::new(self);
|
||||
|
||||
let statements = ast.statements();
|
||||
|
||||
|
@@ -184,10 +184,7 @@ impl Engine {
|
||||
scope: &mut Scope,
|
||||
ast: &AST,
|
||||
) -> RhaiResultOf<T> {
|
||||
let global = &mut GlobalRuntimeState::new();
|
||||
|
||||
#[cfg(feature = "debugging")]
|
||||
global.debugger.activate(self.debugger.is_some());
|
||||
let global = &mut GlobalRuntimeState::new(self);
|
||||
|
||||
let result = self.eval_ast_with_scope_raw(scope, global, ast, 0)?;
|
||||
|
||||
|
@@ -260,12 +260,13 @@ impl Engine {
|
||||
self.debug = Some(Box::new(callback));
|
||||
self
|
||||
}
|
||||
/// _(debugging)_ Register a callback for debugging.
|
||||
/// _(debugging)_ Register callbacks for debugging.
|
||||
/// Exported under the `debugging` feature only.
|
||||
#[cfg(feature = "debugging")]
|
||||
#[inline(always)]
|
||||
pub fn on_debugger(
|
||||
&mut self,
|
||||
init: impl Fn() -> Dynamic + SendSync + 'static,
|
||||
callback: impl Fn(
|
||||
&mut EvalContext,
|
||||
crate::ast::ASTNode,
|
||||
@@ -275,7 +276,7 @@ impl Engine {
|
||||
+ SendSync
|
||||
+ 'static,
|
||||
) -> &mut Self {
|
||||
self.debugger = Some(Box::new(callback));
|
||||
self.debugger = Some((Box::new(init), Box::new(callback)));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@@ -1037,9 +1037,9 @@ impl Engine {
|
||||
|
||||
signatures.extend(self.global_namespace().gen_fn_signatures());
|
||||
|
||||
self.global_sub_modules.iter().for_each(|(name, m)| {
|
||||
for (name, m) in &self.global_sub_modules {
|
||||
signatures.extend(m.gen_fn_signatures().map(|f| format!("{}::{}", name, f)))
|
||||
});
|
||||
}
|
||||
|
||||
signatures.extend(
|
||||
self.global_modules
|
||||
|
@@ -45,9 +45,7 @@ impl Engine {
|
||||
#[inline]
|
||||
pub fn run_ast_with_scope(&self, scope: &mut Scope, ast: &AST) -> RhaiResultOf<()> {
|
||||
let state = &mut EvalState::new();
|
||||
let global = &mut GlobalRuntimeState::new();
|
||||
#[cfg(feature = "debugging")]
|
||||
global.debugger.activate(self.debugger.is_some());
|
||||
let global = &mut GlobalRuntimeState::new(self);
|
||||
global.source = ast.source_raw().clone();
|
||||
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
|
Reference in New Issue
Block a user