Lines Matching refs:L

27 CClosure *luaF_newCclosure (lua_State *L, int nupvals) {  in luaF_newCclosure()  argument
28 GCObject *o = luaC_newobj(L, LUA_VCCL, sizeCclosure(nupvals)); in luaF_newCclosure()
35 LClosure *luaF_newLclosure (lua_State *L, int nupvals) { in luaF_newLclosure() argument
36 GCObject *o = luaC_newobj(L, LUA_VLCL, sizeLclosure(nupvals)); in luaF_newLclosure()
48 void luaF_initupvals (lua_State *L, LClosure *cl) { in luaF_initupvals() argument
51 GCObject *o = luaC_newobj(L, LUA_VUPVAL, sizeof(UpVal)); in luaF_initupvals()
56 luaC_objbarrier(L, cl, uv); in luaF_initupvals()
65 static UpVal *newupval (lua_State *L, int tbc, StkId level, UpVal **prev) { in newupval() argument
66 GCObject *o = luaC_newobj(L, LUA_VUPVAL, sizeof(UpVal)); in newupval()
76 if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ in newupval()
77 L->twups = G(L)->twups; /* link it to the list */ in newupval()
78 G(L)->twups = L; in newupval()
88 UpVal *luaF_findupval (lua_State *L, StkId level) { in luaF_findupval() argument
89 UpVal **pp = &L->openupval; in luaF_findupval()
91 lua_assert(isintwups(L) || L->openupval == NULL); in luaF_findupval()
93 lua_assert(!isdead(G(L), p)); in luaF_findupval()
99 return newupval(L, 0, level, pp); in luaF_findupval()
108 static void callclosemethod (lua_State *L, TValue *obj, TValue *err, int yy) { in callclosemethod() argument
109 StkId top = L->top; in callclosemethod()
110 const TValue *tm = luaT_gettmbyobj(L, obj, TM_CLOSE); in callclosemethod()
111 setobj2s(L, top, tm); /* will call metamethod... */ in callclosemethod()
112 setobj2s(L, top + 1, obj); /* with 'self' as the 1st argument */ in callclosemethod()
113 setobj2s(L, top + 2, err); /* and error msg. as 2nd argument */ in callclosemethod()
114 L->top = top + 3; /* add function and arguments */ in callclosemethod()
116 luaD_call(L, top, 0); in callclosemethod()
118 luaD_callnoyield(L, top, 0); in callclosemethod()
126 static void checkclosemth (lua_State *L, StkId level) { in checkclosemth() argument
127 const TValue *tm = luaT_gettmbyobj(L, s2v(level), TM_CLOSE); in checkclosemth()
129 int idx = cast_int(level - L->ci->func); /* variable index */ in checkclosemth()
130 const char *vname = luaG_findlocal(L, L->ci, idx, NULL); in checkclosemth()
132 luaG_runerror(L, "variable '%s' got a non-closable value", vname); in checkclosemth()
144 static void prepcallclosemth (lua_State *L, StkId level, int status, int yy) { in prepcallclosemth() argument
148 errobj = &G(L)->nilvalue; /* error object is nil */ in prepcallclosemth()
151 luaD_seterrorobj(L, status, level + 1); /* set error object */ in prepcallclosemth()
153 callclosemethod(L, uv, errobj, yy); in prepcallclosemth()
163 ((256ul << ((sizeof(L->stack->tbclist.delta) - 1) * 8)) - 1)
169 void luaF_newtbcupval (lua_State *L, StkId level) { in luaF_newtbcupval() argument
170 lua_assert(level > L->tbclist); in luaF_newtbcupval()
173 checkclosemth(L, level); /* value must have a close method */ in luaF_newtbcupval()
174 while (cast_uint(level - L->tbclist) > MAXDELTA) { in luaF_newtbcupval()
175 L->tbclist += MAXDELTA; /* create a dummy node at maximum delta */ in luaF_newtbcupval()
176 L->tbclist->tbclist.delta = 0; in luaF_newtbcupval()
178 level->tbclist.delta = cast(unsigned short, level - L->tbclist); in luaF_newtbcupval()
179 L->tbclist = level; in luaF_newtbcupval()
194 void luaF_closeupval (lua_State *L, StkId level) { in luaF_closeupval() argument
197 while ((uv = L->openupval) != NULL && (upl = uplevel(uv)) >= level) { in luaF_closeupval()
199 lua_assert(uplevel(uv) < L->top); in luaF_closeupval()
201 setobj(L, slot, uv->v); /* move value to upvalue slot */ in luaF_closeupval()
205 luaC_barrier(L, uv, slot); in luaF_closeupval()
214 static void poptbclist (lua_State *L) { in poptbclist() argument
215 StkId tbc = L->tbclist; in poptbclist()
218 while (tbc > L->stack && tbc->tbclist.delta == 0) in poptbclist()
220 L->tbclist = tbc; in poptbclist()
228 void luaF_close (lua_State *L, StkId level, int status, int yy) { in luaF_close() argument
229 ptrdiff_t levelrel = savestack(L, level); in luaF_close()
230 luaF_closeupval(L, level); /* first, close the upvalues */ in luaF_close()
231 while (L->tbclist >= level) { /* traverse tbc's down to that level */ in luaF_close()
232 StkId tbc = L->tbclist; /* get variable index */ in luaF_close()
233 poptbclist(L); /* remove it from list */ in luaF_close()
234 prepcallclosemth(L, tbc, status, yy); /* close variable */ in luaF_close()
235 level = restorestack(L, levelrel); in luaF_close()
240 Proto *luaF_newproto (lua_State *L) { in luaF_newproto() argument
241 GCObject *o = luaC_newobj(L, LUA_VPROTO, sizeof(Proto)); in luaF_newproto()
267 void luaF_freeproto (lua_State *L, Proto *f) { in luaF_freeproto() argument
268 luaM_freearray(L, f->code, f->sizecode); in luaF_freeproto()
269 luaM_freearray(L, f->p, f->sizep); in luaF_freeproto()
270 luaM_freearray(L, f->k, f->sizek); in luaF_freeproto()
271 luaM_freearray(L, f->lineinfo, f->sizelineinfo); in luaF_freeproto()
272 luaM_freearray(L, f->abslineinfo, f->sizeabslineinfo); in luaF_freeproto()
273 luaM_freearray(L, f->locvars, f->sizelocvars); in luaF_freeproto()
274 luaM_freearray(L, f->upvalues, f->sizeupvalues); in luaF_freeproto()
275 luaM_free(L, f); in luaF_freeproto()