pub struct Context { /* private fields */ }
Expand description
Onion 虚拟机执行上下文。
管理多帧调用栈,支持作用域、变量、栈和帧的各种操作。
Implementations§
Source§impl Context
impl Context
pub fn new() -> Self
pub fn push_frame(&mut self, frame: Frame)
pub fn pop_frame(&mut self) -> Result<Frame, RuntimeError>
pub fn concat_last_frame(&mut self) -> Result<(), RuntimeError>
pub fn clear_stack(&mut self)
pub fn push_object( &mut self, object: OnionStaticObject, ) -> Result<(), RuntimeError>
pub fn pop(&mut self) -> Result<OnionStaticObject, RuntimeError>
pub fn discard_objects(&mut self, count: usize) -> Result<(), RuntimeError>
pub fn discard_objects_offset( &mut self, offset: usize, count: usize, ) -> Result<(), RuntimeError>
pub fn get_object_rev( &self, idx: usize, ) -> Result<&OnionStaticObject, RuntimeError>
pub fn get_object_rev_mut( &mut self, idx: usize, ) -> Result<&mut OnionStaticObject, RuntimeError>
pub fn let_variable( &mut self, name: usize, value: OnionStaticObject, ) -> Result<(), RuntimeError>
pub fn get_variable(&self, name: usize) -> Option<&OnionStaticObject>
pub fn get_variable_mut( &mut self, name: usize, ) -> Option<&mut OnionStaticObject>
pub fn swap(&mut self, idx1: usize, idx2: usize) -> Result<(), RuntimeError>
pub fn get_current_stack_mut( &mut self, ) -> Result<&mut Vec<OnionStaticObject>, RuntimeError>
pub fn push_to_stack( stack: &mut Vec<OnionStaticObject>, object: OnionStaticObject, )
pub fn pop_from_stack( stack: &mut Vec<OnionStaticObject>, ) -> Result<OnionStaticObject, RuntimeError>
pub fn discard_from_stack( stack: &mut Vec<OnionStaticObject>, count: usize, ) -> Result<(), RuntimeError>
pub fn get_object_from_stack( stack: &Vec<OnionStaticObject>, idx: usize, ) -> Result<&OnionStaticObject, RuntimeError>
pub fn get_objects_slice( stack: &Vec<OnionStaticObject>, idx: usize, len: usize, ) -> Result<&[OnionStaticObject], RuntimeError>
pub fn replace_last_object( stack: &mut Vec<OnionStaticObject>, object: OnionStaticObject, )
pub fn format_context(&self, package: &VMInstructionPackage) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
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