From a2d09466f8f688a7933f8e848aca5a12b917fc52 Mon Sep 17 00:00:00 2001 From: "crowder%fiverocks.com" Date: Tue, 5 Jun 2007 20:20:07 +0000 Subject: [PATCH] Bug 380831: incorrect uneval trying to output a getter function that is a sharp definition, r=igor --- js/src/jsobj.c | 56 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/js/src/jsobj.c b/js/src/jsobj.c index 9d765ef8989..ed610b691d5 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -955,6 +955,34 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, if (needOldStyleGetterSetter) gsop[j] = gsopold[j]; + /* If val[j] is a non-sharp object, consider sharpening it. */ + vsharp = NULL; + vsharplength = 0; +#if JS_HAS_SHARP_VARS + if (!JSVAL_IS_PRIMITIVE(val[j]) && vchars[0] != '#') { + he = js_EnterSharpObject(cx, JSVAL_TO_OBJECT(val[j]), NULL, + &vsharp); + if (!he) { + ok = JS_FALSE; + goto error; + } + if (IS_SHARP(he)) { + vchars = vsharp; + vlength = js_strlen(vchars); + needOldStyleGetterSetter = JS_TRUE; + gsop[j] = gsopold[j]; + } else { + if (vsharp) { + vsharplength = js_strlen(vsharp); + MAKE_SHARP(he); + needOldStyleGetterSetter = JS_TRUE; + gsop[j] = gsopold[j]; + } + js_LeaveSharpObject(cx, NULL); + } + } +#endif + #ifndef OLD_GETTER_SETTER /* * Remove '(function ' from the beginning of valstr and ')' from the @@ -1000,34 +1028,6 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, gsop[j] = gsopold[j]; #endif - /* If val[j] is a non-sharp object, consider sharpening it. */ - vsharp = NULL; - vsharplength = 0; -#if JS_HAS_SHARP_VARS - if (!JSVAL_IS_PRIMITIVE(val[j]) && vchars[0] != '#') { - he = js_EnterSharpObject(cx, JSVAL_TO_OBJECT(val[j]), NULL, - &vsharp); - if (!he) { - ok = JS_FALSE; - goto error; - } - if (IS_SHARP(he)) { - vchars = vsharp; - vlength = js_strlen(vchars); - needOldStyleGetterSetter = JS_TRUE; - gsop[j] = gsopold[j]; - } else { - if (vsharp) { - vsharplength = js_strlen(vsharp); - MAKE_SHARP(he); - needOldStyleGetterSetter = JS_TRUE; - gsop[j] = gsopold[j]; - } - js_LeaveSharpObject(cx, NULL); - } - } -#endif - #define SAFE_ADD(n) \ JS_BEGIN_MACRO \ size_t n_ = (n); \