pub fn lookup_path(&self, mut names: &[&str]) -> Result<Interpreted, Exception> {
        let mut scoperef = self.local_scope().unwrap_or(Heap::GLOBAL);
        while let Some((name, rest)) = names.split_first() {
            names = rest;
            let nameval = self.get(scoperef).get_value(name).ok_or_else(|| {
                let what = Interpreted::from(scoperef);
                Exception::TypeErrorGetProperty(what, name.to_string())
            })?;
            scoperef = nameval.to_ref()?;
        }
        Ok(Interpreted::from(scoperef))
    }
/// Lookup a property chain starting from the current scope, e.g.
/// ```
/// # use slothjs::{Heap, Interpreted};
/// # let mut heap = Heap::new();
/// assert_eq!(
///     heap.lookup_path(&["Array", "prototype"]).unwrap(),
///     Interpreted::from(Heap::ARRAY_PROTO)
/// );
/// ```
Lookup a property chain starting from the current scope, e.g.
Lookup a property chain starting from the current scope e . g .
pub fn lookup_path(&self, mut names: &[&str]) -> Result<Interpreted, Exception> {
        let mut scoperef = self.local_scope().unwrap_or(Heap::GLOBAL);
        while let Some((name, rest)) = names.split_first() {
            names = rest;
            let nameval = self.get(scoperef).get_value(name).ok_or_else(|| {
                let what = Interpreted::from(scoperef);
                Exception::TypeErrorGetProperty(what, name.to_string())
            })?;
            scoperef = nameval.to_ref()?;
        }
        Ok(Interpreted::from(scoperef))
    }
pub fn lookup_path ( & self , mut names : & [ & str ] ) -> Result < Interpreted , Exception > { let mut scoperef = self . local_scope ( ) . unwrap_or ( Heap :: GLOBAL ) ; while let Some ( ( name , rest ) ) = names . split_first ( ) { names = rest ; let nameval = self . get ( scoperef ) . get_value ( name ) . ok_or_else ( | | { let what = Interpreted :: from ( scoperef ) ; Exception :: TypeErrorGetProperty ( what , name . to_string ( ) ) } ) ? ; scoperef = nameval . to_ref ( ) ? ; } Ok ( Interpreted :: from ( scoperef ) ) }
Lookup a property chain starting from the current scope, e.g.
Lookup a property chain starting from the current scope e . g .
&self
names
&[&str]
&self
names
&[&str]
use slothjs::{heap, interpreted};
None
let mut heap = heap::new();
assert_eq!(
heap.lookup_path(&["Array", "prototype"]).unwrap(),
Interpreted::from(Heap::ARRAY_PROTO)
);
```
assert_eq! ( heap . lookup_path ( & [ " Array " " prototype " ] ) . unwrap () Interpreted :: from ( Heap :: ARRAY_PROTO ) ) ; ` ` `