diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-10 15:37:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-10 15:37:44 -0300 |
commit | 73aa465a8ed8dee6c6a27a6f8b2f51227b70789d (patch) | |
tree | 496a63ffffe0312f1d0b9882d97944fa38ed7801 /ltable.c | |
parent | 3d0577f4b98908be3f2d697ab75c5fbbd3f6999b (diff) | |
download | lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.gz lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.bz2 lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.zip |
some name changes
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.34 2000/02/08 16:34:31 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.35 2000/03/03 14:58:26 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | #define TagDefault LUA_T_ARRAY | 35 | #define TagDefault TAG_ARRAY |
36 | 36 | ||
37 | 37 | ||
38 | 38 | ||
@@ -43,22 +43,22 @@ | |||
43 | Node *luaH_mainposition (const Hash *t, const TObject *key) { | 43 | Node *luaH_mainposition (const Hash *t, const TObject *key) { |
44 | unsigned long h; | 44 | unsigned long h; |
45 | switch (ttype(key)) { | 45 | switch (ttype(key)) { |
46 | case LUA_T_NUMBER: | 46 | case TAG_NUMBER: |
47 | h = (unsigned long)(long)nvalue(key); | 47 | h = (unsigned long)(long)nvalue(key); |
48 | break; | 48 | break; |
49 | case LUA_T_STRING: case LUA_T_USERDATA: | 49 | case TAG_STRING: case TAG_USERDATA: |
50 | h = tsvalue(key)->hash; | 50 | h = tsvalue(key)->hash; |
51 | break; | 51 | break; |
52 | case LUA_T_ARRAY: | 52 | case TAG_ARRAY: |
53 | h = IntPoint(L, avalue(key)); | 53 | h = IntPoint(L, avalue(key)); |
54 | break; | 54 | break; |
55 | case LUA_T_LPROTO: | 55 | case TAG_LPROTO: |
56 | h = IntPoint(L, tfvalue(key)); | 56 | h = IntPoint(L, tfvalue(key)); |
57 | break; | 57 | break; |
58 | case LUA_T_CPROTO: | 58 | case TAG_CPROTO: |
59 | h = IntPoint(L, fvalue(key)); | 59 | h = IntPoint(L, fvalue(key)); |
60 | break; | 60 | break; |
61 | case LUA_T_LCLOSURE: case LUA_T_CCLOSURE: | 61 | case TAG_LCLOSURE: case TAG_CCLOSURE: |
62 | h = IntPoint(L, clvalue(key)); | 62 | h = IntPoint(L, clvalue(key)); |
63 | break; | 63 | break; |
64 | default: | 64 | default: |
@@ -95,7 +95,7 @@ static Node *hashnodecreate (lua_State *L, int nhash) { | |||
95 | Node *v = luaM_newvector(L, nhash, Node); | 95 | Node *v = luaM_newvector(L, nhash, Node); |
96 | int i; | 96 | int i; |
97 | for (i=0; i<nhash; i++) { | 97 | for (i=0; i<nhash; i++) { |
98 | ttype(&v[i].key) = ttype(&v[i].val) = LUA_T_NIL; | 98 | ttype(&v[i].key) = ttype(&v[i].val) = TAG_NIL; |
99 | v[i].next = NULL; | 99 | v[i].next = NULL; |
100 | } | 100 | } |
101 | return v; | 101 | return v; |
@@ -134,7 +134,7 @@ static int newsize (const Hash *t) { | |||
134 | int realuse = 0; | 134 | int realuse = 0; |
135 | int i; | 135 | int i; |
136 | for (i=0; i<size; i++) { | 136 | for (i=0; i<size; i++) { |
137 | if (ttype(&v[i].val) != LUA_T_NIL) | 137 | if (ttype(&v[i].val) != TAG_NIL) |
138 | realuse++; | 138 | realuse++; |
139 | } | 139 | } |
140 | return luaO_power2(realuse+realuse/4+1); | 140 | return luaO_power2(realuse+realuse/4+1); |
@@ -149,7 +149,7 @@ static void rehash (lua_State *L, Hash *t) { | |||
149 | setnodevector(L, t, newsize(t)); /* create new array of nodes */ | 149 | setnodevector(L, t, newsize(t)); /* create new array of nodes */ |
150 | for (i=0; i<oldsize; i++) { | 150 | for (i=0; i<oldsize; i++) { |
151 | Node *old = nold+i; | 151 | Node *old = nold+i; |
152 | if (ttype(&old->val) != LUA_T_NIL) | 152 | if (ttype(&old->val) != TAG_NIL) |
153 | luaH_set(L, t, &old->key, &old->val); | 153 | luaH_set(L, t, &old->key, &old->val); |
154 | } | 154 | } |
155 | luaM_free(L, nold); /* free old array */ | 155 | luaM_free(L, nold); /* free old array */ |
@@ -182,7 +182,7 @@ void luaH_set (lua_State *L, Hash *t, const TObject *key, const TObject *val) { | |||
182 | else n = n->next; | 182 | else n = n->next; |
183 | } while (n); | 183 | } while (n); |
184 | /* `key' not found; must insert it */ | 184 | /* `key' not found; must insert it */ |
185 | if (ttype(&mp->key) != LUA_T_NIL) { /* main position is not free? */ | 185 | if (ttype(&mp->key) != TAG_NIL) { /* main position is not free? */ |
186 | Node *othern; /* main position of colliding node */ | 186 | Node *othern; /* main position of colliding node */ |
187 | n = t->firstfree; /* get a free place */ | 187 | n = t->firstfree; /* get a free place */ |
188 | /* is colliding node out of its main position? (can only happens if | 188 | /* is colliding node out of its main position? (can only happens if |
@@ -204,7 +204,7 @@ void luaH_set (lua_State *L, Hash *t, const TObject *key, const TObject *val) { | |||
204 | mp->key = *key; | 204 | mp->key = *key; |
205 | mp->val = *val; | 205 | mp->val = *val; |
206 | for (;;) { /* check free places */ | 206 | for (;;) { /* check free places */ |
207 | if (ttype(&(t->firstfree)->key) == LUA_T_NIL) | 207 | if (ttype(&(t->firstfree)->key) == TAG_NIL) |
208 | return; /* OK; table still has a free place */ | 208 | return; /* OK; table still has a free place */ |
209 | else if (t->firstfree == t->node) break; /* cannot decrement from here */ | 209 | else if (t->firstfree == t->node) break; /* cannot decrement from here */ |
210 | else (t->firstfree)--; | 210 | else (t->firstfree)--; |
@@ -215,7 +215,7 @@ void luaH_set (lua_State *L, Hash *t, const TObject *key, const TObject *val) { | |||
215 | 215 | ||
216 | void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val) { | 216 | void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val) { |
217 | TObject index; | 217 | TObject index; |
218 | ttype(&index) = LUA_T_NUMBER; | 218 | ttype(&index) = TAG_NUMBER; |
219 | nvalue(&index) = key; | 219 | nvalue(&index) = key; |
220 | luaH_set(L, t, &index, val); | 220 | luaH_set(L, t, &index, val); |
221 | } | 221 | } |
@@ -223,7 +223,7 @@ void luaH_setint (lua_State *L, Hash *t, int key, const TObject *val) { | |||
223 | 223 | ||
224 | const TObject *luaH_getint (lua_State *L, const Hash *t, int key) { | 224 | const TObject *luaH_getint (lua_State *L, const Hash *t, int key) { |
225 | TObject index; | 225 | TObject index; |
226 | ttype(&index) = LUA_T_NUMBER; | 226 | ttype(&index) = TAG_NUMBER; |
227 | nvalue(&index) = key; | 227 | nvalue(&index) = key; |
228 | return luaH_get(L, t, &index); | 228 | return luaH_get(L, t, &index); |
229 | } | 229 | } |