From b0e3e4ab62570b5ca76b49813aac50ab7dc60449 Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Fri, 17 Aug 2001 10:40:15 +0000 Subject: [PATCH] Don't resolve standard classes if JSRESOLVE_ASSIGNING (NOT PART OF BUILD). --- js/src/js.c | 104 ++++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 47 deletions(-) diff --git a/js/src/js.c b/js/src/js.c index 1b26609ee422..15f4c93eccbc 100644 --- a/js/src/js.c +++ b/js/src/js.c @@ -1887,70 +1887,80 @@ global_enumerate(JSContext *cx, JSObject *obj) } static JSBool -global_resolve(JSContext *cx, JSObject *obj, jsval id) +global_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, + JSObject **objp) { #ifdef LAZY_STANDARD_CLASSES - JSBool resolved; + if ((flags & JSRESOLVE_ASSIGNING) == 0) { + JSBool resolved; - if (!JS_ResolveStandardClass(cx, obj, id, &resolved)) - return JS_FALSE; - if (resolved) - return JS_TRUE; + if (!JS_ResolveStandardClass(cx, obj, id, &resolved)) + return JS_FALSE; + if (resolved) { + *objp = obj; + return JS_TRUE; + } + } #endif #if defined(SHELL_HACK) && defined(DEBUG) && defined(XP_UNIX) - { - /* - * Do this expensive hack only for unoptimized Unix builds, which are not - * used for benchmarking. - */ - char *path, *comp, *full; - const char *name; - JSBool ok, found; - JSFunction *fun; + if ((flags & (JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING)) == 0) { + /* + * Do this expensive hack only for unoptimized Unix builds, which are + * not used for benchmarking. + */ + char *path, *comp, *full; + const char *name; + JSBool ok, found; + JSFunction *fun; - if (!JSVAL_IS_STRING(id)) - return JS_TRUE; - path = getenv("PATH"); - if (!path) - return JS_TRUE; - path = JS_strdup(cx, path); - if (!path) - return JS_FALSE; - name = JS_GetStringBytes(JSVAL_TO_STRING(id)); - ok = JS_TRUE; - for (comp = strtok(path, ":"); comp; comp = strtok(NULL, ":")) { - if (*comp != '\0') { - full = JS_smprintf("%s/%s", comp, name); - if (!full) { - JS_ReportOutOfMemory(cx); - ok = JS_FALSE; + if (!JSVAL_IS_STRING(id)) + return JS_TRUE; + path = getenv("PATH"); + if (!path) + return JS_TRUE; + path = JS_strdup(cx, path); + if (!path) + return JS_FALSE; + name = JS_GetStringBytes(JSVAL_TO_STRING(id)); + ok = JS_TRUE; + for (comp = strtok(path, ":"); comp; comp = strtok(NULL, ":")) { + if (*comp != '\0') { + full = JS_smprintf("%s/%s", comp, name); + if (!full) { + JS_ReportOutOfMemory(cx); + ok = JS_FALSE; + break; + } + } else { + full = (char *)name; + } + found = (access(full, X_OK) == 0); + if (*comp != '\0') + free(full); + if (found) { + fun = JS_DefineFunction(cx, obj, name, Exec, 0, + JSPROP_ENUMERATE); + ok = (fun != NULL); + if (ok) + *objp = obj; break; } - } else { - full = (char *)name; - } - found = (access(full, X_OK) == 0); - if (*comp != '\0') - free(full); - if (found) { - fun = JS_DefineFunction(cx, obj, name, Exec, 0, JSPROP_ENUMERATE); - ok = (fun != NULL); - break; } + JS_free(cx, path); + return ok; } - JS_free(cx, path); - return ok; - } #else return JS_TRUE; #endif } static JSClass global_class = { - "global", 0, - JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, - global_enumerate, global_resolve, JS_ConvertStub, JS_FinalizeStub + "global", JSCLASS_NEW_RESOLVE, + JS_PropertyStub, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, + global_enumerate, (JSResolveOp) global_resolve, + JS_ConvertStub, JS_FinalizeStub }; int