Add symbol name to bound kinds

The `Get`, `DefLocal`, and `DefGlobal` bound kinds now store the symbol
name associated with the variable. This information is useful for
debugging and provides more context in the compiled output.
This commit is contained in:
Michael Schimmel
2026-02-19 16:25:17 +01:00
parent 98668cc683
commit e7628e5cdf
7 changed files with 52 additions and 37 deletions
+5 -5
View File
@@ -35,7 +35,7 @@ impl Dumper {
match &node.kind {
BoundKind::Nop => self.log("Nop", node),
BoundKind::Constant(v) => self.log(&format!("Constant: {}", v), node),
BoundKind::Get(addr) => self.log(&format!("Get: {:?}", addr), node),
BoundKind::Get { addr, name } => self.log(&format!("Get: {} ({:?})", name.name, addr), node),
BoundKind::Set { addr, value } => {
self.log(&format!("Set: {:?}", addr), node);
@@ -44,13 +44,13 @@ impl Dumper {
self.indent -= 1;
}
BoundKind::DefLocal { slot, value, captured_by } => {
BoundKind::DefLocal { name, slot, value, captured_by } => {
let capture_info = if captured_by.is_empty() {
String::from("not captured")
} else {
format!("captured by {} lambdas", captured_by.len())
};
self.log(&format!("DefLocal (Slot: {}, {})", slot, capture_info), node);
self.log(&format!("DefLocal (Name: '{}', Slot: {}, {})", name.name, slot, capture_info), node);
self.indent += 1;
if !captured_by.is_empty() {
@@ -64,8 +64,8 @@ impl Dumper {
self.indent -= 1;
}
BoundKind::DefGlobal { global_index, value } => {
self.log(&format!("DefGlobal (Index: {})", global_index), node);
BoundKind::DefGlobal { name, global_index, value } => {
self.log(&format!("DefGlobal (Name: '{}', Index: {})", name.name, global_index), node);
self.indent += 1;
self.visit(value);
self.indent -= 1;