(Not part of Communicator build.)

Fix 111199 ECMA: don't enumerate parseInt.length
This commit is contained in:
norris 1998-06-12 17:22:04 +00:00
Родитель d415e492d8
Коммит 25c1c4801f
2 изменённых файлов: 48 добавлений и 10 удалений

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

@ -809,6 +809,39 @@ fun_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
return JS_TRUE;
}
static JSBool
fun_enumProperty(JSContext *cx, JSObject *obj)
{
JSScope *scope;
JSScopeProperty *sprop;
/* Because properties of function objects such as "length" are
* not defined in function_props to avoid interfering with
* unqualified lookups in local scopes (which pass through the
* function object as a stand-in for the call object), we
* must twiddle any of the special properties not to be enumer-
* ated in this callback, rather than simply predefining the
* properties without JSPROP_ENUMERATE.
*/
JS_LOCK_OBJ(cx, obj);
scope = (JSScope *) obj->map;
for (sprop = scope->props; sprop; sprop = sprop->next) {
jsval id = sprop->id;
if (!JSVAL_IS_INT(id)) {
if (id == ATOM_KEY(cx->runtime->atomState.arityAtom) ||
id == ATOM_KEY(cx->runtime->atomState.lengthAtom) ||
id == ATOM_KEY(cx->runtime->atomState.callerAtom) ||
id == ATOM_KEY(cx->runtime->atomState.nameAtom))
{
sprop->attrs &= ~JSPROP_ENUMERATE;
}
}
}
return JS_TRUE;
}
static JSBool
fun_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
@ -1121,7 +1154,7 @@ JSClass js_FunctionClass = {
JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE,
JS_PropertyStub, fun_delProperty,
fun_getProperty, fun_setProperty,
JS_EnumerateStub, (JSResolveOp)fun_resolve,
fun_enumProperty, (JSResolveOp)fun_resolve,
fun_convert, fun_finalize,
NULL, NULL,
NULL, NULL,

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

@ -2453,18 +2453,18 @@ out:
#ifdef DEBUG
void printId(jsid id) {
/* Routines to print out values during debugging. */
void printVal(jsval val) {
jsuint i;
JSAtom *atom;
JSString *str;
fprintf(stderr, "id %d (0x%x) = ", id, id);
if (JSVAL_IS_INT(id)) {
fprintf(stderr, "%d\n", JSVAL_TO_INT(id));
} else {
atom = (JSAtom *)id;
str = ATOM_TO_STRING(atom);
fputc('"', stderr);
fprintf(stderr, "val %d (0x%x) = ", val, val);
if (JSVAL_IS_INT(val)) {
fprintf(stderr, "(int) %d\n", JSVAL_TO_INT(val));
} else if (JSVAL_IS_STRING(val)) {
fprintf(stderr, "(string) \"");
str = JSVAL_TO_STRING(val);
for (i=0; i < str->length; i++)
fputc(str->chars[i], stderr);
fputc('"', stderr);
@ -2473,5 +2473,10 @@ void printId(jsid id) {
fflush(stderr);
}
void printId(jsid id) {
fprintf(stderr, "id %d (0x%x) is ", id, id);
printVal(js_IdToValue(id));
}
#endif