pub struct Machine<'a, Constant, Value: Debug> {
pub code: &'a Code<Constant>,
pub globals: HashMap<String, Value>,
/* private fields */
}
Expand description
The entire state of the VM
State contains the code
that the VM is executing and a hashmap of all global variables.
Fields§
§code: &'a Code<Constant>
§globals: HashMap<String, Value>
Implementations§
Source§impl<'a, Constant, Value: Debug> Machine<'a, Constant, Value>
impl<'a, Constant, Value: Debug> Machine<'a, Constant, Value>
pub fn new( code: &'a Code<Constant>, instruction_table: InstructionTable<'a, Constant, Value>, ) -> Machine<'a, Constant, Value>
pub fn start(&mut self) -> bool
pub fn push_operand(&mut self, operand: Value)
pub fn peek_operand(&mut self) -> Result<&Value, EmptyOperandStack>
pub fn pop_operand(&mut self) -> Result<Value, EmptyOperandStack>
pub fn pop_two_operands(&mut self) -> Result<(Value, Value), Exception>
pub fn get_operand(&self, slot: usize) -> Result<&Value, SlotOutOfBounds>
pub fn get_operand_from_top( &self, slot_from_top: usize, ) -> Result<&Value, SlotOutOfBounds>
pub fn set_operand( &mut self, slot: usize, value: Value, ) -> Result<(), SlotOutOfBounds>
pub fn operand_stack_len(&self) -> usize
pub fn peek_frame(&self) -> Result<&CallFrame, EmptyCallStack>
pub fn push_frame(&mut self, chunk_id: usize, name: String, start_slot: usize)
pub fn discard_frame(&mut self) -> Result<CallFrame, EmptyCallStack>
pub fn instruction_pointer( &mut self, ) -> Result<&mut InstructionPointer, EmptyCallStack>
Trait Implementations§
Source§impl<'a, Constant, Value: Debug> ByteReadable<InstructionPointer> for Machine<'a, Constant, Value>
impl<'a, Constant, Value: Debug> ByteReadable<InstructionPointer> for Machine<'a, Constant, Value>
fn read(&self, ptr: &mut InstructionPointer) -> Option<u8>
fn has_next(&self, ptr: &InstructionPointer) -> bool
fn read_n(&self, ptr: &mut Ptr, n: usize) -> Option<Vec<u8>>
fn read_u16(&self, ptr: &mut Ptr) -> Option<u16>
fn read_u32(&self, ptr: &mut Ptr) -> Option<u32>
fn read_i32(&self, ptr: &mut Ptr) -> Option<i32>
Auto Trait Implementations§
impl<'a, Constant, Value> Freeze for Machine<'a, Constant, Value>
impl<'a, Constant, Value> RefUnwindSafe for Machine<'a, Constant, Value>where
Value: RefUnwindSafe,
Constant: RefUnwindSafe,
impl<'a, Constant, Value> Send for Machine<'a, Constant, Value>
impl<'a, Constant, Value> Sync for Machine<'a, Constant, Value>
impl<'a, Constant, Value> Unpin for Machine<'a, Constant, Value>where
Value: Unpin,
impl<'a, Constant, Value> UnwindSafe for Machine<'a, Constant, Value>where
Value: UnwindSafe,
Constant: RefUnwindSafe,
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