/* create a new Lua closure, push it in the stack, and initialize its upvalues. Note that the closure is not cached if prototype is already black (which means that 'cache' was already cleared by the GC).  */
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 closure is not cached if prototype is already black (which means that 'cache' was already cleared by the GC).  */
static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
{
  int nup = p->sizeupvalues;
  Upvaldesc *uv = p->upvalues;
  int i;
  LClosure *ncl = luaF_newLclosure(L, nup);
  ncl->p = p;
  setclLvalue(L, ra, ncl);
  for (i = 0; i < nup; i++) {
    if (uv[i].instack)
      ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
    else
      ncl->upvals[i] = encup[uv[i].idx];
    ncl->upvals[i]->refcount++;
  }
}