procc_ll::program

Struct ProgramBlock

Source
pub struct ProgramBlock {
    pub context: Context,
}
Expand description

is a part of the program, contains the context, i is capable of executing Use example:

use processor::program::{Program, ProgramBlock};
let mut program = Program::new();
let main = program.create_block();

// now use the main ProgramBlock

Fields§

§context: Context

Implementations§

Source§

impl ProgramBlock

Source

pub fn exec(&mut self, token: &str) -> Values

Executes a new token Use example:

use processor::program::{Program, ProgramBlock};

let mut program = Program::new();
let main = program.create_block();

main.borrow_mut().push_internal_key("echo", |tok, prog| {
    print!("{}" ,tok);
    processor::values::Values::Null
});
main.borrow_mut().exec("echo hello world!!");
Source

pub fn push_internal_token(&mut self, token: Box<dyn Token>)

Push a new token in the context

Source

pub fn push_internal_key( &mut self, key: &str, func: impl Fn(String, &mut ProgramBlock) -> Values + 'static, )

push a new key on the context

Source

pub fn push_internal_memory(&mut self, key: &str, val: Values)

push a new value on the context

Source

pub fn push_internal_function( &mut self, name: &str, func: impl Fn(String, &mut ProgramBlock) -> Values + 'static, )

push a new function on the context

Auto Trait Implementations§

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.