diff options
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 36 |
1 files changed, 15 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.170 2014/05/13 19:40:28 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.171 2014/06/10 17:41:38 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -207,7 +207,8 @@ static int testobjref (global_State *g, GCObject *f, GCObject *t) { | |||
207 | return r1; | 207 | return r1; |
208 | } | 208 | } |
209 | 209 | ||
210 | #define checkobjref(g,f,t) lua_assert(testobjref(g,f,obj2gco(t))) | 210 | #define checkobjref(g,f,t) \ |
211 | lua_assert((t) == NULL || testobjref(g,f,obj2gco(t))) | ||
211 | 212 | ||
212 | 213 | ||
213 | static void checkvalref (global_State *g, GCObject *f, const TValue *t) { | 214 | static void checkvalref (global_State *g, GCObject *f, const TValue *t) { |
@@ -220,8 +221,7 @@ static void checktable (global_State *g, Table *h) { | |||
220 | int i; | 221 | int i; |
221 | Node *n, *limit = gnode(h, sizenode(h)); | 222 | Node *n, *limit = gnode(h, sizenode(h)); |
222 | GCObject *hgc = obj2gco(h); | 223 | GCObject *hgc = obj2gco(h); |
223 | if (h->metatable) | 224 | checkobjref(g, hgc, h->metatable); |
224 | checkobjref(g, hgc, h->metatable); | ||
225 | for (i = 0; i < h->sizearray; i++) | 225 | for (i = 0; i < h->sizearray; i++) |
226 | checkvalref(g, hgc, &h->array[i]); | 226 | checkvalref(g, hgc, &h->array[i]); |
227 | for (n = gnode(h, 0); n < limit; n++) { | 227 | for (n = gnode(h, 0); n < limit; n++) { |
@@ -241,24 +241,18 @@ static void checktable (global_State *g, Table *h) { | |||
241 | static void checkproto (global_State *g, Proto *f) { | 241 | static void checkproto (global_State *g, Proto *f) { |
242 | int i; | 242 | int i; |
243 | GCObject *fgc = obj2gco(f); | 243 | GCObject *fgc = obj2gco(f); |
244 | if (f->cache) checkobjref(g, fgc, f->cache); | 244 | checkobjref(g, fgc, f->cache); |
245 | if (f->source) checkobjref(g, fgc, f->source); | 245 | checkobjref(g, fgc, f->source); |
246 | for (i=0; i<f->sizek; i++) { | 246 | for (i=0; i<f->sizek; i++) { |
247 | if (ttisstring(f->k+i)) | 247 | if (ttisstring(f->k+i)) |
248 | checkobjref(g, fgc, rawtsvalue(f->k+i)); | 248 | checkobjref(g, fgc, rawtsvalue(f->k+i)); |
249 | } | 249 | } |
250 | for (i=0; i<f->sizeupvalues; i++) { | 250 | for (i=0; i<f->sizeupvalues; i++) |
251 | if (f->upvalues[i].name) | 251 | checkobjref(g, fgc, f->upvalues[i].name); |
252 | checkobjref(g, fgc, f->upvalues[i].name); | 252 | for (i=0; i<f->sizep; i++) |
253 | } | 253 | checkobjref(g, fgc, f->p[i]); |
254 | for (i=0; i<f->sizep; i++) { | 254 | for (i=0; i<f->sizelocvars; i++) |
255 | if (f->p[i]) | 255 | checkobjref(g, fgc, f->locvars[i].varname); |
256 | checkobjref(g, fgc, f->p[i]); | ||
257 | } | ||
258 | for (i=0; i<f->sizelocvars; i++) { | ||
259 | if (f->locvars[i].varname) | ||
260 | checkobjref(g, fgc, f->locvars[i].varname); | ||
261 | } | ||
262 | } | 256 | } |
263 | 257 | ||
264 | 258 | ||
@@ -274,7 +268,7 @@ static void checkCclosure (global_State *g, CClosure *cl) { | |||
274 | static void checkLclosure (global_State *g, LClosure *cl) { | 268 | static void checkLclosure (global_State *g, LClosure *cl) { |
275 | GCObject *clgc = obj2gco(cl); | 269 | GCObject *clgc = obj2gco(cl); |
276 | int i; | 270 | int i; |
277 | if (cl->p) checkobjref(g, clgc, cl->p); | 271 | checkobjref(g, clgc, cl->p); |
278 | for (i=0; i<cl->nupvalues; i++) { | 272 | for (i=0; i<cl->nupvalues; i++) { |
279 | UpVal *uv = cl->upvals[i]; | 273 | UpVal *uv = cl->upvals[i]; |
280 | if (uv) { | 274 | if (uv) { |
@@ -324,9 +318,9 @@ static void checkobject (global_State *g, GCObject *o, int maybedead) { | |||
324 | case LUA_TUSERDATA: { | 318 | case LUA_TUSERDATA: { |
325 | TValue uservalue; | 319 | TValue uservalue; |
326 | Table *mt = gco2u(o)->metatable; | 320 | Table *mt = gco2u(o)->metatable; |
327 | if (mt) checkobjref(g, o, mt); | 321 | checkobjref(g, o, mt); |
328 | getuservalue(g->mainthread, rawgco2u(o), &uservalue); | 322 | getuservalue(g->mainthread, rawgco2u(o), &uservalue); |
329 | checkobjref(g, o, &uservalue); | 323 | checkvalref(g, o, &uservalue); |
330 | break; | 324 | break; |
331 | } | 325 | } |
332 | case LUA_TTABLE: { | 326 | case LUA_TTABLE: { |