JS_ReportError(cx, "can't convert %s to %s",
JS_ReportErrorNumber(cx, NULL, JSMSG_CANT_CONVERT_TO,
js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp){    jsval v;    JSString *str;    v = OBJECT_TO_JSVAL(obj);    switch (hint) {      case JSTYPE_STRING:	js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL, &v);	if (!JSVAL_IS_PRIMITIVE(v)) {	    if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj, hint, &v))		return JS_FALSE;            /*             * JS1.2 never failed (except for malloc failure) to convert an             * object to a string.  ECMA requires an error if both toString             * and valueOf fail to produce a primitive value.             */            if (!JSVAL_IS_PRIMITIVE(v) && cx->version == JSVERSION_1_2) {                char *bytes = PR_smprintf("[object %s]",                                          OBJ_GET_CLASS(cx, obj)->name);                if (!bytes)                    return JS_FALSE;                str = JS_NewString(cx, bytes, strlen(bytes));                if (!str) {                    free(bytes);                    return JS_FALSE;                }                v = STRING_TO_JSVAL(str);                goto out;            }      	}      	break;      default:	if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj, hint, &v))	    return JS_FALSE;	if (!JSVAL_IS_PRIMITIVE(v)) {	    if (JS_TypeOfValue(cx, v) == hint)	    	goto out;	    /* Don't convert to string (source object literal) for JS1.2. */	    if (cx->version == JSVERSION_1_2 && hint == JSTYPE_BOOLEAN)	    	goto out;	    js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL,			 &v);	}      	break;    }    if (!JSVAL_IS_PRIMITIVE(v)) {	/* Avoid recursive death through js_DecompileValueGenerator. */	if (hint == JSTYPE_STRING) {	    str = JS_InternString(cx, OBJ_GET_CLASS(cx, obj)->name);	    if (!str)	    	return JS_FALSE;	} else {	    str = NULL;	}	*vp = OBJECT_TO_JSVAL(obj);	str = js_DecompileValueGenerator(cx, v, str);	if (str) {	    JS_ReportError(cx, "can't convert %s to %s",			   JS_GetStringBytes(str),			   (hint == JSTYPE_VOID)			   ? "primitive type"			   : js_type_str[hint]);	}	return JS_FALSE;    }out:    *vp = v;    return JS_TRUE;}