зеркало из https://github.com/mozilla/pjs.git
r=norris
Delayed functionDef from creating property until after the body parses succesfully.
This commit is contained in:
Родитель
77d1ba1011
Коммит
f578335319
|
@ -453,7 +453,6 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
||||||
JSObject *pobj;
|
JSObject *pobj;
|
||||||
JSScopeProperty *sprop;
|
JSScopeProperty *sprop;
|
||||||
JSTreeContext funtc;
|
JSTreeContext funtc;
|
||||||
jsval junk;
|
|
||||||
|
|
||||||
/* Make a TOK_FUNCTION node. */
|
/* Make a TOK_FUNCTION node. */
|
||||||
pn = NewParseNode(cx, &CURRENT_TOKEN(ts), PN_FUNC);
|
pn = NewParseNode(cx, &CURRENT_TOKEN(ts), PN_FUNC);
|
||||||
|
@ -509,8 +508,8 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Override any previously defined property using js_DefineFunction. */
|
/* Don't add the function to it's parent until the parse succeeds. */
|
||||||
fun = js_DefineFunction(cx, parent, funAtom, NULL, 0, JSPROP_ENUMERATE);
|
fun = js_NewFunction(cx, NULL, NULL, 0, 0, parent, funAtom);
|
||||||
named = (fun != NULL);
|
named = (fun != NULL);
|
||||||
}
|
}
|
||||||
if (!fun) {
|
if (!fun) {
|
||||||
|
@ -610,10 +609,13 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
||||||
pn->pn_op = JSOP_NOP;
|
pn->pn_op = JSOP_NOP;
|
||||||
|
|
||||||
ok = JS_TRUE;
|
ok = JS_TRUE;
|
||||||
|
if (named)
|
||||||
|
if (!OBJ_DEFINE_PROPERTY(cx, parent, (jsid)funAtom, OBJECT_TO_JSVAL(fun->object),
|
||||||
|
NULL, NULL, JSPROP_ENUMERATE, NULL)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
out:
|
out:
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (named)
|
|
||||||
(void) OBJ_DELETE_PROPERTY(cx, parent, (jsid)funAtom, &junk);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return pn;
|
return pn;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче