Struct Ctx

Source
pub struct Ctx {
    pub values: Vec<N>,
    pub idents: Vec<String>,
    pub code: Vec<char>,
    pub deep: usize,
}
Expand description

Interpreter context, holds all state during execution.

Fields§

§values: Vec<N>§idents: Vec<String>§code: Vec<char>§deep: usize

Implementations§

Source§

impl Ctx

Source

pub fn new() -> Ctx

Source

pub fn drain(&mut self, from: usize)

Source

pub fn set_val(&mut self, name: &str, n: N)

Source

pub fn set_val_absolute(&mut self, i: usize, name: &str, n: N)

Source

pub fn find_var(&mut self, name: &str) -> Option<(usize, &mut N)>

Find a variable declared in the scope, or any parent scope

returns the path and the variable value

Source

pub fn insert_code(&mut self, code: &str)

Source

pub fn parse_next_expr(&mut self) -> Result<N, &'static str>

Trait Implementations§

Source§

impl Default for Ctx

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Ctx

§

impl !RefUnwindSafe for Ctx

§

impl !Send for Ctx

§

impl !Sync for Ctx

§

impl Unpin for Ctx

§

impl !UnwindSafe for Ctx

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.