mirror of
https://github.com/lua/lua
synced 2025-03-08 06:51:34 +03:00
tags T_NIL, etc, changed to LUA_T_NIL, etc
This commit is contained in:
parent
ac68a3abc4
commit
0162decc58
52
hash.c
52
hash.c
@ -3,7 +3,7 @@
|
||||
** hash manager for lua
|
||||
*/
|
||||
|
||||
char *rcs_hash="$Id: hash.c,v 2.9 1994/10/17 19:03:23 celes Exp roberto $";
|
||||
char *rcs_hash="$Id: hash.c,v 2.10 1994/11/01 17:54:31 roberto Exp roberto $";
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -54,9 +54,9 @@ static int hashindex (Hash *t, Object *ref) /* hash function */
|
||||
{
|
||||
switch (tag(ref))
|
||||
{
|
||||
case T_NUMBER:
|
||||
case LUA_T_NUMBER:
|
||||
return (((int)nvalue(ref))%nhash(t));
|
||||
case T_STRING:
|
||||
case LUA_T_STRING:
|
||||
{
|
||||
int h;
|
||||
char *name = svalue(ref);
|
||||
@ -68,13 +68,13 @@ static int hashindex (Hash *t, Object *ref) /* hash function */
|
||||
}
|
||||
return h;
|
||||
}
|
||||
case T_FUNCTION:
|
||||
case LUA_T_FUNCTION:
|
||||
return (((int)bvalue(ref))%nhash(t));
|
||||
case T_CFUNCTION:
|
||||
case LUA_T_CFUNCTION:
|
||||
return (((int)fvalue(ref))%nhash(t));
|
||||
case T_ARRAY:
|
||||
case LUA_T_ARRAY:
|
||||
return (((int)avalue(ref))%nhash(t));
|
||||
case T_USERDATA:
|
||||
case LUA_T_USERDATA:
|
||||
return (((int)uvalue(ref))%nhash(t));
|
||||
default:
|
||||
lua_reportbug ("unexpected type to index table");
|
||||
@ -87,8 +87,8 @@ static int equalObj (Object *t1, Object *t2)
|
||||
if (tag(t1) != tag(t2)) return 0;
|
||||
switch (tag(t1))
|
||||
{
|
||||
case T_NUMBER: return nvalue(t1) == nvalue(t2);
|
||||
case T_STRING: return streq(svalue(t1), svalue(t2));
|
||||
case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2);
|
||||
case LUA_T_STRING: return streq(svalue(t1), svalue(t2));
|
||||
default: return uvalue(t1) == uvalue(t2);
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ static int present (Hash *t, Object *ref)
|
||||
{
|
||||
int h = hashindex(t, ref);
|
||||
if (h < 0) return h;
|
||||
while (tag(ref(node(t, h))) != T_NIL)
|
||||
while (tag(ref(node(t, h))) != LUA_T_NIL)
|
||||
{
|
||||
if (equalObj(ref, ref(node(t, h))))
|
||||
return h;
|
||||
@ -120,7 +120,7 @@ static Node *hashnodecreate (int nhash)
|
||||
return NULL;
|
||||
}
|
||||
for (i=0; i<nhash; i++)
|
||||
tag(ref(&v[i])) = T_NIL;
|
||||
tag(ref(&v[i])) = LUA_T_NIL;
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ void lua_hashmark (Hash *h)
|
||||
for (i=0; i<nhash(h); i++)
|
||||
{
|
||||
Node *n = node(h,i);
|
||||
if (tag(ref(n)) != T_NIL)
|
||||
if (tag(ref(n)) != LUA_T_NIL)
|
||||
{
|
||||
lua_markobject(&n->ref);
|
||||
lua_markobject(&n->val);
|
||||
@ -243,7 +243,7 @@ static void rehash (Hash *t)
|
||||
for (i=0; i<nold; i++)
|
||||
{
|
||||
Node *n = vold+i;
|
||||
if (tag(ref(n)) != T_NIL && tag(val(n)) != T_NIL)
|
||||
if (tag(ref(n)) != LUA_T_NIL && tag(val(n)) != LUA_T_NIL)
|
||||
*node(t, present(t, ref(n))) = *n; /* copy old node to new hahs */
|
||||
}
|
||||
free(vold);
|
||||
@ -257,10 +257,10 @@ static void rehash (Hash *t)
|
||||
Object *lua_hashget (Hash *t, Object *ref)
|
||||
{
|
||||
static int count = 1000;
|
||||
static Object nil_obj = {T_NIL, {NULL}};
|
||||
static Object nil_obj = {LUA_T_NIL, {NULL}};
|
||||
int h = present(t, ref);
|
||||
if (h < 0) return &nil_obj;
|
||||
if (tag(ref(node(t, h))) != T_NIL) return val(node(t, h));
|
||||
if (tag(ref(node(t, h))) != LUA_T_NIL) return val(node(t, h));
|
||||
if (--count == 0)
|
||||
{
|
||||
lua_reportbug ("hierarchy too deep (maybe there is an inheritance loop)");
|
||||
@ -271,25 +271,25 @@ Object *lua_hashget (Hash *t, Object *ref)
|
||||
Hash *p;
|
||||
Object parent;
|
||||
Object godparent;
|
||||
tag(&parent) = T_STRING; svalue(&parent) = "parent";
|
||||
tag(&godparent) = T_STRING; svalue(&godparent) = "godparent";
|
||||
tag(&parent) = LUA_T_STRING; svalue(&parent) = "parent";
|
||||
tag(&godparent) = LUA_T_STRING; svalue(&godparent) = "godparent";
|
||||
|
||||
h = present(t, &parent); /* assert(h >= 0); */
|
||||
p = tag(ref(node(t, h))) != T_NIL && tag(val(node(t, h))) == T_ARRAY ?
|
||||
p = tag(ref(node(t, h))) != LUA_T_NIL && tag(val(node(t, h))) == LUA_T_ARRAY ?
|
||||
avalue(val(node(t, h))) : NULL;
|
||||
if (p != NULL)
|
||||
{
|
||||
Object *r = lua_hashget(p, ref);
|
||||
if (tag(r) != T_NIL) { count++; return r; }
|
||||
if (tag(r) != LUA_T_NIL) { count++; return r; }
|
||||
}
|
||||
|
||||
h = present(t, &godparent); /* assert(h >= 0); */
|
||||
p = tag(ref(node(t, h))) != T_NIL && tag(val(node(t, h))) == T_ARRAY ?
|
||||
p = tag(ref(node(t, h))) != LUA_T_NIL && tag(val(node(t, h))) == LUA_T_ARRAY ?
|
||||
avalue(val(node(t, h))) : NULL;
|
||||
if (p != NULL)
|
||||
{
|
||||
Object *r = lua_hashget(p, ref);
|
||||
if (tag(r) != T_NIL) { count++; return r; }
|
||||
if (tag(r) != LUA_T_NIL) { count++; return r; }
|
||||
}
|
||||
}
|
||||
count++;
|
||||
@ -308,7 +308,7 @@ Object *lua_hashdefine (Hash *t, Object *ref)
|
||||
h = present(t, ref);
|
||||
if (h < 0) return NULL;
|
||||
n = node(t, h);
|
||||
if (tag(ref(n)) == T_NIL)
|
||||
if (tag(ref(n)) == LUA_T_NIL)
|
||||
{
|
||||
nuse(t)++;
|
||||
if ((float)nuse(t) > (float)nhash(t)*REHASH_LIMIT)
|
||||
@ -318,7 +318,7 @@ Object *lua_hashdefine (Hash *t, Object *ref)
|
||||
n = node(t, h);
|
||||
}
|
||||
*ref(n) = *ref;
|
||||
tag(val(n)) = T_NIL;
|
||||
tag(val(n)) = LUA_T_NIL;
|
||||
}
|
||||
return (val(n));
|
||||
}
|
||||
@ -337,7 +337,7 @@ static void hashnext (Hash *t, int i)
|
||||
lua_pushnil(); lua_pushnil();
|
||||
return;
|
||||
}
|
||||
while (tag(ref(node(t,i))) == T_NIL || tag(val(node(t,i))) == T_NIL)
|
||||
while (tag(ref(node(t,i))) == LUA_T_NIL || tag(val(node(t,i))) == LUA_T_NIL)
|
||||
{
|
||||
if (++i >= nhash(t))
|
||||
{
|
||||
@ -358,11 +358,11 @@ void lua_next (void)
|
||||
{ lua_error ("too few arguments to function `next'"); return; }
|
||||
if (lua_getparam (3) != NULL)
|
||||
{ lua_error ("too many arguments to function `next'"); return; }
|
||||
if (tag(o) != T_ARRAY)
|
||||
if (tag(o) != LUA_T_ARRAY)
|
||||
{ lua_error ("first argument of function `next' is not a table"); return; }
|
||||
|
||||
t = avalue(o);
|
||||
if (tag(r) == T_NIL)
|
||||
if (tag(r) == LUA_T_NIL)
|
||||
{
|
||||
hashnext(t, 0);
|
||||
}
|
||||
|
28
table.c
28
table.c
@ -3,7 +3,7 @@
|
||||
** Module to control static tables
|
||||
*/
|
||||
|
||||
char *rcs_table="$Id: table.c,v 2.6 1994/10/18 18:34:47 roberto Exp $";
|
||||
char *rcs_table="$Id: table.c,v 2.7 1994/11/02 19:09:23 roberto Exp roberto $";
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -54,19 +54,19 @@ static void lua_initsymbol (void)
|
||||
return;
|
||||
}
|
||||
n = lua_findsymbol("type");
|
||||
s_tag(n) = T_CFUNCTION; s_fvalue(n) = lua_type;
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_type;
|
||||
n = lua_findsymbol("tonumber");
|
||||
s_tag(n) = T_CFUNCTION; s_fvalue(n) = lua_obj2number;
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_obj2number;
|
||||
n = lua_findsymbol("next");
|
||||
s_tag(n) = T_CFUNCTION; s_fvalue(n) = lua_next;
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_next;
|
||||
n = lua_findsymbol("nextvar");
|
||||
s_tag(n) = T_CFUNCTION; s_fvalue(n) = lua_nextvar;
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_nextvar;
|
||||
n = lua_findsymbol("print");
|
||||
s_tag(n) = T_CFUNCTION; s_fvalue(n) = lua_print;
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_print;
|
||||
n = lua_findsymbol("dofile");
|
||||
s_tag(n) = T_CFUNCTION; s_fvalue(n) = lua_internaldofile;
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_internaldofile;
|
||||
n = lua_findsymbol("dostring");
|
||||
s_tag(n) = T_CFUNCTION; s_fvalue(n) = lua_internaldostring;
|
||||
s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_internaldostring;
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ int lua_findsymbol (char *s)
|
||||
}
|
||||
}
|
||||
indexstring(n) = lua_ntable;
|
||||
s_tag(lua_ntable) = T_NIL;
|
||||
s_tag(lua_ntable) = LUA_T_NIL;
|
||||
lua_ntable++;
|
||||
}
|
||||
return indexstring(n);
|
||||
@ -190,9 +190,9 @@ void lua_travsymbol (void (*fn)(Object *))
|
||||
*/
|
||||
void lua_markobject (Object *o)
|
||||
{
|
||||
if (tag(o) == T_STRING && indexstring(svalue(o)) == UNMARKED_STRING)
|
||||
if (tag(o) == LUA_T_STRING && indexstring(svalue(o)) == UNMARKED_STRING)
|
||||
indexstring(svalue(o)) = MARKED_STRING;
|
||||
else if (tag(o) == T_ARRAY)
|
||||
else if (tag(o) == LUA_T_ARRAY)
|
||||
lua_hashmark (avalue(o));
|
||||
}
|
||||
|
||||
@ -278,11 +278,11 @@ void lua_nextvar (void)
|
||||
{ lua_error ("too few arguments to function `nextvar'"); return; }
|
||||
if (lua_getparam (2) != NULL)
|
||||
{ lua_error ("too many arguments to function `nextvar'"); return; }
|
||||
if (tag(o) == T_NIL)
|
||||
if (tag(o) == LUA_T_NIL)
|
||||
{
|
||||
varname = 0;
|
||||
}
|
||||
else if (tag(o) != T_STRING)
|
||||
else if (tag(o) != LUA_T_STRING)
|
||||
{
|
||||
lua_error ("incorrect argument to function `nextvar'");
|
||||
return;
|
||||
@ -300,7 +300,7 @@ void lua_nextvar (void)
|
||||
else
|
||||
{
|
||||
Object name;
|
||||
tag(&name) = T_STRING;
|
||||
tag(&name) = LUA_T_STRING;
|
||||
svalue(&name) = next;
|
||||
if (lua_pushobject (&name)) return;
|
||||
if (lua_pushobject (&s_object(indexstring(next)))) return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user