pub struct VM<'rant> { /* private fields */ }
Expand description
The Rant Virtual Machine.
Implementations
sourceimpl<'rant> VM<'rant>
impl<'rant> VM<'rant>
pub fn push_getter_intents(
&mut self,
path: &Rc<AccessPath>,
override_print: bool,
prefer_function: bool,
fallback: Option<Rc<Sequence>>
)
sourcepub fn call_func(
&mut self,
func: RantFunctionHandle,
args: Vec<RantValue>,
override_print: bool
) -> RuntimeResult<()>
pub fn call_func(
&mut self,
func: RantFunctionHandle,
args: Vec<RantValue>,
override_print: bool
) -> RuntimeResult<()>
Prepares a call to a function with the specified arguments.
sourcepub fn tick_current_block(&mut self) -> RuntimeResult<()>
pub fn tick_current_block(&mut self) -> RuntimeResult<()>
Checks for an active block and attempts to iterate it. If a valid element is returned, it is pushed onto the call stack.
sourcepub fn pre_push_block(&mut self, block: &Rc<Block>) -> RuntimeResult<()>
pub fn pre_push_block(&mut self, block: &Rc<Block>) -> RuntimeResult<()>
Performs any necessary preparation (such as pushing weight intents) before pushing a block. If the block can be pushed immediately, it will be.
sourcepub fn push_block(
&mut self,
block: &Block,
weights: Option<Weights>
) -> RuntimeResult<()>
pub fn push_block(
&mut self,
block: &Block,
weights: Option<Weights>
) -> RuntimeResult<()>
Consumes attributes and pushes a block onto the resolver stack.
sourcepub fn get_var_value(
&self,
varname: &str,
access: VarAccessMode,
prefer_function: bool
) -> RuntimeResult<RantValue>
pub fn get_var_value(
&self,
varname: &str,
access: VarAccessMode,
prefer_function: bool
) -> RuntimeResult<RantValue>
Gets the value of an existing variable.
sourcepub fn def_var_value(
&mut self,
varname: &str,
access: VarAccessMode,
val: RantValue,
is_const: bool
) -> RuntimeResult<()>
pub fn def_var_value(
&mut self,
varname: &str,
access: VarAccessMode,
val: RantValue,
is_const: bool
) -> RuntimeResult<()>
Defines a new variable in the current scope.
sourcepub fn push_val(&mut self, val: RantValue) -> RuntimeResult<usize>
pub fn push_val(&mut self, val: RantValue) -> RuntimeResult<usize>
Pushes a value onto the value stack.
sourcepub fn pop_val(&mut self) -> RuntimeResult<RantValue>
pub fn pop_val(&mut self) -> RuntimeResult<RantValue>
Removes and returns the topmost value from the value stack.
sourcepub fn pop_frame(&mut self) -> RuntimeResult<StackFrame<Intent>>
pub fn pop_frame(&mut self) -> RuntimeResult<StackFrame<Intent>>
Removes and returns the topmost frame from the call stack.
sourcepub fn push_frame(
&mut self,
callee: Rc<Sequence>,
has_scope: bool
) -> RuntimeResult<()>
pub fn push_frame(
&mut self,
callee: Rc<Sequence>,
has_scope: bool
) -> RuntimeResult<()>
Pushes a frame onto the call stack.
sourcepub fn push_native_call_frame(
&mut self,
callee: Box<dyn FnOnce(&mut VM<'_>) -> RuntimeResult<()>>,
flavor: StackFrameFlavor
) -> RuntimeResult<()>
pub fn push_native_call_frame(
&mut self,
callee: Box<dyn FnOnce(&mut VM<'_>) -> RuntimeResult<()>>,
flavor: StackFrameFlavor
) -> RuntimeResult<()>
Pushes an empty frame onto the call stack with a single RuntimeCall
intent.
sourcepub fn push_frame_flavored(
&mut self,
callee: Rc<Sequence>,
flavor: StackFrameFlavor
) -> RuntimeResult<()>
pub fn push_frame_flavored(
&mut self,
callee: Rc<Sequence>,
flavor: StackFrameFlavor
) -> RuntimeResult<()>
Pushes a flavored frame onto the call stack.
sourcepub fn interrupt_repeater(
&mut self,
break_val: Option<RantValue>,
should_continue: bool
) -> RuntimeResult<()>
pub fn interrupt_repeater(
&mut self,
break_val: Option<RantValue>,
should_continue: bool
) -> RuntimeResult<()>
Interrupts execution of a repeater and either continues the next iteration or exits the block.
sourcepub fn func_return(&mut self, ret_val: Option<RantValue>) -> RuntimeResult<()>
pub fn func_return(&mut self, ret_val: Option<RantValue>) -> RuntimeResult<()>
Returns from the currently running function.
sourcepub fn cur_frame_mut(&mut self) -> &mut StackFrame<Intent>
pub fn cur_frame_mut(&mut self) -> &mut StackFrame<Intent>
Gets a mutable reference to the topmost frame on the call stack.
sourcepub fn any_cur_frame_mut(&mut self) -> Option<&mut StackFrame<Intent>>
pub fn any_cur_frame_mut(&mut self) -> Option<&mut StackFrame<Intent>>
Safely attempts to get a mutable reference to the topmost frame on the call stack.
sourcepub fn parent_frame_mut(
&mut self,
depth: usize
) -> Option<&mut StackFrame<Intent>>
pub fn parent_frame_mut(
&mut self,
depth: usize
) -> Option<&mut StackFrame<Intent>>
Safely attempts to get a mutable reference to the frame depth
frames below the top of the call stack.
sourcepub fn parent_frame(&self, depth: usize) -> Option<&StackFrame<Intent>>
pub fn parent_frame(&self, depth: usize) -> Option<&StackFrame<Intent>>
Safely attempts to get a reference to the frame depth
frames below the top of the call stack.
sourcepub fn cur_frame(&self) -> &StackFrame<Intent>
pub fn cur_frame(&self) -> &StackFrame<Intent>
Gets a reference to the topmost frame on the call stack.
sourcepub fn pop_rng(&mut self) -> Option<Rc<RantRng>>
pub fn pop_rng(&mut self) -> Option<Rc<RantRng>>
Removes the topmost RNG from the RNG stack and returns it.
sourcepub fn context_mut(&mut self) -> &mut Rant
pub fn context_mut(&mut self) -> &mut Rant
Gets a mutable reference to the Rant context that created the VM.
sourcepub fn resolver_mut(&mut self) -> &mut Resolver
pub fn resolver_mut(&mut self) -> &mut Resolver
Gets a mutable reference to the resolver associated with the VM.
sourcepub fn program(&self) -> &RantProgram
pub fn program(&self) -> &RantProgram
Gets a reference to the program being executed by the VM.
pub fn push_unwind_state(&mut self, handler: Option<RantFunctionHandle>)
pub fn unwind(&mut self) -> Option<UnwindState>
Auto Trait Implementations
impl<'rant> !RefUnwindSafe for VM<'rant>
impl<'rant> !Send for VM<'rant>
impl<'rant> !Sync for VM<'rant>
impl<'rant> Unpin for VM<'rant>
impl<'rant> !UnwindSafe for VM<'rant>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more