Bug 380831: incorrect uneval trying to output a getter function that is a sharp definition, r=igor

This commit is contained in:
crowder%fiverocks.com 2007-06-05 20:20:07 +00:00
Родитель a97f5a8d53
Коммит a2d09466f8
1 изменённых файлов: 28 добавлений и 28 удалений

Просмотреть файл

@ -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); \