/* create a new Lua closure, push it in the stack, and initialize its upvalues. Note that the call to 'luaC_barrierproto' must come before the assignment to 'p->cache', as the function needs the original value of that field.  */
static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
/* create a new Lua closure, push it in the stack, and initialize its upvalues. Note that the call to 'luaC_barrierproto' must come before the assignment to 'p->cache', as the function needs the original value of that field.  */
static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
{
  int nup = p->sizeupvalues;
  Upvaldesc *uv = p->upvalues;
  int i;
  Closure *ncl = luaF_newLclosure(L, nup);
  ncl->l.p = p;
  setclLvalue(L, ra, ncl);
  for (i = 0; i < nup; i++) {
    if (uv[i].instack)
      ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx);
    else
      ncl->l.upvals[i] = encup[uv[i].idx];
  }
  luaC_barrierproto(L, p, ncl);
  p->cache = ncl;
}