Browse Source

`TObject' renamed to `TValue' + other name changes and better assertions
for incremental garbage collection

Roberto Ierusalimschy 21 năm trước cách đây
mục cha
commit
47fc57a252
29 tập tin đã thay đổi với 456 bổ sung441 xóa
  1. 56 55
      lapi.c
  2. 2 2
      lapi.h
  3. 13 11
      lcode.c
  4. 10 10
      ldebug.c
  5. 4 4
      ldebug.h
  6. 18 17
      ldo.c
  7. 3 3
      ldo.h
  8. 3 3
      ldump.c
  9. 10 10
      lfunc.c
  10. 4 4
      lfunc.h
  11. 52 52
      lgc.c
  12. 5 5
      lgc.h
  13. 2 2
      llex.c
  14. 5 5
      lobject.c
  15. 55 48
      lobject.h
  16. 4 4
      lparser.c
  17. 10 9
      lstate.c
  18. 14 12
      lstate.h
  19. 5 5
      lstring.c
  20. 36 36
      ltable.c
  21. 8 8
      ltable.h
  22. 4 4
      ltests.c
  23. 1 2
      ltests.h
  24. 5 5
      ltm.c
  25. 3 3
      ltm.h
  26. 13 11
      lundump.c
  27. 79 79
      lvm.c
  28. 6 6
      lvm.h
  29. 26 26
      makefile

+ 56 - 55
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 1.250 2003/12/01 18:22:56 roberto Exp roberto $
+** $Id: lapi.c,v 1.251 2003/12/09 16:56:11 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -41,7 +41,7 @@ const char lua_ident[] =
 
 
 
 
 #ifndef api_check
 #ifndef api_check
-#define api_check(L, o)		/*{ assert(o); }*/
+#define api_check(L, o)		lua_assert(o)
 #endif
 #endif
 
 
 #define api_checknelems(L, n)	api_check(L, (n) <= (L->top - L->base))
 #define api_checknelems(L, n)	api_check(L, (n) <= (L->top - L->base))
@@ -52,11 +52,11 @@ const char lua_ident[] =
 
 
 
 
 
 
-static TObject *luaA_index (lua_State *L, int idx) {
+static TValue *luaA_index (lua_State *L, int idx) {
   if (idx > 0) {
   if (idx > 0) {
-    TObject *o = L->base + (idx - 1);
+    TValue *o = L->base + (idx - 1);
     api_check(L, idx <= L->stack_last - L->base);
     api_check(L, idx <= L->stack_last - L->base);
-    if (o >= L->top) return cast(TObject *, &luaO_nilobject);
+    if (o >= L->top) return cast(TValue *, &luaO_nilobject);
     else return o;
     else return o;
   }
   }
   else if (idx > LUA_REGISTRYINDEX) {
   else if (idx > LUA_REGISTRYINDEX) {
@@ -67,19 +67,19 @@ static TObject *luaA_index (lua_State *L, int idx) {
     case LUA_REGISTRYINDEX: return registry(L);
     case LUA_REGISTRYINDEX: return registry(L);
     case LUA_GLOBALSINDEX: return gt(L);
     case LUA_GLOBALSINDEX: return gt(L);
     default: {
     default: {
-      TObject *func = (L->base - 1);
+      TValue *func = (L->base - 1);
       idx = LUA_GLOBALSINDEX - idx;
       idx = LUA_GLOBALSINDEX - idx;
       lua_assert(iscfunction(func));
       lua_assert(iscfunction(func));
       return (idx <= clvalue(func)->c.nupvalues)
       return (idx <= clvalue(func)->c.nupvalues)
                 ? &clvalue(func)->c.upvalue[idx-1]
                 ? &clvalue(func)->c.upvalue[idx-1]
-                : cast(TObject *, &luaO_nilobject);
+                : cast(TValue *, &luaO_nilobject);
     }
     }
   }
   }
 }
 }
 
 
 
 
-void luaA_pushobject (lua_State *L, const TObject *o) {
-  setobj2s(L->top, o);
+void luaA_pushobject (lua_State *L, const TValue *o) {
+  setobj2s(L, L->top, o);
   incr_top(L);
   incr_top(L);
 }
 }
 
 
@@ -107,7 +107,7 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
   api_checknelems(from, n);
   api_checknelems(from, n);
   from->top -= n;
   from->top -= n;
   for (i = 0; i < n; i++) {
   for (i = 0; i < n; i++) {
-    setobj2s(to->top, from->top + i);
+    setobj2s(to, to->top, from->top + i);
     api_incr_top(to);
     api_incr_top(to);
   }
   }
   lua_unlock(to);
   lua_unlock(to);
@@ -129,7 +129,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) {
   lua_lock(L);
   lua_lock(L);
   luaC_checkGC(L);
   luaC_checkGC(L);
   L1 = luaE_newthread(L);
   L1 = luaE_newthread(L);
-  setthvalue(L->top, L1);
+  setthvalue(L, L->top, L1);
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
   lua_userstateopen(L1);
   lua_userstateopen(L1);
@@ -169,7 +169,7 @@ LUA_API void lua_remove (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
   p = luaA_index(L, idx);
   p = luaA_index(L, idx);
   api_checkvalidindex(L, p);
   api_checkvalidindex(L, p);
-  while (++p < L->top) setobjs2s(p-1, p);
+  while (++p < L->top) setobjs2s(L, p-1, p);
   L->top--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -181,8 +181,8 @@ LUA_API void lua_insert (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
   p = luaA_index(L, idx);
   p = luaA_index(L, idx);
   api_checkvalidindex(L, p);
   api_checkvalidindex(L, p);
-  for (q = L->top; q>p; q--) setobjs2s(q, q-1);
-  setobjs2s(p, L->top);
+  for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
+  setobjs2s(L, p, L->top);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
@@ -193,7 +193,7 @@ LUA_API void lua_replace (lua_State *L, int idx) {
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   o = luaA_index(L, idx);
   o = luaA_index(L, idx);
   api_checkvalidindex(L, o);
   api_checkvalidindex(L, o);
-  setobj(o, L->top - 1);  /* write barrier???? */
+  setobj(L, o, L->top - 1);  /* write barrier???? */
   L->top--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -201,7 +201,7 @@ LUA_API void lua_replace (lua_State *L, int idx) {
 
 
 LUA_API void lua_pushvalue (lua_State *L, int idx) {
 LUA_API void lua_pushvalue (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
-  setobj2s(L->top, luaA_index(L, idx));
+  setobj2s(L, L->top, luaA_index(L, idx));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -232,8 +232,8 @@ LUA_API int lua_iscfunction (lua_State *L, int idx) {
 
 
 
 
 LUA_API int lua_isnumber (lua_State *L, int idx) {
 LUA_API int lua_isnumber (lua_State *L, int idx) {
-  TObject n;
-  const TObject *o = luaA_index(L, idx);
+  TValue n;
+  const TValue *o = luaA_index(L, idx);
   return tonumber(o, &n);
   return tonumber(o, &n);
 }
 }
 
 
@@ -245,7 +245,7 @@ LUA_API int lua_isstring (lua_State *L, int idx) {
 
 
 
 
 LUA_API int lua_isuserdata (lua_State *L, int idx) {
 LUA_API int lua_isuserdata (lua_State *L, int idx) {
-  const TObject *o = luaA_index(L, idx);
+  const TValue *o = luaA_index(L, idx);
   return (ttisuserdata(o) || ttislightuserdata(o));
   return (ttisuserdata(o) || ttislightuserdata(o));
 }
 }
 
 
@@ -286,8 +286,8 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
 
 
 
 
 LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
 LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
-  TObject n;
-  const TObject *o = luaA_index(L, idx);
+  TValue n;
+  const TValue *o = luaA_index(L, idx);
   if (tonumber(o, &n))
   if (tonumber(o, &n))
     return nvalue(o);
     return nvalue(o);
   else
   else
@@ -296,8 +296,8 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
 
 
 
 
 LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
 LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
-  TObject n;
-  const TObject *o = luaA_index(L, idx);
+  TValue n;
+  const TValue *o = luaA_index(L, idx);
   if (tonumber(o, &n)) {
   if (tonumber(o, &n)) {
     lua_Integer res;
     lua_Integer res;
     lua_number2integer(res, nvalue(o));
     lua_number2integer(res, nvalue(o));
@@ -309,7 +309,7 @@ LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
 
 
 
 
 LUA_API int lua_toboolean (lua_State *L, int idx) {
 LUA_API int lua_toboolean (lua_State *L, int idx) {
-  const TObject *o = luaA_index(L, idx);
+  const TValue *o = luaA_index(L, idx);
   return !l_isfalse(o);
   return !l_isfalse(o);
 }
 }
 
 
@@ -332,11 +332,11 @@ LUA_API const char *lua_tostring (lua_State *L, int idx) {
 LUA_API size_t lua_strlen (lua_State *L, int idx) {
 LUA_API size_t lua_strlen (lua_State *L, int idx) {
   StkId o = luaA_index(L, idx);
   StkId o = luaA_index(L, idx);
   if (ttisstring(o))
   if (ttisstring(o))
-    return tsvalue(o)->tsv.len;
+    return tsvalue(o)->len;
   else {
   else {
     size_t l;
     size_t l;
     lua_lock(L);  /* `luaV_tostring' may create a new string */
     lua_lock(L);  /* `luaV_tostring' may create a new string */
-    l = (luaV_tostring(L, o) ? tsvalue(o)->tsv.len : 0);
+    l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
     lua_unlock(L);
     lua_unlock(L);
     return l;
     return l;
   }
   }
@@ -352,7 +352,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
 LUA_API void *lua_touserdata (lua_State *L, int idx) {
 LUA_API void *lua_touserdata (lua_State *L, int idx) {
   StkId o = luaA_index(L, idx);
   StkId o = luaA_index(L, idx);
   switch (ttype(o)) {
   switch (ttype(o)) {
-    case LUA_TUSERDATA: return (uvalue(o) + 1);
+    case LUA_TUSERDATA: return (rawuvalue(o) + 1);
     case LUA_TLIGHTUSERDATA: return pvalue(o);
     case LUA_TLIGHTUSERDATA: return pvalue(o);
     default: return NULL;
     default: return NULL;
   }
   }
@@ -412,7 +412,7 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
 LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
 LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
   lua_lock(L);
   lua_lock(L);
   luaC_checkGC(L);
   luaC_checkGC(L);
-  setsvalue2s(L->top, luaS_newlstr(L, s, len));
+  setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -459,8 +459,9 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
   cl->c.f = fn;
   cl->c.f = fn;
   L->top -= n;
   L->top -= n;
   while (n--)
   while (n--)
-    setobj2n(&cl->c.upvalue[n], L->top+n);
-  setclvalue(L->top, cl);
+    setobj2n(L, &cl->c.upvalue[n], L->top+n);
+  setclvalue(L, L->top, cl);
+  lua_assert(iswhite(obj2gco(cl)));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -500,11 +501,11 @@ LUA_API void lua_gettable (lua_State *L, int idx) {
 
 
 LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
 LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
   StkId t;
   StkId t;
-  TObject key;
+  TValue key;
   lua_lock(L);
   lua_lock(L);
   t = luaA_index(L, idx);
   t = luaA_index(L, idx);
   api_checkvalidindex(L, t);
   api_checkvalidindex(L, t);
-  setsvalue(&key, luaS_new(L, k));
+  setsvalue(L, &key, luaS_new(L, k));
   luaV_gettable(L, t, &key, L->top);
   luaV_gettable(L, t, &key, L->top);
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
@@ -516,7 +517,7 @@ LUA_API void lua_rawget (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
   t = luaA_index(L, idx);
   t = luaA_index(L, idx);
   api_check(L, ttistable(t));
   api_check(L, ttistable(t));
-  setobj2s(L->top - 1, luaH_get(hvalue(t), L->top - 1));
+  setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
@@ -526,7 +527,7 @@ LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
   lua_lock(L);
   lua_lock(L);
   o = luaA_index(L, idx);
   o = luaA_index(L, idx);
   api_check(L, ttistable(o));
   api_check(L, ttistable(o));
-  setobj2s(L->top, luaH_getnum(hvalue(o), n));
+  setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -535,14 +536,14 @@ LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
 LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
 LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
   lua_lock(L);
   lua_lock(L);
   luaC_checkGC(L);
   luaC_checkGC(L);
-  sethvalue(L->top, luaH_new(L, narray, luaO_log2(nrec) + 1));
+  sethvalue(L, L->top, luaH_new(L, narray, luaO_log2(nrec) + 1));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
 LUA_API int lua_getmetatable (lua_State *L, int objindex) {
 LUA_API int lua_getmetatable (lua_State *L, int objindex) {
-  const TObject *obj;
+  const TValue *obj;
   Table *mt = NULL;
   Table *mt = NULL;
   int res;
   int res;
   lua_lock(L);
   lua_lock(L);
@@ -552,13 +553,13 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
       mt = hvalue(obj)->metatable;
       mt = hvalue(obj)->metatable;
       break;
       break;
     case LUA_TUSERDATA:
     case LUA_TUSERDATA:
-      mt = uvalue(obj)->uv.metatable;
+      mt = uvalue(obj)->metatable;
       break;
       break;
   }
   }
   if (mt == NULL)
   if (mt == NULL)
     res = 0;
     res = 0;
   else {
   else {
-    sethvalue(L->top, mt);
+    sethvalue(L, L->top, mt);
     api_incr_top(L);
     api_incr_top(L);
     res = 1;
     res = 1;
   }
   }
@@ -572,7 +573,7 @@ LUA_API void lua_getfenv (lua_State *L, int idx) {
   lua_lock(L);
   lua_lock(L);
   o = luaA_index(L, idx);
   o = luaA_index(L, idx);
   api_checkvalidindex(L, o);
   api_checkvalidindex(L, o);
-  setobj2s(L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L));
+  setobj2s(L, L->top, isLfunction(o) ? &clvalue(o)->l.g : gt(L));
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -597,12 +598,12 @@ LUA_API void lua_settable (lua_State *L, int idx) {
 
 
 LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
 LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
   StkId t;
   StkId t;
-  TObject key;
+  TValue key;
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   t = luaA_index(L, idx);
   t = luaA_index(L, idx);
   api_checkvalidindex(L, t);
   api_checkvalidindex(L, t);
-  setsvalue(&key, luaS_new(L, k));
+  setsvalue(L, &key, luaS_new(L, k));
   luaV_settable(L, t, &key, L->top - 1);
   luaV_settable(L, t, &key, L->top - 1);
   L->top--;  /* pop value */
   L->top--;  /* pop value */
   lua_unlock(L);
   lua_unlock(L);
@@ -615,7 +616,7 @@ LUA_API void lua_rawset (lua_State *L, int idx) {
   api_checknelems(L, 2);
   api_checknelems(L, 2);
   t = luaA_index(L, idx);
   t = luaA_index(L, idx);
   api_check(L, ttistable(t));
   api_check(L, ttistable(t));
-  setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1);
+  setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
   luaC_barrier(L, hvalue(t), L->top-1);
   luaC_barrier(L, hvalue(t), L->top-1);
   L->top -= 2;
   L->top -= 2;
   lua_unlock(L);
   lua_unlock(L);
@@ -628,7 +629,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   o = luaA_index(L, idx);
   o = luaA_index(L, idx);
   api_check(L, ttistable(o));
   api_check(L, ttistable(o));
-  setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1);
+  setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
   luaC_barrier(L, hvalue(o), L->top-1);
   luaC_barrier(L, hvalue(o), L->top-1);
   L->top--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);
@@ -636,7 +637,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
 
 
 
 
 LUA_API int lua_setmetatable (lua_State *L, int objindex) {
 LUA_API int lua_setmetatable (lua_State *L, int objindex) {
-  TObject *obj;
+  TValue *obj;
   Table *mt;
   Table *mt;
   int res = 1;
   int res = 1;
   lua_lock(L);
   lua_lock(L);
@@ -657,9 +658,9 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
       break;
       break;
     }
     }
     case LUA_TUSERDATA: {
     case LUA_TUSERDATA: {
-      uvalue(obj)->uv.metatable = mt;
+      uvalue(obj)->metatable = mt;
       if (mt)
       if (mt)
-        luaC_objbarrier(L, uvalue(obj), mt);
+        luaC_objbarrier(L, rawuvalue(obj), mt);
       break;
       break;
     }
     }
     default: {
     default: {
@@ -756,7 +757,7 @@ static void f_Ccall (lua_State *L, void *ud) {
   Closure *cl;
   Closure *cl;
   cl = luaF_newCclosure(L, 0);
   cl = luaF_newCclosure(L, 0);
   cl->c.f = c->func;
   cl->c.f = c->func;
-  setclvalue(L->top, cl);  /* push function */
+  setclvalue(L, L->top, cl);  /* push function */
   incr_top(L);
   incr_top(L);
   setpvalue(L->top, c->ud);  /* push only argument */
   setpvalue(L->top, c->ud);  /* push only argument */
   incr_top(L);
   incr_top(L);
@@ -791,7 +792,7 @@ LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
 
 
 LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) {
 LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) {
   int status;
   int status;
-  TObject *o;
+  TValue *o;
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   o = L->top - 1;
   o = L->top - 1;
@@ -885,7 +886,7 @@ LUA_API void lua_concat (lua_State *L, int n) {
     L->top -= (n-1);
     L->top -= (n-1);
   }
   }
   else if (n == 0) {  /* push empty string */
   else if (n == 0) {  /* push empty string */
-    setsvalue2s(L->top, luaS_newlstr(L, NULL, 0));
+    setsvalue2s(L, L->top, luaS_newlstr(L, NULL, 0));
     api_incr_top(L);
     api_incr_top(L);
   }
   }
   /* else n == 1; nothing to do */
   /* else n == 1; nothing to do */
@@ -904,7 +905,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
   lua_lock(L);
   lua_lock(L);
   luaC_checkGC(L);
   luaC_checkGC(L);
   u = luaS_newudata(L, size);
   u = luaS_newudata(L, size);
-  setuvalue(L->top, u);
+  setuvalue(L, L->top, u);
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
   return u + 1;
   return u + 1;
@@ -913,7 +914,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
 
 
 
 
 
 
-static const char *aux_upvalue (lua_State *L, StkId fi, int n, TObject **val) {
+static const char *aux_upvalue (lua_State *L, StkId fi, int n, TValue **val) {
   Closure *f;
   Closure *f;
   if (!ttisfunction(fi)) return NULL;
   if (!ttisfunction(fi)) return NULL;
   f = clvalue(fi);
   f = clvalue(fi);
@@ -933,11 +934,11 @@ static const char *aux_upvalue (lua_State *L, StkId fi, int n, TObject **val) {
 
 
 LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
 LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
   const char *name;
   const char *name;
-  TObject *val;
+  TValue *val;
   lua_lock(L);
   lua_lock(L);
   name = aux_upvalue(L, luaA_index(L, funcindex), n, &val);
   name = aux_upvalue(L, luaA_index(L, funcindex), n, &val);
   if (name) {
   if (name) {
-    setobj2s(L->top, val);
+    setobj2s(L, L->top, val);
     api_incr_top(L);
     api_incr_top(L);
   }
   }
   lua_unlock(L);
   lua_unlock(L);
@@ -947,7 +948,7 @@ LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
 
 
 LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
 LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
   const char *name;
   const char *name;
-  TObject *val;
+  TValue *val;
   StkId fi;
   StkId fi;
   lua_lock(L);
   lua_lock(L);
   fi = luaA_index(L, funcindex);
   fi = luaA_index(L, funcindex);
@@ -955,7 +956,7 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
   name = aux_upvalue(L, fi, n, &val);
   name = aux_upvalue(L, fi, n, &val);
   if (name) {
   if (name) {
     L->top--;
     L->top--;
-    setobj(val, L->top);
+    setobj(L, val, L->top);
     luaC_barrier(L, clvalue(fi), L->top);
     luaC_barrier(L, clvalue(fi), L->top);
   }
   }
   lua_unlock(L);
   lua_unlock(L);

+ 2 - 2
lapi.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.h,v 1.20 2000/08/31 14:08:27 roberto Exp roberto $
+** $Id: lapi.h,v 1.21 2002/03/04 21:29:41 roberto Exp roberto $
 ** Auxiliary functions from Lua API
 ** Auxiliary functions from Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -11,6 +11,6 @@
 #include "lobject.h"
 #include "lobject.h"
 
 
 
 
-void luaA_pushobject (lua_State *L, const TObject *o);
+void luaA_pushobject (lua_State *L, const TValue *o);
 
 
 #endif
 #endif

+ 13 - 11
lcode.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lcode.c,v 1.120 2003/11/19 19:59:18 roberto Exp roberto $
+** $Id: lcode.c,v 1.121 2003/12/09 16:56:11 roberto Exp roberto $
 ** Code generator for Lua
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -207,8 +207,9 @@ static void freeexp (FuncState *fs, expdesc *e) {
 }
 }
 
 
 
 
-static int addk (FuncState *fs, TObject *k, TObject *v) {
-  TObject *idx = luaH_set(fs->L, fs->h, k);
+static int addk (FuncState *fs, TValue *k, TValue *v) {
+  lua_State *L = fs->L;
+  TValue *idx = luaH_set(L, fs->h, k);
   Proto *f = fs->f;
   Proto *f = fs->f;
   int oldsize = f->sizek;
   int oldsize = f->sizek;
   if (ttisnumber(idx)) {
   if (ttisnumber(idx)) {
@@ -217,34 +218,35 @@ static int addk (FuncState *fs, TObject *k, TObject *v) {
   }
   }
   else {  /* constant not found; create a new entry */
   else {  /* constant not found; create a new entry */
     setnvalue(idx, cast(lua_Number, fs->nk));
     setnvalue(idx, cast(lua_Number, fs->nk));
-    luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
+    luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
                     MAXARG_Bx, "constant table overflow");
                     MAXARG_Bx, "constant table overflow");
     while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
     while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
-    setobj(&f->k[fs->nk], v);
-    luaC_barrier(fs->L, f, v);
+    setobj(L, &f->k[fs->nk], v);
+    luaC_barrier(L, f, v);
     return fs->nk++;
     return fs->nk++;
   }
   }
 }
 }
 
 
 
 
 int luaK_stringK (FuncState *fs, TString *s) {
 int luaK_stringK (FuncState *fs, TString *s) {
-  TObject o;
-  setsvalue(&o, s);
+  TValue o;
+  setsvalue(fs->L, &o, s);
   return addk(fs, &o, &o);
   return addk(fs, &o, &o);
 }
 }
 
 
 
 
 int luaK_numberK (FuncState *fs, lua_Number r) {
 int luaK_numberK (FuncState *fs, lua_Number r) {
-  TObject o;
+  TValue o;
   setnvalue(&o, r);
   setnvalue(&o, r);
   return addk(fs, &o, &o);
   return addk(fs, &o, &o);
 }
 }
 
 
 
 
 static int nil_constant (FuncState *fs) {
 static int nil_constant (FuncState *fs) {
-  TObject k, v;
+  TValue k, v;
   setnilvalue(&v);
   setnilvalue(&v);
-  sethvalue(&k, fs->h);  /* cannot use nil as key; instead use table itself */
+  /* cannot use nil as key; instead use table itself to represent nil */
+  sethvalue(fs->L, &k, fs->h);
   return addk(fs, &k, &v);
   return addk(fs, &k, &v);
 }
 }
 
 

+ 10 - 10
ldebug.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldebug.c,v 1.156 2003/10/02 19:21:09 roberto Exp roberto $
+** $Id: ldebug.c,v 1.157 2003/10/20 18:42:28 roberto Exp roberto $
 ** Debug Interface
 ** Debug Interface
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -136,7 +136,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
     if (!name || name[0] == '(')  /* `(' starts private locals */
     if (!name || name[0] == '(')  /* `(' starts private locals */
       name = NULL;
       name = NULL;
     else
     else
-      setobjs2s(ci->base+(n-1), L->top);
+      setobjs2s(L, ci->base+(n-1), L->top);
   }
   }
   lua_unlock(L);
   lua_unlock(L);
   return name;
   return name;
@@ -196,7 +196,7 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
         break;
         break;
       }
       }
       case 'f': {
       case 'f': {
-        setobj2s(L->top, f);
+        setobj2s(L, L->top, f);
         break;
         break;
       }
       }
       default: status = 0;  /* invalid option */
       default: status = 0;  /* invalid option */
@@ -484,7 +484,7 @@ static const char *getfuncname (CallInfo *ci, const char **name) {
 
 
 
 
 /* only ANSI way to check whether a pointer points to an array */
 /* only ANSI way to check whether a pointer points to an array */
-static int isinstack (CallInfo *ci, const TObject *o) {
+static int isinstack (CallInfo *ci, const TValue *o) {
   StkId p;
   StkId p;
   for (p = ci->base; p < ci->top; p++)
   for (p = ci->base; p < ci->top; p++)
     if (o == p) return 1;
     if (o == p) return 1;
@@ -492,7 +492,7 @@ static int isinstack (CallInfo *ci, const TObject *o) {
 }
 }
 
 
 
 
-void luaG_typeerror (lua_State *L, const TObject *o, const char *op) {
+void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
   const char *name = NULL;
   const char *name = NULL;
   const char *t = luaT_typenames[ttype(o)];
   const char *t = luaT_typenames[ttype(o)];
   const char *kind = (isinstack(L->ci, o)) ?
   const char *kind = (isinstack(L->ci, o)) ?
@@ -512,15 +512,15 @@ void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
 }
 }
 
 
 
 
-void luaG_aritherror (lua_State *L, const TObject *p1, const TObject *p2) {
-  TObject temp;
+void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
+  TValue temp;
   if (luaV_tonumber(p1, &temp) == NULL)
   if (luaV_tonumber(p1, &temp) == NULL)
     p2 = p1;  /* first operand is wrong */
     p2 = p1;  /* first operand is wrong */
   luaG_typeerror(L, p2, "perform arithmetic on");
   luaG_typeerror(L, p2, "perform arithmetic on");
 }
 }
 
 
 
 
-int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) {
+int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
   const char *t1 = luaT_typenames[ttype(p1)];
   const char *t1 = luaT_typenames[ttype(p1)];
   const char *t2 = luaT_typenames[ttype(p2)];
   const char *t2 = luaT_typenames[ttype(p2)];
   if (t1[2] == t2[2])
   if (t1[2] == t2[2])
@@ -546,8 +546,8 @@ void luaG_errormsg (lua_State *L) {
   if (L->errfunc != 0) {  /* is there an error handling function? */
   if (L->errfunc != 0) {  /* is there an error handling function? */
     StkId errfunc = restorestack(L, L->errfunc);
     StkId errfunc = restorestack(L, L->errfunc);
     if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
     if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
-    setobjs2s(L->top, L->top - 1);  /* move argument */
-    setobjs2s(L->top - 1, errfunc);  /* push function */
+    setobjs2s(L, L->top, L->top - 1);  /* move argument */
+    setobjs2s(L, L->top - 1, errfunc);  /* push function */
     incr_top(L);
     incr_top(L);
     luaD_call(L, L->top - 2, 1);  /* call it */
     luaD_call(L, L->top - 2, 1);  /* call it */
   }
   }

+ 4 - 4
ldebug.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldebug.h,v 1.32 2002/11/18 11:01:55 roberto Exp $
+** $Id: ldebug.h,v 1.33 2003/07/16 20:49:02 roberto Exp roberto $
 ** Auxiliary functions from Debug Interface module
 ** Auxiliary functions from Debug Interface module
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -18,10 +18,10 @@
 #define resethookcount(L)	(L->hookcount = L->basehookcount)
 #define resethookcount(L)	(L->hookcount = L->basehookcount)
 
 
 
 
-void luaG_typeerror (lua_State *L, const TObject *o, const char *opname);
+void luaG_typeerror (lua_State *L, const TValue *o, const char *opname);
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
-void luaG_aritherror (lua_State *L, const TObject *p1, const TObject *p2);
-int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2);
+void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2);
+int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2);
 void luaG_runerror (lua_State *L, const char *fmt, ...);
 void luaG_runerror (lua_State *L, const char *fmt, ...);
 void luaG_errormsg (lua_State *L);
 void luaG_errormsg (lua_State *L);
 int luaG_checkcode (const Proto *pt);
 int luaG_checkcode (const Proto *pt);

+ 18 - 17
ldo.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldo.c,v 1.228 2003/10/20 17:42:41 roberto Exp roberto $
+** $Id: ldo.c,v 1.229 2003/11/11 16:34:17 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -64,16 +64,16 @@ struct lua_longjmp {
 static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
 static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
   switch (errcode) {
   switch (errcode) {
     case LUA_ERRMEM: {
     case LUA_ERRMEM: {
-      setsvalue2s(oldtop, luaS_newliteral(L, MEMERRMSG));
+      setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG));
       break;
       break;
     }
     }
     case LUA_ERRERR: {
     case LUA_ERRERR: {
-      setsvalue2s(oldtop, luaS_newliteral(L, "error in error handling"));
+      setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
       break;
       break;
     }
     }
     case LUA_ERRSYNTAX:
     case LUA_ERRSYNTAX:
     case LUA_ERRRUN: {
     case LUA_ERRRUN: {
-      setobjs2s(oldtop, L->top - 1);  /* error message on current top */
+      setobjs2s(L, oldtop, L->top - 1);  /* error message on current top */
       break;
       break;
     }
     }
   }
   }
@@ -118,12 +118,12 @@ static void restore_stack_limit (lua_State *L) {
 /* }====================================================== */
 /* }====================================================== */
 
 
 
 
-static void correctstack (lua_State *L, TObject *oldstack) {
+static void correctstack (lua_State *L, TValue *oldstack) {
   CallInfo *ci;
   CallInfo *ci;
   GCObject *up;
   GCObject *up;
   L->top = (L->top - oldstack) + L->stack;
   L->top = (L->top - oldstack) + L->stack;
   for (up = L->openupval; up != NULL; up = up->gch.next)
   for (up = L->openupval; up != NULL; up = up->gch.next)
-    gcotouv(up)->v = (gcotouv(up)->v - oldstack) + L->stack;
+    gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
   for (ci = L->base_ci; ci <= L->ci; ci++) {
   for (ci = L->base_ci; ci <= L->ci; ci++) {
     ci->top = (ci->top - oldstack) + L->stack;
     ci->top = (ci->top - oldstack) + L->stack;
     ci->base = (ci->base - oldstack) + L->stack;
     ci->base = (ci->base - oldstack) + L->stack;
@@ -133,8 +133,8 @@ static void correctstack (lua_State *L, TObject *oldstack) {
 
 
 
 
 void luaD_reallocstack (lua_State *L, int newsize) {
 void luaD_reallocstack (lua_State *L, int newsize) {
-  TObject *oldstack = L->stack;
-  luaM_reallocvector(L, L->stack, L->stacksize, newsize, TObject);
+  TValue *oldstack = L->stack;
+  luaM_reallocvector(L, L->stack, L->stacksize, newsize, TValue);
   L->stacksize = newsize;
   L->stacksize = newsize;
   L->stack_last = L->stack+newsize-1-EXTRA_STACK;
   L->stack_last = L->stack+newsize-1-EXTRA_STACK;
   correctstack(L, oldstack);
   correctstack(L, oldstack);
@@ -207,27 +207,28 @@ static void adjust_varargs (lua_State *L, int nfixargs, StkId base) {
   actual -= nfixargs;  /* number of extra arguments */
   actual -= nfixargs;  /* number of extra arguments */
   htab = luaH_new(L, actual, 1);  /* create `arg' table */
   htab = luaH_new(L, actual, 1);  /* create `arg' table */
   for (i=0; i<actual; i++)  /* put extra arguments into `arg' table */
   for (i=0; i<actual; i++)  /* put extra arguments into `arg' table */
-    setobj2n(luaH_setnum(L, htab, i+1), L->top - actual + i);
+    setobj2n(L, luaH_setnum(L, htab, i+1), L->top - actual + i);
   /* store counter in field `n' */
   /* store counter in field `n' */
   setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")),
   setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")),
                                  cast(lua_Number, actual));
                                  cast(lua_Number, actual));
   L->top -= actual;  /* remove extra elements from the stack */
   L->top -= actual;  /* remove extra elements from the stack */
-  sethvalue(L->top, htab);
+  sethvalue(L, L->top, htab);
+  lua_assert(iswhite(obj2gco(htab)));
   incr_top(L);
   incr_top(L);
 }
 }
 
 
 
 
 static StkId tryfuncTM (lua_State *L, StkId func) {
 static StkId tryfuncTM (lua_State *L, StkId func) {
-  const TObject *tm = luaT_gettmbyobj(L, func, TM_CALL);
+  const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
   StkId p;
   StkId p;
   ptrdiff_t funcr = savestack(L, func);
   ptrdiff_t funcr = savestack(L, func);
   if (!ttisfunction(tm))
   if (!ttisfunction(tm))
     luaG_typeerror(L, func, "call");
     luaG_typeerror(L, func, "call");
   /* Open a hole inside the stack at `func' */
   /* Open a hole inside the stack at `func' */
-  for (p = L->top; p > func; p--) setobjs2s(p, p-1);
+  for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
   incr_top(L);
   incr_top(L);
   func = restorestack(L, funcr);  /* previous call may change stack */
   func = restorestack(L, funcr);  /* previous call may change stack */
-  setobj2s(func, tm);  /* tag method is the new function to be called */
+  setobj2s(L, func, tm);  /* tag method is the new function to be called */
   return func;
   return func;
 }
 }
 
 
@@ -294,7 +295,7 @@ void luaD_poscall (lua_State *L, int wanted, StkId firstResult) {
   L->base = L->ci->base;  /* restore base */
   L->base = L->ci->base;  /* restore base */
   /* move results to correct place */
   /* move results to correct place */
   while (wanted != 0 && firstResult < L->top) {
   while (wanted != 0 && firstResult < L->top) {
-    setobjs2s(res++, firstResult++);
+    setobjs2s(L, res++, firstResult++);
     wanted--;
     wanted--;
   }
   }
   while (wanted-- > 0)
   while (wanted-- > 0)
@@ -354,7 +355,7 @@ static void resume (lua_State *L, void *ud) {
 
 
 static int resume_error (lua_State *L, const char *msg) {
 static int resume_error (lua_State *L, const char *msg) {
   L->top = L->ci->base;
   L->top = L->ci->base;
-  setsvalue2s(L->top, luaS_new(L, msg));
+  setsvalue2s(L, L->top, luaS_new(L, msg));
   incr_top(L);
   incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
   return LUA_ERRRUN;
   return LUA_ERRRUN;
@@ -400,7 +401,7 @@ LUA_API int lua_yield (lua_State *L, int nresults) {
     if (L->top - nresults > L->base) {  /* is there garbage in the stack? */
     if (L->top - nresults > L->base) {  /* is there garbage in the stack? */
       int i;
       int i;
       for (i=0; i<nresults; i++)  /* move down results */
       for (i=0; i<nresults; i++)  /* move down results */
-        setobjs2s(L->base + i, L->top - nresults + i);
+        setobjs2s(L, L->base + i, L->top - nresults + i);
       L->top = L->base + nresults;
       L->top = L->base + nresults;
     }
     }
   } /* else it's an yield inside a hook: nothing to do */
   } /* else it's an yield inside a hook: nothing to do */
@@ -457,7 +458,7 @@ static void f_parser (lua_State *L, void *ud) {
   cl->l.p = tf;
   cl->l.p = tf;
   for (i = 0; i < tf->nups; i++)  /* initialize eventual upvalues */
   for (i = 0; i < tf->nups; i++)  /* initialize eventual upvalues */
     cl->l.upvals[i] = luaF_newupval(L);
     cl->l.upvals[i] = luaF_newupval(L);
-  setclvalue(L->top, cl);
+  setclvalue(L, L->top, cl);
   incr_top(L);
   incr_top(L);
 }
 }
 
 

+ 3 - 3
ldo.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldo.h,v 1.57 2003/08/25 19:51:54 roberto Exp roberto $
+** $Id: ldo.h,v 1.58 2003/08/27 21:01:44 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -24,7 +24,7 @@
 
 
 
 
 #define luaD_checkstack(L,n)	\
 #define luaD_checkstack(L,n)	\
-  if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TObject)) \
+  if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
     luaD_growstack(L, n); \
     luaD_growstack(L, n); \
   else condhardstacktests(luaD_reallocstack(L, L->stacksize));
   else condhardstacktests(luaD_reallocstack(L, L->stacksize));
 
 
@@ -32,7 +32,7 @@
 #define incr_top(L) {luaD_checkstack(L,1); L->top++;}
 #define incr_top(L) {luaD_checkstack(L,1); L->top++;}
 
 
 #define savestack(L,p)		((char *)(p) - (char *)L->stack)
 #define savestack(L,p)		((char *)(p) - (char *)L->stack)
-#define restorestack(L,n)	((TObject *)((char *)L->stack + (n)))
+#define restorestack(L,n)	((TValue *)((char *)L->stack + (n)))
 
 
 #define saveci(L,p)		((char *)(p) - (char *)L->base_ci)
 #define saveci(L,p)		((char *)(p) - (char *)L->base_ci)
 #define restoreci(L,n)		((CallInfo *)((char *)L->base_ci + (n)))
 #define restoreci(L,n)		((CallInfo *)((char *)L->base_ci + (n)))

+ 3 - 3
ldump.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldump.c,v 1.4 2003/02/11 23:52:12 lhf Exp lhf $
+** $Id: ldump.c,v 1.6 2003/08/15 13:48:53 roberto Exp roberto $
 ** save bytecodes
 ** save bytecodes
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -104,7 +104,7 @@ static void DumpConstants(const Proto* f, DumpState* D)
  DumpInt(n=f->sizek,D);
  DumpInt(n=f->sizek,D);
  for (i=0; i<n; i++)
  for (i=0; i<n; i++)
  {
  {
-  const TObject* o=&f->k[i];
+  const TValue* o=&f->k[i];
   DumpByte(ttype(o),D);
   DumpByte(ttype(o),D);
   switch (ttype(o))
   switch (ttype(o))
   {
   {
@@ -112,7 +112,7 @@ static void DumpConstants(const Proto* f, DumpState* D)
 	DumpNumber(nvalue(o),D);
 	DumpNumber(nvalue(o),D);
 	break;
 	break;
    case LUA_TSTRING:
    case LUA_TSTRING:
-	DumpString(tsvalue(o),D);
+	DumpString(rawtsvalue(o),D);
 	break;
 	break;
    case LUA_TNIL:
    case LUA_TNIL:
 	break;
 	break;

+ 10 - 10
lfunc.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lfunc.c,v 1.73 2003/12/03 20:03:07 roberto Exp roberto $
+** $Id: lfunc.c,v 1.74 2003/12/09 16:56:11 roberto Exp roberto $
 ** Auxiliary functions to manipulate prototypes and closures
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -21,16 +21,16 @@
 
 
 Closure *luaF_newCclosure (lua_State *L, int nelems) {
 Closure *luaF_newCclosure (lua_State *L, int nelems) {
   Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
   Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
-  luaC_link(L, valtogco(c), LUA_TFUNCTION);
+  luaC_link(L, obj2gco(c), LUA_TFUNCTION);
   c->c.isC = 1;
   c->c.isC = 1;
   c->c.nupvalues = cast(lu_byte, nelems);
   c->c.nupvalues = cast(lu_byte, nelems);
   return c;
   return c;
 }
 }
 
 
 
 
-Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e) {
+Closure *luaF_newLclosure (lua_State *L, int nelems, TValue *e) {
   Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
   Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
-  luaC_link(L, valtogco(c), LUA_TFUNCTION);
+  luaC_link(L, obj2gco(c), LUA_TFUNCTION);
   c->l.isC = 0;
   c->l.isC = 0;
   c->l.g = *e;
   c->l.g = *e;
   c->l.nupvalues = cast(lu_byte, nelems);
   c->l.nupvalues = cast(lu_byte, nelems);
@@ -40,7 +40,7 @@ Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e) {
 
 
 UpVal *luaF_newupval (lua_State *L) {
 UpVal *luaF_newupval (lua_State *L) {
   UpVal *uv = luaM_new(L, UpVal);
   UpVal *uv = luaM_new(L, UpVal);
-  luaC_link(L, valtogco(uv), LUA_TUPVAL);
+  luaC_link(L, obj2gco(uv), LUA_TUPVAL);
   uv->v = &uv->value;
   uv->v = &uv->value;
   setnilvalue(uv->v);
   setnilvalue(uv->v);
   return uv;
   return uv;
@@ -60,7 +60,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
   uv->marked = bitmask(FIXEDBIT);  /* open upvalues cannot be collected */
   uv->marked = bitmask(FIXEDBIT);  /* open upvalues cannot be collected */
   uv->v = level;  /* current value lives in the stack */
   uv->v = level;  /* current value lives in the stack */
   uv->next = *pp;  /* chain it in the proper position */
   uv->next = *pp;  /* chain it in the proper position */
-  *pp = valtogco(uv);
+  *pp = obj2gco(uv);
   return uv;
   return uv;
 }
 }
 
 
@@ -68,18 +68,18 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
 void luaF_close (lua_State *L, StkId level) {
 void luaF_close (lua_State *L, StkId level) {
   UpVal *uv;
   UpVal *uv;
   while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) {
   while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) {
-    setobj(&uv->value, uv->v);
+    setobj(L, &uv->value, uv->v);
     luaC_barrier(L, uv, uv->v);
     luaC_barrier(L, uv, uv->v);
     uv->v = &uv->value;  /* now current value lives here */
     uv->v = &uv->value;  /* now current value lives here */
     L->openupval = uv->next;  /* remove from `open' list */
     L->openupval = uv->next;  /* remove from `open' list */
-    luaC_link(L, valtogco(uv), LUA_TUPVAL);
+    luaC_link(L, obj2gco(uv), LUA_TUPVAL);
   }
   }
 }
 }
 
 
 
 
 Proto *luaF_newproto (lua_State *L) {
 Proto *luaF_newproto (lua_State *L) {
   Proto *f = luaM_new(L, Proto);
   Proto *f = luaM_new(L, Proto);
-  luaC_link(L, valtogco(f), LUA_TPROTO);
+  luaC_link(L, obj2gco(f), LUA_TPROTO);
   f->k = NULL;
   f->k = NULL;
   f->sizek = 0;
   f->sizek = 0;
   f->p = NULL;
   f->p = NULL;
@@ -105,7 +105,7 @@ Proto *luaF_newproto (lua_State *L) {
 void luaF_freeproto (lua_State *L, Proto *f) {
 void luaF_freeproto (lua_State *L, Proto *f) {
   luaM_freearray(L, f->code, f->sizecode, Instruction);
   luaM_freearray(L, f->code, f->sizecode, Instruction);
   luaM_freearray(L, f->p, f->sizep, Proto *);
   luaM_freearray(L, f->p, f->sizep, Proto *);
-  luaM_freearray(L, f->k, f->sizek, TObject);
+  luaM_freearray(L, f->k, f->sizek, TValue);
   luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
   luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
   luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
   luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
   luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
   luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);

+ 4 - 4
lfunc.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lfunc.h,v 1.22 2003/10/20 17:42:41 roberto Exp roberto $
+** $Id: lfunc.h,v 1.23 2003/11/24 18:50:36 roberto Exp roberto $
 ** Auxiliary functions to manipulate prototypes and closures
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -12,15 +12,15 @@
 
 
 
 
 #define sizeCclosure(n)	(cast(int, sizeof(CClosure)) + \
 #define sizeCclosure(n)	(cast(int, sizeof(CClosure)) + \
-                         cast(int, sizeof(TObject)*((n)-1)))
+                         cast(int, sizeof(TValue)*((n)-1)))
 
 
 #define sizeLclosure(n)	(cast(int, sizeof(LClosure)) + \
 #define sizeLclosure(n)	(cast(int, sizeof(LClosure)) + \
-                         cast(int, sizeof(TObject *)*((n)-1)))
+                         cast(int, sizeof(TValue *)*((n)-1)))
 
 
 
 
 Proto *luaF_newproto (lua_State *L);
 Proto *luaF_newproto (lua_State *L);
 Closure *luaF_newCclosure (lua_State *L, int nelems);
 Closure *luaF_newCclosure (lua_State *L, int nelems);
-Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e);
+Closure *luaF_newLclosure (lua_State *L, int nelems, TValue *e);
 UpVal *luaF_newupval (lua_State *L);
 UpVal *luaF_newupval (lua_State *L);
 UpVal *luaF_findupval (lua_State *L, StkId level);
 UpVal *luaF_findupval (lua_State *L, StkId level);
 void luaF_close (lua_State *L, StkId level);
 void luaF_close (lua_State *L, StkId level);

+ 52 - 52
lgc.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lgc.c,v 1.186 2003/12/04 18:52:23 roberto Exp roberto $
+** $Id: lgc.c,v 1.187 2003/12/09 16:56:11 roberto Exp roberto $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -22,7 +22,7 @@
 #include "ltm.h"
 #include "ltm.h"
 
 
 
 
-#define GCSTEPSIZE	(20*sizeof(TObject))
+#define GCSTEPSIZE	(20*sizeof(TValue))
 
 
 
 
 #define gray2black(x)	setbit((x)->gch.marked, BLACKBIT)
 #define gray2black(x)	setbit((x)->gch.marked, BLACKBIT)
@@ -39,8 +39,8 @@
 #define stringmark(s)	reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
 #define stringmark(s)	reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
 
 
 
 
-#define isfinalized(u)		testbit((u)->uv.marked, FINALIZEDBIT)
-#define markfinalized(u)	setbit((u)->uv.marked, FINALIZEDBIT)
+#define isfinalized(u)		testbit((u)->marked, FINALIZEDBIT)
+#define markfinalized(u)	setbit((u)->marked, FINALIZEDBIT)
 
 
 
 
 #define KEYWEAK         bitmask(KEYWEAKBIT)
 #define KEYWEAK         bitmask(KEYWEAKBIT)
@@ -55,8 +55,8 @@
   if (iscollectable(o) && iswhite(gcvalue(o)) && (c)) \
   if (iscollectable(o) && iswhite(gcvalue(o)) && (c)) \
     reallymarkobject(g,gcvalue(o)); }
     reallymarkobject(g,gcvalue(o)); }
 
 
-#define markobject(g,t) { if (iswhite(valtogco(t))) \
-		reallymarkobject(g, valtogco(t)); }
+#define markobject(g,t) { if (iswhite(obj2gco(t))) \
+		reallymarkobject(g, obj2gco(t)); }
 
 
 
 
 
 
@@ -66,34 +66,34 @@
 static size_t objsize (GCObject *o) {
 static size_t objsize (GCObject *o) {
   switch (o->gch.tt) {
   switch (o->gch.tt) {
     case LUA_TSTRING: {
     case LUA_TSTRING: {
-      TString *ts = gcotots(o);
+      TString *ts = rawgco2ts(o);
       return sizestring(ts->tsv.len);
       return sizestring(ts->tsv.len);
     }
     }
     case LUA_TUSERDATA: {
     case LUA_TUSERDATA: {
-      Udata *u = gcotou(o);
+      Udata *u = rawgco2u(o);
       return sizeudata(u->uv.len);
       return sizeudata(u->uv.len);
     }
     }
     case LUA_TTABLE: {
     case LUA_TTABLE: {
-      Table *h = gcotoh(o);
-      return sizeof(Table) + sizeof(TObject) * h->sizearray +
+      Table *h = gco2h(o);
+      return sizeof(Table) + sizeof(TValue) * h->sizearray +
                              sizeof(Node) * sizenode(h);
                              sizeof(Node) * sizenode(h);
     }
     }
     case LUA_TUPVAL:
     case LUA_TUPVAL:
       return sizeof(UpVal);
       return sizeof(UpVal);
     case LUA_TFUNCTION: {
     case LUA_TFUNCTION: {
-      Closure *cl = gcotocl(o);
+      Closure *cl = gco2cl(o);
       return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
       return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
                            sizeLclosure(cl->l.nupvalues);
                            sizeLclosure(cl->l.nupvalues);
     }
     }
     case LUA_TTHREAD: {
     case LUA_TTHREAD: {
-      lua_State *th = gcototh(o);
-      return sizeof(lua_State) + sizeof(TObject) * th->stacksize +
+      lua_State *th = gco2th(o);
+      return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
              sizeof(CallInfo) * th->size_ci;
              sizeof(CallInfo) * th->size_ci;
     }
     }
     case LUA_TPROTO: {
     case LUA_TPROTO: {
-      Proto *p = gcotop(o);
+      Proto *p = gco2p(o);
       return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
       return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
-             sizeof(Proto *) * p->sizep + sizeof(TObject) * p->sizek + 
+             sizeof(Proto *) * p->sizep + sizeof(TValue) * p->sizek + 
              sizeof(int) * p->sizelineinfo + sizeof(LocVar) * p->sizelocvars +
              sizeof(int) * p->sizelineinfo + sizeof(LocVar) * p->sizelocvars +
              sizeof(TString *) * p->sizeupvalues;
              sizeof(TString *) * p->sizeupvalues;
     }
     }
@@ -112,29 +112,29 @@ static void reallymarkobject (global_State *g, GCObject *o) {
       return;
       return;
     }
     }
     case LUA_TUSERDATA: {
     case LUA_TUSERDATA: {
-      Table *mt = gcotou(o)->uv.metatable;
+      Table *mt = gco2u(o)->metatable;
       gray2black(o);  /* udata are never gray */
       gray2black(o);  /* udata are never gray */
       if (mt) markobject(g, mt);
       if (mt) markobject(g, mt);
       return;
       return;
     }
     }
     case LUA_TFUNCTION: {
     case LUA_TFUNCTION: {
-      gcotocl(o)->c.gclist = g->gray;
+      gco2cl(o)->c.gclist = g->gray;
       break;
       break;
     }
     }
     case LUA_TTABLE: {
     case LUA_TTABLE: {
-      gcotoh(o)->gclist = g->gray;
+      gco2h(o)->gclist = g->gray;
       break;
       break;
     }
     }
     case LUA_TTHREAD: {
     case LUA_TTHREAD: {
-      gcototh(o)->gclist = g->gray;
+      gco2th(o)->gclist = g->gray;
       break;
       break;
     }
     }
     case LUA_TPROTO: {
     case LUA_TPROTO: {
-      gcotop(o)->gclist = g->gray;
+      gco2p(o)->gclist = g->gray;
       break;
       break;
     }
     }
     case LUA_TUPVAL: {
     case LUA_TUPVAL: {
-      gcotouv(o)->gclist = g->gray;
+      gco2uv(o)->gclist = g->gray;
       break;
       break;
     }
     }
     default: lua_assert(0);
     default: lua_assert(0);
@@ -161,15 +161,15 @@ size_t luaC_separateudata (lua_State *L) {
   GCObject **lastcollected = &collected;
   GCObject **lastcollected = &collected;
   while ((curr = *p) != NULL) {
   while ((curr = *p) != NULL) {
     lua_assert(curr->gch.tt == LUA_TUSERDATA);
     lua_assert(curr->gch.tt == LUA_TUSERDATA);
-    if (!iswhite(curr) || isfinalized(gcotou(curr)))
+    if (!iswhite(curr) || isfinalized(gco2u(curr)))
       p = &curr->gch.next;  /* don't bother with them */
       p = &curr->gch.next;  /* don't bother with them */
-    else if (fasttm(L, gcotou(curr)->uv.metatable, TM_GC) == NULL) {
-      markfinalized(gcotou(curr));  /* don't need finalization */
+    else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
+      markfinalized(gco2u(curr));  /* don't need finalization */
       p = &curr->gch.next;
       p = &curr->gch.next;
     }
     }
     else {  /* must call its gc method */
     else {  /* must call its gc method */
-      deadmem += sizeudata(gcotou(curr)->uv.len);
-      markfinalized(gcotou(curr));
+      deadmem += sizeudata(gco2u(curr)->len);
+      markfinalized(gco2u(curr));
       *p = curr->gch.next;
       *p = curr->gch.next;
       curr->gch.next = NULL;  /* link `curr' at the end of `collected' list */
       curr->gch.next = NULL;  /* link `curr' at the end of `collected' list */
       *lastcollected = curr;
       *lastcollected = curr;
@@ -187,7 +187,7 @@ static void traversetable (global_State *g, Table *h) {
   int i;
   int i;
   int weakkey = 0;
   int weakkey = 0;
   int weakvalue = 0;
   int weakvalue = 0;
-  const TObject *mode;
+  const TValue *mode;
   if (h->metatable)
   if (h->metatable)
     markobject(g, h->metatable);
     markobject(g, h->metatable);
   lua_assert(h->lsizenode || h->node == g->dummynode);
   lua_assert(h->lsizenode || h->node == g->dummynode);
@@ -200,7 +200,7 @@ static void traversetable (global_State *g, Table *h) {
       h->marked |= cast(lu_byte, (weakkey << KEYWEAKBIT) |
       h->marked |= cast(lu_byte, (weakkey << KEYWEAKBIT) |
                                  (weakvalue << VALUEWEAKBIT));
                                  (weakvalue << VALUEWEAKBIT));
       h->gclist = g->weak;  /* must be cleared after GC, ... */
       h->gclist = g->weak;  /* must be cleared after GC, ... */
-      g->weak = valtogco(h);  /* ... so put in the appropriate list */
+      g->weak = obj2gco(h);  /* ... so put in the appropriate list */
     }
     }
   }
   }
   if (weakkey && weakvalue) return;
   if (weakkey && weakvalue) return;
@@ -230,7 +230,7 @@ static void traverseproto (global_State *g, Proto *f) {
   if (f->source) stringmark(f->source);
   if (f->source) stringmark(f->source);
   for (i=0; i<f->sizek; i++) {  /* mark literal strings */
   for (i=0; i<f->sizek; i++) {  /* mark literal strings */
     if (ttisstring(f->k+i))
     if (ttisstring(f->k+i))
-      stringmark(tsvalue(f->k+i));
+      stringmark(rawtsvalue(f->k+i));
   }
   }
   for (i=0; i<f->sizeupvalues; i++) {  /* mark upvalue names */
   for (i=0; i<f->sizeupvalues; i++) {  /* mark upvalue names */
     if (f->upvalues[i])
     if (f->upvalues[i])
@@ -306,19 +306,19 @@ static l_mem propagatemarks (global_State *g, l_mem lim) {
     gray2black(o);
     gray2black(o);
     switch (o->gch.tt) {
     switch (o->gch.tt) {
       case LUA_TTABLE: {
       case LUA_TTABLE: {
-        Table *h = gcotoh(o);
+        Table *h = gco2h(o);
         g->gray = h->gclist;
         g->gray = h->gclist;
         traversetable(g, h);
         traversetable(g, h);
         break;
         break;
       }
       }
       case LUA_TFUNCTION: {
       case LUA_TFUNCTION: {
-        Closure *cl = gcotocl(o);
+        Closure *cl = gco2cl(o);
         g->gray = cl->c.gclist;
         g->gray = cl->c.gclist;
         traverseclosure(g, cl);
         traverseclosure(g, cl);
         break;
         break;
       }
       }
       case LUA_TTHREAD: {
       case LUA_TTHREAD: {
-        lua_State *th = gcototh(o);
+        lua_State *th = gco2th(o);
         g->gray = th->gclist;
         g->gray = th->gclist;
         th->gclist = g->grayagain;
         th->gclist = g->grayagain;
         g->grayagain = o;
         g->grayagain = o;
@@ -327,13 +327,13 @@ static l_mem propagatemarks (global_State *g, l_mem lim) {
         break;
         break;
       }
       }
       case LUA_TPROTO: {
       case LUA_TPROTO: {
-        Proto *p = gcotop(o);
+        Proto *p = gco2p(o);
         g->gray = p->gclist;
         g->gray = p->gclist;
         traverseproto(g, p);
         traverseproto(g, p);
         break;
         break;
       }
       }
       case LUA_TUPVAL: {
       case LUA_TUPVAL: {
-        UpVal *uv = gcotouv(o);
+        UpVal *uv = gco2uv(o);
         g->gray = uv->gclist;
         g->gray = uv->gclist;
         if (uv->v != &uv->value) {  /* open? */
         if (uv->v != &uv->value) {  /* open? */
           uv->gclist = g->grayagain;
           uv->gclist = g->grayagain;
@@ -360,10 +360,10 @@ static l_mem propagatemarks (global_State *g, l_mem lim) {
 ** other objects: if really collected, cannot keep them; for userdata
 ** other objects: if really collected, cannot keep them; for userdata
 ** being finalized, keep them in keys, but not in values
 ** being finalized, keep them in keys, but not in values
 */
 */
-static int iscleared (const TObject *o, int iskey) {
+static int iscleared (const TValue *o, int iskey) {
   if (!iscollectable(o)) return 0;
   if (!iscollectable(o)) return 0;
   if (ttisstring(o)) {
   if (ttisstring(o)) {
-    stringmark(tsvalue(o));  /* strings are `values', so are never weak */
+    stringmark(rawtsvalue(o));  /* strings are `values', so are never weak */
     return 0;
     return 0;
   }
   }
   return iswhite(gcvalue(o)) ||
   return iswhite(gcvalue(o)) ||
@@ -383,13 +383,13 @@ static void removekey (Node *n) {
 */
 */
 static void cleartable (GCObject *l) {
 static void cleartable (GCObject *l) {
   while (l) {
   while (l) {
-    Table *h = gcotoh(l);
+    Table *h = gco2h(l);
     int i = h->sizearray;
     int i = h->sizearray;
     lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
     lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
                testbit(h->marked, KEYWEAKBIT));
                testbit(h->marked, KEYWEAKBIT));
     if (testbit(h->marked, VALUEWEAKBIT)) {
     if (testbit(h->marked, VALUEWEAKBIT)) {
       while (i--) {
       while (i--) {
-        TObject *o = &h->array[i];
+        TValue *o = &h->array[i];
         if (iscleared(o, 0))  /* value was collected? */
         if (iscleared(o, 0))  /* value was collected? */
           setnilvalue(o);  /* remove value */
           setnilvalue(o);  /* remove value */
       }
       }
@@ -408,21 +408,21 @@ static void cleartable (GCObject *l) {
 
 
 static void freeobj (lua_State *L, GCObject *o) {
 static void freeobj (lua_State *L, GCObject *o) {
   switch (o->gch.tt) {
   switch (o->gch.tt) {
-    case LUA_TPROTO: luaF_freeproto(L, gcotop(o)); break;
-    case LUA_TFUNCTION: luaF_freeclosure(L, gcotocl(o)); break;
-    case LUA_TUPVAL: luaM_freelem(L, gcotouv(o)); break;
-    case LUA_TTABLE: luaH_free(L, gcotoh(o)); break;
+    case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
+    case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
+    case LUA_TUPVAL: luaM_freelem(L, gco2uv(o)); break;
+    case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
     case LUA_TTHREAD: {
     case LUA_TTHREAD: {
-      lua_assert(gcototh(o) != L && gcototh(o) != G(L)->mainthread);
-      luaE_freethread(L, gcototh(o));
+      lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
+      luaE_freethread(L, gco2th(o));
       break;
       break;
     }
     }
     case LUA_TSTRING: {
     case LUA_TSTRING: {
-      luaM_free(L, o, sizestring(gcotots(o)->tsv.len));
+      luaM_free(L, o, sizestring(gco2ts(o)->len));
       break;
       break;
     }
     }
     case LUA_TUSERDATA: {
     case LUA_TUSERDATA: {
-      luaM_free(L, o, sizeudata(gcotou(o)->uv.len));
+      luaM_free(L, o, sizeudata(gco2u(o)->len));
       break;
       break;
     }
     }
     default: lua_assert(0);
     default: lua_assert(0);
@@ -463,7 +463,7 @@ static l_mem sweepstrings (lua_State *L, int all, l_mem lim) {
     GCObject **p = &G(L)->strt.hash[i];
     GCObject **p = &G(L)->strt.hash[i];
     while ((curr = *p) != NULL) {
     while ((curr = *p) != NULL) {
       int mark = curr->gch.marked;
       int mark = curr->gch.marked;
-      lu_mem size = sizestring(gcotots(curr)->tsv.len);
+      lu_mem size = sizestring(gco2ts(curr)->len);
       if (!all && (!(mark & dead) || testbit(mark, FIXEDBIT))) {
       if (!all && (!(mark & dead) || testbit(mark, FIXEDBIT))) {
         makewhite(g, curr);
         makewhite(g, curr);
         lua_assert(iswhite(curr) && !isdead(g, curr));
         lua_assert(iswhite(curr) && !isdead(g, curr));
@@ -503,8 +503,8 @@ static void GCTM (lua_State *L) {
     g->gcstate = GCSroot;  /* will restart GC */
     g->gcstate = GCSroot;  /* will restart GC */
   else {
   else {
     GCObject *o = g->tmudata;
     GCObject *o = g->tmudata;
-    Udata *udata = gcotou(o);
-    const TObject *tm;
+    Udata *udata = rawgco2u(o);
+    const TValue *tm;
     g->tmudata = udata->uv.next;  /* remove udata from `tmudata' */
     g->tmudata = udata->uv.next;  /* remove udata from `tmudata' */
     udata->uv.next = g->firstudata->uv.next;  /* return it to `root' list */
     udata->uv.next = g->firstudata->uv.next;  /* return it to `root' list */
     g->firstudata->uv.next = o;
     g->firstudata->uv.next = o;
@@ -513,8 +513,8 @@ static void GCTM (lua_State *L) {
     if (tm != NULL) {
     if (tm != NULL) {
       lu_byte oldah = L->allowhook;
       lu_byte oldah = L->allowhook;
       L->allowhook = 0;  /* stop debug hooks during GC tag method */
       L->allowhook = 0;  /* stop debug hooks during GC tag method */
-      setobj2s(L->top, tm);
-      setuvalue(L->top+1, udata);
+      setobj2s(L, L->top, tm);
+      setuvalue(L, L->top+1, udata);
       L->top += 2;
       L->top += 2;
       luaD_call(L, L->top - 2, 0);
       luaD_call(L, L->top - 2, 0);
       L->allowhook = oldah;  /* restore hooks */
       L->allowhook = oldah;  /* restore hooks */
@@ -545,7 +545,7 @@ static void markroot (lua_State *L) {
   global_State *g = G(L);
   global_State *g = G(L);
   lua_assert(g->gray == NULL);
   lua_assert(g->gray == NULL);
   g->weak = NULL;
   g->weak = NULL;
-  makewhite(g, valtogco(g->mainthread));
+  makewhite(g, obj2gco(g->mainthread));
   markobject(g, g->mainthread);
   markobject(g, g->mainthread);
   markvalue(g, registry(L));
   markvalue(g, registry(L));
   markobject(g, L);  /* mark running thread */
   markobject(g, L);  /* mark running thread */

+ 5 - 5
lgc.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lgc.h,v 1.27 2003/12/04 17:22:42 roberto Exp roberto $
+** $Id: lgc.h,v 1.28 2003/12/09 16:56:11 roberto Exp roberto $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -76,12 +76,12 @@
 	luaC_step(L); }
 	luaC_step(L); }
 
 
 
 
-#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(valtogco(p)))  \
-	luaC_barrierf(L,valtogco(p),gcvalue(v)); }
+#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p)))  \
+	luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
 
 
 #define luaC_objbarrier(L,p,o)  \
 #define luaC_objbarrier(L,p,o)  \
-	{ if (iswhite(valtogco(o)) && isblack(valtogco(p))) \
-		luaC_barrierf(L,valtogco(p),valtogco(o)); }
+	{ if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
+		luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
 
 
 size_t luaC_separateudata (lua_State *L);
 size_t luaC_separateudata (lua_State *L);
 void luaC_callGCTM (lua_State *L);
 void luaC_callGCTM (lua_State *L);

+ 2 - 2
llex.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: llex.c,v 1.127 2003/10/03 16:07:44 roberto Exp roberto $
+** $Id: llex.c,v 1.128 2003/10/20 12:24:34 roberto Exp roberto $
 ** Lexical Analyzer
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -110,7 +110,7 @@ void luaX_syntaxerror (LexState *ls, const char *msg) {
 TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
 TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
   lua_State *L = ls->L;
   lua_State *L = ls->L;
   TString *ts = luaS_newlstr(L, str, l);
   TString *ts = luaS_newlstr(L, str, l);
-  TObject *o = luaH_setstr(L, ls->fs->h, ts);  /* entry for `str' */
+  TValue *o = luaH_setstr(L, ls->fs->h, ts);  /* entry for `str' */
   if (ttisnil(o))
   if (ttisnil(o))
     setbvalue(o, 1);  /* make sure `str' will not be collected */
     setbvalue(o, 1);  /* make sure `str' will not be collected */
   return ts;
   return ts;

+ 5 - 5
lobject.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.c,v 1.98 2003/04/28 13:30:14 roberto Exp roberto $
+** $Id: lobject.c,v 1.99 2003/06/10 12:36:26 roberto Exp roberto $
 ** Some generic functions over Lua objects
 ** Some generic functions over Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -27,7 +27,7 @@
 #endif
 #endif
 
 
 
 
-const TObject luaO_nilobject = {LUA_TNIL, {NULL}};
+const TValue luaO_nilobject = {LUA_TNIL, {NULL}};
 
 
 
 
 /*
 /*
@@ -62,7 +62,7 @@ int luaO_log2 (unsigned int x) {
 }
 }
 
 
 
 
-int luaO_rawequalObj (const TObject *t1, const TObject *t2) {
+int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
   if (ttype(t1) != ttype(t2)) return 0;
   if (ttype(t1) != ttype(t2)) return 0;
   else switch (ttype(t1)) {
   else switch (ttype(t1)) {
     case LUA_TNIL:
     case LUA_TNIL:
@@ -93,7 +93,7 @@ int luaO_str2d (const char *s, lua_Number *result) {
 
 
 
 
 static void pushstr (lua_State *L, const char *str) {
 static void pushstr (lua_State *L, const char *str) {
-  setsvalue2s(L->top, luaS_new(L, str));
+  setsvalue2s(L, L->top, luaS_new(L, str));
   incr_top(L);
   incr_top(L);
 }
 }
 
 
@@ -105,7 +105,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
   for (;;) {
   for (;;) {
     const char *e = strchr(fmt, '%');
     const char *e = strchr(fmt, '%');
     if (e == NULL) break;
     if (e == NULL) break;
-    setsvalue2s(L->top, luaS_newlstr(L, fmt, e-fmt));
+    setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
     incr_top(L);
     incr_top(L);
     switch (*(e+1)) {
     switch (*(e+1)) {
       case 's':
       case 's':

+ 55 - 48
lobject.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.h,v 1.161 2003/08/27 21:01:44 roberto Exp roberto $
+** $Id: lobject.h,v 1.162 2003/11/18 14:55:11 roberto Exp roberto $
 ** Type definitions for Lua objects
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -58,12 +58,12 @@ typedef union {
 
 
 
 
 /*
 /*
-** Lua values (or `tagged objects')
+** Tagged Values
 */
 */
-typedef struct lua_TObject {
+typedef struct lua_TValue {
   int tt;
   int tt;
   Value value;
   Value value;
-} TObject;
+} TValue;
 
 
 
 
 /* Macros to test type */
 /* Macros to test type */
@@ -82,8 +82,10 @@ typedef struct lua_TObject {
 #define gcvalue(o)	check_exp(iscollectable(o), (o)->value.gc)
 #define gcvalue(o)	check_exp(iscollectable(o), (o)->value.gc)
 #define pvalue(o)	check_exp(ttislightuserdata(o), (o)->value.p)
 #define pvalue(o)	check_exp(ttislightuserdata(o), (o)->value.p)
 #define nvalue(o)	check_exp(ttisnumber(o), (o)->value.n)
 #define nvalue(o)	check_exp(ttisnumber(o), (o)->value.n)
-#define tsvalue(o)	check_exp(ttisstring(o), &(o)->value.gc->ts)
-#define uvalue(o)	check_exp(ttisuserdata(o), &(o)->value.gc->u)
+#define rawtsvalue(o)	check_exp(ttisstring(o), &(o)->value.gc->ts)
+#define tsvalue(o)	(&rawtsvalue(o)->tsv)
+#define rawuvalue(o)	check_exp(ttisuserdata(o), &(o)->value.gc->u)
+#define uvalue(o)	(&rawuvalue(o)->uv)
 #define clvalue(o)	check_exp(ttisfunction(o), &(o)->value.gc->cl)
 #define clvalue(o)	check_exp(ttisfunction(o), &(o)->value.gc->cl)
 #define hvalue(o)	check_exp(ttistable(o), &(o)->value.gc->h)
 #define hvalue(o)	check_exp(ttistable(o), &(o)->value.gc->h)
 #define bvalue(o)	check_exp(ttisboolean(o), (o)->value.b)
 #define bvalue(o)	check_exp(ttisboolean(o), (o)->value.b)
@@ -91,64 +93,69 @@ typedef struct lua_TObject {
 
 
 #define l_isfalse(o)	(ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
 #define l_isfalse(o)	(ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
 
 
+/*
+** for internal debug only
+*/
+#define checkconsistency(obj) \
+  lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
+
+#define checkliveness(L,obj) \
+  lua_assert(!iscollectable(obj) || \
+  ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(G(L), (obj)->value.gc)))
+
+
 /* Macros to set values */
 /* Macros to set values */
 #define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
 #define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
 
 
 #define setnvalue(obj,x) \
 #define setnvalue(obj,x) \
-  { TObject *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
+  { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
 
 
 #define chgnvalue(obj,x) \
 #define chgnvalue(obj,x) \
 	check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x))
 	check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x))
 
 
 #define setpvalue(obj,x) \
 #define setpvalue(obj,x) \
-  { TObject *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
+  { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
 
 
 #define setbvalue(obj,x) \
 #define setbvalue(obj,x) \
-  { TObject *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
+  { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
 
 
-#define setsvalue(obj,x) \
-  { TObject *i_o=(obj); \
+#define setsvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
-    lua_assert(i_o->value.gc->gch.tt == LUA_TSTRING); }
+    checkliveness(L,i_o); }
 
 
-#define setuvalue(obj,x) \
-  { TObject *i_o=(obj); \
+#define setuvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
-    lua_assert(i_o->value.gc->gch.tt == LUA_TUSERDATA); }
+    checkliveness(L,i_o); }
 
 
-#define setthvalue(obj,x) \
-  { TObject *i_o=(obj); \
+#define setthvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
-    lua_assert(i_o->value.gc->gch.tt == LUA_TTHREAD); }
+    checkliveness(L,i_o); }
 
 
-#define setclvalue(obj,x) \
-  { TObject *i_o=(obj); \
+#define setclvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
-    lua_assert(i_o->value.gc->gch.tt == LUA_TFUNCTION); }
+    checkliveness(L,i_o); }
 
 
-#define sethvalue(obj,x) \
-  { TObject *i_o=(obj); \
+#define sethvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
-    lua_assert(i_o->value.gc->gch.tt == LUA_TTABLE); }
+    checkliveness(L,i_o); }
 
 
-#define setptvalue(obj,x) \
-  { TObject *i_o=(obj); \
+#define setptvalue(L,obj,x) \
+  { TValue *i_o=(obj); \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
     i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
-    lua_assert(i_o->value.gc->gch.tt == LUA_TPROTO); }
-
+    checkliveness(L,i_o); }
 
 
 
 
-/*
-** for internal debug only
-*/
-#define checkconsistency(obj) \
-  lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
 
 
 
 
-#define setobj(obj1,obj2) \
-  { const TObject *o2=(obj2); TObject *o1=(obj1); \
-    checkconsistency(o2); \
-    o1->tt=o2->tt; o1->value = o2->value; }
+#define setobj(L,obj1,obj2) \
+  { const TValue *o2=(obj2); TValue *o1=(obj1); \
+    o1->tt=o2->tt; o1->value = o2->value; \
+    checkliveness(L,o1); }
 
 
 
 
 /*
 /*
@@ -177,7 +184,7 @@ typedef struct lua_TObject {
 
 
 
 
 
 
-typedef TObject *StkId;  /* index to stack elements */
+typedef TValue *StkId;  /* index to stack elements */
 
 
 
 
 /*
 /*
@@ -216,7 +223,7 @@ typedef union Udata {
 */
 */
 typedef struct Proto {
 typedef struct Proto {
   CommonHeader;
   CommonHeader;
-  TObject *k;  /* constants used by the function */
+  TValue *k;  /* constants used by the function */
   Instruction *code;
   Instruction *code;
   struct Proto **p;  /* functions defined inside the function */
   struct Proto **p;  /* functions defined inside the function */
   int *lineinfo;  /* map from opcodes to source lines */
   int *lineinfo;  /* map from opcodes to source lines */
@@ -253,8 +260,8 @@ typedef struct LocVar {
 typedef struct UpVal {
 typedef struct UpVal {
   CommonHeader;
   CommonHeader;
   GCObject *gclist;
   GCObject *gclist;
-  TObject *v;  /* points to stack or to its own value */
-  TObject value;  /* the value (when closed) */
+  TValue *v;  /* points to stack or to its own value */
+  TValue value;  /* the value (when closed) */
 } UpVal;
 } UpVal;
 
 
 
 
@@ -268,14 +275,14 @@ typedef struct UpVal {
 typedef struct CClosure {
 typedef struct CClosure {
   ClosureHeader;
   ClosureHeader;
   lua_CFunction f;
   lua_CFunction f;
-  TObject upvalue[1];
+  TValue upvalue[1];
 } CClosure;
 } CClosure;
 
 
 
 
 typedef struct LClosure {
 typedef struct LClosure {
   ClosureHeader;
   ClosureHeader;
   struct Proto *p;
   struct Proto *p;
-  TObject g;  /* global table for this closure */
+  TValue g;  /* global table for this closure */
   UpVal *upvals[1];
   UpVal *upvals[1];
 } LClosure;
 } LClosure;
 
 
@@ -295,8 +302,8 @@ typedef union Closure {
 */
 */
 
 
 typedef struct Node {
 typedef struct Node {
-  TObject i_key;
-  TObject i_val;
+  TValue i_key;
+  TValue i_val;
   struct Node *next;  /* for chaining */
   struct Node *next;  /* for chaining */
 } Node;
 } Node;
 
 
@@ -306,7 +313,7 @@ typedef struct Table {
   lu_byte flags;  /* 1<<p means tagmethod(p) is not present */ 
   lu_byte flags;  /* 1<<p means tagmethod(p) is not present */ 
   lu_byte lsizenode;  /* log2 of size of `node' array */
   lu_byte lsizenode;  /* log2 of size of `node' array */
   struct Table *metatable;
   struct Table *metatable;
-  TObject *array;  /* array part */
+  TValue *array;  /* array part */
   Node *node;
   Node *node;
   Node *firstfree;  /* this position is free; all positions after it are full */
   Node *firstfree;  /* this position is free; all positions after it are full */
   GCObject *gclist;
   GCObject *gclist;
@@ -327,13 +334,13 @@ typedef struct Table {
 
 
 
 
 
 
-extern const TObject luaO_nilobject;
+extern const TValue luaO_nilobject;
 
 
 int luaO_log2 (unsigned int x);
 int luaO_log2 (unsigned int x);
 int luaO_int2fb (unsigned int x);
 int luaO_int2fb (unsigned int x);
 #define fb2int(x)	(((x) & 7) << ((x) >> 3))
 #define fb2int(x)	(((x) & 7) << ((x) >> 3))
 
 
-int luaO_rawequalObj (const TObject *t1, const TObject *t2);
+int luaO_rawequalObj (const TValue *t1, const TValue *t2);
 int luaO_str2d (const char *s, lua_Number *result);
 int luaO_str2d (const char *s, lua_Number *result);
 
 
 const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp);
 const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp);

+ 4 - 4
lparser.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lparser.c,v 1.221 2003/10/09 17:56:23 roberto Exp roberto $
+** $Id: lparser.c,v 1.222 2003/12/09 16:56:11 roberto Exp roberto $
 ** Lua Parser
 ** Lua Parser
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -340,9 +340,9 @@ static void open_func (LexState *ls, FuncState *fs) {
   f->maxstacksize = 2;  /* registers 0/1 are always valid */
   f->maxstacksize = 2;  /* registers 0/1 are always valid */
   fs->h = luaH_new(L, 0, 0);
   fs->h = luaH_new(L, 0, 0);
   /* anchor table of constants and prototype (to avoid being collected) */
   /* anchor table of constants and prototype (to avoid being collected) */
-  sethvalue2s(L->top, fs->h);
+  sethvalue2s(L, L->top, fs->h);
   incr_top(L);
   incr_top(L);
-  setptvalue2s(L->top, f);
+  setptvalue2s(L, L->top, f);
   incr_top(L);
   incr_top(L);
 }
 }
 
 
@@ -357,7 +357,7 @@ static void close_func (LexState *ls) {
   f->sizecode = fs->pc;
   f->sizecode = fs->pc;
   luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
   luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
   f->sizelineinfo = fs->pc;
   f->sizelineinfo = fs->pc;
-  luaM_reallocvector(L, f->k, f->sizek, fs->nk, TObject);
+  luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue);
   f->sizek = fs->nk;
   f->sizek = fs->nk;
   luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
   luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *);
   f->sizep = fs->np;
   f->sizep = fs->np;

+ 10 - 9
lstate.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.c,v 1.133 2003/12/04 17:22:42 roberto Exp roberto $
+** $Id: lstate.c,v 1.134 2003/12/04 18:52:23 roberto Exp roberto $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -50,7 +50,7 @@ typedef struct LG {
 
 
 
 
 static void stack_init (lua_State *L1, lua_State *L) {
 static void stack_init (lua_State *L1, lua_State *L) {
-  L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TObject);
+  L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue);
   L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
   L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK;
   L1->top = L1->stack;
   L1->top = L1->stack;
   L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
   L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1;
@@ -66,7 +66,7 @@ static void stack_init (lua_State *L1, lua_State *L) {
 
 
 static void freestack (lua_State *L, lua_State *L1) {
 static void freestack (lua_State *L, lua_State *L1) {
   luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
   luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
-  luaM_freearray(L, L1->stack, L1->stacksize, TObject);
+  luaM_freearray(L, L1->stack, L1->stacksize, TValue);
 }
 }
 
 
 
 
@@ -79,12 +79,12 @@ static void f_luaopen (lua_State *L, void *ud) {
   u = cast(Udata *, luaM_malloc(L, sizeudata(0)));
   u = cast(Udata *, luaM_malloc(L, sizeudata(0)));
   u->uv.len = 0;
   u->uv.len = 0;
   u->uv.metatable = NULL;
   u->uv.metatable = NULL;
-  G(L)->firstudata = valtogco(u);
-  luaC_link(L, valtogco(u), LUA_TUSERDATA);
+  G(L)->firstudata = obj2gco(u);
+  luaC_link(L, obj2gco(u), LUA_TUSERDATA);
   setbit(u->uv.marked, FIXEDBIT);
   setbit(u->uv.marked, FIXEDBIT);
   stack_init(L, L);  /* init stack */
   stack_init(L, L);  /* init stack */
-  sethvalue(gt(L), luaH_new(L, 0, 4));  /* table of globals */
-  sethvalue(registry(L), luaH_new(L, 4, 4));  /* registry */
+  sethvalue(L, gt(L), luaH_new(L, 0, 4));  /* table of globals */
+  sethvalue(L, registry(L), luaH_new(L, 4, 4));  /* registry */
   luaS_resize(L, MINSTRTABSIZE);  /* initial size of string table */
   luaS_resize(L, MINSTRTABSIZE);  /* initial size of string table */
   luaT_init(L);
   luaT_init(L);
   luaX_init(L);
   luaX_init(L);
@@ -127,11 +127,12 @@ static void close_state (lua_State *L) {
 
 
 lua_State *luaE_newthread (lua_State *L) {
 lua_State *luaE_newthread (lua_State *L) {
   lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
   lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
-  luaC_link(L, valtogco(L1), LUA_TTHREAD);
+  luaC_link(L, obj2gco(L1), LUA_TTHREAD);
   preinit_state(L1);
   preinit_state(L1);
   L1->l_G = L->l_G;
   L1->l_G = L->l_G;
   stack_init(L1, L);  /* init stack */
   stack_init(L1, L);  /* init stack */
-  setobj2n(gt(L1), gt(L));  /* share table of globals */
+  setobj2n(L, gt(L1), gt(L));  /* share table of globals */
+  lua_assert(iswhite(obj2gco(L1)));
   return L1;
   return L1;
 }
 }
 
 

+ 14 - 12
lstate.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.h,v 1.118 2003/12/04 17:22:42 roberto Exp roberto $
+** $Id: lstate.h,v 1.119 2003/12/04 18:52:23 roberto Exp roberto $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -111,7 +111,7 @@ typedef struct global_State {
   lu_mem GCthreshold;
   lu_mem GCthreshold;
   lu_mem nblocks;  /* number of `bytes' currently allocated */
   lu_mem nblocks;  /* number of `bytes' currently allocated */
   lua_CFunction panic;  /* to be called in unprotected errors */
   lua_CFunction panic;  /* to be called in unprotected errors */
-  TObject _registry;
+  TValue _registry;
   struct lua_State *mainthread;
   struct lua_State *mainthread;
   Node dummynode[1];  /* common node array for all empty tables */
   Node dummynode[1];  /* common node array for all empty tables */
   TString *tmname[TM_N];  /* array with tag-method names */
   TString *tmname[TM_N];  /* array with tag-method names */
@@ -140,7 +140,7 @@ struct lua_State {
   int basehookcount;
   int basehookcount;
   int hookcount;
   int hookcount;
   lua_Hook hook;
   lua_Hook hook;
-  TObject _gt;  /* table of globals */
+  TValue _gt;  /* table of globals */
   GCObject *openupval;  /* list of open upvalues in this stack */
   GCObject *openupval;  /* list of open upvalues in this stack */
   GCObject *gclist;
   GCObject *gclist;
   struct lua_longjmp *errorJmp;  /* current error recover point */
   struct lua_longjmp *errorJmp;  /* current error recover point */
@@ -167,18 +167,20 @@ union GCObject {
 
 
 
 
 /* macros to convert a GCObject into a specific value */
 /* macros to convert a GCObject into a specific value */
-#define gcotots(o)	check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
-#define gcotou(o)	check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
-#define gcotocl(o)	check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
-#define gcotoh(o)	check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
-#define gcotop(o)	check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
-#define gcotouv(o)	check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
+#define rawgco2ts(o)	check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
+#define gco2ts(o)	(&rawgco2ts(o)->tsv)
+#define rawgco2u(o)	check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
+#define gco2u(o)	(&rawgco2u(o)->uv)
+#define gco2cl(o)	check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
+#define gco2h(o)	check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
+#define gco2p(o)	check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
+#define gco2uv(o)	check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
 #define ngcotouv(o) \
 #define ngcotouv(o) \
 	check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
 	check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
-#define gcototh(o)	check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
+#define gco2th(o)	check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
 
 
-/* macro to convert any value into a GCObject */
-#define valtogco(v)	(cast(GCObject *, (v)))
+/* macro to convert any Lua object into a GCObject */
+#define obj2gco(v)	(cast(GCObject *, (v)))
 
 
 
 
 lua_State *luaE_newthread (lua_State *L);
 lua_State *luaE_newthread (lua_State *L);

+ 5 - 5
lstring.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstring.c,v 1.84 2003/12/04 17:22:42 roberto Exp roberto $
+** $Id: lstring.c,v 1.85 2003/12/09 16:56:11 roberto Exp roberto $
 ** String table (keeps all strings handled by Lua)
 ** String table (keeps all strings handled by Lua)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -37,7 +37,7 @@ void luaS_resize (lua_State *L, int newsize) {
     GCObject *p = tb->hash[i];
     GCObject *p = tb->hash[i];
     while (p) {  /* for each node in the list */
     while (p) {  /* for each node in the list */
       GCObject *next = p->gch.next;  /* save next */
       GCObject *next = p->gch.next;  /* save next */
-      unsigned int h = gcotots(p)->tsv.hash;
+      unsigned int h = gco2ts(p)->hash;
       int h1 = lmod(h, newsize);  /* new position */
       int h1 = lmod(h, newsize);  /* new position */
       lua_assert(cast(int, h%newsize) == lmod(h, newsize));
       lua_assert(cast(int, h%newsize) == lmod(h, newsize));
       p->gch.next = newhash[h1];  /* chain it */
       p->gch.next = newhash[h1];  /* chain it */
@@ -65,7 +65,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
   tb = &G(L)->strt;
   tb = &G(L)->strt;
   h = lmod(h, tb->size);
   h = lmod(h, tb->size);
   ts->tsv.next = tb->hash[h];  /* chain new entry */
   ts->tsv.next = tb->hash[h];  /* chain new entry */
-  tb->hash[h] = valtogco(ts);
+  tb->hash[h] = obj2gco(ts);
   tb->nuse++;
   tb->nuse++;
   if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
   if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
     luaS_resize(L, tb->size*2);  /* too crowded */
     luaS_resize(L, tb->size*2);  /* too crowded */
@@ -83,7 +83,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
   for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
   for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
        o != NULL;
        o != NULL;
        o = o->gch.next) {
        o = o->gch.next) {
-    TString *ts = gcotots(o);
+    TString *ts = rawgco2ts(o);
     if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
     if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
       /* string may be dead */
       /* string may be dead */
       if (isdead(G(L), o)) changewhite(o);
       if (isdead(G(L), o)) changewhite(o);
@@ -103,7 +103,7 @@ Udata *luaS_newudata (lua_State *L, size_t s) {
   u->uv.metatable = NULL;
   u->uv.metatable = NULL;
   /* chain it on udata list */
   /* chain it on udata list */
   u->uv.next = G(L)->firstudata->uv.next;
   u->uv.next = G(L)->firstudata->uv.next;
-  G(L)->firstudata->uv.next = valtogco(u);
+  G(L)->firstudata->uv.next = obj2gco(u);
   return u;
   return u;
 }
 }
 
 

+ 36 - 36
ltable.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltable.c,v 1.137 2003/12/01 18:22:56 roberto Exp roberto $
+** $Id: ltable.c,v 1.138 2003/12/09 16:56:11 roberto Exp roberto $
 ** Lua tables (hash)
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -91,12 +91,12 @@ static Node *hashnum (const Table *t, lua_Number n) {
 ** returns the `main' position of an element in a table (that is, the index
 ** returns the `main' position of an element in a table (that is, the index
 ** of its hash value)
 ** of its hash value)
 */
 */
-Node *luaH_mainposition (const Table *t, const TObject *key) {
+Node *luaH_mainposition (const Table *t, const TValue *key) {
   switch (ttype(key)) {
   switch (ttype(key)) {
     case LUA_TNUMBER:
     case LUA_TNUMBER:
       return hashnum(t, nvalue(key));
       return hashnum(t, nvalue(key));
     case LUA_TSTRING:
     case LUA_TSTRING:
-      return hashstr(t, tsvalue(key));
+      return hashstr(t, rawtsvalue(key));
     case LUA_TBOOLEAN:
     case LUA_TBOOLEAN:
       return hashboolean(t, bvalue(key));
       return hashboolean(t, bvalue(key));
     case LUA_TLIGHTUSERDATA:
     case LUA_TLIGHTUSERDATA:
@@ -111,7 +111,7 @@ Node *luaH_mainposition (const Table *t, const TObject *key) {
 ** returns the index for `key' if `key' is an appropriate key to live in
 ** returns the index for `key' if `key' is an appropriate key to live in
 ** the array part of the table, -1 otherwise.
 ** the array part of the table, -1 otherwise.
 */
 */
-static int arrayindex (const TObject *key, lua_Number lim) {
+static int arrayindex (const TValue *key, lua_Number lim) {
   if (ttisnumber(key)) {
   if (ttisnumber(key)) {
     lua_Number n = nvalue(key);
     lua_Number n = nvalue(key);
     int k;
     int k;
@@ -137,7 +137,7 @@ static int luaH_index (lua_State *L, Table *t, StkId key) {
     return i-1;  /* yes; that's the index (corrected to C) */
     return i-1;  /* yes; that's the index (corrected to C) */
   }
   }
   else {
   else {
-    const TObject *v = luaH_get(t, key);
+    const TValue *v = luaH_get(t, key);
     if (v == &luaO_nilobject)
     if (v == &luaO_nilobject)
       luaG_runerror(L, "invalid key for `next'");
       luaG_runerror(L, "invalid key for `next'");
     i = cast(int, (cast(const lu_byte *, v) -
     i = cast(int, (cast(const lu_byte *, v) -
@@ -152,14 +152,14 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
   for (i++; i < t->sizearray; i++) {  /* try first array part */
   for (i++; i < t->sizearray; i++) {  /* try first array part */
     if (!ttisnil(&t->array[i])) {  /* a non-nil value? */
     if (!ttisnil(&t->array[i])) {  /* a non-nil value? */
       setnvalue(key, cast(lua_Number, i+1));
       setnvalue(key, cast(lua_Number, i+1));
-      setobj2s(key+1, &t->array[i]);
+      setobj2s(L, key+1, &t->array[i]);
       return 1;
       return 1;
     }
     }
   }
   }
   for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
   for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
     if (!ttisnil(gval(gnode(t, i)))) {  /* a non-nil value? */
     if (!ttisnil(gval(gnode(t, i)))) {  /* a non-nil value? */
-      setobj2s(key, gkey(gnode(t, i)));
-      setobj2s(key+1, gval(gnode(t, i)));
+      setobj2s(L, key, gkey(gnode(t, i)));
+      setobj2s(L, key+1, gval(gnode(t, i)));
       return 1;
       return 1;
     }
     }
   }
   }
@@ -239,7 +239,7 @@ static void numuse (const Table *t, int *narray, int *nhash) {
 
 
 static void setarrayvector (lua_State *L, Table *t, int size) {
 static void setarrayvector (lua_State *L, Table *t, int size) {
   int i;
   int i;
-  luaM_reallocvector(L, t->array, t->sizearray, size, TObject);
+  luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
   for (i=t->sizearray; i<size; i++)
   for (i=t->sizearray; i<size; i++)
      setnilvalue(&t->array[i]);
      setnilvalue(&t->array[i]);
   t->sizearray = size;
   t->sizearray = size;
@@ -296,16 +296,16 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
     /* re-insert elements from vanishing slice */
     /* re-insert elements from vanishing slice */
     for (i=nasize; i<oldasize; i++) {
     for (i=nasize; i<oldasize; i++) {
       if (!ttisnil(&t->array[i]))
       if (!ttisnil(&t->array[i]))
-        setobjt2t(luaH_setnum(L, t, i+1), &t->array[i]);
+        setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
     }
     }
     /* shrink array */
     /* shrink array */
-    luaM_reallocvector(L, t->array, oldasize, nasize, TObject);
+    luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
   }
   }
   /* re-insert elements in hash part */
   /* re-insert elements in hash part */
   for (i = twoto(oldhsize) - 1; i >= 0; i--) {
   for (i = twoto(oldhsize) - 1; i >= 0; i--) {
     Node *old = nold+i;
     Node *old = nold+i;
     if (!ttisnil(gval(old)))
     if (!ttisnil(gval(old)))
-      setobjt2t(luaH_set(L, t, gkey(old)), gval(old));
+      setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
   }
   }
   if (oldhsize)
   if (oldhsize)
     luaM_freearray(L, nold, twoto(oldhsize), Node);  /* free old array */
     luaM_freearray(L, nold, twoto(oldhsize), Node);  /* free old array */
@@ -327,7 +327,7 @@ static void rehash (lua_State *L, Table *t) {
 
 
 Table *luaH_new (lua_State *L, int narray, int lnhash) {
 Table *luaH_new (lua_State *L, int narray, int lnhash) {
   Table *t = luaM_new(L, Table);
   Table *t = luaM_new(L, Table);
-  luaC_link(L, valtogco(t), LUA_TTABLE);
+  luaC_link(L, obj2gco(t), LUA_TTABLE);
   t->metatable = NULL;
   t->metatable = NULL;
   t->flags = cast(lu_byte, ~0);
   t->flags = cast(lu_byte, ~0);
   /* temporary values (kept only if some malloc fails) */
   /* temporary values (kept only if some malloc fails) */
@@ -344,7 +344,7 @@ Table *luaH_new (lua_State *L, int narray, int lnhash) {
 void luaH_free (lua_State *L, Table *t) {
 void luaH_free (lua_State *L, Table *t) {
   if (t->lsizenode)
   if (t->lsizenode)
     luaM_freearray(L, t->node, sizenode(t), Node);
     luaM_freearray(L, t->node, sizenode(t), Node);
-  luaM_freearray(L, t->array, t->sizearray, TObject);
+  luaM_freearray(L, t->array, t->sizearray, TValue);
   luaM_freelem(L, t);
   luaM_freelem(L, t);
 }
 }
 
 
@@ -377,8 +377,8 @@ void luaH_remove (Table *t, Node *e) {
 ** put new key in its main position; otherwise (colliding node is in its main 
 ** put new key in its main position; otherwise (colliding node is in its main 
 ** position), new key goes to an empty position. 
 ** position), new key goes to an empty position. 
 */
 */
-static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
-  TObject *val;
+static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
+  TValue *val;
   Node *mp = luaH_mainposition(t, key);
   Node *mp = luaH_mainposition(t, key);
   if (!ttisnil(gval(mp))) {  /* main position is not free? */
   if (!ttisnil(gval(mp))) {  /* main position is not free? */
     Node *othern = luaH_mainposition(t, gkey(mp));  /* `mp' of colliding node */
     Node *othern = luaH_mainposition(t, gkey(mp));  /* `mp' of colliding node */
@@ -398,7 +398,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
       mp = n;
       mp = n;
     }
     }
   }
   }
-  setobj2t(gkey(mp), key);
+  setobj2t(L, gkey(mp), key);
   luaC_barrier(L, t, key);
   luaC_barrier(L, t, key);
   lua_assert(ttisnil(gval(mp)));
   lua_assert(ttisnil(gval(mp)));
   for (;;) {  /* correct `firstfree' */
   for (;;) {  /* correct `firstfree' */
@@ -410,7 +410,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
   /* no more free places; must create one */
   /* no more free places; must create one */
   setbvalue(gval(mp), 0);  /* avoid new key being removed */
   setbvalue(gval(mp), 0);  /* avoid new key being removed */
   rehash(L, t);  /* grow table */
   rehash(L, t);  /* grow table */
-  val = cast(TObject *, luaH_get(t, key));  /* get new position */
+  val = cast(TValue *, luaH_get(t, key));  /* get new position */
   lua_assert(ttisboolean(val));
   lua_assert(ttisboolean(val));
   setnilvalue(val);
   setnilvalue(val);
   return val;
   return val;
@@ -420,7 +420,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
 /*
 /*
 ** generic search function
 ** generic search function
 */
 */
-static const TObject *luaH_getany (Table *t, const TObject *key) {
+static const TValue *luaH_getany (Table *t, const TValue *key) {
   if (!ttisnil(key)) {
   if (!ttisnil(key)) {
     Node *n = luaH_mainposition(t, key);
     Node *n = luaH_mainposition(t, key);
     do {  /* check whether `key' is somewhere in the chain */
     do {  /* check whether `key' is somewhere in the chain */
@@ -435,7 +435,7 @@ static const TObject *luaH_getany (Table *t, const TObject *key) {
 /*
 /*
 ** search function for integers
 ** search function for integers
 */
 */
-const TObject *luaH_getnum (Table *t, int key) {
+const TValue *luaH_getnum (Table *t, int key) {
   if (1 <= key && key <= t->sizearray)
   if (1 <= key && key <= t->sizearray)
     return &t->array[key-1];
     return &t->array[key-1];
   else {
   else {
@@ -454,10 +454,10 @@ const TObject *luaH_getnum (Table *t, int key) {
 /*
 /*
 ** search function for strings
 ** search function for strings
 */
 */
-const TObject *luaH_getstr (Table *t, TString *key) {
+const TValue *luaH_getstr (Table *t, TString *key) {
   Node *n = hashstr(t, key);
   Node *n = hashstr(t, key);
   do {  /* check whether `key' is somewhere in the chain */
   do {  /* check whether `key' is somewhere in the chain */
-    if (ttisstring(gkey(n)) && tsvalue(gkey(n)) == key)
+    if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
       return gval(n);  /* that's it */
       return gval(n);  /* that's it */
     else n = n->next;
     else n = n->next;
   } while (n);
   } while (n);
@@ -468,9 +468,9 @@ const TObject *luaH_getstr (Table *t, TString *key) {
 /*
 /*
 ** main search function
 ** main search function
 */
 */
-const TObject *luaH_get (Table *t, const TObject *key) {
+const TValue *luaH_get (Table *t, const TValue *key) {
   switch (ttype(key)) {
   switch (ttype(key)) {
-    case LUA_TSTRING: return luaH_getstr(t, tsvalue(key));
+    case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
     case LUA_TNUMBER: {
     case LUA_TNUMBER: {
       int k;
       int k;
       lua_number2int(k, (nvalue(key)));
       lua_number2int(k, (nvalue(key)));
@@ -483,11 +483,11 @@ const TObject *luaH_get (Table *t, const TObject *key) {
 }
 }
 
 
 
 
-TObject *luaH_set (lua_State *L, Table *t, const TObject *key) {
-  const TObject *p = luaH_get(t, key);
+TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
+  const TValue *p = luaH_get(t, key);
   t->flags = 0;
   t->flags = 0;
   if (p != &luaO_nilobject)
   if (p != &luaO_nilobject)
-    return cast(TObject *, p);
+    return cast(TValue *, p);
   else {
   else {
     if (ttisnil(key)) luaG_runerror(L, "table index is nil");
     if (ttisnil(key)) luaG_runerror(L, "table index is nil");
     else if (ttisnumber(key) && nvalue(key) != nvalue(key))
     else if (ttisnumber(key) && nvalue(key) != nvalue(key))
@@ -497,25 +497,25 @@ TObject *luaH_set (lua_State *L, Table *t, const TObject *key) {
 }
 }
 
 
 
 
-TObject *luaH_setnum (lua_State *L, Table *t, int key) {
-  const TObject *p = luaH_getnum(t, key);
+TValue *luaH_setnum (lua_State *L, Table *t, int key) {
+  const TValue *p = luaH_getnum(t, key);
   if (p != &luaO_nilobject)
   if (p != &luaO_nilobject)
-    return cast(TObject *, p);
+    return cast(TValue *, p);
   else {
   else {
-    TObject k;
+    TValue k;
     setnvalue(&k, cast(lua_Number, key));
     setnvalue(&k, cast(lua_Number, key));
     return newkey(L, t, &k);
     return newkey(L, t, &k);
   }
   }
 }
 }
 
 
 
 
-TObject *luaH_setstr (lua_State *L, Table *t, TString *key) {
-  const TObject *p = luaH_getstr(t, key);
+TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
+  const TValue *p = luaH_getstr(t, key);
   if (p != &luaO_nilobject)
   if (p != &luaO_nilobject)
-    return cast(TObject *, p);
+    return cast(TValue *, p);
   else {
   else {
-    TObject k;
-    setsvalue(&k, key);
+    TValue k;
+    setsvalue(L, &k, key);
     return newkey(L, t, &k);
     return newkey(L, t, &k);
   }
   }
 }
 }

+ 8 - 8
ltable.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltable.h,v 1.44 2003/03/18 12:50:04 roberto Exp roberto $
+** $Id: ltable.h,v 1.45 2003/08/26 12:04:13 roberto Exp roberto $
 ** Lua tables (hash)
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -15,18 +15,18 @@
 #define gval(n)		(&(n)->i_val)
 #define gval(n)		(&(n)->i_val)
 
 
 
 
-const TObject *luaH_getnum (Table *t, int key);
-TObject *luaH_setnum (lua_State *L, Table *t, int key);
-const TObject *luaH_getstr (Table *t, TString *key);
-TObject *luaH_setstr (lua_State *L, Table *t, TString *key);
-const TObject *luaH_get (Table *t, const TObject *key);
-TObject *luaH_set (lua_State *L, Table *t, const TObject *key);
+const TValue *luaH_getnum (Table *t, int key);
+TValue *luaH_setnum (lua_State *L, Table *t, int key);
+const TValue *luaH_getstr (Table *t, TString *key);
+TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
+const TValue *luaH_get (Table *t, const TValue *key);
+TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
 Table *luaH_new (lua_State *L, int narray, int lnhash);
 Table *luaH_new (lua_State *L, int narray, int lnhash);
 void luaH_free (lua_State *L, Table *t);
 void luaH_free (lua_State *L, Table *t);
 int luaH_next (lua_State *L, Table *t, StkId key);
 int luaH_next (lua_State *L, Table *t, StkId key);
 
 
 /* exported only for debugging */
 /* exported only for debugging */
-Node *luaH_mainposition (const Table *t, const TObject *key);
+Node *luaH_mainposition (const Table *t, const TValue *key);
 
 
 
 
 #endif
 #endif

+ 4 - 4
ltests.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.c,v 1.168 2003/11/05 11:59:14 roberto Exp roberto $
+** $Id: ltests.c,v 1.169 2003/11/19 12:21:57 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -269,10 +269,10 @@ static int mem_query (lua_State *L) {
 static int hash_query (lua_State *L) {
 static int hash_query (lua_State *L) {
   if (lua_isnone(L, 2)) {
   if (lua_isnone(L, 2)) {
     luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
     luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
-    lua_pushinteger(L, tsvalue(func_at(L, 1))->tsv.hash);
+    lua_pushinteger(L, tsvalue(func_at(L, 1))->hash);
   }
   }
   else {
   else {
-    TObject *o = func_at(L, 1);
+    TValue *o = func_at(L, 1);
     Table *t;
     Table *t;
     luaL_checktype(L, 2, LUA_TTABLE);
     luaL_checktype(L, 2, LUA_TTABLE);
     t = hvalue(func_at(L, 2));
     t = hvalue(func_at(L, 2));
@@ -338,7 +338,7 @@ static int string_query (lua_State *L) {
     GCObject *ts;
     GCObject *ts;
     int n = 0;
     int n = 0;
     for (ts = tb->hash[s]; ts; ts = ts->gch.next) {
     for (ts = tb->hash[s]; ts; ts = ts->gch.next) {
-      setsvalue2s(L->top, gcotots(ts));
+      setsvalue2s(L, L->top, gco2ts(ts));
       incr_top(L);
       incr_top(L);
       n++;
       n++;
     }
     }

+ 1 - 2
ltests.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.h,v 1.20 2002/12/04 17:29:05 roberto Exp roberto $
+** $Id: ltests.h,v 1.21 2003/10/02 20:31:17 roberto Exp roberto $
 ** Internal Header for Debugging of the Lua Implementation
 ** Internal Header for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -19,7 +19,6 @@
 #include <assert.h>
 #include <assert.h>
 #define lua_assert(c)           assert(c)
 #define lua_assert(c)           assert(c)
 #define check_exp(c,e)		(lua_assert(c), (e))
 #define check_exp(c,e)		(lua_assert(c), (e))
-#define api_check(L, o)		lua_assert(o)
 
 
 
 
 /* to avoid warnings, and to make sure value is really unused */
 /* to avoid warnings, and to make sure value is really unused */

+ 5 - 5
ltm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltm.c,v 1.106 2003/04/03 13:35:34 roberto Exp roberto $
+** $Id: ltm.c,v 1.107 2003/12/01 18:22:56 roberto Exp roberto $
 ** Tag methods
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -45,8 +45,8 @@ void luaT_init (lua_State *L) {
 ** function to be used with macro "fasttm": optimized for absence of
 ** function to be used with macro "fasttm": optimized for absence of
 ** tag methods
 ** tag methods
 */
 */
-const TObject *luaT_gettm (Table *events, TMS event, TString *ename) {
-  const TObject *tm = luaH_getstr(events, ename);
+const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
+  const TValue *tm = luaH_getstr(events, ename);
   lua_assert(event <= TM_EQ);
   lua_assert(event <= TM_EQ);
   if (ttisnil(tm)) {  /* no tag method? */
   if (ttisnil(tm)) {  /* no tag method? */
     events->flags |= cast(lu_byte, 1u<<event);  /* cache this fact */
     events->flags |= cast(lu_byte, 1u<<event);  /* cache this fact */
@@ -56,14 +56,14 @@ const TObject *luaT_gettm (Table *events, TMS event, TString *ename) {
 }
 }
 
 
 
 
-const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event) {
+const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
   Table *mt;
   Table *mt;
   switch (ttype(o)) {
   switch (ttype(o)) {
     case LUA_TTABLE:
     case LUA_TTABLE:
       mt = hvalue(o)->metatable;
       mt = hvalue(o)->metatable;
       break;
       break;
     case LUA_TUSERDATA:
     case LUA_TUSERDATA:
-      mt = uvalue(o)->uv.metatable;
+      mt = uvalue(o)->metatable;
       break;
       break;
     default:
     default:
       mt = NULL;
       mt = NULL;

+ 3 - 3
ltm.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltm.h,v 1.41 2002/11/14 11:51:50 roberto Exp roberto $
+** $Id: ltm.h,v 1.42 2003/12/01 18:22:56 roberto Exp roberto $
 ** Tag methods
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -42,8 +42,8 @@ typedef enum {
 #define fasttm(l,et,e)	gfasttm(G(l), et, e)
 #define fasttm(l,et,e)	gfasttm(G(l), et, e)
 
 
 
 
-const TObject *luaT_gettm (Table *events, TMS event, TString *ename);
-const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event);
+const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
+const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event);
 void luaT_init (lua_State *L);
 void luaT_init (lua_State *L);
 
 
 extern const char *const luaT_typenames[];
 extern const char *const luaT_typenames[];

+ 13 - 11
lundump.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lundump.c,v 1.63 2003/08/25 19:51:54 roberto Exp roberto $
+** $Id: lundump.c,v 1.64 2003/08/27 21:01:44 roberto Exp roberto $
 ** load pre-compiled Lua chunks
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -158,13 +158,14 @@ static Proto* LoadFunction (LoadState* S, TString* p);
 static void LoadConstants (LoadState* S, Proto* f)
 static void LoadConstants (LoadState* S, Proto* f)
 {
 {
  int i,n;
  int i,n;
+ lua_State *L=S->L;
  n=LoadInt(S);
  n=LoadInt(S);
- f->k=luaM_newvector(S->L,n,TObject);
+ f->k=luaM_newvector(L,n,TValue);
  f->sizek=n;
  f->sizek=n;
  for (i=0; i<n; i++) setnilvalue(&f->k[i]);
  for (i=0; i<n; i++) setnilvalue(&f->k[i]);
  for (i=0; i<n; i++)
  for (i=0; i<n; i++)
  {
  {
-  TObject* o=&f->k[i];
+  TValue* o=&f->k[i];
   int t=LoadByte(S);
   int t=LoadByte(S);
   switch (t)
   switch (t)
   {
   {
@@ -172,18 +173,18 @@ static void LoadConstants (LoadState* S, Proto* f)
 	setnvalue(o,LoadNumber(S));
 	setnvalue(o,LoadNumber(S));
 	break;
 	break;
    case LUA_TSTRING:
    case LUA_TSTRING:
-	setsvalue2n(o,LoadString(S));
+	setsvalue2n(L, o,LoadString(S));
 	break;
 	break;
    case LUA_TNIL:
    case LUA_TNIL:
    	setnilvalue(o);
    	setnilvalue(o);
 	break;
 	break;
    default:
    default:
-	luaG_runerror(S->L,"bad constant type (%d) in %s",t,S->name);
+	luaG_runerror(L,"bad constant type (%d) in %s",t,S->name);
 	break;
 	break;
   }
   }
  }
  }
  n=LoadInt(S);
  n=LoadInt(S);
- f->p=luaM_newvector(S->L,n,Proto*);
+ f->p=luaM_newvector(L,n,Proto*);
  f->sizep=n;
  f->sizep=n;
  for (i=0; i<n; i++) f->p[i]=NULL;
  for (i=0; i<n; i++) f->p[i]=NULL;
  for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
  for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
@@ -191,9 +192,10 @@ static void LoadConstants (LoadState* S, Proto* f)
 
 
 static Proto* LoadFunction (LoadState* S, TString* p)
 static Proto* LoadFunction (LoadState* S, TString* p)
 {
 {
- Proto* f=luaF_newproto(S->L);
- setptvalue2s(S->L->top, f);
- incr_top(S->L);
+ lua_State *L=S->L;
+ Proto* f=luaF_newproto(L);
+ setptvalue2s(L, L->top, f);
+ incr_top(L);
  f->source=LoadString(S); if (f->source==NULL) f->source=p;
  f->source=LoadString(S); if (f->source==NULL) f->source=p;
  f->lineDefined=LoadInt(S);
  f->lineDefined=LoadInt(S);
  f->nups=LoadByte(S);
  f->nups=LoadByte(S);
@@ -206,9 +208,9 @@ static Proto* LoadFunction (LoadState* S, TString* p)
  LoadConstants(S,f);
  LoadConstants(S,f);
  LoadCode(S,f);
  LoadCode(S,f);
 #ifndef TRUST_BINARIES
 #ifndef TRUST_BINARIES
- if (!luaG_checkcode(f)) luaG_runerror(S->L,"bad code in %s",S->name);
+ if (!luaG_checkcode(f)) luaG_runerror(L,"bad code in %s",S->name);
 #endif
 #endif
- S->L->top--;
+ L->top--;
  return f;
  return f;
 }
 }
 
 

+ 79 - 79
lvm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.c,v 1.290 2003/10/27 19:14:31 roberto Exp roberto $
+** $Id: lvm.c,v 1.291 2003/12/09 16:56:11 roberto Exp roberto $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -40,7 +40,7 @@
 #define MAXTAGLOOP	100
 #define MAXTAGLOOP	100
 
 
 
 
-const TObject *luaV_tonumber (const TObject *obj, TObject *n) {
+const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
   lua_Number num;
   lua_Number num;
   if (ttisnumber(obj)) return obj;
   if (ttisnumber(obj)) return obj;
   if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
   if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
@@ -58,7 +58,7 @@ int luaV_tostring (lua_State *L, StkId obj) {
   else {
   else {
     char s[32];  /* 16 digits, sign, point and \0  (+ some extra...) */
     char s[32];  /* 16 digits, sign, point and \0  (+ some extra...) */
     lua_number2str(s, nvalue(obj));
     lua_number2str(s, nvalue(obj));
-    setsvalue2s(obj, luaS_new(L, s));
+    setsvalue2s(L, obj, luaS_new(L, s));
     return 1;
     return 1;
   }
   }
 }
 }
@@ -88,11 +88,11 @@ static void traceexec (lua_State *L, const Instruction *pc) {
 }
 }
 
 
 
 
-static void prepTMcall (lua_State *L, const TObject *f,
-                        const TObject *p1, const TObject *p2) {
-  setobj2s(L->top, f);  /* push function */
-  setobj2s(L->top+1, p1);  /* 1st argument */
-  setobj2s(L->top+2, p2);  /* 2nd argument */
+static void prepTMcall (lua_State *L, const TValue *f,
+                        const TValue *p1, const TValue *p2) {
+  setobj2s(L, L->top, f);  /* push function */
+  setobj2s(L, L->top+1, p1);  /* 1st argument */
+  setobj2s(L, L->top+2, p2);  /* 2nd argument */
 }
 }
 
 
 
 
@@ -103,7 +103,7 @@ static void callTMres (lua_State *L, StkId res) {
   luaD_call(L, L->top - 3, 1);
   luaD_call(L, L->top - 3, 1);
   res = restorestack(L, result);
   res = restorestack(L, result);
   L->top--;
   L->top--;
-  setobjs2s(res, L->top);
+  setobjs2s(L, res, L->top);
 }
 }
 
 
 
 
@@ -115,16 +115,16 @@ static void callTM (lua_State *L) {
 }
 }
 
 
 
 
-void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId val) {
+void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
   int loop;
   int loop;
   for (loop = 0; loop < MAXTAGLOOP; loop++) {
   for (loop = 0; loop < MAXTAGLOOP; loop++) {
-    const TObject *tm;
+    const TValue *tm;
     if (ttistable(t)) {  /* `t' is a table? */
     if (ttistable(t)) {  /* `t' is a table? */
       Table *h = hvalue(t);
       Table *h = hvalue(t);
-      const TObject *res = luaH_get(h, key); /* do a primitive set */
+      const TValue *res = luaH_get(h, key); /* do a primitive set */
       if (!ttisnil(res) ||  /* result is no nil? */
       if (!ttisnil(res) ||  /* result is no nil? */
           (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
           (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
-        setobj2s(val, res);
+        setobj2s(L, val, res);
         return;
         return;
       }
       }
       /* else will try the tag method */
       /* else will try the tag method */
@@ -142,16 +142,16 @@ void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId val) {
 }
 }
 
 
 
 
-void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {
+void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
   int loop;
   int loop;
   for (loop = 0; loop < MAXTAGLOOP; loop++) {
   for (loop = 0; loop < MAXTAGLOOP; loop++) {
-    const TObject *tm;
+    const TValue *tm;
     if (ttistable(t)) {  /* `t' is a table? */
     if (ttistable(t)) {  /* `t' is a table? */
       Table *h = hvalue(t);
       Table *h = hvalue(t);
-      TObject *oldval = luaH_set(L, h, key); /* do a primitive set */
+      TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
       if (!ttisnil(oldval) ||  /* result is no nil? */
       if (!ttisnil(oldval) ||  /* result is no nil? */
           (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
           (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
-        setobj2t(oldval, val);
+        setobj2t(L, oldval, val);
         luaC_barrier(L, h, val);
         luaC_barrier(L, h, val);
         return;
         return;
       }
       }
@@ -161,7 +161,7 @@ void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {
       luaG_typeerror(L, t, "index");
       luaG_typeerror(L, t, "index");
     if (ttisfunction(tm)) {
     if (ttisfunction(tm)) {
       prepTMcall(L, tm, t, key);
       prepTMcall(L, tm, t, key);
-      setobj2s(L->top+3, val);  /* 3th argument */
+      setobj2s(L, L->top+3, val);  /* 3th argument */
       callTM(L);
       callTM(L);
       return;
       return;
     }
     }
@@ -171,9 +171,9 @@ void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {
 }
 }
 
 
 
 
-static int call_binTM (lua_State *L, const TObject *p1, const TObject *p2,
+static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
                        StkId res, TMS event) {
                        StkId res, TMS event) {
-  const TObject *tm = luaT_gettmbyobj(L, p1, event);  /* try first operand */
+  const TValue *tm = luaT_gettmbyobj(L, p1, event);  /* try first operand */
   if (ttisnil(tm))
   if (ttisnil(tm))
     tm = luaT_gettmbyobj(L, p2, event);  /* try second operand */
     tm = luaT_gettmbyobj(L, p2, event);  /* try second operand */
   if (!ttisfunction(tm)) return 0;
   if (!ttisfunction(tm)) return 0;
@@ -183,10 +183,10 @@ static int call_binTM (lua_State *L, const TObject *p1, const TObject *p2,
 }
 }
 
 
 
 
-static const TObject *get_compTM (lua_State *L, Table *mt1, Table *mt2,
+static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
                                   TMS event) {
                                   TMS event) {
-  const TObject *tm1 = fasttm(L, mt1, event);
-  const TObject *tm2;
+  const TValue *tm1 = fasttm(L, mt1, event);
+  const TValue *tm2;
   if (tm1 == NULL) return NULL;  /* no metamethod */
   if (tm1 == NULL) return NULL;  /* no metamethod */
   if (mt1 == mt2) return tm1;  /* same metatables => same metamethods */
   if (mt1 == mt2) return tm1;  /* same metatables => same metamethods */
   tm2 = fasttm(L, mt2, event);
   tm2 = fasttm(L, mt2, event);
@@ -197,10 +197,10 @@ static const TObject *get_compTM (lua_State *L, Table *mt1, Table *mt2,
 }
 }
 
 
 
 
-static int call_orderTM (lua_State *L, const TObject *p1, const TObject *p2,
+static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
                          TMS event) {
                          TMS event) {
-  const TObject *tm1 = luaT_gettmbyobj(L, p1, event);
-  const TObject *tm2;
+  const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
+  const TValue *tm2;
   if (ttisnil(tm1)) return -1;  /* no metamethod? */
   if (ttisnil(tm1)) return -1;  /* no metamethod? */
   tm2 = luaT_gettmbyobj(L, p2, event);
   tm2 = luaT_gettmbyobj(L, p2, event);
   if (!luaO_rawequalObj(tm1, tm2))  /* different metamethods? */
   if (!luaO_rawequalObj(tm1, tm2))  /* different metamethods? */
@@ -233,28 +233,28 @@ static int luaV_strcmp (const TString *ls, const TString *rs) {
 }
 }
 
 
 
 
-int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r) {
+int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
   int res;
   int res;
   if (ttype(l) != ttype(r))
   if (ttype(l) != ttype(r))
     return luaG_ordererror(L, l, r);
     return luaG_ordererror(L, l, r);
   else if (ttisnumber(l))
   else if (ttisnumber(l))
     return nvalue(l) < nvalue(r);
     return nvalue(l) < nvalue(r);
   else if (ttisstring(l))
   else if (ttisstring(l))
-    return luaV_strcmp(tsvalue(l), tsvalue(r)) < 0;
+    return luaV_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
   else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
   else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
     return res;
     return res;
   return luaG_ordererror(L, l, r);
   return luaG_ordererror(L, l, r);
 }
 }
 
 
 
 
-static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) {
+static int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
   int res;
   int res;
   if (ttype(l) != ttype(r))
   if (ttype(l) != ttype(r))
     return luaG_ordererror(L, l, r);
     return luaG_ordererror(L, l, r);
   else if (ttisnumber(l))
   else if (ttisnumber(l))
     return nvalue(l) <= nvalue(r);
     return nvalue(l) <= nvalue(r);
   else if (ttisstring(l))
   else if (ttisstring(l))
-    return luaV_strcmp(tsvalue(l), tsvalue(r)) <= 0;
+    return luaV_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
   else if ((res = call_orderTM(L, l, r, TM_LE)) != -1)  /* first try `le' */
   else if ((res = call_orderTM(L, l, r, TM_LE)) != -1)  /* first try `le' */
     return res;
     return res;
   else if ((res = call_orderTM(L, r, l, TM_LT)) != -1)  /* else try `lt' */
   else if ((res = call_orderTM(L, r, l, TM_LT)) != -1)  /* else try `lt' */
@@ -263,8 +263,8 @@ static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) {
 }
 }
 
 
 
 
-int luaV_equalval (lua_State *L, const TObject *t1, const TObject *t2) {
-  const TObject *tm;
+int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
+  const TValue *tm;
   lua_assert(ttype(t1) == ttype(t2));
   lua_assert(ttype(t1) == ttype(t2));
   switch (ttype(t1)) {
   switch (ttype(t1)) {
     case LUA_TNIL: return 1;
     case LUA_TNIL: return 1;
@@ -273,7 +273,7 @@ int luaV_equalval (lua_State *L, const TObject *t1, const TObject *t2) {
     case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
     case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
     case LUA_TUSERDATA: {
     case LUA_TUSERDATA: {
       if (uvalue(t1) == uvalue(t2)) return 1;
       if (uvalue(t1) == uvalue(t2)) return 1;
-      tm = get_compTM(L, uvalue(t1)->uv.metatable, uvalue(t2)->uv.metatable,
+      tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
                          TM_EQ);
                          TM_EQ);
       break;  /* will try TM */
       break;  /* will try TM */
     }
     }
@@ -298,25 +298,25 @@ void luaV_concat (lua_State *L, int total, int last) {
     if (!tostring(L, top-2) || !tostring(L, top-1)) {
     if (!tostring(L, top-2) || !tostring(L, top-1)) {
       if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
       if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
         luaG_concaterror(L, top-2, top-1);
         luaG_concaterror(L, top-2, top-1);
-    } else if (tsvalue(top-1)->tsv.len > 0) {  /* if len=0, do nothing */
+    } else if (tsvalue(top-1)->len > 0) {  /* if len=0, do nothing */
       /* at least two string values; get as many as possible */
       /* at least two string values; get as many as possible */
-      lu_mem tl = cast(lu_mem, tsvalue(top-1)->tsv.len) +
-                  cast(lu_mem, tsvalue(top-2)->tsv.len);
+      lu_mem tl = cast(lu_mem, tsvalue(top-1)->len) +
+                  cast(lu_mem, tsvalue(top-2)->len);
       char *buffer;
       char *buffer;
       int i;
       int i;
       while (n < total && tostring(L, top-n-1)) {  /* collect total length */
       while (n < total && tostring(L, top-n-1)) {  /* collect total length */
-        tl += tsvalue(top-n-1)->tsv.len;
+        tl += tsvalue(top-n-1)->len;
         n++;
         n++;
       }
       }
       if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow");
       if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow");
       buffer = luaZ_openspace(L, &G(L)->buff, tl);
       buffer = luaZ_openspace(L, &G(L)->buff, tl);
       tl = 0;
       tl = 0;
       for (i=n; i>0; i--) {  /* concat all strings */
       for (i=n; i>0; i--) {  /* concat all strings */
-        size_t l = tsvalue(top-i)->tsv.len;
+        size_t l = tsvalue(top-i)->len;
         memcpy(buffer+tl, svalue(top-i), l);
         memcpy(buffer+tl, svalue(top-i), l);
         tl += l;
         tl += l;
       }
       }
-      setsvalue2s(top-n, luaS_newlstr(L, buffer, tl));
+      setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
     }
     }
     total -= n-1;  /* got `n' strings to create 1 new */
     total -= n-1;  /* got `n' strings to create 1 new */
     last -= n-1;
     last -= n-1;
@@ -324,10 +324,10 @@ void luaV_concat (lua_State *L, int total, int last) {
 }
 }
 
 
 
 
-static StkId Arith (lua_State *L, StkId ra, const TObject *rb,
-                    const TObject *rc, TMS op, const Instruction *pc) {
-  TObject tempb, tempc;
-  const TObject *b, *c;
+static StkId Arith (lua_State *L, StkId ra, const TValue *rb,
+                    const TValue *rc, TMS op, const Instruction *pc) {
+  TValue tempb, tempc;
+  const TValue *b, *c;
   L->ci->u.l.savedpc = pc;
   L->ci->u.l.savedpc = pc;
   if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
   if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
       (c = luaV_tonumber(rc, &tempc)) != NULL) {
       (c = luaV_tonumber(rc, &tempc)) != NULL) {
@@ -337,7 +337,7 @@ static StkId Arith (lua_State *L, StkId ra, const TObject *rb,
       case TM_MUL: setnvalue(ra, nvalue(b) * nvalue(c)); break;
       case TM_MUL: setnvalue(ra, nvalue(b) * nvalue(c)); break;
       case TM_DIV: setnvalue(ra, nvalue(b) / nvalue(c)); break;
       case TM_DIV: setnvalue(ra, nvalue(b) / nvalue(c)); break;
       case TM_POW: {
       case TM_POW: {
-        const TObject *f = luaH_getstr(hvalue(gt(L)), G(L)->tmname[TM_POW]);
+        const TValue *f = luaH_getstr(hvalue(gt(L)), G(L)->tmname[TM_POW]);
         if (!ttisfunction(f))
         if (!ttisfunction(f))
           luaG_runerror(L, "`__pow' (`^' operator) is not a function");
           luaG_runerror(L, "`__pow' (`^' operator) is not a function");
         prepTMcall(L, f, b, c);
         prepTMcall(L, f, b, c);
@@ -376,7 +376,7 @@ static StkId Arith (lua_State *L, StkId ra, const TObject *rb,
 
 
 StkId luaV_execute (lua_State *L, int nexeccalls) {
 StkId luaV_execute (lua_State *L, int nexeccalls) {
   LClosure *cl;
   LClosure *cl;
-  TObject *k;
+  TValue *k;
   StkId base;
   StkId base;
   const Instruction *pc;
   const Instruction *pc;
  callentry:  /* entry point when calling new functions */
  callentry:  /* entry point when calling new functions */
@@ -409,11 +409,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
          GET_OPCODE(i) == OP_RETURN || GET_OPCODE(i) == OP_SETLISTO);
          GET_OPCODE(i) == OP_RETURN || GET_OPCODE(i) == OP_SETLISTO);
     switch (GET_OPCODE(i)) {
     switch (GET_OPCODE(i)) {
       case OP_MOVE: {
       case OP_MOVE: {
-        setobjs2s(ra, RB(i));
+        setobjs2s(L, ra, RB(i));
         break;
         break;
       }
       }
       case OP_LOADK: {
       case OP_LOADK: {
-        setobj2s(ra, KBx(i));
+        setobj2s(L, ra, KBx(i));
         break;
         break;
       }
       }
       case OP_LOADBOOL: {
       case OP_LOADBOOL: {
@@ -422,7 +422,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         break;
         break;
       }
       }
       case OP_LOADNIL: {
       case OP_LOADNIL: {
-        TObject *rb = RB(i);
+        TValue *rb = RB(i);
         do {
         do {
           setnilvalue(rb--);
           setnilvalue(rb--);
         } while (rb >= ra);
         } while (rb >= ra);
@@ -430,11 +430,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
       }
       }
       case OP_GETUPVAL: {
       case OP_GETUPVAL: {
         int b = GETARG_B(i);
         int b = GETARG_B(i);
-        setobj2s(ra, cl->upvals[b]->v);
+        setobj2s(L, ra, cl->upvals[b]->v);
         break;
         break;
       }
       }
       case OP_GETGLOBAL: {
       case OP_GETGLOBAL: {
-        TObject *rb = KBx(i);
+        TValue *rb = KBx(i);
         lua_assert(ttisstring(rb) && ttistable(&cl->g));
         lua_assert(ttisstring(rb) && ttistable(&cl->g));
         L->ci->u.l.savedpc = pc;
         L->ci->u.l.savedpc = pc;
         luaV_gettable(L, &cl->g, rb, ra);  /***/
         luaV_gettable(L, &cl->g, rb, ra);  /***/
@@ -456,7 +456,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
       }
       }
       case OP_SETUPVAL: {
       case OP_SETUPVAL: {
         UpVal *uv = cl->upvals[GETARG_B(i)];
         UpVal *uv = cl->upvals[GETARG_B(i)];
-        setobj(uv->v, ra);
+        setobj(L, uv->v, ra);
         luaC_barrier(L, uv, ra);
         luaC_barrier(L, uv, ra);
         break;
         break;
       }
       }
@@ -469,7 +469,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
       case OP_NEWTABLE: {
       case OP_NEWTABLE: {
         int b = GETARG_B(i);
         int b = GETARG_B(i);
         b = fb2int(b);
         b = fb2int(b);
-        sethvalue(ra, luaH_new(L, b, GETARG_C(i)));
+        sethvalue(L, ra, luaH_new(L, b, GETARG_C(i)));
         L->ci->u.l.savedpc = pc;
         L->ci->u.l.savedpc = pc;
         luaC_checkGC(L);  /***/
         luaC_checkGC(L);  /***/
         base = L->base;
         base = L->base;
@@ -477,15 +477,15 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
       }
       }
       case OP_SELF: {
       case OP_SELF: {
         StkId rb = RB(i);
         StkId rb = RB(i);
-        setobjs2s(ra+1, rb);
+        setobjs2s(L, ra+1, rb);
         L->ci->u.l.savedpc = pc;
         L->ci->u.l.savedpc = pc;
         luaV_gettable(L, rb, RKC(i), ra);  /***/
         luaV_gettable(L, rb, RKC(i), ra);  /***/
         base = L->base;
         base = L->base;
         break;
         break;
       }
       }
       case OP_ADD: {
       case OP_ADD: {
-        TObject *rb = RKB(i);
-        TObject *rc = RKC(i);
+        TValue *rb = RKB(i);
+        TValue *rc = RKC(i);
         if (ttisnumber(rb) && ttisnumber(rc)) {
         if (ttisnumber(rb) && ttisnumber(rc)) {
           setnvalue(ra, nvalue(rb) + nvalue(rc));
           setnvalue(ra, nvalue(rb) + nvalue(rc));
         }
         }
@@ -494,8 +494,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         break;
         break;
       }
       }
       case OP_SUB: {
       case OP_SUB: {
-        TObject *rb = RKB(i);
-        TObject *rc = RKC(i);
+        TValue *rb = RKB(i);
+        TValue *rc = RKC(i);
         if (ttisnumber(rb) && ttisnumber(rc)) {
         if (ttisnumber(rb) && ttisnumber(rc)) {
           setnvalue(ra, nvalue(rb) - nvalue(rc));
           setnvalue(ra, nvalue(rb) - nvalue(rc));
         }
         }
@@ -504,8 +504,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         break;
         break;
       }
       }
       case OP_MUL: {
       case OP_MUL: {
-        TObject *rb = RKB(i);
-        TObject *rc = RKC(i);
+        TValue *rb = RKB(i);
+        TValue *rc = RKC(i);
         if (ttisnumber(rb) && ttisnumber(rc)) {
         if (ttisnumber(rb) && ttisnumber(rc)) {
           setnvalue(ra, nvalue(rb) * nvalue(rc));
           setnvalue(ra, nvalue(rb) * nvalue(rc));
         }
         }
@@ -514,8 +514,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         break;
         break;
       }
       }
       case OP_DIV: {
       case OP_DIV: {
-        TObject *rb = RKB(i);
-        TObject *rc = RKC(i);
+        TValue *rb = RKB(i);
+        TValue *rc = RKC(i);
         if (ttisnumber(rb) && ttisnumber(rc)) {
         if (ttisnumber(rb) && ttisnumber(rc)) {
           setnvalue(ra, nvalue(rb) / nvalue(rc));
           setnvalue(ra, nvalue(rb) / nvalue(rc));
         }
         }
@@ -528,8 +528,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         break;
         break;
       }
       }
       case OP_UNM: {
       case OP_UNM: {
-        const TObject *rb = RB(i);
-        TObject temp;
+        const TValue *rb = RB(i);
+        TValue temp;
         if (tonumber(rb, &temp)) {
         if (tonumber(rb, &temp)) {
           setnvalue(ra, -nvalue(rb));
           setnvalue(ra, -nvalue(rb));
         }
         }
@@ -554,7 +554,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         luaV_concat(L, c-b+1, c);  /* may change `base' (and `ra') */  /***/
         luaV_concat(L, c-b+1, c);  /* may change `base' (and `ra') */  /***/
         luaC_checkGC(L);  /***/
         luaC_checkGC(L);  /***/
         base = L->base;
         base = L->base;
-        setobjs2s(RA(i), base+b);
+        setobjs2s(L, RA(i), base+b);
         break;
         break;
       }
       }
       case OP_JMP: {
       case OP_JMP: {
@@ -583,10 +583,10 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         break;
         break;
       }
       }
       case OP_TEST: {
       case OP_TEST: {
-        TObject *rb = RB(i);
+        TValue *rb = RB(i);
         if (l_isfalse(rb) == GETARG_C(i)) pc++;
         if (l_isfalse(rb) == GETARG_C(i)) pc++;
         else {
         else {
-          setobjs2s(ra, rb);
+          setobjs2s(L, ra, rb);
           dojump(pc, GETARG_sBx(*pc) + 1);
           dojump(pc, GETARG_sBx(*pc) + 1);
         }
         }
         break;
         break;
@@ -617,7 +617,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
             ra = RA(i);
             ra = RA(i);
             if (L->openupval) luaF_close(L, base);
             if (L->openupval) luaF_close(L, base);
             for (aux = 0; ra+aux < L->top; aux++)  /* move frame down */
             for (aux = 0; ra+aux < L->top; aux++)  /* move frame down */
-              setobjs2s(base+aux-1, ra+aux);
+              setobjs2s(L, base+aux-1, ra+aux);
             (L->ci - 1)->top = L->top = base+aux;  /* correct top */
             (L->ci - 1)->top = L->top = base+aux;  /* correct top */
             (L->ci - 1)->u.l.savedpc = L->ci->u.l.savedpc;
             (L->ci - 1)->u.l.savedpc = L->ci->u.l.savedpc;
             (L->ci - 1)->u.l.tailcalls++;  /* one more call lost */
             (L->ci - 1)->u.l.tailcalls++;  /* one more call lost */
@@ -659,9 +659,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         break;
         break;
       }
       }
       case OP_FORPREP: {  /***/
       case OP_FORPREP: {  /***/
-        const TObject *init = ra;
-        const TObject *plimit = ra+1;
-        const TObject *pstep = ra+2;
+        const TValue *init = ra;
+        const TValue *plimit = ra+1;
+        const TValue *pstep = ra+2;
         L->ci->u.l.savedpc = pc;
         L->ci->u.l.savedpc = pc;
         if (!tonumber(init, ra))
         if (!tonumber(init, ra))
           luaG_runerror(L, "`for' initial value must be a number");
           luaG_runerror(L, "`for' initial value must be a number");
@@ -675,9 +675,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
       }
       }
       case OP_TFORLOOP: {
       case OP_TFORLOOP: {
         StkId cb = ra + 3;  /* call base */
         StkId cb = ra + 3;  /* call base */
-        setobjs2s(cb+2, ra+2);
-        setobjs2s(cb+1, ra+1);
-        setobjs2s(cb, ra);
+        setobjs2s(L, cb+2, ra+2);
+        setobjs2s(L, cb+1, ra+1);
+        setobjs2s(L, cb, ra);
         L->top = cb+3;  /* func. + 2 args (state and index) */
         L->top = cb+3;  /* func. + 2 args (state and index) */
         L->ci->u.l.savedpc = pc;
         L->ci->u.l.savedpc = pc;
         luaD_call(L, cb, GETARG_C(i));  /***/
         luaD_call(L, cb, GETARG_C(i));  /***/
@@ -687,15 +687,15 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         if (ttisnil(cb))  /* break loop? */
         if (ttisnil(cb))  /* break loop? */
           pc++;  /* skip jump (break loop) */
           pc++;  /* skip jump (break loop) */
         else {
         else {
-          setobjs2s(cb-1, cb);  /* save control variable */
+          setobjs2s(L, cb-1, cb);  /* save control variable */
           dojump(pc, GETARG_sBx(*pc) + 1);  /* jump back */
           dojump(pc, GETARG_sBx(*pc) + 1);  /* jump back */
         }
         }
         break;
         break;
       }
       }
       case OP_TFORPREP: {  /* for compatibility only */
       case OP_TFORPREP: {  /* for compatibility only */
         if (ttistable(ra)) {
         if (ttistable(ra)) {
-          setobjs2s(ra+1, ra);
-          setobj2s(ra, luaH_getstr(hvalue(gt(L)), luaS_new(L, "next")));
+          setobjs2s(L, ra+1, ra);
+          setobj2s(L, ra, luaH_getstr(hvalue(gt(L)), luaS_new(L, "next")));
         }
         }
         dojump(pc, GETARG_sBx(i));
         dojump(pc, GETARG_sBx(i));
         break;
         break;
@@ -716,8 +716,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         }
         }
         bc &= ~(LFIELDS_PER_FLUSH-1);  /* bc = bc - bc%FPF */
         bc &= ~(LFIELDS_PER_FLUSH-1);  /* bc = bc - bc%FPF */
         for (; n > 0; n--) {
         for (; n > 0; n--) {
-          TObject *val = ra+n;
-          setobj2t(luaH_setnum(L, h, bc+n), val);
+          TValue *val = ra+n;
+          setobj2t(L, luaH_setnum(L, h, bc+n), val);
           luaC_barrier(L, h, val);
           luaC_barrier(L, h, val);
         }
         }
         break;
         break;
@@ -742,7 +742,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
             ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
             ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
           }
           }
         }
         }
-        setclvalue(ra, ncl);
+        setclvalue(L, ra, ncl);
         L->ci->u.l.savedpc = pc;
         L->ci->u.l.savedpc = pc;
         luaC_checkGC(L);  /***/
         luaC_checkGC(L);  /***/
         base = L->base;
         base = L->base;

+ 6 - 6
lvm.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.h,v 1.48 2003/05/05 18:39:57 roberto Exp $
+** $Id: lvm.h,v 1.49 2003/07/16 20:49:02 roberto Exp roberto $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -22,12 +22,12 @@
 	(ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
 	(ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
 
 
 
 
-int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r);
-int luaV_equalval (lua_State *L, const TObject *t1, const TObject *t2);
-const TObject *luaV_tonumber (const TObject *obj, TObject *n);
+int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
+int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
+const TValue *luaV_tonumber (const TValue *obj, TValue *n);
 int luaV_tostring (lua_State *L, StkId obj);
 int luaV_tostring (lua_State *L, StkId obj);
-void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId val);
-void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val);
+void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val);
+void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val);
 StkId luaV_execute (lua_State *L, int nexeccalls);
 StkId luaV_execute (lua_State *L, int nexeccalls);
 void luaV_concat (lua_State *L, int total, int last);
 void luaV_concat (lua_State *L, int total, int last);
 
 

+ 26 - 26
makefile

@@ -1,5 +1,5 @@
 #
 #
-## $Id: makefile,v 1.40 2003/03/19 21:27:30 roberto Exp roberto $
+## $Id: makefile,v 1.41 2003/04/07 20:11:53 roberto Exp roberto $
 ## Makefile
 ## Makefile
 ## See Copyright Notice in lua.h
 ## See Copyright Notice in lua.h
 #
 #
@@ -8,7 +8,7 @@
 #CONFIGURATION
 #CONFIGURATION
 
 
 # -DEXTERNMEMCHECK -DHARDSTACKTESTS
 # -DEXTERNMEMCHECK -DHARDSTACKTESTS
-# DEBUG = -g -DLUA_USER_H='"ltests.h"'
+DEBUG = -g -DLUA_USER_H='"ltests.h"'
 OPTIMIZE =  -O2 \
 OPTIMIZE =  -O2 \
   -D'lua_number2int(i,d)=__asm__("fldl %1\nfistpl %0":"=m"(i):"m"(d))' \
   -D'lua_number2int(i,d)=__asm__("fldl %1\nfistpl %0":"=m"(i):"m"(d))' \
 #   -fomit-frame-pointer
 #   -fomit-frame-pointer
@@ -104,53 +104,53 @@ clear	:
 
 
 
 
 lapi.o: lapi.c lua.h lapi.h lobject.h llimits.h ldebug.h lstate.h ltm.h \
 lapi.o: lapi.c lua.h lapi.h lobject.h llimits.h ldebug.h lstate.h ltm.h \
-  lzio.h ldo.h lfunc.h lgc.h lmem.h lstring.h ltable.h lundump.h lvm.h
+  lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h lundump.h lvm.h
 lauxlib.o: lauxlib.c lua.h lauxlib.h
 lauxlib.o: lauxlib.c lua.h lauxlib.h
 lbaselib.o: lbaselib.c lua.h lauxlib.h lualib.h
 lbaselib.o: lbaselib.c lua.h lauxlib.h lualib.h
-lcode.o: lcode.c lua.h lcode.h llex.h lobject.h llimits.h lzio.h \
-  lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h ldo.h lmem.h
+lcode.o: lcode.c lua.h lcode.h llex.h lobject.h llimits.h lzio.h lmem.h \
+  lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h ldo.h lgc.h
 ldblib.o: ldblib.c lua.h lauxlib.h lualib.h
 ldblib.o: ldblib.c lua.h lauxlib.h lualib.h
 ldebug.o: ldebug.c lua.h lapi.h lobject.h llimits.h lcode.h llex.h lzio.h \
 ldebug.o: ldebug.c lua.h lapi.h lobject.h llimits.h lcode.h llex.h lzio.h \
-  lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h ldo.h lfunc.h \
-  lstring.h lvm.h
+  lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h ldo.h \
+  lfunc.h lstring.h lgc.h lvm.h
 ldo.o: ldo.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
 ldo.o: ldo.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
-  ldo.h lfunc.h lgc.h lmem.h lopcodes.h lparser.h ltable.h lstring.h \
+  lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h ltable.h lstring.h \
   lundump.h lvm.h
   lundump.h lvm.h
 ldump.o: ldump.c lua.h lobject.h llimits.h lopcodes.h lstate.h ltm.h \
 ldump.o: ldump.c lua.h lobject.h llimits.h lopcodes.h lstate.h ltm.h \
-  lzio.h lundump.h
+  lzio.h lmem.h lundump.h
 lfunc.o: lfunc.c lua.h lfunc.h lobject.h llimits.h lgc.h lmem.h lstate.h \
 lfunc.o: lfunc.c lua.h lfunc.h lobject.h llimits.h lgc.h lmem.h lstate.h \
   ltm.h lzio.h
   ltm.h lzio.h
 lgc.o: lgc.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
 lgc.o: lgc.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
-  ldo.h lfunc.h lgc.h lmem.h lstring.h ltable.h
+  lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
 liolib.o: liolib.c lua.h lauxlib.h lualib.h
 liolib.o: liolib.c lua.h lauxlib.h lualib.h
 llex.o: llex.c lua.h ldo.h lobject.h llimits.h lstate.h ltm.h lzio.h \
 llex.o: llex.c lua.h ldo.h lobject.h llimits.h lstate.h ltm.h lzio.h \
-  llex.h lparser.h ltable.h lstring.h
+  lmem.h llex.h lparser.h ltable.h lstring.h lgc.h
 lmathlib.o: lmathlib.c lua.h lauxlib.h lualib.h
 lmathlib.o: lmathlib.c lua.h lauxlib.h lualib.h
 lmem.o: lmem.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
 lmem.o: lmem.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
-  ldo.h lmem.h
-lobject.o: lobject.c lua.h ldo.h lobject.h llimits.h lstate.h ltm.h \
-  lzio.h lmem.h lstring.h lvm.h
+  lmem.h ldo.h
 loadlib.o: loadlib.c lua.h lauxlib.h lualib.h
 loadlib.o: loadlib.c lua.h lauxlib.h lualib.h
+lobject.o: lobject.c lua.h ldo.h lobject.h llimits.h lstate.h ltm.h \
+  lzio.h lmem.h lstring.h lgc.h lvm.h
 lopcodes.o: lopcodes.c lua.h lobject.h llimits.h lopcodes.h
 lopcodes.o: lopcodes.c lua.h lobject.h llimits.h lopcodes.h
 lparser.o: lparser.c lua.h lcode.h llex.h lobject.h llimits.h lzio.h \
 lparser.o: lparser.c lua.h lcode.h llex.h lobject.h llimits.h lzio.h \
-  lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h lfunc.h lmem.h \
-  lstring.h
+  lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h ldo.h \
+  lfunc.h lstring.h lgc.h
 lstate.o: lstate.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
 lstate.o: lstate.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
-  lzio.h ldo.h lfunc.h lgc.h llex.h lmem.h lstring.h ltable.h
+  lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h
 lstring.o: lstring.c lua.h lmem.h llimits.h lobject.h lstate.h ltm.h \
 lstring.o: lstring.c lua.h lmem.h llimits.h lobject.h lstate.h ltm.h \
-  lzio.h lstring.h
+  lzio.h lstring.h lgc.h
 lstrlib.o: lstrlib.c lua.h lauxlib.h lualib.h
 lstrlib.o: lstrlib.c lua.h lauxlib.h lualib.h
 ltable.o: ltable.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
 ltable.o: ltable.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
-  lzio.h ldo.h lgc.h lmem.h ltable.h
+  lzio.h lmem.h ldo.h lgc.h ltable.h
 ltablib.o: ltablib.c lua.h lauxlib.h lualib.h
 ltablib.o: ltablib.c lua.h lauxlib.h lualib.h
 ltests.o: ltests.c lua.h lapi.h lobject.h llimits.h lauxlib.h lcode.h \
 ltests.o: ltests.c lua.h lapi.h lobject.h llimits.h lauxlib.h lcode.h \
-  llex.h lzio.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h \
-  ldo.h lfunc.h lmem.h lstring.h lualib.h
-ltm.o: ltm.c lua.h lobject.h llimits.h lstate.h ltm.h lzio.h lstring.h \
-  ltable.h
+  llex.h lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h \
+  ltm.h ldo.h lfunc.h lstring.h lgc.h lualib.h
+ltm.o: ltm.c lua.h lobject.h llimits.h lstate.h ltm.h lzio.h lmem.h \
+  lstring.h lgc.h ltable.h
 lua.o: lua.c lua.h lauxlib.h lualib.h
 lua.o: lua.c lua.h lauxlib.h lualib.h
 lundump.o: lundump.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
 lundump.o: lundump.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
-  lzio.h lfunc.h lmem.h lopcodes.h lstring.h lundump.h
+  lzio.h lmem.h ldo.h lfunc.h lopcodes.h lstring.h lgc.h lundump.h
 lvm.o: lvm.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
 lvm.o: lvm.c lua.h ldebug.h lstate.h lobject.h llimits.h ltm.h lzio.h \
-  ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h
-lzio.o: lzio.c lua.h llimits.h lmem.h lzio.h
+  lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h
+lzio.o: lzio.c lua.h llimits.h lmem.h lstate.h lobject.h ltm.h lzio.h