Struct passerine::compiler::hoist::Hoister [−][src]
Keeps track of:
- Local and nonlocal variables in each scope.
- All variables declared.
- Variables that have been used but not declared.
Implementations
impl Hoister
[src]
pub fn new() -> Hoister
[src]
Creates a new hoisted in a root scope. Note that the hoister will always have a root scope.
pub fn walk(&mut self, cst: Spanned<CST>) -> Result<Spanned<SST>, Syntax>
[src]
Walks a CST
to produce an SST
.
This is fairly standard - hoisting happens in
self.assign
, self.lambda
, and self.symbol
.
pub fn walk_pattern(
&mut self,
pattern: Spanned<CSTPattern>,
declare: bool
) -> Spanned<SSTPattern>
[src]
&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.
pub fn symbol(&mut self, name: &str) -> SST
[src]
Replaces a symbol name with a unique identifier for that symbol
pub fn block(&mut self, block: Vec<Spanned<CST>>) -> Result<SST, Syntax>
[src]
Walks a block, nothing fancy here.
pub fn tuple(&mut self, tuple: Vec<Spanned<CST>>) -> Result<SST, Syntax>
[src]
Walks a tuple, nothing fancy here.
pub fn assign(
&mut self,
pattern: Spanned<CSTPattern>,
expression: Spanned<CST>
) -> Result<SST, Syntax>
[src]
&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
pub fn lambda(
&mut self,
pattern: Spanned<CSTPattern>,
expression: Spanned<CST>
) -> Result<SST, Syntax>
[src]
&mut self,
pattern: Spanned<CSTPattern>,
expression: Spanned<CST>
) -> Result<SST, Syntax>
Walks a function definition.
Like assign
, delegates to walk_pattern
for capturing.
But any paramaters will shadow those in outer scopes.
pub fn call(
&mut self,
fun: Spanned<CST>,
arg: Spanned<CST>
) -> Result<SST, Syntax>
[src]
&mut self,
fun: Spanned<CST>,
arg: Spanned<CST>
) -> Result<SST, Syntax>
Walks a function call.
Auto Trait Implementations
impl RefUnwindSafe for Hoister
impl Send for Hoister
impl Sync for Hoister
impl Unpin for Hoister
impl UnwindSafe for Hoister
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,