/// Place a reference to the local at index `i` if it exists into the register
/// If it does not exist return a `VMError`.
Place a reference to the local at index `i` if it exists into the register
If it does not exist return a `VMError`.
Place a reference to the local at index ` i ` if it exists into the register If it does not exist return a ` VMError ` .
pub fn local_take_borrow(&mut self, i: usize, mutable: bool) -> Result<(), VMError> {
        if let Some((abstract_value, _)) = self.locals.get(&i) {
            let ref_token = if mutable {
                SignatureToken::MutableReference(Box::new(abstract_value.token.clone()))
            } else {
                SignatureToken::Reference(Box::new(abstract_value.token.clone()))
            };
            self.register = Some(AbstractValue::new_reference(ref_token, abstract_value.kind));
            Ok(())
        } else {
            Err(VMError::new(format!("Local does not exist at index {}", i)))
        }
    }
pub fn local_take_borrow ( & mut self , i : usize , mutable : bool ) -> Result < ( ) , VMError > { if let Some ( ( abstract_value , _ ) ) = self . locals . get ( & i ) { let ref_token = if mutable { SignatureToken :: MutableReference ( Box :: new ( abstract_value . token . clone ( ) ) ) } else { SignatureToken :: Reference ( Box :: new ( abstract_value . token . clone ( ) ) ) } ; self . register = Some ( AbstractValue :: new_reference ( ref_token , abstract_value . kind ) ) ; Ok ( ( ) ) } else { Err ( VMError :: new ( format ! ( " " i ) ) ) } }
Place a reference to the local at index `i` if it exists into the register
If it does not exist return a `VMError`.
Place a reference to the local at index ` i ` if it exists into the register If it does not exist return a ` VMError ` .
&mut self
i
usize
mutable
bool