17 |
17 |
18 struct lua_longjmp; /* defined in ldo.c */ |
18 struct lua_longjmp; /* defined in ldo.c */ |
19 |
19 |
20 |
20 |
21 /* table of globals */ |
21 /* table of globals */ |
22 #define gt(L) (&L->l_gt) |
22 #define gt(L) (&L->l_gt) |
23 |
23 |
24 /* registry */ |
24 /* registry */ |
25 #define registry(L) (&G(L)->l_registry) |
25 #define registry(L) (&G(L)->l_registry) |
26 |
26 |
27 |
27 |
28 /* extra stack space to handle TM calls and some other extras */ |
28 /* extra stack space to handle TM calls and some other extras */ |
29 #define EXTRA_STACK 5 |
29 #define EXTRA_STACK 5 |
30 |
30 |
46 ** informations about a call |
46 ** informations about a call |
47 */ |
47 */ |
48 typedef struct CallInfo { |
48 typedef struct CallInfo { |
49 StkId base; /* base for this function */ |
49 StkId base; /* base for this function */ |
50 StkId func; /* function index in the stack */ |
50 StkId func; /* function index in the stack */ |
51 StkId top; /* top for this function */ |
51 StkId top; /* top for this function */ |
52 const Instruction *savedpc; |
52 const Instruction *savedpc; |
53 int nresults; /* expected number of results from this function */ |
53 int nresults; /* expected number of results from this function */ |
54 int tailcalls; /* number of tail calls lost under this entry */ |
54 int tailcalls; /* number of tail calls lost under this entry */ |
55 } CallInfo; |
55 } CallInfo; |
56 |
56 |
57 |
57 |
58 |
58 |
59 #define curr_func(L) (clvalue(L->ci->func)) |
59 #define curr_func(L) (clvalue(L->ci->func)) |
60 #define ci_func(ci) (clvalue((ci)->func)) |
60 #define ci_func(ci) (clvalue((ci)->func)) |
61 #define f_isLua(ci) (!ci_func(ci)->c.isC) |
61 #define f_isLua(ci) (!ci_func(ci)->c.isC) |
62 #define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) |
62 #define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) |
63 |
63 |
64 |
64 |
65 /* |
65 /* |
66 ** `global state', shared by all threads of this state |
66 ** `global state', shared by all threads of this state |
67 */ |
67 */ |
144 struct lua_State th; /* thread */ |
144 struct lua_State th; /* thread */ |
145 }; |
145 }; |
146 |
146 |
147 |
147 |
148 /* macros to convert a GCObject into a specific value */ |
148 /* macros to convert a GCObject into a specific value */ |
149 #define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) |
149 #define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) |
150 #define gco2ts(o) (&rawgco2ts(o)->tsv) |
150 #define gco2ts(o) (&rawgco2ts(o)->tsv) |
151 #define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) |
151 #define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) |
152 #define gco2u(o) (&rawgco2u(o)->uv) |
152 #define gco2u(o) (&rawgco2u(o)->uv) |
153 #define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) |
153 #define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) |
154 #define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) |
154 #define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) |
155 #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) |
155 #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) |
156 #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) |
156 #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) |
157 #define ngcotouv(o) \ |
157 #define ngcotouv(o) \ |
158 check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) |
158 check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) |
159 #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) |
159 #define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) |
160 |
160 |
161 /* macro to convert any Lua object into a GCObject */ |
161 /* macro to convert any Lua object into a GCObject */ |
162 #define obj2gco(v) (cast(GCObject *, (v))) |
162 #define obj2gco(v) (cast(GCObject *, (v))) |
163 |
163 |
164 |
164 |
165 LUAI_FUNC lua_State *luaE_newthread (lua_State *L); |
165 LUAI_FUNC lua_State *luaE_newthread (lua_State *L); |
166 LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); |
166 LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); |
167 |
167 |