aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ltable.c b/ltable.c
index 9ad52cfe..aa9822ab 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.27 2005/10/24 17:37:52 roberto Exp roberto $ 2** $Id: ltable.c,v 2.28 2005/11/25 13:29:32 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*/
@@ -66,7 +66,7 @@
66/* 66/*
67** number of ints inside a lua_Number 67** number of ints inside a lua_Number
68*/ 68*/
69#define numints cast(int, sizeof(lua_Number)/sizeof(int)) 69#define numints cast_int(sizeof(lua_Number)/sizeof(int))
70 70
71 71
72 72
@@ -120,7 +120,7 @@ static int arrayindex (const TValue *key) {
120 lua_Number n = nvalue(key); 120 lua_Number n = nvalue(key);
121 int k; 121 int k;
122 lua_number2int(k, n); 122 lua_number2int(k, n);
123 if (luai_numeq(cast(lua_Number, k), nvalue(key))) 123 if (luai_numeq(cast_num(k), nvalue(key)))
124 return k; 124 return k;
125 } 125 }
126 return -1; /* `key' did not match some condition */ 126 return -1; /* `key' did not match some condition */
@@ -145,7 +145,7 @@ static int findindex (lua_State *L, Table *t, StkId key) {
145 if (luaO_rawequalObj(key2tval(n), key) || 145 if (luaO_rawequalObj(key2tval(n), key) ||
146 (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && 146 (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
147 gcvalue(gkey(n)) == gcvalue(key))) { 147 gcvalue(gkey(n)) == gcvalue(key))) {
148 i = cast(int, n - gnode(t, 0)); /* key index in hash table */ 148 i = cast_int(n - gnode(t, 0)); /* key index in hash table */
149 /* hash elements are numbered after array ones */ 149 /* hash elements are numbered after array ones */
150 return i + t->sizearray; 150 return i + t->sizearray;
151 } 151 }
@@ -161,7 +161,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) {
161 int i = findindex(L, t, key); /* find original element */ 161 int i = findindex(L, t, key); /* find original element */
162 for (i++; i < t->sizearray; i++) { /* try first array part */ 162 for (i++; i < t->sizearray; i++) { /* try first array part */
163 if (!ttisnil(&t->array[i])) { /* a non-nil value? */ 163 if (!ttisnil(&t->array[i])) { /* a non-nil value? */
164 setnvalue(key, cast(lua_Number, i+1)); 164 setnvalue(key, cast_num(i+1));
165 setobj2s(L, key+1, &t->array[i]); 165 setobj2s(L, key+1, &t->array[i]);
166 return 1; 166 return 1;
167 } 167 }
@@ -286,7 +286,7 @@ static void setnodevector (lua_State *L, Table *t, int size) {
286 setnilvalue(gval(gnode(t, i))); 286 setnilvalue(gval(gnode(t, i)));
287 } 287 }
288 } 288 }
289 t->lsizenode = cast(lu_byte, lsize); 289 t->lsizenode = cast_byte(lsize);
290 t->lastfree = gnode(t, size); /* all positions are free */ 290 t->lastfree = gnode(t, size); /* all positions are free */
291} 291}
292 292
@@ -356,7 +356,7 @@ Table *luaH_new (lua_State *L, int narray, int nhash) {
356 Table *t = luaM_new(L, Table); 356 Table *t = luaM_new(L, Table);
357 luaC_link(L, obj2gco(t), LUA_TTABLE); 357 luaC_link(L, obj2gco(t), LUA_TTABLE);
358 t->metatable = NULL; 358 t->metatable = NULL;
359 t->flags = cast(lu_byte, ~0); 359 t->flags = cast_byte(~0);
360 /* temporary values (kept only if some malloc fails) */ 360 /* temporary values (kept only if some malloc fails) */
361 t->array = NULL; 361 t->array = NULL;
362 t->sizearray = 0; 362 t->sizearray = 0;
@@ -434,7 +434,7 @@ const TValue *luaH_getnum (Table *t, int key) {
434 if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) 434 if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
435 return &t->array[key-1]; 435 return &t->array[key-1];
436 else { 436 else {
437 lua_Number nk = cast(lua_Number, key); 437 lua_Number nk = cast_num(key);
438 Node *n = hashnum(t, nk); 438 Node *n = hashnum(t, nk);
439 do { /* check whether `key' is somewhere in the chain */ 439 do { /* check whether `key' is somewhere in the chain */
440 if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) 440 if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk))
@@ -471,7 +471,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
471 int k; 471 int k;
472 lua_Number n = nvalue(key); 472 lua_Number n = nvalue(key);
473 lua_number2int(k, n); 473 lua_number2int(k, n);
474 if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is int? */ 474 if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */
475 return luaH_getnum(t, k); /* use specialized version */ 475 return luaH_getnum(t, k); /* use specialized version */
476 /* else go through */ 476 /* else go through */
477 } 477 }
@@ -508,7 +508,7 @@ TValue *luaH_setnum (lua_State *L, Table *t, int key) {
508 return cast(TValue *, p); 508 return cast(TValue *, p);
509 else { 509 else {
510 TValue k; 510 TValue k;
511 setnvalue(&k, cast(lua_Number, key)); 511 setnvalue(&k, cast_num(key));
512 return newkey(L, t, &k); 512 return newkey(L, t, &k);
513 } 513 }
514} 514}