pub struct Frame {
pub function_idx: usize,
pub ip: usize,
pub bp: usize,
pub locals: HashMap<String, Value>,
pub return_ip: Option<usize>,
pub return_function: Option<usize>,
}Expand description
Represents a call frame in the VM’s call stack.
Each function call creates a new frame that contains:
- The function being executed
- The instruction pointer within that function
- Local variables
- The stack base pointer for this frame
Fields§
§function_idx: usizeIndex of the function being executed
ip: usizeCurrent instruction pointer within the function
bp: usizeBase pointer in the stack for this frame
locals: HashMap<String, Value>Local variables for this frame
return_ip: Option<usize>Return address (instruction pointer to return to)
return_function: Option<usize>Function index to return to
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(function_idx: usize, bp: usize) -> Self
pub fn new(function_idx: usize, bp: usize) -> Self
Creates a new call frame for a function call
Sourcepub fn with_return(
function_idx: usize,
bp: usize,
return_ip: usize,
return_function: usize,
) -> Self
pub fn with_return( function_idx: usize, bp: usize, return_ip: usize, return_function: usize, ) -> Self
Creates a new call frame with return information
Sourcepub fn is_tail_position(&self, next_instruction: Option<&Instruction>) -> bool
pub fn is_tail_position(&self, next_instruction: Option<&Instruction>) -> bool
Checks if this is a tail call position (i.e., the next instruction would be a return)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
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