pub struct Hoister { /* private fields */ }
Expand description
Keeps track of:
- Local and nonlocal variables in each scope.
- All variables declared.
- Variables that have been used but not declared.
Implementations§
Source§impl Hoister
impl Hoister
Sourcepub fn walk(&mut self, cst: Spanned<CST>) -> Result<Spanned<SST>, Syntax>
pub fn walk(&mut self, cst: Spanned<CST>) -> Result<Spanned<SST>, Syntax>
Walks a CST
to produce an SST
.
This is fairly standard - hoisting happens in
self.assign
, self.lambda
, and self.symbol
.
Sourcepub fn walk_pattern(
&mut self,
pattern: Spanned<CSTPattern>,
declare: bool,
) -> Spanned<SSTPattern>
pub fn walk_pattern( &mut self, pattern: Spanned<CSTPattern>, declare: bool, ) -> Spanned<SSTPattern>
Walks a pattern. If declare
is true, we shadow variables in existing scopes
and creates a new variable in the local scope.
Sourcepub fn symbol(&mut self, name: &str) -> SST
pub fn symbol(&mut self, name: &str) -> SST
Replaces a symbol name with a unique identifier for that symbol
Sourcepub fn block(&mut self, block: Vec<Spanned<CST>>) -> Result<SST, Syntax>
pub fn block(&mut self, block: Vec<Spanned<CST>>) -> Result<SST, Syntax>
Walks a block, nothing fancy here.
Sourcepub fn tuple(&mut self, tuple: Vec<Spanned<CST>>) -> Result<SST, Syntax>
pub fn tuple(&mut self, tuple: Vec<Spanned<CST>>) -> Result<SST, Syntax>
Walks a tuple, nothing fancy here.
Sourcepub fn assign(
&mut self,
pattern: Spanned<CSTPattern>,
expression: Spanned<CST>,
) -> Result<SST, Syntax>
pub fn assign( &mut self, pattern: Spanned<CSTPattern>, expression: Spanned<CST>, ) -> Result<SST, Syntax>
Walks an assignment.
Delegates to walk_pattern
for capturing.
Assignments can capture existing variables
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hoister
impl RefUnwindSafe for Hoister
impl Send for Hoister
impl Sync for Hoister
impl Unpin for Hoister
impl UnwindSafe for Hoister
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