aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c12
-rw-r--r--ldebug.c2
-rw-r--r--ldo.c10
-rw-r--r--lgc.c2
-rw-r--r--lobject.h3
-rw-r--r--lstate.c4
-rw-r--r--ltests.c2
-rw-r--r--ltm.c10
-rw-r--r--lvm.c2
9 files changed, 24 insertions, 23 deletions
diff --git a/lapi.c b/lapi.c
index 53eb1719..fb994594 100644
--- a/lapi.c
+++ b/lapi.c
@@ -187,7 +187,7 @@ LUA_API void lua_settop (lua_State *L, int idx) {
187 api_check(L, idx <= ci->top.p - (func + 1), "new top too large"); 187 api_check(L, idx <= ci->top.p - (func + 1), "new top too large");
188 diff = ((func + 1) + idx) - L->top.p; 188 diff = ((func + 1) + idx) - L->top.p;
189 for (; diff > 0; diff--) 189 for (; diff > 0; diff--)
190 setnilvalue(s2v(L->top.p++)); /* clear new slots */ 190 setnilvalue2s(L->top.p++); /* clear new slots */
191 } 191 }
192 else { 192 else {
193 api_check(L, -(idx+1) <= (L->top.p - (func + 1)), "invalid new top"); 193 api_check(L, -(idx+1) <= (L->top.p - (func + 1)), "invalid new top");
@@ -210,7 +210,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) {
210 api_check(L, (L->ci->callstatus & CIST_TBC) && (L->tbclist.p == level), 210 api_check(L, (L->ci->callstatus & CIST_TBC) && (L->tbclist.p == level),
211 "no variable to close at given level"); 211 "no variable to close at given level");
212 level = luaF_close(L, level, CLOSEKTOP, 0); 212 level = luaF_close(L, level, CLOSEKTOP, 0);
213 setnilvalue(s2v(level)); 213 setnilvalue2s(level);
214 lua_unlock(L); 214 lua_unlock(L);
215} 215}
216 216
@@ -513,7 +513,7 @@ LUA_API const void *lua_topointer (lua_State *L, int idx) {
513 513
514LUA_API void lua_pushnil (lua_State *L) { 514LUA_API void lua_pushnil (lua_State *L) {
515 lua_lock(L); 515 lua_lock(L);
516 setnilvalue(s2v(L->top.p)); 516 setnilvalue2s(L->top.p);
517 api_incr_top(L); 517 api_incr_top(L);
518 lua_unlock(L); 518 lua_unlock(L);
519} 519}
@@ -570,7 +570,7 @@ LUA_API const char *lua_pushexternalstring (lua_State *L,
570LUA_API const char *lua_pushstring (lua_State *L, const char *s) { 570LUA_API const char *lua_pushstring (lua_State *L, const char *s) {
571 lua_lock(L); 571 lua_lock(L);
572 if (s == NULL) 572 if (s == NULL)
573 setnilvalue(s2v(L->top.p)); 573 setnilvalue2s(L->top.p);
574 else { 574 else {
575 TString *ts; 575 TString *ts;
576 ts = luaS_new(L, s); 576 ts = luaS_new(L, s);
@@ -743,7 +743,7 @@ LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
743 743
744static int finishrawget (lua_State *L, lu_byte tag) { 744static int finishrawget (lua_State *L, lu_byte tag) {
745 if (tagisempty(tag)) /* avoid copying empty items to the stack */ 745 if (tagisempty(tag)) /* avoid copying empty items to the stack */
746 setnilvalue(s2v(L->top.p)); 746 setnilvalue2s(L->top.p);
747 api_incr_top(L); 747 api_incr_top(L);
748 lua_unlock(L); 748 lua_unlock(L);
749 return novariant(tag); 749 return novariant(tag);
@@ -836,7 +836,7 @@ LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) {
836 o = index2value(L, idx); 836 o = index2value(L, idx);
837 api_check(L, ttisfulluserdata(o), "full userdata expected"); 837 api_check(L, ttisfulluserdata(o), "full userdata expected");
838 if (n <= 0 || n > uvalue(o)->nuvalue) { 838 if (n <= 0 || n > uvalue(o)->nuvalue) {
839 setnilvalue(s2v(L->top.p)); 839 setnilvalue2s(L->top.p);
840 t = LUA_TNONE; 840 t = LUA_TNONE;
841 } 841 }
842 else { 842 else {
diff --git a/ldebug.c b/ldebug.c
index 2665ec7b..5293ccb9 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -291,7 +291,7 @@ static int nextline (const Proto *p, int currentline, int pc) {
291 291
292static void collectvalidlines (lua_State *L, Closure *f) { 292static void collectvalidlines (lua_State *L, Closure *f) {
293 if (!LuaClosure(f)) { 293 if (!LuaClosure(f)) {
294 setnilvalue(s2v(L->top.p)); 294 setnilvalue2s(L->top.p);
295 api_incr_top(L); 295 api_incr_top(L);
296 } 296 }
297 else { 297 else {
diff --git a/ldo.c b/ldo.c
index ec360ee8..1f18b186 100644
--- a/ldo.c
+++ b/ldo.c
@@ -349,7 +349,7 @@ int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) {
349 correctstack(L, oldstack); /* change offsets back to pointers */ 349 correctstack(L, oldstack); /* change offsets back to pointers */
350 L->stack_last.p = L->stack.p + newsize; 350 L->stack_last.p = L->stack.p + newsize;
351 for (i = oldsize + EXTRA_STACK; i < newsize + EXTRA_STACK; i++) 351 for (i = oldsize + EXTRA_STACK; i < newsize + EXTRA_STACK; i++)
352 setnilvalue(s2v(newstack + i)); /* erase new segment */ 352 setnilvalue2s(newstack + i); /* erase new segment */
353 return 1; 353 return 1;
354} 354}
355 355
@@ -554,7 +554,7 @@ l_sinline void genmoveresults (lua_State *L, StkId res, int nres,
554 for (i = 0; i < nres; i++) /* move all results to correct place */ 554 for (i = 0; i < nres; i++) /* move all results to correct place */
555 setobjs2s(L, res + i, firstresult + i); 555 setobjs2s(L, res + i, firstresult + i);
556 for (; i < wanted; i++) /* complete wanted number of results */ 556 for (; i < wanted; i++) /* complete wanted number of results */
557 setnilvalue(s2v(res + i)); 557 setnilvalue2s(res + i);
558 L->top.p = res + wanted; /* top points after the last result */ 558 L->top.p = res + wanted; /* top points after the last result */
559} 559}
560 560
@@ -574,7 +574,7 @@ l_sinline void moveresults (lua_State *L, StkId res, int nres,
574 return; 574 return;
575 case 1 + 1: /* one value needed */ 575 case 1 + 1: /* one value needed */
576 if (nres == 0) /* no results? */ 576 if (nres == 0) /* no results? */
577 setnilvalue(s2v(res)); /* adjust with nil */ 577 setnilvalue2s(res); /* adjust with nil */
578 else /* at least one result */ 578 else /* at least one result */
579 setobjs2s(L, res, L->top.p - nres); /* move it to proper place */ 579 setobjs2s(L, res, L->top.p - nres); /* move it to proper place */
580 L->top.p = res + 1; 580 L->top.p = res + 1;
@@ -694,7 +694,7 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
694 setobjs2s(L, ci->func.p + i, func + i); 694 setobjs2s(L, ci->func.p + i, func + i);
695 func = ci->func.p; /* moved-down function */ 695 func = ci->func.p; /* moved-down function */
696 for (; narg1 <= nfixparams; narg1++) 696 for (; narg1 <= nfixparams; narg1++)
697 setnilvalue(s2v(func + narg1)); /* complete missing arguments */ 697 setnilvalue2s(func + narg1); /* complete missing arguments */
698 ci->top.p = func + 1 + fsize; /* top for new function */ 698 ci->top.p = func + 1 + fsize; /* top for new function */
699 lua_assert(ci->top.p <= L->stack_last.p); 699 lua_assert(ci->top.p <= L->stack_last.p);
700 ci->u.l.savedpc = p->code; /* starting point */ 700 ci->u.l.savedpc = p->code; /* starting point */
@@ -741,7 +741,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) {
741 L->ci = ci = prepCallInfo(L, func, status, func + 1 + fsize); 741 L->ci = ci = prepCallInfo(L, func, status, func + 1 + fsize);
742 ci->u.l.savedpc = p->code; /* starting point */ 742 ci->u.l.savedpc = p->code; /* starting point */
743 for (; narg < nfixparams; narg++) 743 for (; narg < nfixparams; narg++)
744 setnilvalue(s2v(L->top.p++)); /* complete missing arguments */ 744 setnilvalue2s(L->top.p++); /* complete missing arguments */
745 lua_assert(ci->top.p <= L->stack_last.p); 745 lua_assert(ci->top.p <= L->stack_last.p);
746 return ci; 746 return ci;
747 } 747 }
diff --git a/lgc.c b/lgc.c
index 0f89451c..a463e41e 100644
--- a/lgc.c
+++ b/lgc.c
@@ -709,7 +709,7 @@ static l_mem traversethread (global_State *g, lua_State *th) {
709 if (!g->gcemergency) 709 if (!g->gcemergency)
710 luaD_shrinkstack(th); /* do not change stack in emergency cycle */ 710 luaD_shrinkstack(th); /* do not change stack in emergency cycle */
711 for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++) 711 for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++)
712 setnilvalue(s2v(o)); /* clear dead stack slice */ 712 setnilvalue2s(o); /* clear dead stack slice */
713 /* 'remarkupvals' may have removed thread from 'twups' list */ 713 /* 'remarkupvals' may have removed thread from 'twups' list */
714 if (!isintwups(th) && th->openupval != NULL) { 714 if (!isintwups(th) && th->openupval != NULL) {
715 th->twups = g->twups; /* link it back to the list */ 715 th->twups = g->twups; /* link it back to the list */
diff --git a/lobject.h b/lobject.h
index 156c942f..bf5b65b4 100644
--- a/lobject.h
+++ b/lobject.h
@@ -208,7 +208,8 @@ typedef union {
208#define ttisstrictnil(o) checktag((o), LUA_VNIL) 208#define ttisstrictnil(o) checktag((o), LUA_VNIL)
209 209
210 210
211#define setnilvalue(obj) settt_(obj, LUA_VNIL) 211#define setnilvalue(obj) settt_(obj, LUA_VNIL)
212#define setnilvalue2s(stk) setnilvalue(s2v(stk))
212 213
213 214
214#define isabstkey(v) checktag((v), LUA_VABSTKEY) 215#define isabstkey(v) checktag((v), LUA_VABSTKEY)
diff --git a/lstate.c b/lstate.c
index 7d341991..ada0b856 100644
--- a/lstate.c
+++ b/lstate.c
@@ -151,7 +151,7 @@ LUAI_FUNC void luaE_incCstack (lua_State *L) {
151static void resetCI (lua_State *L) { 151static void resetCI (lua_State *L) {
152 CallInfo *ci = L->ci = &L->base_ci; 152 CallInfo *ci = L->ci = &L->base_ci;
153 ci->func.p = L->stack.p; 153 ci->func.p = L->stack.p;
154 setnilvalue(s2v(ci->func.p)); /* 'function' entry for basic 'ci' */ 154 setnilvalue2s(ci->func.p); /* 'function' entry for basic 'ci' */
155 ci->top.p = ci->func.p + 1 + LUA_MINSTACK; /* +1 for 'function' entry */ 155 ci->top.p = ci->func.p + 1 + LUA_MINSTACK; /* +1 for 'function' entry */
156 ci->u.c.k = NULL; 156 ci->u.c.k = NULL;
157 ci->callstatus = CIST_C; 157 ci->callstatus = CIST_C;
@@ -166,7 +166,7 @@ static void stack_init (lua_State *L1, lua_State *L) {
166 L1->stack.p = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue); 166 L1->stack.p = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue);
167 L1->tbclist.p = L1->stack.p; 167 L1->tbclist.p = L1->stack.p;
168 for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++) 168 for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++)
169 setnilvalue(s2v(L1->stack.p + i)); /* erase new stack */ 169 setnilvalue2s(L1->stack.p + i); /* erase new stack */
170 L1->stack_last.p = L1->stack.p + BASIC_STACK_SIZE; 170 L1->stack_last.p = L1->stack.p + BASIC_STACK_SIZE;
171 /* initialize first ci */ 171 /* initialize first ci */
172 resetCI(L1); 172 resetCI(L1);
diff --git a/ltests.c b/ltests.c
index 6ae5f472..2bf5545a 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1145,7 +1145,7 @@ static int table_query (lua_State *L) {
1145 if (!tagisempty(*getArrTag(t, i))) 1145 if (!tagisempty(*getArrTag(t, i)))
1146 arr2obj(t, cast_uint(i), s2v(L->top.p)); 1146 arr2obj(t, cast_uint(i), s2v(L->top.p));
1147 else 1147 else
1148 setnilvalue(s2v(L->top.p)); 1148 setnilvalue2s(L->top.p);
1149 api_incr_top(L); 1149 api_incr_top(L);
1150 lua_pushnil(L); 1150 lua_pushnil(L);
1151 } 1151 }
diff --git a/ltm.c b/ltm.c
index f2a373f8..cfe90e30 100644
--- a/ltm.c
+++ b/ltm.c
@@ -262,7 +262,7 @@ static void buildhiddenargs (lua_State *L, CallInfo *ci, const Proto *p,
262 /* move fixed parameters to after the copied function */ 262 /* move fixed parameters to after the copied function */
263 for (i = 1; i <= nfixparams; i++) { 263 for (i = 1; i <= nfixparams; i++) {
264 setobjs2s(L, L->top.p++, ci->func.p + i); 264 setobjs2s(L, L->top.p++, ci->func.p + i);
265 setnilvalue(s2v(ci->func.p + i)); /* erase original parameter (for GC) */ 265 setnilvalue2s(ci->func.p + i); /* erase original parameter (for GC) */
266 } 266 }
267 ci->func.p += totalargs + 1; /* 'func' now lives after hidden arguments */ 267 ci->func.p += totalargs + 1; /* 'func' now lives after hidden arguments */
268 ci->top.p += totalargs + 1; 268 ci->top.p += totalargs + 1;
@@ -283,7 +283,7 @@ void luaT_adjustvarargs (lua_State *L, CallInfo *ci, const Proto *p) {
283 lua_assert(p->flag & PF_VAHID); 283 lua_assert(p->flag & PF_VAHID);
284 buildhiddenargs(L, ci, p, totalargs, nfixparams, nextra); 284 buildhiddenargs(L, ci, p, totalargs, nfixparams, nextra);
285 /* set vararg parameter to nil */ 285 /* set vararg parameter to nil */
286 setnilvalue(s2v(ci->func.p + nfixparams + 1)); 286 setnilvalue2s(ci->func.p + nfixparams + 1);
287 lua_assert(L->top.p <= ci->top.p && ci->top.p <= L->stack_last.p); 287 lua_assert(L->top.p <= ci->top.p && ci->top.p <= L->stack_last.p);
288 } 288 }
289} 289}
@@ -307,7 +307,7 @@ void luaT_getvararg (CallInfo *ci, StkId ra, TValue *rc) {
307 return; 307 return;
308 } 308 }
309 } 309 }
310 setnilvalue(s2v(ra)); /* else produce nil */ 310 setnilvalue2s(ra); /* else produce nil */
311} 311}
312 312
313 313
@@ -355,10 +355,10 @@ void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted,
355 for (i = 0; i < touse; i++) { 355 for (i = 0; i < touse; i++) {
356 lu_byte tag = luaH_getint(h, i + 1, s2v(where + i)); 356 lu_byte tag = luaH_getint(h, i + 1, s2v(where + i));
357 if (tagisempty(tag)) 357 if (tagisempty(tag))
358 setnilvalue(s2v(where + i)); 358 setnilvalue2s(where + i);
359 } 359 }
360 } 360 }
361 for (; i < wanted; i++) /* complete required results with nil */ 361 for (; i < wanted; i++) /* complete required results with nil */
362 setnilvalue(s2v(where + i)); 362 setnilvalue2s(where + i);
363} 363}
364 364
diff --git a/lvm.c b/lvm.c
index 96ae1639..f9e87b61 100644
--- a/lvm.c
+++ b/lvm.c
@@ -303,7 +303,7 @@ lu_byte luaV_finishget (lua_State *L, const TValue *t, TValue *key,
303 else { /* 't' is a table */ 303 else { /* 't' is a table */
304 tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */ 304 tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */
305 if (tm == NULL) { /* no metamethod? */ 305 if (tm == NULL) { /* no metamethod? */
306 setnilvalue(s2v(val)); /* result is nil */ 306 setnilvalue2s(val); /* result is nil */
307 return LUA_VNIL; 307 return LUA_VNIL;
308 } 308 }
309 /* else will try the metamethod */ 309 /* else will try the metamethod */