[][src]Struct heartfelt::runtime::Runtime

pub struct Runtime { /* fields omitted */ }

A runtime executing heartfelt programs

This runtime unsafely implements Sync and Send. While thread safety is not given for the runtime from the rust perspective it is still sound from the heartfelt domain. The only way to break thread safety is to use the immutably borrowing def and set var functions from multiple threads or to use the run_unsafe function. The second one is allowed to break thread safety because it is marked as unsafe. The first reason should probably be marked as unsafe too as it violates rusts thread safety rules, but as the runtime is the bridge between Rust and Heartfelt it is ok to not mark it as unsafe as it is still sound from the heartfelt perspective

Implementations

impl Runtime[src]

API Functions

pub fn new() -> Self[src]

pub fn run(&mut self) -> Data[src]

pub unsafe fn run_unsafe(&self) -> Data[src]

pub fn set_program(&mut self, program: Program)[src]

pub fn add_instructions(&mut self, instructions: Program)[src]

pub fn add_instruction(&mut self, instructions: InstructionCall)[src]

pub fn prepend_instructions(&mut self, instructions: Program)[src]

pub fn prepend_instruction(&mut self, instruction: InstructionCall)[src]

pub fn clear_program(&mut self)[src]

pub fn clear(&mut self)[src]

pub fn reset_program(&mut self)[src]

pub fn reset(&mut self)[src]

pub fn take_program(&mut self) -> Program[src]

pub fn swap_program(&mut self, new_program: &mut Program)[src]

pub fn def_var(&self, key: String, value: Data) -> Option<Data>[src]

Returns the previous value associated with key

pub fn set_var(&self, key: &str, value: Data) -> bool[src]

Returns true if value existed false otherwise

pub fn get_var_ref(&self, key: &str) -> Option<&Data>[src]

pub unsafe fn get_var_mut_unsafe(&self, key: &str) -> Option<&mut Data>[src]

pub fn get_var_mut(&mut self, key: &str) -> Option<&mut Data>[src]

pub fn get_var(&self, key: &str) -> Option<Data>[src]

pub fn is_var_defined(&self, key: &str) -> bool[src]

pub fn goto(&self, instruction_idx: usize)[src]

pub fn goto_label(&self, label: &str) -> bool[src]

pub fn add_label(&mut self, label: String, instruction_idx: usize)[src]

pub fn set_labels(&mut self, labels: Labels)[src]

pub fn program_len(&self) -> usize[src]

pub fn program_line_count(&self) -> usize[src]

pub fn dump(&self) -> Result<String, Error>[src]

pub fn dump_to(&self, w: &mut impl Write) -> Result<(), IoError>[src]

pub fn fmt_to(&self, w: &mut impl Write) -> FmtResult[src]

Trait Implementations

impl Default for Runtime[src]

impl Send for Runtime[src]

impl Sync for Runtime[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.