Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:37:56

0001 /*
0002 ** $Id: lfunc.h $
0003 ** Auxiliary functions to manipulate prototypes and closures
0004 ** See Copyright Notice in lua.h
0005 */
0006 
0007 #ifndef lfunc_h
0008 #define lfunc_h
0009 
0010 
0011 #include "lobject.h"
0012 
0013 
0014 #define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \
0015                          cast_int(sizeof(TValue)) * (n))
0016 
0017 #define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \
0018                          cast_int(sizeof(TValue *)) * (n))
0019 
0020 
0021 /* test whether thread is in 'twups' list */
0022 #define isintwups(L)    (L->twups != L)
0023 
0024 
0025 /*
0026 ** maximum number of upvalues in a closure (both C and Lua). (Value
0027 ** must fit in a VM register.)
0028 */
0029 #define MAXUPVAL    255
0030 
0031 
0032 #define upisopen(up)    ((up)->v.p != &(up)->u.value)
0033 
0034 
0035 #define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v.p))
0036 
0037 
0038 /*
0039 ** maximum number of misses before giving up the cache of closures
0040 ** in prototypes
0041 */
0042 #define MAXMISS     10
0043 
0044 
0045 
0046 /* special status to close upvalues preserving the top of the stack */
0047 #define CLOSEKTOP   (-1)
0048 
0049 
0050 LUAI_FUNC Proto *luaF_newproto (lua_State *L);
0051 LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals);
0052 LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals);
0053 LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
0054 LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
0055 LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level);
0056 LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level);
0057 LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, int status, int yy);
0058 LUAI_FUNC void luaF_unlinkupval (UpVal *uv);
0059 LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
0060 LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
0061                                          int pc);
0062 
0063 
0064 #endif