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
+5 -11
View File
@@ -22,13 +22,11 @@ impl<'a, T: Clone> LambdaCollector<'a, T> {
}
}
BoundKind::DefGlobal {
global_index,
value,
..
} => {
// Register the full Lambda node as the template.
if let BoundKind::Lambda { .. } = &value.kind {
BoundKind::Define { addr, value, .. } => {
// Register global function definitions (lambdas)
if let Address::Global(global_index) = addr
&& let BoundKind::Lambda { .. } = &value.kind
{
self.registry
.insert(*global_index, (*value).as_ref().clone());
}
@@ -63,10 +61,6 @@ impl<'a, T: Clone> LambdaCollector<'a, T> {
self.visit(body);
}
BoundKind::DefLocal { value, .. } => {
self.visit(value);
}
BoundKind::Call { callee, args } => {
self.visit(callee);
self.visit(args);