зеркало из https://github.com/mozilla/pjs.git
Function code generation is in a separated function. bug=355834 r=brendan
This commit is contained in:
Родитель
7c982af5f6
Коммит
9b23c39125
|
@ -3078,6 +3078,21 @@ bad:
|
|||
goto out;
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_EmitFunctionBytecode(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body)
|
||||
{
|
||||
if (!js_AllocTryNotes(cx, cg))
|
||||
return JS_FALSE;
|
||||
|
||||
if (cg->treeContext.flags & TCF_FUN_IS_GENERATOR) {
|
||||
if (js_Emit1(cx, cg, JSOP_GENERATOR) < 0)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return js_EmitTree(cx, cg, body) &&
|
||||
js_Emit1(cx, cg, JSOP_STOP) >= 0;
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body,
|
||||
JSFunction *fun)
|
||||
|
@ -3086,9 +3101,6 @@ js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body,
|
|||
JSObject *funobj;
|
||||
JSBool ok;
|
||||
|
||||
if (!js_AllocTryNotes(cx, cg))
|
||||
return JS_FALSE;
|
||||
|
||||
fp = cx->fp;
|
||||
funobj = fun->object;
|
||||
JS_ASSERT(!fp || (fp->fun != fun && fp->varobj != funobj &&
|
||||
|
@ -3101,10 +3113,7 @@ js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body,
|
|||
? JSFRAME_COMPILING | JSFRAME_COMPILE_N_GO
|
||||
: JSFRAME_COMPILING;
|
||||
cx->fp = &frame;
|
||||
ok = (!(cg->treeContext.flags & TCF_FUN_IS_GENERATOR) ||
|
||||
js_Emit1(cx, cg, JSOP_GENERATOR) >= 0) &&
|
||||
js_EmitTree(cx, cg, body) &&
|
||||
js_Emit1(cx, cg, JSOP_STOP) >= 0;
|
||||
ok = js_EmitFunctionBytecode(cx, cg, body);
|
||||
cx->fp = fp;
|
||||
if (!ok)
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -478,6 +478,12 @@ js_LexicalLookup(JSTreeContext *tc, JSAtom *atom, jsint *slotp,
|
|||
extern JSBool
|
||||
js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn);
|
||||
|
||||
/*
|
||||
* Emit function code into cg for the tree rooted at body.
|
||||
*/
|
||||
extern JSBool
|
||||
js_EmitFunctionBytecode(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body);
|
||||
|
||||
/*
|
||||
* Emit code into cg for the tree rooted at body, then create a persistent
|
||||
* script for fun from cg.
|
||||
|
|
|
@ -756,9 +756,7 @@ FunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun,
|
|||
JSCodeGenerator *cg = (JSCodeGenerator *) tc;
|
||||
|
||||
if (!js_FoldConstants(cx, pn, tc) ||
|
||||
!js_AllocTryNotes(cx, cg) ||
|
||||
!js_EmitTree(cx, cg, pn) ||
|
||||
js_Emit1(cx, cg, JSOP_STOP) < 0) {
|
||||
!js_EmitFunctionBytecode(cx, cg, pn)) {
|
||||
pn = NULL;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче