pub fn local_take_borrow(&mut self, i: usize, mutability: Mutability) -> Result<(), VMError> {
        if let Some((abstract_value, _)) = self.locals.get(&i) {
            let ref_token = match mutability {
                Mutability::Mutable => {
                    SignatureToken::MutableReference(Box::new(abstract_value.token.clone()))
                }
                Mutability::Immutable => {
                    SignatureToken::Reference(Box::new(abstract_value.token.clone()))
                }
                Mutability::Either => {
                    return Err(VMError::new("Mutability cannot be Either".to_string()))
                }
            };
            self.register = Some(AbstractValue::new_reference(ref_token, abstract_value.kind));
            Ok(())
        } else {
            Err(VMError::new(format!("Local does not exist at index {}", 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`.
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, mutability: Mutability) -> Result<(), VMError> {
        if let Some((abstract_value, _)) = self.locals.get(&i) {
            let ref_token = match mutability {
                Mutability::Mutable => {
                    SignatureToken::MutableReference(Box::new(abstract_value.token.clone()))
                }
                Mutability::Immutable => {
                    SignatureToken::Reference(Box::new(abstract_value.token.clone()))
                }
                Mutability::Either => {
                    return Err(VMError::new("Mutability cannot be Either".to_string()))
                }
            };
            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 , mutability : Mutability ) -> Result < ( ) , VMError > { if let Some ( ( abstract_value , _ ) ) = self . locals . get ( & i ) { let ref_token = match mutability { Mutability :: Mutable => { SignatureToken :: MutableReference ( Box :: new ( abstract_value . token . clone ( ) ) ) } Mutability :: Immutable => { SignatureToken :: Reference ( Box :: new ( abstract_value . token . clone ( ) ) ) } Mutability :: Either => { return Err ( VMError :: new ( " " . to_string ( ) ) ) } } ; 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
mutability
Mutability