Refactor: Use generic Define bound kind

This commit consolidates `DefLocal` and `DefGlobal` into a single
`Define` bound kind. This simplifies the AST and makes it more
consistent.

It also introduces `DeclarationKind` to differentiate between variable
and parameter definitions.
This commit is contained in:
Michael Schimmel
2026-02-25 10:45:36 +01:00
parent f995aaf81b
commit c256a8a992
11 changed files with 280 additions and 464 deletions
+8 -21
View File
@@ -104,34 +104,21 @@ impl Specializer {
node.ty.clone(),
)
}
BoundKind::DefLocal {
BoundKind::Define {
name,
slot,
addr,
kind,
value,
captured_by,
} => {
let value = Box::new(self.visit_node(*value));
(
BoundKind::DefLocal {
name,
slot,
value,
captured_by,
},
node.ty.clone(),
)
}
BoundKind::DefGlobal {
name,
global_index,
value,
} => {
let value = Box::new(self.visit_node(*value));
(
BoundKind::DefGlobal {
name,
global_index,
BoundKind::Define {
name: name.clone(),
addr,
kind,
value,
captured_by: captured_by.clone(),
},
node.ty.clone(),
)