From ebbcd57022f41d6e66d0e75a0b28aafde6ba4a3a Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Thu, 5 May 2022 13:51:44 -0400 Subject: [PATCH] Make visitors public --- compiler/can/src/traverse.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/compiler/can/src/traverse.rs b/compiler/can/src/traverse.rs index 8ad473e0be..de93ad16ef 100644 --- a/compiler/can/src/traverse.rs +++ b/compiler/can/src/traverse.rs @@ -18,11 +18,11 @@ macro_rules! visit_list { }; } -fn walk_decls(visitor: &mut V, decls: &[Declaration]) { +pub fn walk_decls(visitor: &mut V, decls: &[Declaration]) { visit_list!(visitor, visit_decl, decls) } -fn walk_decl(visitor: &mut V, decl: &Declaration) { +pub fn walk_decl(visitor: &mut V, decl: &Declaration) { match decl { Declaration::Declare(def) => { visitor.visit_def(def); @@ -37,7 +37,7 @@ fn walk_decl(visitor: &mut V, decl: &Declaration) { } } -fn walk_def(visitor: &mut V, def: &Def) { +pub fn walk_def(visitor: &mut V, def: &Def) { let Def { loc_pattern, loc_expr, @@ -58,7 +58,7 @@ fn walk_def(visitor: &mut V, def: &Def) { } } -fn walk_expr(visitor: &mut V, expr: &Expr) { +pub fn walk_expr(visitor: &mut V, expr: &Expr) { match expr { Expr::Closure(closure_data) => walk_closure(visitor, closure_data), Expr::When { @@ -84,6 +84,7 @@ fn walk_expr(visitor: &mut V, expr: &Expr) { walk_list(visitor, *elem_var, loc_elems); } Expr::Var(..) => { /* terminal */ } + Expr::AbilityMember(..) => { /* terminal */ } Expr::If { cond_var, branches, @@ -171,7 +172,7 @@ fn walk_expr(visitor: &mut V, expr: &Expr) { } #[inline(always)] -fn walk_closure(visitor: &mut V, clos: &ClosureData) { +pub fn walk_closure(visitor: &mut V, clos: &ClosureData) { let ClosureData { arguments, loc_body, @@ -187,7 +188,7 @@ fn walk_closure(visitor: &mut V, clos: &ClosureData) { } #[inline(always)] -fn walk_when( +pub fn walk_when( visitor: &mut V, cond_var: Variable, expr_var: Variable, @@ -202,7 +203,7 @@ fn walk_when( } #[inline(always)] -fn walk_when_branch(visitor: &mut V, branch: &WhenBranch, expr_var: Variable) { +pub fn walk_when_branch(visitor: &mut V, branch: &WhenBranch, expr_var: Variable) { let WhenBranch { patterns, value, @@ -220,14 +221,14 @@ fn walk_when_branch(visitor: &mut V, branch: &WhenBranch, expr_var: } #[inline(always)] -fn walk_list(visitor: &mut V, elem_var: Variable, loc_elems: &[Loc]) { +pub fn walk_list(visitor: &mut V, elem_var: Variable, loc_elems: &[Loc]) { loc_elems .iter() .for_each(|le| visitor.visit_expr(&le.value, le.region, elem_var)); } #[inline(always)] -fn walk_if( +pub fn walk_if( visitor: &mut V, cond_var: Variable, branches: &[(Loc, Loc)], @@ -242,7 +243,7 @@ fn walk_if( } #[inline(always)] -fn walk_call( +pub fn walk_call( visitor: &mut V, fn_var: Variable, fn_expr: &Loc, @@ -254,7 +255,7 @@ fn walk_call( } #[inline(always)] -fn walk_record_fields<'a, V: Visitor>( +pub fn walk_record_fields<'a, V: Visitor>( visitor: &mut V, fields: impl Iterator, ) { @@ -270,7 +271,7 @@ fn walk_record_fields<'a, V: Visitor>( ) } -trait Visitor: Sized + PatternVisitor { +pub trait Visitor: Sized + PatternVisitor { fn visit_decls(&mut self, decls: &[Declaration]) { walk_decls(self, decls); } @@ -292,11 +293,11 @@ trait Visitor: Sized + PatternVisitor { } } -fn walk_pattern(_visitor: &mut V, _pattern: &Pattern) { +pub fn walk_pattern(_visitor: &mut V, _pattern: &Pattern) { // ignore for now } -trait PatternVisitor: Sized { +pub trait PatternVisitor: Sized { fn visit_pattern(&mut self, pattern: &Pattern, _region: Region, _opt_var: Option) { walk_pattern(self, pattern); }