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

@@ -46,6 +46,9 @@ pub struct GlobalRuntimeState<'a> {
#[cfg(not(feature = "no_function"))]
constants:
Option<Shared<crate::Locked<std::collections::BTreeMap<Identifier, crate::Dynamic>>>>,
/// Debugging interface.
#[cfg(feature = "debugging")]
pub debugger: super::Debugger,
/// Take care of the lifetime parameter.
dummy: PhantomData<&'a ()>,
}
@@ -75,6 +78,8 @@ impl GlobalRuntimeState<'_> {
#[cfg(not(feature = "no_module"))]
#[cfg(not(feature = "no_function"))]
constants: None,
#[cfg(feature = "debugging")]
debugger: crate::eval::Debugger::new(),
dummy: PhantomData::default(),
}
}
@@ -179,6 +184,15 @@ impl GlobalRuntimeState<'_> {
.rev()
.find_map(|m| m.get_qualified_iter(id))
}
/// Get the current source.
#[inline]
#[must_use]
pub fn source(&self) -> Option<&str> {
match self.source.as_str() {
"" => None,
s => Some(s),
}
}
/// Get a mutable reference to the cache of globally-defined constants.
#[cfg(not(feature = "no_module"))]
#[cfg(not(feature = "no_function"))]