mirror of https://github.com/rusefi/lua.git
name changes to avoid name collision between macros and variables
This commit is contained in:
parent
81cdbabf09
commit
ab9e062928
8
ldebug.c
8
ldebug.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldebug.c,v 1.147 2003/02/27 12:32:30 roberto Exp roberto $
|
** $Id: ldebug.c,v 1.148 2003/03/18 12:24:38 roberto Exp roberto $
|
||||||
** Debug Interface
|
** Debug Interface
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -178,9 +178,9 @@ static const char *travglobals (lua_State *L, const TObject *o) {
|
||||||
Table *g = hvalue(gt(L));
|
Table *g = hvalue(gt(L));
|
||||||
int i = sizenode(g);
|
int i = sizenode(g);
|
||||||
while (i--) {
|
while (i--) {
|
||||||
Node *n = node(g, i);
|
Node *n = gnode(g, i);
|
||||||
if (luaO_rawequalObj(o, val(n)) && ttisstring(key(n)))
|
if (luaO_rawequalObj(o, gval(n)) && ttisstring(gkey(n)))
|
||||||
return getstr(tsvalue(key(n)));
|
return getstr(tsvalue(gkey(n)));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
6
lfunc.c
6
lfunc.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lfunc.c,v 1.65 2002/12/19 11:11:55 roberto Exp roberto $
|
** $Id: lfunc.c,v 1.66 2003/02/11 10:46:24 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
|
||||||
*/
|
*/
|
||||||
|
@ -35,11 +35,11 @@ Closure *luaF_newCclosure (lua_State *L, int nelems) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *gt) {
|
Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *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, valtogco(c), LUA_TFUNCTION);
|
||||||
c->l.isC = 0;
|
c->l.isC = 0;
|
||||||
c->l.g = *gt;
|
c->l.g = *e;
|
||||||
c->l.nupvalues = cast(lu_byte, nelems);
|
c->l.nupvalues = cast(lu_byte, nelems);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
4
lfunc.h
4
lfunc.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lfunc.h,v 1.19 2001/11/29 20:22:22 roberto Exp roberto $
|
** $Id: lfunc.h,v 1.20 2002/06/20 20:41:46 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
|
||||||
*/
|
*/
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
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 *gt);
|
Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e);
|
||||||
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);
|
||||||
void luaF_freeproto (lua_State *L, Proto *f);
|
void luaF_freeproto (lua_State *L, Proto *f);
|
||||||
|
|
46
lgc.c
46
lgc.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 1.168 2003/02/10 17:32:50 roberto Exp roberto $
|
** $Id: lgc.c,v 1.169 2003/02/11 10:46:24 roberto Exp roberto $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,7 @@ typedef struct GCState {
|
||||||
GCObject *wk; /* list of traversed key-weak tables (to be cleared) */
|
GCObject *wk; /* list of traversed key-weak tables (to be cleared) */
|
||||||
GCObject *wv; /* list of traversed value-weak tables */
|
GCObject *wv; /* list of traversed value-weak tables */
|
||||||
GCObject *wkv; /* list of traversed key-value weak tables */
|
GCObject *wkv; /* list of traversed key-value weak tables */
|
||||||
global_State *G;
|
global_State *g;
|
||||||
} GCState;
|
} GCState;
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ static void reallymarkobject (GCState *st, GCObject *o) {
|
||||||
|
|
||||||
static void marktmu (GCState *st) {
|
static void marktmu (GCState *st) {
|
||||||
GCObject *u;
|
GCObject *u;
|
||||||
for (u = st->G->tmudata; u; u = u->gch.next) {
|
for (u = st->g->tmudata; u; u = u->gch.next) {
|
||||||
unmark(u); /* may be marked, if left from previous GC */
|
unmark(u); /* may be marked, if left from previous GC */
|
||||||
reallymarkobject(st, u);
|
reallymarkobject(st, u);
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,9 @@ void luaC_separateudata (lua_State *L) {
|
||||||
|
|
||||||
|
|
||||||
static void removekey (Node *n) {
|
static void removekey (Node *n) {
|
||||||
setnilvalue(val(n)); /* remove corresponding value ... */
|
setnilvalue(gval(n)); /* remove corresponding value ... */
|
||||||
if (iscollectable(key(n)))
|
if (iscollectable(gkey(n)))
|
||||||
setttype(key(n), LUA_TNONE); /* dead key; remove it */
|
setttype(gkey(n), LUA_TNONE); /* dead key; remove it */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,8 +150,8 @@ static void traversetable (GCState *st, Table *h) {
|
||||||
int weakvalue = 0;
|
int weakvalue = 0;
|
||||||
const TObject *mode;
|
const TObject *mode;
|
||||||
markvalue(st, h->metatable);
|
markvalue(st, h->metatable);
|
||||||
lua_assert(h->lsizenode || h->node == st->G->dummynode);
|
lua_assert(h->lsizenode || h->node == st->g->dummynode);
|
||||||
mode = gfasttm(st->G, h->metatable, TM_MODE);
|
mode = gfasttm(st->g, h->metatable, TM_MODE);
|
||||||
if (mode && ttisstring(mode)) { /* is there a weak mode? */
|
if (mode && ttisstring(mode)) { /* is there a weak mode? */
|
||||||
weakkey = (strchr(svalue(mode), 'k') != NULL);
|
weakkey = (strchr(svalue(mode), 'k') != NULL);
|
||||||
weakvalue = (strchr(svalue(mode), 'v') != NULL);
|
weakvalue = (strchr(svalue(mode), 'v') != NULL);
|
||||||
|
@ -167,17 +167,17 @@ static void traversetable (GCState *st, Table *h) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!weakvalue) {
|
if (!weakvalue) {
|
||||||
i = sizearray(h);
|
i = h->sizearray;
|
||||||
while (i--)
|
while (i--)
|
||||||
markobject(st, &h->array[i]);
|
markobject(st, &h->array[i]);
|
||||||
}
|
}
|
||||||
i = sizenode(h);
|
i = sizenode(h);
|
||||||
while (i--) {
|
while (i--) {
|
||||||
Node *n = node(h, i);
|
Node *n = gnode(h, i);
|
||||||
if (!ttisnil(val(n))) {
|
if (!ttisnil(gval(n))) {
|
||||||
lua_assert(!ttisnil(key(n)));
|
lua_assert(!ttisnil(gkey(n)));
|
||||||
condmarkobject(st, key(n), !weakkey);
|
condmarkobject(st, gkey(n), !weakkey);
|
||||||
condmarkobject(st, val(n), !weakvalue);
|
condmarkobject(st, gval(n), !weakvalue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,8 +303,8 @@ static void cleartablekeys (GCObject *l) {
|
||||||
int i = sizenode(h);
|
int i = sizenode(h);
|
||||||
lua_assert(h->marked & KEYWEAK);
|
lua_assert(h->marked & KEYWEAK);
|
||||||
while (i--) {
|
while (i--) {
|
||||||
Node *n = node(h, i);
|
Node *n = gnode(h, i);
|
||||||
if (!valismarked(key(n))) /* key was collected? */
|
if (!valismarked(gkey(n))) /* key was collected? */
|
||||||
removekey(n); /* remove entry from table */
|
removekey(n); /* remove entry from table */
|
||||||
}
|
}
|
||||||
l = h->gclist;
|
l = h->gclist;
|
||||||
|
@ -318,7 +318,7 @@ static void cleartablekeys (GCObject *l) {
|
||||||
static void cleartablevalues (GCObject *l) {
|
static void cleartablevalues (GCObject *l) {
|
||||||
while (l) {
|
while (l) {
|
||||||
Table *h = gcotoh(l);
|
Table *h = gcotoh(l);
|
||||||
int i = sizearray(h);
|
int i = h->sizearray;
|
||||||
lua_assert(h->marked & VALUEWEAK);
|
lua_assert(h->marked & VALUEWEAK);
|
||||||
while (i--) {
|
while (i--) {
|
||||||
TObject *o = &h->array[i];
|
TObject *o = &h->array[i];
|
||||||
|
@ -327,8 +327,8 @@ static void cleartablevalues (GCObject *l) {
|
||||||
}
|
}
|
||||||
i = sizenode(h);
|
i = sizenode(h);
|
||||||
while (i--) {
|
while (i--) {
|
||||||
Node *n = node(h, i);
|
Node *n = gnode(h, i);
|
||||||
if (!valismarked(val(n))) /* value was collected? */
|
if (!valismarked(gval(n))) /* value was collected? */
|
||||||
removekey(n); /* remove entry from table */
|
removekey(n); /* remove entry from table */
|
||||||
}
|
}
|
||||||
l = h->gclist;
|
l = h->gclist;
|
||||||
|
@ -441,11 +441,11 @@ void luaC_sweep (lua_State *L, int all) {
|
||||||
|
|
||||||
/* mark root set */
|
/* mark root set */
|
||||||
static void markroot (GCState *st, lua_State *L) {
|
static void markroot (GCState *st, lua_State *L) {
|
||||||
global_State *G = st->G;
|
global_State *g = st->g;
|
||||||
markobject(st, defaultmeta(L));
|
markobject(st, defaultmeta(L));
|
||||||
markobject(st, registry(L));
|
markobject(st, registry(L));
|
||||||
traversestack(st, G->mainthread);
|
traversestack(st, g->mainthread);
|
||||||
if (L != G->mainthread) /* another thread is running? */
|
if (L != g->mainthread) /* another thread is running? */
|
||||||
markvalue(st, L); /* cannot collect it */
|
markvalue(st, L); /* cannot collect it */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ static void markroot (GCState *st, lua_State *L) {
|
||||||
static void mark (lua_State *L) {
|
static void mark (lua_State *L) {
|
||||||
GCState st;
|
GCState st;
|
||||||
GCObject *wkv;
|
GCObject *wkv;
|
||||||
st.G = G(L);
|
st.g = G(L);
|
||||||
st.tmark = NULL;
|
st.tmark = NULL;
|
||||||
st.wkv = st.wk = st.wv = NULL;
|
st.wkv = st.wk = st.wv = NULL;
|
||||||
markroot(&st, L);
|
markroot(&st, L);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 1.157 2003/02/11 10:46:24 roberto Exp roberto $
|
** $Id: lobject.h,v 1.158 2003/02/18 16:02:56 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
|
||||||
*/
|
*/
|
||||||
|
@ -316,7 +316,6 @@ typedef struct Table {
|
||||||
|
|
||||||
#define twoto(x) (1<<(x))
|
#define twoto(x) (1<<(x))
|
||||||
#define sizenode(t) (twoto((t)->lsizenode))
|
#define sizenode(t) (twoto((t)->lsizenode))
|
||||||
#define sizearray(t) ((t)->sizearray)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
6
lstate.c
6
lstate.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstate.c,v 1.120 2003/02/13 16:07:57 roberto Exp roberto $
|
** $Id: lstate.c,v 1.121 2003/02/28 19:45:15 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -104,8 +104,8 @@ static void f_luaopen (lua_State *L, void *ud) {
|
||||||
g->rootgc = NULL;
|
g->rootgc = NULL;
|
||||||
g->rootudata = NULL;
|
g->rootudata = NULL;
|
||||||
g->tmudata = NULL;
|
g->tmudata = NULL;
|
||||||
setnilvalue(key(g->dummynode));
|
setnilvalue(gkey(g->dummynode));
|
||||||
setnilvalue(val(g->dummynode));
|
setnilvalue(gval(g->dummynode));
|
||||||
g->dummynode->next = NULL;
|
g->dummynode->next = NULL;
|
||||||
g->nblocks = sizeof(lua_State) + sizeof(global_State);
|
g->nblocks = sizeof(lua_State) + sizeof(global_State);
|
||||||
stack_init(L, L); /* init stack */
|
stack_init(L, L); /* init stack */
|
||||||
|
|
72
ltable.c
72
ltable.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ltable.c,v 1.127 2003/02/13 16:08:32 roberto Exp roberto $
|
** $Id: ltable.c,v 1.128 2003/02/20 20:12:39 roberto Exp roberto $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -56,15 +56,15 @@
|
||||||
|
|
||||||
|
|
||||||
#define hashnum(t,n) \
|
#define hashnum(t,n) \
|
||||||
(node(t, lmod(cast(lu_hash, cast(ls_hash, n)), sizenode(t))))
|
(gnode(t, lmod(cast(lu_hash, cast(ls_hash, n)), sizenode(t))))
|
||||||
#define hashstr(t,str) (node(t, lmod((str)->tsv.hash, sizenode(t))))
|
#define hashstr(t,str) (gnode(t, lmod((str)->tsv.hash, sizenode(t))))
|
||||||
#define hashboolean(t,p) (node(t, lmod(p, sizenode(t))))
|
#define hashboolean(t,p) (gnode(t, lmod(p, sizenode(t))))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** avoid modulus by power of 2 for pointers, as they tend to have many
|
** avoid modulus by power of 2 for pointers, as they tend to have many
|
||||||
** 2 factors.
|
** 2 factors.
|
||||||
*/
|
*/
|
||||||
#define hashpointer(t,p) (node(t, (IntPoint(p) % ((sizenode(t)-1)|1))))
|
#define hashpointer(t,p) (gnode(t, (IntPoint(p) % ((sizenode(t)-1)|1))))
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -122,7 +122,7 @@ static int luaH_index (lua_State *L, Table *t, StkId 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) -
|
||||||
cast(const lu_byte *, val(node(t, 0)))) / sizeof(Node));
|
cast(const lu_byte *, gval(gnode(t, 0)))) / sizeof(Node));
|
||||||
return i + t->sizearray; /* hash elements are numbered after array ones */
|
return i + t->sizearray; /* hash elements are numbered after array ones */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,9 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
|
for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
|
||||||
if (!ttisnil(val(node(t, i)))) { /* a non-nil value? */
|
if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
|
||||||
setobj2s(key, key(node(t, i)));
|
setobj2s(key, gkey(gnode(t, i)));
|
||||||
setobj2s(key+1, val(node(t, i)));
|
setobj2s(key+1, gval(gnode(t, i)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,8 +201,8 @@ static void numuse (const Table *t, int *narray, int *nhash) {
|
||||||
i = sizenode(t);
|
i = sizenode(t);
|
||||||
while (i--) {
|
while (i--) {
|
||||||
Node *n = &t->node[i];
|
Node *n = &t->node[i];
|
||||||
if (!ttisnil(val(n))) {
|
if (!ttisnil(gval(n))) {
|
||||||
int k = arrayindex(key(n));
|
int k = arrayindex(gkey(n));
|
||||||
if (k >= 0) { /* is `key' an appropriate array index? */
|
if (k >= 0) { /* is `key' an appropriate array index? */
|
||||||
nums[luaO_log2(k-1)+1]++; /* count as such */
|
nums[luaO_log2(k-1)+1]++; /* count as such */
|
||||||
(*narray)++;
|
(*narray)++;
|
||||||
|
@ -230,20 +230,20 @@ static void setnodevector (lua_State *L, Table *t, int lsize) {
|
||||||
luaG_runerror(L, "table overflow");
|
luaG_runerror(L, "table overflow");
|
||||||
if (lsize == 0) { /* no elements to hash part? */
|
if (lsize == 0) { /* no elements to hash part? */
|
||||||
t->node = G(L)->dummynode; /* use common `dummynode' */
|
t->node = G(L)->dummynode; /* use common `dummynode' */
|
||||||
lua_assert(ttisnil(key(t->node))); /* assert invariants: */
|
lua_assert(ttisnil(gkey(t->node))); /* assert invariants: */
|
||||||
lua_assert(ttisnil(val(t->node)));
|
lua_assert(ttisnil(gval(t->node)));
|
||||||
lua_assert(t->node->next == NULL); /* (`dummynode' must be empty) */
|
lua_assert(t->node->next == NULL); /* (`dummynode' must be empty) */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t->node = luaM_newvector(L, size, Node);
|
t->node = luaM_newvector(L, size, Node);
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
t->node[i].next = NULL;
|
t->node[i].next = NULL;
|
||||||
setnilvalue(key(node(t, i)));
|
setnilvalue(gkey(gnode(t, i)));
|
||||||
setnilvalue(val(node(t, i)));
|
setnilvalue(gval(gnode(t, i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t->lsizenode = cast(lu_byte, lsize);
|
t->lsizenode = cast(lu_byte, lsize);
|
||||||
t->firstfree = node(t, size-1); /* first free position to be used */
|
t->firstfree = gnode(t, size-1); /* first free position to be used */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,8 +259,8 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
|
||||||
lua_assert(t->node == G(L)->dummynode);
|
lua_assert(t->node == G(L)->dummynode);
|
||||||
temp[0] = t->node[0]; /* copy it to `temp' */
|
temp[0] = t->node[0]; /* copy it to `temp' */
|
||||||
nold = temp;
|
nold = temp;
|
||||||
setnilvalue(key(G(L)->dummynode)); /* restate invariant */
|
setnilvalue(gkey(G(L)->dummynode)); /* restate invariant */
|
||||||
setnilvalue(val(G(L)->dummynode));
|
setnilvalue(gval(G(L)->dummynode));
|
||||||
lua_assert(G(L)->dummynode->next == NULL);
|
lua_assert(G(L)->dummynode->next == NULL);
|
||||||
}
|
}
|
||||||
if (nasize > oldasize) /* array part must grow? */
|
if (nasize > oldasize) /* array part must grow? */
|
||||||
|
@ -281,8 +281,8 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
|
||||||
/* 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(val(old)))
|
if (!ttisnil(gval(old)))
|
||||||
setobjt2t(luaH_set(L, t, key(old)), val(old));
|
setobjt2t(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 */
|
||||||
|
@ -332,7 +332,7 @@ void luaH_free (lua_State *L, Table *t) {
|
||||||
** (because gc can call `remove' during a table traversal)
|
** (because gc can call `remove' during a table traversal)
|
||||||
*/
|
*/
|
||||||
void luaH_remove (Table *t, Node *e) {
|
void luaH_remove (Table *t, Node *e) {
|
||||||
Node *mp = luaH_mainposition(t, key(e));
|
Node *mp = luaH_mainposition(t, gkey(e));
|
||||||
if (e != mp) { /* element not in its main position? */
|
if (e != mp) { /* element not in its main position? */
|
||||||
while (mp->next != e) mp = mp->next; /* find previous */
|
while (mp->next != e) mp = mp->next; /* find previous */
|
||||||
mp->next = e->next; /* remove `e' from its list */
|
mp->next = e->next; /* remove `e' from its list */
|
||||||
|
@ -340,8 +340,8 @@ void luaH_remove (Table *t, Node *e) {
|
||||||
else {
|
else {
|
||||||
if (e->next != NULL) ??
|
if (e->next != NULL) ??
|
||||||
}
|
}
|
||||||
lua_assert(ttisnil(val(node)));
|
lua_assert(ttisnil(gval(node)));
|
||||||
setnilvalue(key(e)); /* clear node `e' */
|
setnilvalue(gkey(e)); /* clear node `e' */
|
||||||
e->next = NULL;
|
e->next = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -357,8 +357,8 @@ void luaH_remove (Table *t, Node *e) {
|
||||||
static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
|
static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
|
||||||
TObject *val;
|
TObject *val;
|
||||||
Node *mp = luaH_mainposition(t, key);
|
Node *mp = luaH_mainposition(t, key);
|
||||||
if (!ttisnil(val(mp))) { /* main position is not free? */
|
if (!ttisnil(gval(mp))) { /* main position is not free? */
|
||||||
Node *othern = luaH_mainposition(t, key(mp)); /* `mp' of colliding node */
|
Node *othern = luaH_mainposition(t, gkey(mp)); /* `mp' of colliding node */
|
||||||
Node *n = t->firstfree; /* get a free place */
|
Node *n = t->firstfree; /* get a free place */
|
||||||
if (othern != mp) { /* is colliding node out of its main position? */
|
if (othern != mp) { /* is colliding node out of its main position? */
|
||||||
/* yes; move colliding node into free position */
|
/* yes; move colliding node into free position */
|
||||||
|
@ -366,7 +366,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
|
||||||
othern->next = n; /* redo the chain with `n' in place of `mp' */
|
othern->next = n; /* redo the chain with `n' in place of `mp' */
|
||||||
*n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
|
*n = *mp; /* copy colliding node into free pos. (mp->next also goes) */
|
||||||
mp->next = NULL; /* now `mp' is free */
|
mp->next = NULL; /* now `mp' is free */
|
||||||
setnilvalue(val(mp));
|
setnilvalue(gval(mp));
|
||||||
}
|
}
|
||||||
else { /* colliding node is in its own main position */
|
else { /* colliding node is in its own main position */
|
||||||
/* new node will go into free position */
|
/* new node will go into free position */
|
||||||
|
@ -375,16 +375,16 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
|
||||||
mp = n;
|
mp = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setobj2t(key(mp), key); /* write barrier */
|
setobj2t(gkey(mp), key); /* write barrier */
|
||||||
lua_assert(ttisnil(val(mp)));
|
lua_assert(ttisnil(gval(mp)));
|
||||||
for (;;) { /* correct `firstfree' */
|
for (;;) { /* correct `firstfree' */
|
||||||
if (ttisnil(key(t->firstfree)))
|
if (ttisnil(gkey(t->firstfree)))
|
||||||
return val(mp); /* OK; table still has a free place */
|
return gval(mp); /* OK; table still has a free place */
|
||||||
else if (t->firstfree == t->node) break; /* cannot decrement from here */
|
else if (t->firstfree == t->node) break; /* cannot decrement from here */
|
||||||
else (t->firstfree)--;
|
else (t->firstfree)--;
|
||||||
}
|
}
|
||||||
/* no more free places; must create one */
|
/* no more free places; must create one */
|
||||||
setbvalue(val(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(TObject *, luaH_get(t, key)); /* get new position */
|
||||||
lua_assert(ttisboolean(val));
|
lua_assert(ttisboolean(val));
|
||||||
|
@ -401,7 +401,7 @@ static const TObject *luaH_getany (Table *t, const TObject *key) {
|
||||||
else {
|
else {
|
||||||
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 */
|
||||||
if (luaO_rawequalObj(key(n), key)) return val(n); /* that's it */
|
if (luaO_rawequalObj(gkey(n), key)) return gval(n); /* that's it */
|
||||||
else n = n->next;
|
else n = n->next;
|
||||||
} while (n);
|
} while (n);
|
||||||
return &luaO_nilobject;
|
return &luaO_nilobject;
|
||||||
|
@ -418,8 +418,8 @@ const TObject *luaH_getnum (Table *t, int key) {
|
||||||
else {
|
else {
|
||||||
Node *n = hashnum(t, key);
|
Node *n = hashnum(t, key);
|
||||||
do { /* check whether `key' is somewhere in the chain */
|
do { /* check whether `key' is somewhere in the chain */
|
||||||
if (ttisnumber(key(n)) && nvalue(key(n)) == (lua_Number)key)
|
if (ttisnumber(gkey(n)) && nvalue(gkey(n)) == (lua_Number)key)
|
||||||
return val(n); /* that's it */
|
return gval(n); /* that's it */
|
||||||
else n = n->next;
|
else n = n->next;
|
||||||
} while (n);
|
} while (n);
|
||||||
return &luaO_nilobject;
|
return &luaO_nilobject;
|
||||||
|
@ -433,8 +433,8 @@ const TObject *luaH_getnum (Table *t, int key) {
|
||||||
const TObject *luaH_getstr (Table *t, TString *key) {
|
const TObject *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(key(n)) && tsvalue(key(n)) == key)
|
if (ttisstring(gkey(n)) && tsvalue(gkey(n)) == key)
|
||||||
return val(n); /* that's it */
|
return gval(n); /* that's it */
|
||||||
else n = n->next;
|
else n = n->next;
|
||||||
} while (n);
|
} while (n);
|
||||||
return &luaO_nilobject;
|
return &luaO_nilobject;
|
||||||
|
|
8
ltable.h
8
ltable.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ltable.h,v 1.42 2002/05/27 20:35:40 roberto Exp roberto $
|
** $Id: ltable.h,v 1.43 2002/11/07 16:03:33 roberto Exp roberto $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -10,9 +10,9 @@
|
||||||
#include "lobject.h"
|
#include "lobject.h"
|
||||||
|
|
||||||
|
|
||||||
#define node(t,i) (&(t)->node[i])
|
#define gnode(t,i) (&(t)->node[i])
|
||||||
#define key(n) (&(n)->i_key)
|
#define gkey(n) (&(n)->i_key)
|
||||||
#define val(n) (&(n)->i_val)
|
#define gval(n) (&(n)->i_val)
|
||||||
|
|
||||||
|
|
||||||
const TObject *luaH_getnum (Table *t, int key);
|
const TObject *luaH_getnum (Table *t, int key);
|
||||||
|
|
Loading…
Reference in New Issue