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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user