commit 8ca9534d048782af13141874e0d2fec0d0f806af
parent 8bcf6228765e56be19feb90c8805cc2fb2223188
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 8 Jun 2000 15:26:51 -0300
access to `values' in TObject always through macros
Diffstat:
11 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 1.82 2000/05/26 19:17:57 roberto Exp roberto $
+** $Id: lapi.c,v 1.83 2000/06/06 16:31:41 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -63,7 +63,7 @@ lua_Object lua_pop (lua_State *L) {
void lua_pushglobaltable (lua_State *L) {
- avalue(L->top) = L->gt;
+ hvalue(L->top) = L->gt;
ttype(L->top) = TAG_TABLE;
incr_top;
}
@@ -72,7 +72,7 @@ void lua_pushglobaltable (lua_State *L) {
void lua_setglobaltable (lua_State *L, lua_Object newtable) {
if (lua_type(L, newtable)[0] != 't') /* type == "table"? */
lua_error(L, "Lua API error - invalid value for global table");
- L->gt = avalue(newtable);
+ L->gt = hvalue(newtable);
}
@@ -125,7 +125,7 @@ lua_Object lua_rawget (lua_State *L) {
luaA_checkCargs(L, 2);
if (ttype(L->top-2) != TAG_TABLE)
lua_error(L, "indexed expression not a table");
- res = luaA_putluaObject(L, luaH_get(L, avalue(L->top-2), L->top-1));
+ res = luaA_putluaObject(L, luaH_get(L, hvalue(L->top-2), L->top-1));
L->top -= 2;
return res;
}
@@ -144,7 +144,7 @@ void lua_rawset (lua_State *L) {
luaA_checkCargs(L, 3);
if (ttype(L->top-3) != TAG_TABLE)
lua_error(L, "indexed expression not a table");
- *luaH_set(L, avalue(L->top-3), L->top-2) = *(L->top-1);
+ *luaH_set(L, hvalue(L->top-3), L->top-2) = *(L->top-1);
L->top -= 3;
}
@@ -152,7 +152,7 @@ void lua_rawset (lua_State *L) {
lua_Object lua_createtable (lua_State *L) {
TObject o;
luaC_checkGC(L);
- avalue(&o) = luaH_new(L, 0);
+ hvalue(&o) = luaH_new(L, 0);
ttype(&o) = TAG_TABLE;
return luaA_putluaObject(L, &o);
}
@@ -311,7 +311,7 @@ int lua_tag (lua_State *L, lua_Object o) {
if (o == LUA_NOOBJECT)
return TAG_NIL;
else if (ttype(o) == TAG_USERDATA) /* to allow `old' tags (deprecated) */
- return o->value.ts->u.d.tag;
+ return tsvalue(o)->u.d.tag;
else
return luaT_effectivetag(L, o);
}
@@ -322,10 +322,10 @@ void lua_settag (lua_State *L, int tag) {
luaT_realtag(L, tag);
switch (ttype(L->top-1)) {
case TAG_TABLE:
- (L->top-1)->value.a->htag = tag;
+ hvalue(L->top-1)->htag = tag;
break;
case TAG_USERDATA:
- (L->top-1)->value.ts->u.d.tag = tag;
+ tsvalue(L->top-1)->u.d.tag = tag;
break;
default:
luaL_verror(L, "cannot change the tag of a %.20s",
@@ -352,7 +352,7 @@ int luaA_next (lua_State *L, const Hash *t, int i) {
int lua_next (lua_State *L, lua_Object t, int i) {
if (ttype(t) != TAG_TABLE)
lua_error(L, "Lua API error - object is not a table in `lua_next'");
- i = luaA_next(L, avalue(t), i);
+ i = luaA_next(L, hvalue(t), i);
top2LC(L, (i==0) ? 0 : 2);
return i;
}
diff --git a/lbuiltin.c b/lbuiltin.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbuiltin.c,v 1.113 2000/06/05 20:15:33 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.114 2000/06/06 16:31:41 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@@ -74,7 +74,7 @@ static Number getnarg (lua_State *L, const Hash *a) {
static Hash *gettable (lua_State *L, int arg) {
- return avalue(luaL_tablearg(L, arg));
+ return hvalue(luaL_tablearg(L, arg));
}
/* }====================================================== */
@@ -358,14 +358,14 @@ void luaB_tostring (lua_State *L) {
lua_pushobject(L, o);
return;
case TAG_TABLE:
- sprintf(buff, "table: %p", o->value.a);
+ sprintf(buff, "table: %p", hvalue(o));
break;
case TAG_LCLOSURE: case TAG_CCLOSURE:
- sprintf(buff, "function: %p", o->value.cl);
+ sprintf(buff, "function: %p", clvalue(o));
break;
case TAG_USERDATA:
- sprintf(buff, "userdata: %p(%d)", o->value.ts->u.d.value,
- o->value.ts->u.d.tag);
+ sprintf(buff, "userdata: %p(%d)", tsvalue(o)->u.d.value,
+ tsvalue(o)->u.d.tag);
break;
case TAG_NIL:
lua_pushstring(L, "nil");
@@ -602,7 +602,7 @@ static void deprecated_funcs (lua_State *L) {
TObject gt;
int i;
ttype(>) = TAG_TABLE;
- avalue(>) = L->gt;
+ hvalue(>) = L->gt;
for (i=0; i<num_deprecated; i++) {
lua_pushobject(L, >);
lua_pushcclosure(L, deprecated_global_funcs[i].func, 1);
diff --git a/ldebug.c b/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 1.20 2000/05/15 19:30:41 roberto Exp roberto $
+** $Id: ldebug.c,v 1.21 2000/05/30 19:00:31 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -89,7 +89,7 @@ static int lua_nups (StkId f) {
switch (ttype(f)) {
case TAG_LCLOSURE: case TAG_CCLOSURE:
case TAG_LMARK: case TAG_CMARK:
- return f->value.cl->nupvalues;
+ return clvalue(f)->nupvalues;
default:
return 0;
}
diff --git a/lgc.c b/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 1.54 2000/06/05 14:56:18 roberto Exp roberto $
+** $Id: lgc.c,v 1.55 2000/06/05 20:07:53 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -96,7 +96,7 @@ static int markobject (lua_State *L, TObject *o) {
strmark(L, tsvalue(o));
break;
case TAG_TABLE:
- tablemark(L, avalue(o));
+ tablemark(L, hvalue(o));
break;
case TAG_LCLOSURE: case TAG_LMARK:
protomark(L, clvalue(o)->f.l);
diff --git a/lobject.c b/lobject.c
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.c,v 1.38 2000/04/26 13:43:10 roberto Exp roberto $
+** $Id: lobject.c,v 1.39 2000/05/24 13:54:49 roberto Exp roberto $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -40,7 +40,7 @@ int luaO_equalObj (const TObject *t1, const TObject *t2) {
case TAG_STRING: case TAG_USERDATA:
return tsvalue(t1) == tsvalue(t2);
case TAG_TABLE:
- return avalue(t1) == avalue(t2);
+ return hvalue(t1) == hvalue(t2);
case TAG_CCLOSURE: case TAG_LCLOSURE:
return clvalue(t1) == clvalue(t2);
default:
diff --git a/lobject.h b/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 1.65 2000/05/24 13:54:49 roberto Exp roberto $
+** $Id: lobject.h,v 1.66 2000/05/30 19:00:31 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -73,10 +73,10 @@ typedef union {
/* Macros to access values */
#define ttype(o) ((o)->ttype)
#define nvalue(o) ((o)->value.n)
-#define svalue(o) ((o)->value.ts->str)
#define tsvalue(o) ((o)->value.ts)
#define clvalue(o) ((o)->value.cl)
-#define avalue(o) ((o)->value.a)
+#define hvalue(o) ((o)->value.a)
+#define svalue(o) (tsvalue(o)->str)
typedef struct lua_TObject {
diff --git a/lref.c b/lref.c
@@ -1,5 +1,5 @@
/*
-** $Id: lref.c,v 1.11 2000/03/29 20:19:20 roberto Exp roberto $
+** $Id: lref.c,v 1.12 2000/05/24 13:54:49 roberto Exp roberto $
** reference mechanism
** See Copyright Notice in lua.h
*/
@@ -84,11 +84,11 @@ static int ismarked (const TObject *o) {
/* valid only for locked objects */
switch (o->ttype) {
case TAG_STRING: case TAG_USERDATA:
- return o->value.ts->marked;
+ return tsvalue(o)->marked;
case TAG_TABLE:
- return o->value.a->marked;
+ return hvalue(o)->marked;
case TAG_LCLOSURE: case TAG_CCLOSURE:
- return o->value.cl->marked;
+ return clvalue(o)->marked;
default: /* number */
return 1;
}
diff --git a/ltable.c b/ltable.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.c,v 1.45 2000/06/05 20:15:33 roberto Exp roberto $
+** $Id: ltable.c,v 1.46 2000/06/06 16:31:41 roberto Exp roberto $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -54,7 +54,7 @@ Node *luaH_mainposition (const Hash *t, const TObject *key) {
h = IntPoint(tsvalue(key));
break;
case TAG_TABLE:
- h = IntPoint(avalue(key));
+ h = IntPoint(hvalue(key));
break;
case TAG_LCLOSURE: case TAG_CCLOSURE:
h = IntPoint(clvalue(key));
diff --git a/ltests.c b/ltests.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltests.c,v 1.22 2000/06/02 17:06:42 roberto Exp roberto $
+** $Id: ltests.c,v 1.23 2000/06/02 19:10:01 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@@ -161,14 +161,14 @@ static void hash_query (void) {
lua_pushnumber(tsvalue(o)->u.s.hash);
}
else {
- const Hash *t = avalue(luaL_tablearg(2));
+ const Hash *t = hvalue(luaL_tablearg(2));
lua_pushnumber(luaH_mainposition(t, o) - t->node);
}
}
static void table_query (void) {
- const Hash *t = avalue(luaL_tablearg(1));
+ const Hash *t = hvalue(luaL_tablearg(1));
int i = luaL_opt_int(2, -1);
if (i == -1) {
lua_pushnumber(t->size);
diff --git a/ltm.c b/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 1.40 2000/05/24 13:54:49 roberto Exp roberto $
+** $Id: ltm.c,v 1.41 2000/05/30 18:54:49 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -110,10 +110,10 @@ int luaT_effectivetag (lua_State *L, const TObject *o) {
lua_Type t = ttype(o);
switch (t) {
case TAG_USERDATA: {
- int tag = o->value.ts->u.d.tag;
+ int tag = tsvalue(o)->u.d.tag;
return (tag > L->last_tag) ? TAG_USERDATA : tag; /* deprecated test */
}
- case TAG_TABLE: return o->value.a->htag;
+ case TAG_TABLE: return hvalue(o)->htag;
default: return t;
}
}
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.112 2000/06/05 20:15:33 roberto Exp roberto $
+** $Id: lvm.c,v 1.113 2000/06/06 16:31:41 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -104,10 +104,10 @@ void luaV_gettable (lua_State *L, StkId top) {
}
}
else { /* object is a table... */
- int tg = table->value.a->htag;
+ int tg = hvalue(table)->htag;
im = luaT_getim(L, tg, IM_GETTABLE);
if (ttype(im) == TAG_NIL) { /* and does not have a `gettable' TM */
- const TObject *h = luaH_get(L, avalue(table), table+1);
+ const TObject *h = luaH_get(L, hvalue(table), table+1);
if (ttype(h) == TAG_NIL &&
(ttype(im=luaT_getim(L, tg, IM_INDEX)) != TAG_NIL)) {
/* result is nil and there is an `index' tag method */
@@ -138,9 +138,9 @@ void luaV_settable (lua_State *L, StkId t, StkId top) {
luaG_indexerror(L, t);
}
else { /* object is a table... */
- im = luaT_getim(L, avalue(t)->htag, IM_SETTABLE);
+ im = luaT_getim(L, hvalue(t)->htag, IM_SETTABLE);
if (ttype(im) == TAG_NIL) { /* and does not have a `settable' method */
- *luaH_set(L, avalue(t), t+1) = *(top-1);
+ *luaH_set(L, hvalue(t), t+1) = *(top-1);
return;
}
/* else it has a `settable' method, go through to next command */
@@ -301,7 +301,7 @@ static void strconc (lua_State *L, int total, StkId top) {
void luaV_pack (lua_State *L, StkId firstelem, int nvararg, TObject *tab) {
int i;
Hash *htab;
- htab = avalue(tab) = luaH_new(L, nvararg+1); /* +1 for field `n' */
+ htab = hvalue(tab) = luaH_new(L, nvararg+1); /* +1 for field `n' */
ttype(tab) = TAG_TABLE;
for (i=0; i<nvararg; i++)
*luaH_setint(L, htab, i+1) = *(firstelem+i);
@@ -445,7 +445,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
case OP_CREATETABLE:
L->top = top;
luaC_checkGC(L);
- avalue(top) = luaH_new(L, GETARG_U(i));
+ hvalue(top) = luaH_new(L, GETARG_U(i));
ttype(top) = TAG_TABLE;
top++;
break;
@@ -467,7 +467,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
case OP_SETLIST: {
int aux = GETARG_A(i) * LFIELDS_PER_FLUSH;
int n = GETARG_B(i);
- Hash *arr = avalue(top-n-1);
+ Hash *arr = hvalue(top-n-1);
L->top = top-n; /* final value of `top' (in case of errors) */
for (; n; n--)
*luaH_setint(L, arr, n+aux) = *(--top);
@@ -477,7 +477,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
case OP_SETMAP: {
int n = GETARG_U(i);
StkId finaltop = top-2*n;
- Hash *arr = avalue(finaltop-1);
+ Hash *arr = hvalue(finaltop-1);
L->top = finaltop; /* final value of `top' (in case of errors) */
for (; n; n--) {
top-=2;
@@ -656,7 +656,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
LUA_ASSERT(L, ttype(top-2) == TAG_TABLE, "invalid table");
LUA_ASSERT(L, ttype(top-1) == TAG_NUMBER, "invalid counter");
L->top = top;
- n = luaA_next(L, avalue(top-2), (int)nvalue(top-1));
+ n = luaA_next(L, hvalue(top-2), (int)nvalue(top-1));
if (n == 0) /* end loop? */
top -= 2; /* remove table and counter */
else {