Add debugging interface.

This commit is contained in:
Stephen Chung
2022-01-24 17:04:40 +08:00
parent 182870c9ed
commit fc87dec128
24 changed files with 1255 additions and 414 deletions

View File

@@ -64,7 +64,7 @@ impl Engine {
self.resolve_var = Some(Box::new(callback));
self
}
/// _(internals)_ Provide a callback that will be invoked during parsing to remap certain tokens.
/// _(internals)_ Register a callback that will be invoked during parsing to remap certain tokens.
/// Exported under the `internals` feature only.
///
/// # Callback Function Signature
@@ -261,4 +261,22 @@ impl Engine {
self.debug = Some(Box::new(callback));
self
}
/// _(debugging)_ Register a callback for debugging.
/// Exported under the `debugging` feature only.
#[cfg(feature = "debugging")]
#[inline(always)]
pub fn on_debugger(
&mut self,
callback: impl Fn(
&mut EvalContext,
crate::ast::ASTNode,
Option<&str>,
Position,
) -> crate::eval::DebuggerCommand
+ SendSync
+ 'static,
) -> &mut Self {
self.debugger = Some(Box::new(callback));
self
}
}