aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/lua/lstate.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/3rdParty/lua/lstate.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/3rdParty/lua/lstate.c b/src/3rdParty/lua/lstate.c
index 1ffe1a0..1fbefb4 100644
--- a/src/3rdParty/lua/lstate.c
+++ b/src/3rdParty/lua/lstate.c
@@ -180,33 +180,33 @@ LUAI_FUNC void luaE_incCstack (lua_State *L) {
180static void stack_init (lua_State *L1, lua_State *L) { 180static void stack_init (lua_State *L1, lua_State *L) {
181 int i; CallInfo *ci; 181 int i; CallInfo *ci;
182 /* initialize stack array */ 182 /* initialize stack array */
183 L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue); 183 L1->stack.p = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue);
184 L1->tbclist = L1->stack; 184 L1->tbclist.p = L1->stack.p;
185 for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++) 185 for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++)
186 setnilvalue(s2v(L1->stack + i)); /* erase new stack */ 186 setnilvalue(s2v(L1->stack.p + i)); /* erase new stack */
187 L1->top = L1->stack; 187 L1->top.p = L1->stack.p;
188 L1->stack_last = L1->stack + BASIC_STACK_SIZE; 188 L1->stack_last.p = L1->stack.p + BASIC_STACK_SIZE;
189 /* initialize first ci */ 189 /* initialize first ci */
190 ci = &L1->base_ci; 190 ci = &L1->base_ci;
191 ci->next = ci->previous = NULL; 191 ci->next = ci->previous = NULL;
192 ci->callstatus = CIST_C; 192 ci->callstatus = CIST_C;
193 ci->func = L1->top; 193 ci->func.p = L1->top.p;
194 ci->u.c.k = NULL; 194 ci->u.c.k = NULL;
195 ci->nresults = 0; 195 ci->nresults = 0;
196 setnilvalue(s2v(L1->top)); /* 'function' entry for this 'ci' */ 196 setnilvalue(s2v(L1->top.p)); /* 'function' entry for this 'ci' */
197 L1->top++; 197 L1->top.p++;
198 ci->top = L1->top + LUA_MINSTACK; 198 ci->top.p = L1->top.p + LUA_MINSTACK;
199 L1->ci = ci; 199 L1->ci = ci;
200} 200}
201 201
202 202
203static void freestack (lua_State *L) { 203static void freestack (lua_State *L) {
204 if (L->stack == NULL) 204 if (L->stack.p == NULL)
205 return; /* stack not completely built yet */ 205 return; /* stack not completely built yet */
206 L->ci = &L->base_ci; /* free the entire 'ci' list */ 206 L->ci = &L->base_ci; /* free the entire 'ci' list */
207 luaE_freeCI(L); 207 luaE_freeCI(L);
208 lua_assert(L->nci == 0); 208 lua_assert(L->nci == 0);
209 luaM_freearray(L, L->stack, stacksize(L) + EXTRA_STACK); /* free stack */ 209 luaM_freearray(L, L->stack.p, stacksize(L) + EXTRA_STACK); /* free stack */
210} 210}
211 211
212 212
@@ -248,7 +248,7 @@ static void f_luaopen (lua_State *L, void *ud) {
248*/ 248*/
249static void preinit_thread (lua_State *L, global_State *g) { 249static void preinit_thread (lua_State *L, global_State *g) {
250 G(L) = g; 250 G(L) = g;
251 L->stack = NULL; 251 L->stack.p = NULL;
252 L->ci = NULL; 252 L->ci = NULL;
253 L->nci = 0; 253 L->nci = 0;
254 L->twups = L; /* thread has no upvalues */ 254 L->twups = L; /* thread has no upvalues */
@@ -284,20 +284,16 @@ static void close_state (lua_State *L) {
284 284
285 285
286LUA_API lua_State *lua_newthread (lua_State *L) { 286LUA_API lua_State *lua_newthread (lua_State *L) {
287 global_State *g; 287 global_State *g = G(L);
288 GCObject *o;
288 lua_State *L1; 289 lua_State *L1;
289 lua_lock(L); 290 lua_lock(L);
290 g = G(L);
291 luaC_checkGC(L); 291 luaC_checkGC(L);
292 /* create new thread */ 292 /* create new thread */
293 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; 293 o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l));
294 L1->marked = luaC_white(g); 294 L1 = gco2th(o);
295 L1->tt = LUA_VTHREAD;
296 /* link it on list 'allgc' */
297 L1->next = g->allgc;
298 g->allgc = obj2gco(L1);
299 /* anchor it on L stack */ 295 /* anchor it on L stack */
300 setthvalue2s(L, L->top, L1); 296 setthvalue2s(L, L->top.p, L1);
301 api_incr_top(L); 297 api_incr_top(L);
302 preinit_thread(L1, g); 298 preinit_thread(L1, g);
303 L1->hookmask = L->hookmask; 299 L1->hookmask = L->hookmask;
@@ -316,7 +312,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) {
316 312
317void luaE_freethread (lua_State *L, lua_State *L1) { 313void luaE_freethread (lua_State *L, lua_State *L1) {
318 LX *l = fromstate(L1); 314 LX *l = fromstate(L1);
319 luaF_closeupval(L1, L1->stack); /* close all upvalues */ 315 luaF_closeupval(L1, L1->stack.p); /* close all upvalues */
320 lua_assert(L1->openupval == NULL); 316 lua_assert(L1->openupval == NULL);
321 luai_userstatefree(L, L1); 317 luai_userstatefree(L, L1);
322 freestack(L1); 318 freestack(L1);
@@ -326,26 +322,27 @@ void luaE_freethread (lua_State *L, lua_State *L1) {
326 322
327int luaE_resetthread (lua_State *L, int status) { 323int luaE_resetthread (lua_State *L, int status) {
328 CallInfo *ci = L->ci = &L->base_ci; /* unwind CallInfo list */ 324 CallInfo *ci = L->ci = &L->base_ci; /* unwind CallInfo list */
329 setnilvalue(s2v(L->stack)); /* 'function' entry for basic 'ci' */ 325 setnilvalue(s2v(L->stack.p)); /* 'function' entry for basic 'ci' */
330 ci->func = L->stack; 326 ci->func.p = L->stack.p;
331 ci->callstatus = CIST_C; 327 ci->callstatus = CIST_C;
332 if (status == LUA_YIELD) 328 if (status == LUA_YIELD)
333 status = LUA_OK; 329 status = LUA_OK;
334 L->status = LUA_OK; /* so it can run __close metamethods */ 330 L->status = LUA_OK; /* so it can run __close metamethods */
335 status = luaD_closeprotected(L, 1, status); 331 status = luaD_closeprotected(L, 1, status);
336 if (status != LUA_OK) /* errors? */ 332 if (status != LUA_OK) /* errors? */
337 luaD_seterrorobj(L, status, L->stack + 1); 333 luaD_seterrorobj(L, status, L->stack.p + 1);
338 else 334 else
339 L->top = L->stack + 1; 335 L->top.p = L->stack.p + 1;
340 ci->top = L->top + LUA_MINSTACK; 336 ci->top.p = L->top.p + LUA_MINSTACK;
341 luaD_reallocstack(L, cast_int(ci->top - L->stack), 0); 337 luaD_reallocstack(L, cast_int(ci->top.p - L->stack.p), 0);
342 return status; 338 return status;
343} 339}
344 340
345 341
346LUA_API int lua_resetthread (lua_State *L) { 342LUA_API int lua_resetthread (lua_State *L, lua_State *from) {
347 int status; 343 int status;
348 lua_lock(L); 344 lua_lock(L);
345 L->nCcalls = (from) ? getCcalls(from) : 0;
349 status = luaE_resetthread(L, L->status); 346 status = luaE_resetthread(L, L->status);
350 lua_unlock(L); 347 lua_unlock(L);
351 return status; 348 return status;
@@ -426,7 +423,7 @@ void luaE_warning (lua_State *L, const char *msg, int tocont) {
426** Generate a warning from an error message 423** Generate a warning from an error message
427*/ 424*/
428void luaE_warnerror (lua_State *L, const char *where) { 425void luaE_warnerror (lua_State *L, const char *where) {
429 TValue *errobj = s2v(L->top - 1); /* error object */ 426 TValue *errobj = s2v(L->top.p - 1); /* error object */
430 const char *msg = (ttisstring(errobj)) 427 const char *msg = (ttisstring(errobj))
431 ? svalue(errobj) 428 ? svalue(errobj)
432 : "error object is not a string"; 429 : "error object is not a string";