** create a new Lua closure, push it in the stack, and initialize ** its upvalues. */
| 782 | ** its upvalues. |
| 783 | */ |
| 784 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, |
| 785 | StkId ra) { |
| 786 | int nup = p->sizeupvalues; |
| 787 | Upvaldesc *uv = p->upvalues; |
| 788 | int i; |
| 789 | LClosure *ncl = luaF_newLclosure(L, nup); |
| 790 | ncl->p = p; |
| 791 | setclLvalue2s(L, ra, ncl); /* anchor new closure in stack */ |
| 792 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ |
| 793 | if (uv[i].instack) /* upvalue refers to local variable? */ |
| 794 | ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx); |
| 795 | else /* get upvalue from enclosing function */ |
| 796 | ncl->upvals[i] = encup[uv[i].idx]; |
| 797 | luaC_objbarrier(L, ncl, ncl->upvals[i]); |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | |
| 802 | /* |
no test coverage detected