mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix js_FindDuplicateFormal to crack the fun->u.i.names union correctly, and spruce it up with C++ (532041, r=jimb).
This commit is contained in:
parent
dbe4c12454
commit
5bcc54508f
@ -3062,16 +3062,17 @@ js_FreezeLocalNames(JSContext *cx, JSFunction *fun)
|
||||
#endif
|
||||
}
|
||||
|
||||
extern JSAtom *
|
||||
js_FindDuplicateFormal(JSFunction *fun)
|
||||
JSAtom *
|
||||
JSFunction::findDuplicateFormal() const
|
||||
{
|
||||
unsigned nargs = fun->nargs;
|
||||
if (nargs <= 1)
|
||||
return NULL;
|
||||
|
||||
/* Function with two to MAX_ARRAY_LOCALS parameters use an aray. */
|
||||
if (nargs <= MAX_ARRAY_LOCALS) {
|
||||
jsuword *array = fun->u.i.names.array;
|
||||
unsigned n = nargs + u.i.nvars + u.i.nupvars;
|
||||
if (n <= MAX_ARRAY_LOCALS) {
|
||||
jsuword *array = u.i.names.array;
|
||||
|
||||
/* Quadratic, but MAX_ARRAY_LOCALS is 8, so at most 28 comparisons. */
|
||||
for (unsigned i = 0; i < nargs; i++) {
|
||||
for (unsigned j = i + 1; j < nargs; j++) {
|
||||
@ -3087,6 +3088,6 @@ js_FindDuplicateFormal(JSFunction *fun)
|
||||
* table. Hashed local name maps have already made a list of any
|
||||
* duplicate argument names for us.
|
||||
*/
|
||||
JSNameIndexPair *dup = fun->u.i.names.map->lastdup;
|
||||
JSNameIndexPair *dup = u.i.names.map->lastdup;
|
||||
return dup ? dup->name : NULL;
|
||||
}
|
||||
|
@ -180,6 +180,12 @@ struct JSFunction : public JSObject {
|
||||
|
||||
int sharpSlotBase(JSContext *cx);
|
||||
|
||||
/*
|
||||
* If fun's formal parameters include any duplicate names, return one
|
||||
* of them (chosen arbitrarily). If they are all unique, return NULL.
|
||||
*/
|
||||
JSAtom *findDuplicateFormal() const;
|
||||
|
||||
uint32 countInterpretedReservedSlots() const;
|
||||
};
|
||||
|
||||
@ -436,13 +442,6 @@ js_GetLocalNameArray(JSContext *cx, JSFunction *fun, struct JSArenaPool *pool);
|
||||
extern void
|
||||
js_FreezeLocalNames(JSContext *cx, JSFunction *fun);
|
||||
|
||||
/*
|
||||
* If fun's formal parameters include any duplicate names, return one
|
||||
* of them (chosen arbitrarily). If they are all unique, return NULL.
|
||||
*/
|
||||
extern JSAtom *
|
||||
js_FindDuplicateFormal(JSFunction *fun);
|
||||
|
||||
extern JSBool
|
||||
js_fun_apply(JSContext *cx, uintN argc, jsval *vp);
|
||||
|
||||
|
@ -1263,7 +1263,7 @@ CheckStrictFormals(JSContext *cx, JSTreeContext *tc, JSFunction *fun,
|
||||
if (!tc->needStrictChecks())
|
||||
return true;
|
||||
|
||||
atom = js_FindDuplicateFormal(fun);
|
||||
atom = fun->findDuplicateFormal();
|
||||
if (atom) {
|
||||
/*
|
||||
* We have found a duplicate parameter name. If we can find the
|
||||
|
Loading…
Reference in New Issue
Block a user