fn try_object_slot_index_get(
        &mut self,
        target: &Value,
        string_slot: usize,
    ) -> Result<Option<Value>, VmError> {
        let index = self.unit.lookup_string(string_slot)?;

        Ok(match target {
            Value::Object(object) => {
                let object = object.borrow_ref()?;

                match object.get(&***index).cloned() {
                    Some(value) => Some(value),
                    None => {
                        return Err(VmError::from(VmErrorKind::ObjectIndexMissing {
                            slot: string_slot,
                        }));
                    }
                }
            }
            Value::Struct(typed_object) => {
                let typed_object = typed_object.borrow_ref()?;

                match typed_object.get(&***index).cloned() {
                    Some(value) => Some(value),
                    None => {
                        return Err(VmError::from(VmErrorKind::ObjectIndexMissing {
                            slot: string_slot,
                        }));
                    }
                }
            }
            Value::Variant(variant) => {
                let variant = variant.borrow_ref()?;

                match variant.data() {
                    VariantData::Struct(data) => match data.get(&***index).cloned() {
                        Some(value) => Some(value),
                        None => {
                            return Err(VmError::from(VmErrorKind::ObjectIndexMissing {
                                slot: string_slot,
                            }));
                        }
                    },
                    _ => None,
                }
            }
            target => {
                let hash = index.hash();

                if self.call_field_fn(Protocol::GET, target, hash, ())? {
                    Some(self.stack.pop()?)
                } else {
                    None
                }
            }
        })
    }
/// Implementation of getting a string index on an object-like type.
Implementation of getting a string index on an object-like type.
Implementation of getting a string index on an object - like type .
fn try_object_slot_index_get(
        &mut self,
        target: &Value,
        string_slot: usize,
    ) -> Result<Option<Value>, VmError> {
        let index = self.unit.lookup_string(string_slot)?;
        Ok(match target {
            Value::Object(object) => {
                let object = object.borrow_ref()?;
                match object.get(&***index).cloned() {
                    Some(value) => Some(value),
                    None => {
                        return Err(VmError::from(VmErrorKind::ObjectIndexMissing {
                            slot: string_slot,
                        }));
                    }
                }
            }
            Value::Struct(typed_object) => {
                let typed_object = typed_object.borrow_ref()?;
                match typed_object.get(&***index).cloned() {
                    Some(value) => Some(value),
                    None => {
                        return Err(VmError::from(VmErrorKind::ObjectIndexMissing {
                            slot: string_slot,
                        }));
                    }
                }
            }
            Value::Variant(variant) => {
                let variant = variant.borrow_ref()?;
                match variant.data() {
                    VariantData::Struct(data) => match data.get(&***index).cloned() {
                        Some(value) => Some(value),
                        None => {
                            return Err(VmError::from(VmErrorKind::ObjectIndexMissing {
                                slot: string_slot,
                            }));
                        }
                    },
                    _ => None,
                }
            }
            target => {
                let hash = index.hash();
                if self.call_field_fn(Protocol::GET, target, hash, ())? {
                    Some(self.stack.pop()?)
                } else {
                    None
                }
            }
        })
    }
fn try_object_slot_index_get ( & mut self , target : & Value , string_slot : usize , ) -> Result < Option < Value > , VmError > { let index = self . unit . lookup_string ( string_slot ) ? ; Ok ( match target { Value :: Object ( object ) => { let object = object . borrow_ref ( ) ? ; match object . get ( & * * * index ) . cloned ( ) { Some ( value ) => Some ( value ) , None => { return Err ( VmError :: from ( VmErrorKind :: ObjectIndexMissing { slot : string_slot , } ) ) ; } } } Value :: Struct ( typed_object ) => { let typed_object = typed_object . borrow_ref ( ) ? ; match typed_object . get ( & * * * index ) . cloned ( ) { Some ( value ) => Some ( value ) , None => { return Err ( VmError :: from ( VmErrorKind :: ObjectIndexMissing { slot : string_slot , } ) ) ; } } } Value :: Variant ( variant ) => { let variant = variant . borrow_ref ( ) ? ; match variant . data ( ) { VariantData :: Struct ( data ) => match data . get ( & * * * index ) . cloned ( ) { Some ( value ) => Some ( value ) , None => { return Err ( VmError :: from ( VmErrorKind :: ObjectIndexMissing { slot : string_slot , } ) ) ; } } , _ => None , } } target => { let hash = index . hash ( ) ; if self . call_field_fn ( Protocol :: GET , target , hash , ( ) ) ? { Some ( self . stack . pop ( ) ? ) } else { None } } } ) }
Implementation of getting a string index on an object-like type.
Implementation of getting a string index on an object - like type .
&mut self
target
&Value
string_slot
usize
&mut self
target
&Value
string_slot
usize