Struct ArgumentStorage
pub struct ArgumentStorage { /* private fields */ }Expand description
Storage for method arguments.
Arguments are passed to a method by the caller and can be read or modified
during method execution. For instance methods, argument 0 is typically this.
§Example
use dotscope::emulation::{ArgumentStorage, EmValue};
use dotscope::metadata::typesystem::CilFlavor;
// Create arguments from caller's values
let mut args = ArgumentStorage::new(
vec![EmValue::I32(10), EmValue::I32(20)],
vec![CilFlavor::I4, CilFlavor::I4],
);
// Access arguments
assert_eq!(args.get(0).unwrap(), &EmValue::I32(10));
assert_eq!(args.get(1).unwrap(), &EmValue::I32(20));
// Modify argument (for ref/out parameters)
args.set(0, EmValue::I32(42)).unwrap();Implementations§
§impl ArgumentStorage
impl ArgumentStorage
pub fn with_this(
this_ref: EmValue,
arg_values: Vec<EmValue>,
arg_types: Vec<CilFlavor>,
) -> Self
pub fn with_this( this_ref: EmValue, arg_values: Vec<EmValue>, arg_types: Vec<CilFlavor>, ) -> Self
Creates argument storage for an instance method.
Argument 0 will be the this reference.
§Arguments
this_ref- The ‘this’ object referencearg_values- Additional argument valuesarg_types- CIL type flavors for additional arguments
pub fn empty() -> Self
pub fn empty() -> Self
Creates empty argument storage.
pub fn get(&self, index: usize) -> Result<&EmValue>
pub fn get(&self, index: usize) -> Result<&EmValue>
Gets the value of an argument.
§Arguments
index- The argument index (0-based)
§Errors
Returns EmulationError::ArgumentIndexOutOfBounds if index is out of bounds.
pub fn get_mut(&mut self, index: usize) -> Result<&mut EmValue>
pub fn get_mut(&mut self, index: usize) -> Result<&mut EmValue>
Gets a mutable reference to an argument.
§Arguments
index- The argument index (0-based)
§Errors
Returns EmulationError::ArgumentIndexOutOfBounds if index is out of bounds.
pub fn this(&self) -> Option<&EmValue>
pub fn this(&self) -> Option<&EmValue>
Gets the this reference for instance methods.
§Returns
Some(&EmValue) if this is an instance method, None otherwise.
Trait Implementations§
§impl Clone for ArgumentStorage
impl Clone for ArgumentStorage
§fn clone(&self) -> ArgumentStorage
fn clone(&self) -> ArgumentStorage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for ArgumentStorage
impl Debug for ArgumentStorage
§impl Default for ArgumentStorage
impl Default for ArgumentStorage
Auto Trait Implementations§
impl Freeze for ArgumentStorage
impl RefUnwindSafe for ArgumentStorage
impl Send for ArgumentStorage
impl Sync for ArgumentStorage
impl Unpin for ArgumentStorage
impl UnwindSafe for ArgumentStorage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more