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 ProgramBlockFields§
§context: ContextImplementations§
Source§impl ProgramBlock
impl ProgramBlock
Sourcepub fn exec(&mut self, token: &str) -> Values
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!!");Sourcepub fn push_internal_token(&mut self, token: Box<dyn Token>)
pub fn push_internal_token(&mut self, token: Box<dyn Token>)
Push a new token in the context
Sourcepub fn push_internal_key(
&mut self,
key: &str,
func: impl Fn(String, &mut ProgramBlock) -> Values + 'static,
)
pub fn push_internal_key( &mut self, key: &str, func: impl Fn(String, &mut ProgramBlock) -> Values + 'static, )
push a new key on the context
Sourcepub fn push_internal_memory(&mut self, key: &str, val: Values)
pub fn push_internal_memory(&mut self, key: &str, val: Values)
push a new value on the context
Sourcepub fn push_internal_function(
&mut self,
name: &str,
func: impl Fn(String, &mut ProgramBlock) -> Values + 'static,
)
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§
impl Freeze for ProgramBlock
impl !RefUnwindSafe for ProgramBlock
impl !Send for ProgramBlock
impl !Sync for ProgramBlock
impl Unpin for ProgramBlock
impl !UnwindSafe for ProgramBlock
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