conlang: Unify binding operations!

This breaks out the pattern matching/unification algorithm from cl-interpret/interpret.rs to cl-interpret/pattern.rs

TODO: pattern destructuring in const, static :^)
This commit is contained in:
2025-02-22 05:16:37 -06:00
parent 7a8da33de9
commit e3d94d8949
14 changed files with 202 additions and 171 deletions

View File

@@ -67,8 +67,8 @@ impl<'a> Visit<'a> for CollectUpvars<'_> {
fn visit_function(&mut self, f: &'a cl_ast::Function) {
let Function { name: _, sign: _, bind, body } = f;
// parameters can never be upvars
for Param { mutability: _, name } in bind {
self.bind_name(name);
for Param { mutability: _, bind } in bind {
self.visit_pattern(bind);
}
if let Some(body) = body {
self.visit_expr(body);