static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) { LexState *ls = (LexState *)ud; GCproto *pt; GCfunc *fn; int bc; UNUSED(dummy); cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ bc = lj_lex_setup(L, ls); if (ls->mode && !strchr(ls->mode, bc ? 'b' : 't')) { setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); lj_err_throw(L, LUA_ERRSYNTAX); } pt = bc ? lj_bcread(ls) : lj_parse(ls); fn = lj_func_newL_empty(L, pt, tabref(L->env)); /* Don't combine above/below into one statement. */ setfuncV(L, L->top++, fn); return NULL; }
static const uint8_t *lib_read_lfunc(lua_State *L, const uint8_t *p, GCtab *tab) { int len = *p++; GCstr *name = lj_str_new(L, (const char *)p, len); LexState ls; GCproto *pt; GCfunc *fn; memset(&ls, 0, sizeof(ls)); ls.L = L; ls.p = (const char *)(p+len); ls.pe = (const char *)~(uintptr_t)0; ls.c = -1; ls.level = (BCDUMP_F_STRIP|(LJ_BE*BCDUMP_F_BE)); ls.chunkname = name; pt = lj_bcread_proto(&ls); pt->firstline = ~(BCLine)0; fn = lj_func_newL_empty(L, pt, tabref(L->env)); /* NOBARRIER: See below for common barrier. */ setfuncV(L, lj_tab_setstr(L, tab, name), fn); return (const uint8_t *)ls.p; }