cl-ast: Move let into Expr

This commit is contained in:
2024-07-30 18:02:09 -05:00
parent a3e383b53f
commit b0341f06fd
8 changed files with 62 additions and 58 deletions

View File

@@ -192,7 +192,7 @@ pub trait Visit<'a>: Sized {
}
fn visit_semi(&mut self, _s: &'a Semi) {}
fn visit_let(&mut self, l: &'a Let) {
let Let { mutable, name, ty, init } = l;
let Let { mutable, name, ty, init, tail } = l;
self.visit_mutability(mutable);
self.visit_sym(name);
if let Some(ty) = ty {
@@ -201,6 +201,9 @@ pub trait Visit<'a>: Sized {
if let Some(init) = init {
self.visit_expr(init)
}
if let Some(tail) = tail {
self.visit_expr(tail)
}
}
fn visit_expr(&mut self, e: &'a Expr) {
let Expr { extents, kind } = e;
@@ -448,7 +451,6 @@ pub fn or_visit_ty_kind<'a, V: Visit<'a>>(visitor: &mut V, kind: &'a TyKind) {
pub fn or_visit_stmt_kind<'a, V: Visit<'a>>(visitor: &mut V, kind: &'a StmtKind) {
match kind {
StmtKind::Empty => {}
StmtKind::Local(l) => visitor.visit_let(l),
StmtKind::Item(i) => visitor.visit_item(i),
StmtKind::Expr(e) => visitor.visit_expr(e),
}
@@ -457,6 +459,7 @@ pub fn or_visit_stmt_kind<'a, V: Visit<'a>>(visitor: &mut V, kind: &'a StmtKind)
pub fn or_visit_expr_kind<'a, V: Visit<'a>>(visitor: &mut V, e: &'a ExprKind) {
match e {
ExprKind::Empty => {}
ExprKind::Let(l) => visitor.visit_let(l),
ExprKind::Assign(a) => visitor.visit_assign(a),
ExprKind::Modify(m) => visitor.visit_modify(m),
ExprKind::Binary(b) => visitor.visit_binary(b),