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