2 ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $
3 ** Auxiliary functions to manipulate prototypes and closures
4 ** See Copyright Notice in lua.h
14 #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15 cast(int, sizeof(TValue)*((n)-1)))
17 #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18 cast(int, sizeof(TValue *)*((n)-1)))
21 /* test whether thread is in 'twups' list */
22 #define isintwups(L) (L->twups != L)
26 ** maximum number of upvalues in a closure (both C and Lua). (Value
27 ** must fit in a VM register.)
33 ** Upvalues for Lua closures
36 TValue *v; /* points to stack or to its own value */
37 lu_mem refcount; /* reference counter */
39 struct { /* (when open) */
40 UpVal *next; /* linked list */
41 int touched; /* mark to avoid cycles with dead threads */
43 TValue value; /* the value (when closed) */
47 #define upisopen(up) ((up)->v != &(up)->u.value)
50 LUAI_FUNC Proto *luaF_newproto (lua_State *L);
51 LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
52 LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
53 LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
54 LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
55 LUAI_FUNC void luaF_close (lua_State *L, StkId level);
56 LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
57 LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,