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
+6 -1
View File
@@ -104,7 +104,10 @@ impl Binder {
UntypedKind::Identifier(sym) => {
let addr = self.resolve_variable(sym)?;
Ok(self.make_node(node.identity.clone(), BoundKind::Get(addr)))
Ok(self.make_node(node.identity.clone(), BoundKind::Get {
addr,
name: sym.clone()
}))
},
UntypedKind::If { cond, then_br, else_br } => {
@@ -143,12 +146,14 @@ impl Binder {
// 3. Return Node
if self.functions.len() == 1 {
Ok(self.make_node(node.identity.clone(), BoundKind::DefGlobal {
name: name.clone(),
global_index: slot_or_idx,
value: Box::new(val_node)
}))
} else {
let captured_by = self.capture_map.get(&node.identity).cloned().unwrap_or_default();
Ok(self.make_node(node.identity.clone(), BoundKind::DefLocal {
name: name.clone(),
slot: slot_or_idx,
value: Box::new(val_node) ,
captured_by