pub fn resolve_call(&self, heap: &Heap) -> Result<(JSRef, JSRef, &str), Exception> {
        match self {
            Interpreted::Member { of: this_ref, name } => {
                let of = match heap.lookup_protochain(*this_ref, name) {
                    Some(Interpreted::Member { of, .. }) => of,
                    Some(_) => unreachable!(),
                    None => return Err(Exception::TypeErrorNotCallable(self.clone())),
                };
                let func_value = (heap.get(of).get_value(&name)).ok_or(
                    Exception::TypeErrorNotCallable(Interpreted::member(of, &name)),
                )?;
                let func_ref = (func_value.to_ref())
                    .map_err(|_| Exception::TypeErrorNotCallable(Interpreted::member(of, &name)))?;
                Ok((func_ref, *this_ref, name))
            }
            Interpreted::Value(JSValue::Ref(func_ref)) => {
                let this_ref = Heap::GLOBAL; // TODO: figure out what is this
                Ok((*func_ref, this_ref, "<anonymous>"))
            }
            _ => return Err(Exception::TypeErrorNotCallable(self.clone())),
        }
    }
/// Resolve self to: a callable JSRef, `this` JSRef and the method name.
Resolve self to: a callable JSRef, `this` JSRef and the method name.
Resolve self to : a callable JSRef ` this ` JSRef and the method name .
pub fn resolve_call(&self, heap: &Heap) -> Result<(JSRef, JSRef, &str), Exception> {
        match self {
            Interpreted::Member { of: this_ref, name } => {
                let of = match heap.lookup_protochain(*this_ref, name) {
                    Some(Interpreted::Member { of, .. }) => of,
                    Some(_) => unreachable!(),
                    None => return Err(Exception::TypeErrorNotCallable(self.clone())),
                };
                let func_value = (heap.get(of).get_value(&name)).ok_or(
                    Exception::TypeErrorNotCallable(Interpreted::member(of, &name)),
                )?;
                let func_ref = (func_value.to_ref())
                    .map_err(|_| Exception::TypeErrorNotCallable(Interpreted::member(of, &name)))?;
                Ok((func_ref, *this_ref, name))
            }
            Interpreted::Value(JSValue::Ref(func_ref)) => {
                let this_ref = Heap::GLOBAL; // TODO: figure out what is this
                Ok((*func_ref, this_ref, "<anonymous>"))
            }
            _ => return Err(Exception::TypeErrorNotCallable(self.clone())),
        }
    }
pub fn resolve_call ( & self , heap : & Heap ) -> Result < ( JSRef , JSRef , & str ) , Exception > { match self { Interpreted :: Member { of : this_ref , name } => { let of = match heap . lookup_protochain ( * this_ref , name ) { Some ( Interpreted :: Member { of , .. } ) => of , Some ( _ ) => unreachable ! ( ) , None => return Err ( Exception :: TypeErrorNotCallable ( self . clone ( ) ) ) , } ; let func_value = ( heap . get ( of ) . get_value ( & name ) ) . ok_or ( Exception :: TypeErrorNotCallable ( Interpreted :: member ( of , & name ) ) , ) ? ; let func_ref = ( func_value . to_ref ( ) ) . map_err ( | _ | Exception :: TypeErrorNotCallable ( Interpreted :: member ( of , & name ) ) ) ? ; Ok ( ( func_ref , * this_ref , name ) ) } Interpreted :: Value ( JSValue :: Ref ( func_ref ) ) => { let this_ref = Heap :: GLOBAL ; // TODO: figure out what is this Ok ( ( * func_ref , this_ref , " " ) ) } _ => return Err ( Exception :: TypeErrorNotCallable ( self . clone ( ) ) ) , } }
Resolve self to: a callable JSRef, `this` JSRef and the method name.
Resolve self to : a callable JSRef ` this ` JSRef and the method name .
&self
heap
&Heap
&self
heap
&Heap