native Lua  0.5.0-devel
Lua on the platform you use with the compiler you choose
lfunc.h
Go to the documentation of this file.
1 /*
2 ** $Id: lfunc.h $
3 ** Auxiliary functions to manipulate prototypes and closures
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef lfunc_h
8 #define lfunc_h
9 
10 
11 #include "lobject.h"
12 
13 #include "_native_lua_config.h" /* native Lua */
14 
15 
16 #define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \
17  cast_int(sizeof(TValue)) * (n))
18 
19 #define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \
20  cast_int(sizeof(TValue *)) * (n))
21 
22 
23 /* test whether thread is in 'twups' list */
24 #define isintwups(L) (L->twups != L)
25 
26 
27 /*
28 ** maximum number of upvalues in a closure (both C and Lua). (Value
29 ** must fit in a VM register.)
30 */
31 #define MAXUPVAL 255
32 
33 
34 #define upisopen(up) ((up)->v != &(up)->u.value)
35 
36 
37 #define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v))
38 
39 
40 /*
41 ** maximum number of misses before giving up the cache of closures
42 ** in prototypes
43 */
44 #define MAXMISS 10
45 
46 
47 /*
48 ** Special "status" for 'luaF_close'
49 */
50 
51 /* close upvalues without running their closing methods */
52 #define NOCLOSINGMETH (-1)
53 
54 /* close upvalues running all closing methods in protected mode */
55 #define CLOSEPROTECT (-2)
56 
57 
59 LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals);
60 LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals);
63 LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level);
64 LUAI_FUNC int luaF_close (lua_State *L, StkId level, int status);
67 LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
68  int pc);
69 
70 
71 #endif
luaF_close
LUAI_FUNC int luaF_close(lua_State *L, StkId level, int status)
Definition: lfunc.c:223
luaF_newproto
LUAI_FUNC Proto * luaF_newproto(lua_State *L)
Definition: lfunc.c:245
LUAI_FUNC
#define LUAI_FUNC
Definition: luaconf.h:324
luaF_newtbcupval
LUAI_FUNC void luaF_newtbcupval(lua_State *L, StkId level)
Definition: lfunc.c:194
_native_lua_config.h
native Lua configuration file
StackValue
Definition: lobject.h:140
luaF_getlocalname
LUAI_FUNC const char * luaF_getlocalname(const Proto *func, int local_number, int pc)
Definition: lfunc.c:288
UpVal
Definition: lobject.h:605
CClosure
Definition: lobject.h:623
lobject.h
lua_State
Definition: lstate.h:283
LClosure
Definition: lobject.h:630
luaF_newLclosure
LUAI_FUNC LClosure * luaF_newLclosure(lua_State *L, int nupvals)
Definition: lfunc.c:35
Proto
Definition: lobject.h:529
luaF_newCclosure
LUAI_FUNC CClosure * luaF_newCclosure(lua_State *L, int nupvals)
Definition: lfunc.c:27
luaF_freeproto
LUAI_FUNC void luaF_freeproto(lua_State *L, Proto *f)
Definition: lfunc.c:272
luaF_findupval
LUAI_FUNC UpVal * luaF_findupval(lua_State *L, StkId level)
Definition: lfunc.c:88
luaF_unlinkupval
LUAI_FUNC void luaF_unlinkupval(UpVal *uv)
Definition: lfunc.c:215
luaF_initupvals
LUAI_FUNC void luaF_initupvals(lua_State *L, LClosure *cl)
Definition: lfunc.c:48