** create a new Lua closure, push it in the stack, and initialize ** its upvalues. */
| 801 | ** its upvalues. |
| 802 | */ |
| 803 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, |
| 804 | StkId ra) { |
| 805 | int nup = p->sizeupvalues; |
| 806 | Upvaldesc *uv = p->upvalues; |
| 807 | int i; |
| 808 | LClosure *ncl = luaF_newLclosure(L, nup); |
| 809 | ncl->p = p; |
| 810 | setclLvalue2s(L, ra, ncl); /* anchor new closure in stack */ |
| 811 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ |
| 812 | if (uv[i].instack) /* upvalue refers to local variable? */ |
| 813 | ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx); |
| 814 | else /* get upvalue from enclosing function */ |
| 815 | ncl->upvals[i] = encup[uv[i].idx]; |
| 816 | luaC_objbarrier(L, ncl, ncl->upvals[i]); |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | |
| 821 | /* |
no test coverage detected