pub trait VariableManager {
// Required methods
fn get_local(&self, idx: usize) -> Option<&Value>;
fn set_local(&mut self, idx: usize, value: Value);
fn get_global(&self, idx: usize) -> Option<&Value>;
fn set_global(&mut self, idx: usize, value: Value);
fn get_local_mut(&mut self, idx: usize) -> Option<&mut Value>;
fn get_global_mut(&mut self, idx: usize) -> Option<&mut Value>;
// Provided methods
fn get_argument(&self, idx: usize) -> Option<&Value> { ... }
fn set_argument(&mut self, idx: usize, value: Value) { ... }
}Expand description
Defines operations for managing VM variables
This trait provides the interface for all variable operations including local variables, global variables, and function arguments.
Required Methods§
Sourcefn set_local(&mut self, idx: usize, value: Value)
fn set_local(&mut self, idx: usize, value: Value)
Sets a local variable by index
§Arguments
idx- The index of the local variablevalue- The value to assign to the variable
Sourcefn get_global(&self, idx: usize) -> Option<&Value>
fn get_global(&self, idx: usize) -> Option<&Value>
Sourcefn set_global(&mut self, idx: usize, value: Value)
fn set_global(&mut self, idx: usize, value: Value)
Sets a global variable by index
§Arguments
idx- The index of the global variablevalue- The value to assign to the variable
Sourcefn get_local_mut(&mut self, idx: usize) -> Option<&mut Value>
fn get_local_mut(&mut self, idx: usize) -> Option<&mut Value>
Provided Methods§
Sourcefn get_argument(&self, idx: usize) -> Option<&Value>
fn get_argument(&self, idx: usize) -> Option<&Value>
Sourcefn set_argument(&mut self, idx: usize, value: Value)
fn set_argument(&mut self, idx: usize, value: Value)
Sets a function argument by index
This is a convenience method that delegates to set_local().
§Arguments
idx- The index of the argumentvalue- The value to assign to the argument