pub fn stringify(&self, heap: &mut Heap) -> Result<String, Exception> {
        match self {
            JSValue::Undefined => Ok("undefined".to_string()),
            JSValue::Bool(b) => Ok(b.to_string()),
            JSValue::Number(n) => Ok(n.to_string()),
            JSValue::String(s) => Ok(s.clone()),
            JSValue::Ref(r) if r == &Heap::NULL => Ok("null".to_string()),
            JSValue::Ref(r) => match heap.lookup_protochain(*r, "toString") {
                Some(to_string) => {
                    let funcref = to_string.to_ref(heap)?;
                    let call = CallContext {
                        this_ref: *r,
                        method_name: "toString".to_string(),
                        arguments: vec![],
                        loc: None,
                    };
                    let result = call.execute(funcref, heap)?;
                    Ok(result.to_value(heap)?.stringify(heap)?)
                }
                None => Ok("[object Object]".to_string()),
            },
        }
    }
/// stringify() makes everything into a string
/// used for evaluation in a string context.
/// It corresponds to .toString() in JavaScript
stringify() makes everything into a string
used for evaluation in a string context.
It corresponds to .toString() in JavaScript
stringify () makes everything into a string used for evaluation in a string context . It corresponds to . toString () in JavaScript
pub fn stringify(&self, heap: &mut Heap) -> Result<String, Exception> {
        match self {
            JSValue::Undefined => Ok("undefined".to_string()),
            JSValue::Bool(b) => Ok(b.to_string()),
            JSValue::Number(n) => Ok(n.to_string()),
            JSValue::String(s) => Ok(s.clone()),
            JSValue::Ref(r) if r == &Heap::NULL => Ok("null".to_string()),
            JSValue::Ref(r) => match heap.lookup_protochain(*r, "toString") {
                Some(to_string) => {
                    let funcref = to_string.to_ref(heap)?;
                    let call = CallContext {
                        this_ref: *r,
                        method_name: "toString".to_string(),
                        arguments: vec![],
                        loc: None,
                    };
                    let result = call.execute(funcref, heap)?;
                    Ok(result.to_value(heap)?.stringify(heap)?)
                }
                None => Ok("[object Object]".to_string()),
            },
        }
    }
pub fn stringify ( & self , heap : & mut Heap ) -> Result < String , Exception > { match self { JSValue :: Undefined => Ok ( " " . to_string ( ) ) , JSValue :: Bool ( b ) => Ok ( b . to_string ( ) ) , JSValue :: Number ( n ) => Ok ( n . to_string ( ) ) , JSValue :: String ( s ) => Ok ( s . clone ( ) ) , JSValue :: Ref ( r ) if r == & Heap :: NULL => Ok ( " " . to_string ( ) ) , JSValue :: Ref ( r ) => match heap . lookup_protochain ( * r , " " ) { Some ( to_string ) => { let funcref = to_string . to_ref ( heap ) ? ; let call = CallContext { this_ref : * r , method_name : " " . to_string ( ) , arguments : vec ! [ ] , loc : None , } ; let result = call . execute ( funcref , heap ) ? ; Ok ( result . to_value ( heap ) ? . stringify ( heap ) ? ) } None => Ok ( " " . to_string ( ) ) , } , } }
stringify() makes everything into a string
used for evaluation in a string context.
stringify () makes everything into a string used for evaluation in a string context .
&self
heap
&mut Heap
&self
heap
&mut Heap