Lines Matching refs:t

51 #define hashpow2(t,n)		(gnode(t, lmod((n), sizenode(t))))  argument
53 #define hashstr(t,str) hashpow2(t, (str)->tsv.hash) argument
54 #define hashboolean(t,p) hashpow2(t, p) argument
61 #define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) argument
64 #define hashpointer(t,p) hashmod(t, IntPoint(p)) argument
82 static Node *hashnum (const Table *t, lua_Number n) { in hashnum() argument
86 return gnode(t, 0); in hashnum()
89 return hashmod(t, a[0]); in hashnum()
98 static Node *mainposition (const Table *t, const TValue *key) { in mainposition() argument
101 return hashnum(t, nvalue(key)); in mainposition()
108 return hashstr(t, rawtsvalue(key)); in mainposition()
111 return hashstr(t, rawtsvalue(key)); in mainposition()
113 return hashboolean(t, bvalue(key)); in mainposition()
115 return hashpointer(t, pvalue(key)); in mainposition()
117 return hashpointer(t, fvalue(key)); in mainposition()
119 return hashpointer(t, gcvalue(key)); in mainposition()
145 static int findindex (lua_State *L, Table *t, StkId key) { in findindex() argument
149 if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ in findindex()
152 Node *n = mainposition(t, key); in findindex()
158 i = cast_int(n - gnode(t, 0)); /* key index in hash table */ in findindex()
160 return i + t->sizearray; in findindex()
170 int luaH_next (lua_State *L, Table *t, StkId key) { in luaH_next() argument
171 int i = findindex(L, t, key); /* find original element */ in luaH_next()
172 for (i++; i < t->sizearray; i++) { /* try first array part */ in luaH_next()
173 if (!ttisnil(&t->array[i])) { /* a non-nil value? */ in luaH_next()
175 setobj2s(L, key+1, &t->array[i]); in luaH_next()
179 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ in luaH_next()
180 if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ in luaH_next()
181 setobj2s(L, key, gkey(gnode(t, i))); in luaH_next()
182 setobj2s(L, key+1, gval(gnode(t, i))); in luaH_next()
230 static int numusearray (const Table *t, int *nums) { in numusearray() argument
238 if (lim > t->sizearray) { in numusearray()
239 lim = t->sizearray; /* adjust upper limit */ in numusearray()
245 if (!ttisnil(&t->array[i-1])) in numusearray()
255 static int numusehash (const Table *t, int *nums, int *pnasize) { in numusehash() argument
258 int i = sizenode(t); in numusehash()
260 Node *n = &t->node[i]; in numusehash()
271 static void setarrayvector (lua_State *L, Table *t, int size) { in setarrayvector() argument
273 luaM_reallocvector(L, t->array, t->sizearray, size, TValue); in setarrayvector()
274 for (i=t->sizearray; i<size; i++) in setarrayvector()
275 setnilvalue(&t->array[i]); in setarrayvector()
276 t->sizearray = size; in setarrayvector()
280 static void setnodevector (lua_State *L, Table *t, int size) { in setnodevector() argument
283 t->node = cast(Node *, dummynode); /* use common `dummynode' */ in setnodevector()
292 t->node = luaM_newvector(L, size, Node); in setnodevector()
294 Node *n = gnode(t, i); in setnodevector()
300 t->lsizenode = cast_byte(lsize); in setnodevector()
301 t->lastfree = gnode(t, size); /* all positions are free */ in setnodevector()
305 void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) { in luaH_resize() argument
307 int oldasize = t->sizearray; in luaH_resize()
308 int oldhsize = t->lsizenode; in luaH_resize()
309 Node *nold = t->node; /* save old hash ... */ in luaH_resize()
311 setarrayvector(L, t, nasize); in luaH_resize()
313 setnodevector(L, t, nhsize); in luaH_resize()
315 t->sizearray = nasize; in luaH_resize()
318 if (!ttisnil(&t->array[i])) in luaH_resize()
319 luaH_setint(L, t, i + 1, &t->array[i]); in luaH_resize()
322 luaM_reallocvector(L, t->array, oldasize, nasize, TValue); in luaH_resize()
330 setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old)); in luaH_resize()
338 void luaH_resizearray (lua_State *L, Table *t, int nasize) { in luaH_resizearray() argument
339 int nsize = isdummy(t->node) ? 0 : sizenode(t); in luaH_resizearray()
340 luaH_resize(L, t, nasize, nsize); in luaH_resizearray()
344 static void rehash (lua_State *L, Table *t, const TValue *ek) { in rehash() argument
350 nasize = numusearray(t, nums); /* count keys in array part */ in rehash()
352 totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ in rehash()
359 luaH_resize(L, t, nasize, totaluse - na); in rehash()
370 Table *t = &luaC_newobj(L, LUA_TTABLE, sizeof(Table), NULL, 0)->h; in luaH_new() local
371 t->metatable = NULL; in luaH_new()
372 t->flags = cast_byte(~0); in luaH_new()
373 t->array = NULL; in luaH_new()
374 t->sizearray = 0; in luaH_new()
375 setnodevector(L, t, 0); in luaH_new()
376 return t; in luaH_new()
380 void luaH_free (lua_State *L, Table *t) { in luaH_free() argument
381 if (!isdummy(t->node)) in luaH_free()
382 luaM_freearray(L, t->node, cast(size_t, sizenode(t))); in luaH_free()
383 luaM_freearray(L, t->array, t->sizearray); in luaH_free()
384 luaM_free(L, t); in luaH_free()
388 static Node *getfreepos (Table *t) { in getfreepos() argument
389 while (t->lastfree > t->node) { in getfreepos()
390 t->lastfree--; in getfreepos()
391 if (ttisnil(gkey(t->lastfree))) in getfreepos()
392 return t->lastfree; in getfreepos()
406 TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { in luaH_newkey() argument
411 mp = mainposition(t, key); in luaH_newkey()
414 Node *n = getfreepos(t); /* get a free place */ in luaH_newkey()
416 rehash(L, t, key); /* grow table */ in luaH_newkey()
418 return luaH_set(L, t, key); /* insert key into grown table */ in luaH_newkey()
421 othern = mainposition(t, gkey(mp)); in luaH_newkey()
438 luaC_barrierback(L, obj2gco(t), key); in luaH_newkey()
447 const TValue *luaH_getint (Table *t, int key) { in luaH_getint() argument
449 if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) in luaH_getint()
450 return &t->array[key-1]; in luaH_getint()
453 Node *n = hashnum(t, nk); in luaH_getint()
467 const TValue *luaH_getstr (Table *t, TString *key) { in luaH_getstr() argument
468 Node *n = hashstr(t, key); in luaH_getstr()
482 const TValue *luaH_get (Table *t, const TValue *key) { in luaH_get() argument
484 case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key)); in luaH_get()
491 return luaH_getint(t, k); /* use specialized version */ in luaH_get()
495 Node *n = mainposition(t, key); in luaH_get()
511 TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { in luaH_set() argument
512 const TValue *p = luaH_get(t, key); in luaH_set()
515 else return luaH_newkey(L, t, key); in luaH_set()
519 void luaH_setint (lua_State *L, Table *t, int key, TValue *value) { in luaH_setint() argument
520 const TValue *p = luaH_getint(t, key); in luaH_setint()
527 cell = luaH_newkey(L, t, &k); in luaH_setint()
533 static int unbound_search (Table *t, unsigned int j) { in unbound_search() argument
537 while (!ttisnil(luaH_getint(t, j))) { in unbound_search()
543 while (!ttisnil(luaH_getint(t, i))) i++; in unbound_search()
550 if (ttisnil(luaH_getint(t, m))) j = m; in unbound_search()
561 int luaH_getn (Table *t) { in luaH_getn() argument
562 unsigned int j = t->sizearray; in luaH_getn()
563 if (j > 0 && ttisnil(&t->array[j - 1])) { in luaH_getn()
568 if (ttisnil(&t->array[m - 1])) j = m; in luaH_getn()
574 else if (isdummy(t->node)) /* hash part is empty? */ in luaH_getn()
576 else return unbound_search(t, j); in luaH_getn()
583 Node *luaH_mainposition (const Table *t, const TValue *key) { in luaH_mainposition() argument
584 return mainposition(t, key); in luaH_mainposition()