cl-ast: Cleanup

- Function bind is now one Pattern
- TyRef now allows &Ty (i.e. &[i32], &(char, bool)
- Range patterns (they cannot bind, only check whether a value is in range
- ArrayRep repeat has been reverted to usize, for now, until early consteval is implemented.
This commit is contained in:
2025-04-21 04:17:45 -04:00
parent ef92d8b798
commit 7ba808594c
15 changed files with 252 additions and 134 deletions

View File

@@ -82,7 +82,7 @@ pub trait Visit<'a>: Sized {
let Function { name, sign, bind, body } = f;
self.visit_sym(name);
self.visit_ty_fn(sign);
bind.iter().for_each(|p| self.visit_pattern(p));
self.visit_pattern(bind);
if let Some(b) = body {
self.visit_expr(b)
}
@@ -154,7 +154,7 @@ pub trait Visit<'a>: Sized {
fn visit_ty_ref(&mut self, t: &'a TyRef) {
let TyRef { mutable, count: _, to } = t;
self.visit_mutability(mutable);
self.visit_path(to);
self.visit_ty(to);
}
fn visit_ty_fn(&mut self, t: &'a TyFn) {
let TyFn { args, rety } = t;
@@ -215,6 +215,14 @@ pub trait Visit<'a>: Sized {
self.visit_mutability(mutability);
self.visit_pattern(pattern);
}
Pattern::RangeExc(head, tail) => {
self.visit_pattern(head);
self.visit_pattern(tail);
}
Pattern::RangeInc(head, tail) => {
self.visit_pattern(head);
self.visit_pattern(tail);
}
Pattern::Tuple(patterns) => {
patterns.iter().for_each(|p| self.visit_pattern(p));
}
@@ -311,9 +319,8 @@ pub trait Visit<'a>: Sized {
values.iter().for_each(|e| self.visit_expr(e))
}
fn visit_array_rep(&mut self, a: &'a ArrayRep) {
let ArrayRep { value, repeat } = a;
let ArrayRep { value, repeat: _ } = a;
self.visit_expr(value);
self.visit_expr(repeat);
}
fn visit_addrof(&mut self, a: &'a AddrOf) {
let AddrOf { mutable, expr } = a;