JSRuntime *rt; JSNewScriptHook hook;
js_NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg, JSFunction *fun){    JSTryNote *trynotes;    jssrcnote *notes;    JSScript *script;    JSRuntime *rt;    JSNewScriptHook hook;    if (!js_FinishTakingTryNotes(cx, cg, &trynotes))        return NULL;    notes = js_FinishTakingSrcNotes(cx, cg);    script = js_NewScriptFromParams(cx, CG_BASE(cg), CG_OFFSET(cg),                                    CG_PROLOG_BASE(cg), CG_PROLOG_OFFSET(cg),                                    cg->filename, cg->firstLine,                                    cg->maxStackDepth, notes, trynotes,                                    cg->principals);    if (!script)        return NULL;    if (!notes || !js_InitAtomMap(cx, &script->atomMap, &cg->atomList)) {        js_DestroyScript(cx, script);        return NULL;    }    /* Tell the debugger about this compiled script. */    rt = cx->runtime;    hook = rt->newScriptHook;    if (hook) {        /*         * We use a dummy stack frame to protect the script from a GC caused         * by debugger-hook execution.         *         * XXX We really need a way to manage local roots and such more         * XXX automatically, at which point we can remove this one-off hack         * XXX and others within the engine.  See bug 40757 for discussion.         */        JSStackFrame dummy;                memset(&dummy, 0, sizeof dummy);        dummy.down = cx->fp;        dummy.script = script;        cx->fp = &dummy;        (*hook)(cx, cg->filename, cg->firstLine, script, fun,                rt->newScriptHookData);        cx->fp = dummy.down;    }    return script;}