ok = js_FoldConstants(cx, pn, &funcg.treeContext) && js_EmitFunctionBody(cx, &funcg, pn, fun);
fun->script = js_NewScriptFromCG(cx, &funcg, fun); if (!fun->script) { ok = JS_FALSE; } else { if (funcg.treeContext.flags & TCF_FUN_HEAVYWEIGHT) fun->flags |= JSFUN_HEAVYWEIGHT; ok = JS_TRUE; }
js_CompileFunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun){    JSCodeGenerator funcg;    JSStackFrame *fp, frame;    JSObject *funobj;    JSParseNode *pn;    JSBool ok;    if (!js_InitCodeGenerator(cx, &funcg, ts->filename, ts->lineno,                              ts->principals)) {        return JS_FALSE;    }    /* Prevent GC activation while compiling. */    JS_DISABLE_GC(cx->runtime);    /* Push a JSStackFrame for use by FunctionBody and js_EmitFunctionBody. */    fp = cx->fp;    funobj = fun->object;    JS_ASSERT(!fp || fp->fun != fun || fp->varobj != funobj ||              fp->scopeChain != funobj);    memset(&frame, 0, sizeof frame);    frame.fun = fun;    frame.varobj = frame.scopeChain = funobj;    frame.down = fp;    cx->fp = &frame;    /* Ensure that the body looks like a block statement to js_EmitTree. */    CURRENT_TOKEN(ts).type = TOK_LC;    pn = FunctionBody(cx, ts, fun, &funcg.treeContext);    if (!pn) {        ok = JS_FALSE;    } else {        ok = js_FoldConstants(cx, pn, &funcg.treeContext) &&             js_EmitFunctionBody(cx, &funcg, pn, fun);    }    /* Restore saved state and release code generation arenas. */    cx->fp = fp;    JS_ENABLE_GC(cx->runtime);    js_FinishCodeGenerator(cx, &funcg);    return ok;}