Add debug mode and VM tracing

Introduce a `debug_mode` flag to the `Environment` and a new `run_debug`
method. This method uses a `TracingObserver` to log the VM's execution
flow, including node evaluation and scope state changes. This allows for
detailed inspection of script execution.

The `BoundKind` enum now also includes a `display_name` method for
better log readability.
This commit is contained in:
Michael Schimmel
2026-02-18 00:56:29 +01:00
parent 25e3bc1d01
commit faada16723
5 changed files with 212 additions and 30 deletions
+32
View File
@@ -91,6 +91,38 @@ pub enum StaticType {
Object(&'static str),
}
impl fmt::Display for StaticType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
StaticType::Any => write!(f, "any"),
StaticType::Void => write!(f, "void"),
StaticType::Bool => write!(f, "bool"),
StaticType::Int => write!(f, "int"),
StaticType::Float => write!(f, "float"),
StaticType::Text => write!(f, "text"),
StaticType::Keyword => write!(f, "keyword"),
StaticType::List(inner) => write!(f, "[{}]", inner),
StaticType::Record(fields) => {
write!(f, "{{")?;
for (i, (k, v)) in fields.iter().enumerate() {
if i > 0 { write!(f, ", ")?; }
write!(f, ":{} {}", k.name(), v)?;
}
write!(f, "}}")
},
StaticType::Function { params, ret } => {
write!(f, "fn(")?;
for (i, p) in params.iter().enumerate() {
if i > 0 { write!(f, " ")?; }
write!(f, "{}", p)?;
}
write!(f, ") -> {}", ret)
},
StaticType::Object(name) => write!(f, "{}", name),
}
}
}
impl Value {
pub fn is_truthy(&self) -> bool {
match self {