aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-18 09:17:54 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-18 09:17:54 -0300
commit56137d58ff7abe8cb22ee3469366e08888c84f28 (patch)
tree6769e3c2403a69cf3f0d6dbf6fb4acb7442367e0 /ltests.c
parent9aec500a2691d2b13c307d143868c8a4fab33220 (diff)
downloadlua-56137d58ff7abe8cb22ee3469366e08888c84f28.tar.gz
lua-56137d58ff7abe8cb22ee3469366e08888c84f28.tar.bz2
lua-56137d58ff7abe8cb22ee3469366e08888c84f28.zip
added check for conversion 'obj2gco' (and corrections for small
problems detected by this check)
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/ltests.c b/ltests.c
index f054b2f0..13cfa043 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.176 2014/07/17 13:53:37 roberto Exp roberto $ 2** $Id: ltests.c,v 2.177 2014/07/17 17:27:49 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,10 +207,11 @@ 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) checkobjref_(g,f,obj2gco(t)) 210#define checkobjref(g,f,t) \
211static void checkobjref_ (global_State *g, GCObject *f, GCObject *t) { 211 { if (t) lua_longassert(testobjref(g,f,obj2gco(t))); }
212 lua_assert((t) == NULL || testobjref(g,f,obj2gco(t))); 212
213} 213#define checkstrref(g,f,t) \
214 { if (t) lua_longassert(testobjref(g,f,ts2gco(t))); }
214 215
215 216
216static void checkvalref (global_State *g, GCObject *f, const TValue *t) { 217static void checkvalref (global_State *g, GCObject *f, const TValue *t) {
@@ -244,17 +245,17 @@ static void checkproto (global_State *g, Proto *f) {
244 int i; 245 int i;
245 GCObject *fgc = obj2gco(f); 246 GCObject *fgc = obj2gco(f);
246 checkobjref(g, fgc, f->cache); 247 checkobjref(g, fgc, f->cache);
247 checkobjref(g, fgc, f->source); 248 checkstrref(g, fgc, f->source);
248 for (i=0; i<f->sizek; i++) { 249 for (i=0; i<f->sizek; i++) {
249 if (ttisstring(f->k+i)) 250 if (ttisstring(f->k + i))
250 checkobjref(g, fgc, rawtsvalue(f->k+i)); 251 checkobjref(g, fgc, tsvalue(f->k + i));
251 } 252 }
252 for (i=0; i<f->sizeupvalues; i++) 253 for (i=0; i<f->sizeupvalues; i++)
253 checkobjref(g, fgc, f->upvalues[i].name); 254 checkstrref(g, fgc, f->upvalues[i].name);
254 for (i=0; i<f->sizep; i++) 255 for (i=0; i<f->sizep; i++)
255 checkobjref(g, fgc, f->p[i]); 256 checkobjref(g, fgc, f->p[i]);
256 for (i=0; i<f->sizelocvars; i++) 257 for (i=0; i<f->sizelocvars; i++)
257 checkobjref(g, fgc, f->locvars[i].varname); 258 checkstrref(g, fgc, f->locvars[i].varname);
258} 259}
259 260
260 261