pub struct Frame<'scope> { /* private fields */ }
Expand description
Represents a stack frame
Methods from Deref<Target = Environment>§
Sourcepub fn eval(&mut self, node: &impl Interpret) -> IResult<ConValue>
pub fn eval(&mut self, node: &impl Interpret) -> IResult<ConValue>
Reflexively evaluates a node
Sourcepub fn call(&mut self, name: Sym, args: &[ConValue]) -> IResult<ConValue>
pub fn call(&mut self, name: Sym, args: &[ConValue]) -> IResult<ConValue>
Calls a function inside the interpreter’s scope, and returns the result
Sourcepub fn bind(&mut self, name: &str, value: impl Into<ConValue>)
pub fn bind(&mut self, name: &str, value: impl Into<ConValue>)
Binds a value to the given name in the current scope.
Sourcepub fn globals(&self) -> &HashMap<Sym, Option<ConValue>>
pub fn globals(&self) -> &HashMap<Sym, Option<ConValue>>
Gets all registered globals, bound or unbound.
Sourcepub fn add_builtins(&mut self, builtins: &'static [Builtin]) -> &mut Self
pub fn add_builtins(&mut self, builtins: &'static [Builtin]) -> &mut Self
pub fn push_frame( &mut self, name: &'static str, frame: HashMap<Sym, Option<ConValue>>, )
pub fn pop_frame( &mut self, ) -> Option<(HashMap<Sym, Option<ConValue>>, &'static str)>
Sourcepub fn frame(&mut self, name: &'static str) -> Frame<'_>
pub fn frame(&mut self, name: &'static str) -> Frame<'_>
Enters a nested scope, returning a Frame
stack-guard.
Frame
implements Deref/DerefMut for Environment
.
Sourcepub fn get_mut(&mut self, name: Sym) -> IResult<&mut Option<ConValue>>
pub fn get_mut(&mut self, name: Sym) -> IResult<&mut Option<ConValue>>
Resolves a variable mutably.
Returns a mutable reference to the variable’s record, if it exists.
Sourcepub fn get(&self, name: Sym) -> IResult<ConValue>
pub fn get(&self, name: Sym) -> IResult<ConValue>
Resolves a variable immutably.
Returns a reference to the variable’s contents, if it is defined and initialized.
pub fn get_id(&self, at: Place) -> Option<&ConValue>
pub fn get_id_mut(&mut self, at: Place) -> Option<&mut Option<ConValue>>
Sourcepub fn insert(&mut self, k: Sym, v: Option<ConValue>)
pub fn insert(&mut self, k: Sym, v: Option<ConValue>)
Inserts a new ConValue into this Environment
Sourcepub fn insert_fn(&mut self, decl: &FnDecl)
pub fn insert_fn(&mut self, decl: &FnDecl)
A convenience function for registering a [FnDecl] as a Function
Sourcepub fn stack_alloc(&mut self, value: ConValue) -> IResult<usize>
pub fn stack_alloc(&mut self, value: ConValue) -> IResult<usize>
Allocates a local variable
pub fn bind_raw(&mut self, name: Sym, id: usize) -> Option<()>
Trait Implementations§
Auto Trait Implementations§
impl<'scope> Freeze for Frame<'scope>
impl<'scope> !RefUnwindSafe for Frame<'scope>
impl<'scope> !Send for Frame<'scope>
impl<'scope> !Sync for Frame<'scope>
impl<'scope> Unpin for Frame<'scope>
impl<'scope> !UnwindSafe for Frame<'scope>
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