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:
@@ -70,7 +70,24 @@ pub enum BoundKind {
|
||||
Map {
|
||||
entries: Vec<(Node<BoundKind, StaticType>, Node<BoundKind, StaticType>)>,
|
||||
},
|
||||
|
||||
// Extension points (need to be adapted for bound nodes if they use variables)
|
||||
// For now, we assume extensions are self-contained or handled dynamically.
|
||||
}
|
||||
|
||||
impl BoundKind {
|
||||
pub fn display_name(&self) -> String {
|
||||
match self {
|
||||
BoundKind::Nop => "NOP".to_string(),
|
||||
BoundKind::Constant(v) => format!("CONST({})", v),
|
||||
BoundKind::Get(addr) => format!("GET({:?})", addr),
|
||||
BoundKind::Set { addr, .. } => format!("SET({:?})", addr),
|
||||
BoundKind::DefLocal { slot, .. } => format!("DEF_LOCAL(Slot:{})", slot),
|
||||
BoundKind::If { .. } => "IF".to_string(),
|
||||
BoundKind::DefGlobal { global_index, .. } => format!("DEF_GLOBAL(Idx:{})", global_index),
|
||||
BoundKind::Lambda { upvalues, .. } => format!("LAMBDA(Captures:{})", upvalues.len()),
|
||||
BoundKind::Call { .. } => "CALL".to_string(),
|
||||
BoundKind::TailCall { .. } => "T-CALL".to_string(),
|
||||
BoundKind::Block { .. } => "BLOCK".to_string(),
|
||||
BoundKind::Tuple { elements } => format!("TUPLE({})", elements.len()),
|
||||
BoundKind::Map { entries } => format!("MAP({})", entries.len()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user