pub struct ScopeWalker<'src, V> { /* private fields */ }Expand description
Drives a ScopeVisitor over an AST, maintaining Scope automatically.
ScopeWalker wraps a ScopeVisitor and tracks the lexical scope as it
descends the tree, updating scope before visiting children and restoring it
on exit from scope-defining nodes (functions, classes, namespaces).
§Usage
let arena = bumpalo::Bump::new();
let src = "<?php class Foo { public function bar() {} }";
let program = parse(&arena, src);
let mut walker = ScopeWalker::new(MyVisitor);
walker.walk(&program);
let _my_visitor = walker.into_inner();Implementations§
Source§impl<'src, V> ScopeWalker<'src, V>
impl<'src, V> ScopeWalker<'src, V>
Sourcepub fn into_inner(self) -> V
pub fn into_inner(self) -> V
Consumes the walker and returns the inner visitor.
Source§impl<'arena, 'src, V: ScopeVisitor<'arena, 'src>> ScopeWalker<'src, V>
impl<'arena, 'src, V: ScopeVisitor<'arena, 'src>> ScopeWalker<'src, V>
Sourcepub fn walk(&mut self, program: &Program<'arena, 'src>) -> ControlFlow<()>
pub fn walk(&mut self, program: &Program<'arena, 'src>) -> ControlFlow<()>
Walks program, calling ScopeVisitor methods with scope context.
Trait Implementations§
Source§impl<'arena, 'src, V: ScopeVisitor<'arena, 'src>> Visitor<'arena, 'src> for ScopeWalker<'src, V>
impl<'arena, 'src, V: ScopeVisitor<'arena, 'src>> Visitor<'arena, 'src> for ScopeWalker<'src, V>
fn visit_program(&mut self, program: &Program<'arena, 'src>) -> ControlFlow<()>
fn visit_stmt(&mut self, stmt: &Stmt<'arena, 'src>) -> ControlFlow<()>
fn visit_expr(&mut self, expr: &Expr<'arena, 'src>) -> ControlFlow<()>
fn visit_class_member( &mut self, member: &ClassMember<'arena, 'src>, ) -> ControlFlow<()>
fn visit_enum_member( &mut self, member: &EnumMember<'arena, 'src>, ) -> ControlFlow<()>
fn visit_param(&mut self, param: &Param<'arena, 'src>) -> ControlFlow<()>
fn visit_arg(&mut self, arg: &Arg<'arena, 'src>) -> ControlFlow<()>
fn visit_property_hook( &mut self, hook: &PropertyHook<'arena, 'src>, ) -> ControlFlow<()>
fn visit_type_hint( &mut self, type_hint: &TypeHint<'arena, 'src>, ) -> ControlFlow<()>
fn visit_attribute( &mut self, attribute: &Attribute<'arena, 'src>, ) -> ControlFlow<()>
fn visit_catch_clause( &mut self, catch: &CatchClause<'arena, 'src>, ) -> ControlFlow<()>
fn visit_match_arm(&mut self, arm: &MatchArm<'arena, 'src>) -> ControlFlow<()>
fn visit_closure_use_var( &mut self, var: &ClosureUseVar<'src>, ) -> ControlFlow<()>
Auto Trait Implementations§
impl<'src, V> Freeze for ScopeWalker<'src, V>where
V: Freeze,
impl<'src, V> RefUnwindSafe for ScopeWalker<'src, V>where
V: RefUnwindSafe,
impl<'src, V> Send for ScopeWalker<'src, V>where
V: Send,
impl<'src, V> Sync for ScopeWalker<'src, V>where
V: Sync,
impl<'src, V> Unpin for ScopeWalker<'src, V>where
V: Unpin,
impl<'src, V> UnsafeUnpin for ScopeWalker<'src, V>where
V: UnsafeUnpin,
impl<'src, V> UnwindSafe for ScopeWalker<'src, V>where
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more