ltable.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /*
  2. ** $Id: ltable.c,v 2.95 2014/09/04 18:15:29 roberto Exp roberto $
  3. ** Lua tables (hash)
  4. ** See Copyright Notice in lua.h
  5. */
  6. /*
  7. ** Implementation of tables (aka arrays, objects, or hash tables).
  8. ** Tables keep its elements in two parts: an array part and a hash part.
  9. ** Non-negative integer keys are all candidates to be kept in the array
  10. ** part. The actual size of the array is the largest `n' such that at
  11. ** least half the slots between 0 and n are in use.
  12. ** Hash uses a mix of chained scatter table with Brent's variation.
  13. ** A main invariant of these tables is that, if an element is not
  14. ** in its main position (i.e. the `original' position that its hash gives
  15. ** to it), then the colliding element is in its own main position.
  16. ** Hence even when the load factor reaches 100%, performance remains good.
  17. */
  18. #include <float.h>
  19. #include <math.h>
  20. #include <string.h>
  21. #include <limits.h>
  22. #define ltable_c
  23. #define LUA_CORE
  24. #include "lua.h"
  25. #include "ldebug.h"
  26. #include "ldo.h"
  27. #include "lgc.h"
  28. #include "lmem.h"
  29. #include "lobject.h"
  30. #include "lstate.h"
  31. #include "lstring.h"
  32. #include "ltable.h"
  33. #include "lvm.h"
  34. /*
  35. ** Maximum size of array part (MAXASIZE) is 2^MAXABITS. MAXABITS is
  36. ** the largest integer such that MAXASIZE fits in an unsigned int.
  37. */
  38. #define MAXABITS cast_int(sizeof(int) * CHAR_BIT - 1)
  39. #define MAXASIZE (1u << MAXABITS)
  40. /*
  41. ** Maximum size of hash part is 2^MAXHBITS. MAXHBITS is the largest
  42. ** integer such that 2^MAXHBITS fits in a signed int. (Note that the
  43. ** maximum number of elements in a table, 2^MAXABITS + 2^MAXHBITS, still
  44. ** fits comfortably in an unsigned int.)
  45. */
  46. #define MAXHBITS (MAXABITS - 1)
  47. #define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
  48. #define hashstr(t,str) hashpow2(t, (str)->hash)
  49. #define hashboolean(t,p) hashpow2(t, p)
  50. #define hashint(t,i) hashpow2(t, i)
  51. /*
  52. ** for some types, it is better to avoid modulus by power of 2, as
  53. ** they tend to have many 2 factors.
  54. */
  55. #define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1))))
  56. #define hashpointer(t,p) hashmod(t, point2int(p))
  57. #define dummynode (&dummynode_)
  58. #define isdummy(n) ((n) == dummynode)
  59. static const Node dummynode_ = {
  60. {NILCONSTANT}, /* value */
  61. {{NILCONSTANT, 0}} /* key */
  62. };
  63. /*
  64. ** Checks whether a float has a value representable as a lua_Integer
  65. ** (and does the conversion if so)
  66. */
  67. static int numisinteger (lua_Number x, lua_Integer *p) {
  68. if ((x) == l_floor(x)) /* integral value? */
  69. return lua_numtointeger(x, p); /* try as an integer */
  70. else return 0;
  71. }
  72. /*
  73. ** hash for floating-point numbers
  74. */
  75. static Node *hashfloat (const Table *t, lua_Number n) {
  76. int i;
  77. n = l_mathop(frexp)(n, &i) * cast_num(INT_MAX - DBL_MAX_EXP);
  78. i += cast_int(n);
  79. if (i < 0) {
  80. if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */
  81. i = 0; /* handle INT_MIN */
  82. i = -i; /* must be a positive value */
  83. }
  84. return hashmod(t, i);
  85. }
  86. /*
  87. ** returns the `main' position of an element in a table (that is, the index
  88. ** of its hash value)
  89. */
  90. static Node *mainposition (const Table *t, const TValue *key) {
  91. switch (ttype(key)) {
  92. case LUA_TNUMINT:
  93. return hashint(t, ivalue(key));
  94. case LUA_TNUMFLT:
  95. return hashfloat(t, fltvalue(key));
  96. case LUA_TSHRSTR:
  97. return hashstr(t, tsvalue(key));
  98. case LUA_TLNGSTR: {
  99. TString *s = tsvalue(key);
  100. if (s->extra == 0) { /* no hash? */
  101. s->hash = luaS_hash(getstr(s), s->len, s->hash);
  102. s->extra = 1; /* now it has its hash */
  103. }
  104. return hashstr(t, tsvalue(key));
  105. }
  106. case LUA_TBOOLEAN:
  107. return hashboolean(t, bvalue(key));
  108. case LUA_TLIGHTUSERDATA:
  109. return hashpointer(t, pvalue(key));
  110. case LUA_TLCF:
  111. return hashpointer(t, fvalue(key));
  112. default:
  113. return hashpointer(t, gcvalue(key));
  114. }
  115. }
  116. /*
  117. ** returns the index for `key' if `key' is an appropriate key to live in
  118. ** the array part of the table, 0 otherwise.
  119. */
  120. static unsigned int arrayindex (const TValue *key) {
  121. if (ttisinteger(key)) {
  122. lua_Integer k = ivalue(key);
  123. if (0 < k && (lua_Unsigned)k <= MAXASIZE)
  124. return cast(unsigned int, k); /* 'key' is an appropriate array index */
  125. }
  126. return 0; /* `key' did not match some condition */
  127. }
  128. /*
  129. ** returns the index of a `key' for table traversals. First goes all
  130. ** elements in the array part, then elements in the hash part. The
  131. ** beginning of a traversal is signaled by 0.
  132. */
  133. static unsigned int findindex (lua_State *L, Table *t, StkId key) {
  134. unsigned int i;
  135. if (ttisnil(key)) return 0; /* first iteration */
  136. i = arrayindex(key);
  137. if (i != 0 && i <= t->sizearray) /* is `key' inside array part? */
  138. return i; /* yes; that's the index */
  139. else {
  140. int nx;
  141. Node *n = mainposition(t, key);
  142. for (;;) { /* check whether `key' is somewhere in the chain */
  143. /* key may be dead already, but it is ok to use it in `next' */
  144. if (luaV_rawequalobj(gkey(n), key) ||
  145. (ttisdeadkey(gkey(n)) && iscollectable(key) &&
  146. deadvalue(gkey(n)) == gcvalue(key))) {
  147. i = cast_int(n - gnode(t, 0)); /* key index in hash table */
  148. /* hash elements are numbered after array ones */
  149. return (i + 1) + t->sizearray;
  150. }
  151. nx = gnext(n);
  152. if (nx == 0)
  153. luaG_runerror(L, "invalid key to 'next'"); /* key not found */
  154. else n += nx;
  155. }
  156. }
  157. }
  158. int luaH_next (lua_State *L, Table *t, StkId key) {
  159. unsigned int i = findindex(L, t, key); /* find original element */
  160. for (; i < t->sizearray; i++) { /* try first array part */
  161. if (!ttisnil(&t->array[i])) { /* a non-nil value? */
  162. setivalue(key, i + 1);
  163. setobj2s(L, key+1, &t->array[i]);
  164. return 1;
  165. }
  166. }
  167. for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) { /* hash part */
  168. if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
  169. setobj2s(L, key, gkey(gnode(t, i)));
  170. setobj2s(L, key+1, gval(gnode(t, i)));
  171. return 1;
  172. }
  173. }
  174. return 0; /* no more elements */
  175. }
  176. /*
  177. ** {=============================================================
  178. ** Rehash
  179. ** ==============================================================
  180. */
  181. /*
  182. ** Compute the optimal size for the array part of table 't'. 'nums' is a
  183. ** "count array" where 'nums[i]' is the number of integers in the table
  184. ** between 2^(i - 1) + 1 and 2^i. Put in '*narray' the optimal size, and
  185. ** return the number of elements that will go to that part.
  186. */
  187. static unsigned int computesizes (unsigned int nums[], unsigned int *narray) {
  188. int i;
  189. unsigned int twotoi; /* 2^i */
  190. unsigned int a = 0; /* number of elements smaller than 2^i */
  191. unsigned int na = 0; /* number of elements to go to array part */
  192. unsigned int n = 0; /* optimal size for array part */
  193. for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
  194. if (nums[i] > 0) {
  195. a += nums[i];
  196. if (a > twotoi/2) { /* more than half elements present? */
  197. n = twotoi; /* optimal size (till now) */
  198. na = a; /* all elements up to 'n' will go to array part */
  199. }
  200. }
  201. if (a == *narray) break; /* all elements already counted */
  202. }
  203. *narray = n;
  204. lua_assert(*narray/2 <= na && na <= *narray);
  205. return na;
  206. }
  207. static int countint (const TValue *key, unsigned int *nums) {
  208. unsigned int k = arrayindex(key);
  209. if (k != 0) { /* is `key' an appropriate array index? */
  210. nums[luaO_ceillog2(k)]++; /* count as such */
  211. return 1;
  212. }
  213. else
  214. return 0;
  215. }
  216. static unsigned int numusearray (const Table *t, unsigned int *nums) {
  217. int lg;
  218. unsigned int ttlg; /* 2^lg */
  219. unsigned int ause = 0; /* summation of `nums' */
  220. unsigned int i = 1; /* count to traverse all array keys */
  221. /* traverse each slice */
  222. for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) {
  223. unsigned int lc = 0; /* counter */
  224. unsigned int lim = ttlg;
  225. if (lim > t->sizearray) {
  226. lim = t->sizearray; /* adjust upper limit */
  227. if (i > lim)
  228. break; /* no more elements to count */
  229. }
  230. /* count elements in range (2^(lg - 1), 2^lg] */
  231. for (; i <= lim; i++) {
  232. if (!ttisnil(&t->array[i-1]))
  233. lc++;
  234. }
  235. nums[lg] += lc;
  236. ause += lc;
  237. }
  238. return ause;
  239. }
  240. static int numusehash (const Table *t, unsigned int *nums,
  241. unsigned int *pnasize) {
  242. int totaluse = 0; /* total number of elements */
  243. int ause = 0; /* elements added to 'nums' (can go to array part) */
  244. int i = sizenode(t);
  245. while (i--) {
  246. Node *n = &t->node[i];
  247. if (!ttisnil(gval(n))) {
  248. ause += countint(gkey(n), nums);
  249. totaluse++;
  250. }
  251. }
  252. *pnasize += ause;
  253. return totaluse;
  254. }
  255. static void setarrayvector (lua_State *L, Table *t, unsigned int size) {
  256. unsigned int i;
  257. luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
  258. for (i=t->sizearray; i<size; i++)
  259. setnilvalue(&t->array[i]);
  260. t->sizearray = size;
  261. }
  262. static void setnodevector (lua_State *L, Table *t, unsigned int size) {
  263. int lsize;
  264. if (size == 0) { /* no elements to hash part? */
  265. t->node = cast(Node *, dummynode); /* use common `dummynode' */
  266. lsize = 0;
  267. }
  268. else {
  269. int i;
  270. lsize = luaO_ceillog2(size);
  271. if (lsize > MAXHBITS)
  272. luaG_runerror(L, "table overflow");
  273. size = twoto(lsize);
  274. t->node = luaM_newvector(L, size, Node);
  275. for (i = 0; i < (int)size; i++) {
  276. Node *n = gnode(t, i);
  277. gnext(n) = 0;
  278. setnilvalue(wgkey(n));
  279. setnilvalue(gval(n));
  280. }
  281. }
  282. t->lsizenode = cast_byte(lsize);
  283. t->lastfree = gnode(t, size); /* all positions are free */
  284. }
  285. void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
  286. unsigned int nhsize) {
  287. unsigned int i;
  288. int j;
  289. unsigned int oldasize = t->sizearray;
  290. int oldhsize = t->lsizenode;
  291. Node *nold = t->node; /* save old hash ... */
  292. if (nasize > oldasize) /* array part must grow? */
  293. setarrayvector(L, t, nasize);
  294. /* create new hash part with appropriate size */
  295. setnodevector(L, t, nhsize);
  296. if (nasize < oldasize) { /* array part must shrink? */
  297. t->sizearray = nasize;
  298. /* re-insert elements from vanishing slice */
  299. for (i=nasize; i<oldasize; i++) {
  300. if (!ttisnil(&t->array[i]))
  301. luaH_setint(L, t, i + 1, &t->array[i]);
  302. }
  303. /* shrink array */
  304. luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
  305. }
  306. /* re-insert elements from hash part */
  307. for (j = twoto(oldhsize) - 1; j >= 0; j--) {
  308. Node *old = nold + j;
  309. if (!ttisnil(gval(old))) {
  310. /* doesn't need barrier/invalidate cache, as entry was
  311. already present in the table */
  312. setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old));
  313. }
  314. }
  315. if (!isdummy(nold))
  316. luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old array */
  317. }
  318. void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize) {
  319. int nsize = isdummy(t->node) ? 0 : sizenode(t);
  320. luaH_resize(L, t, nasize, nsize);
  321. }
  322. /*
  323. ** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i
  324. */
  325. static void rehash (lua_State *L, Table *t, const TValue *ek) {
  326. unsigned int nasize, na;
  327. unsigned int nums[MAXABITS + 1];
  328. int i;
  329. int totaluse;
  330. for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */
  331. nasize = numusearray(t, nums); /* count keys in array part */
  332. totaluse = nasize; /* all those keys are integer keys */
  333. totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */
  334. /* count extra key */
  335. nasize += countint(ek, nums);
  336. totaluse++;
  337. /* compute new size for array part */
  338. na = computesizes(nums, &nasize);
  339. /* resize the table to new computed sizes */
  340. luaH_resize(L, t, nasize, totaluse - na);
  341. }
  342. /*
  343. ** }=============================================================
  344. */
  345. Table *luaH_new (lua_State *L) {
  346. GCObject *o = luaC_newobj(L, LUA_TTABLE, sizeof(Table));
  347. Table *t = gco2t(o);
  348. t->metatable = NULL;
  349. t->flags = cast_byte(~0);
  350. t->array = NULL;
  351. t->sizearray = 0;
  352. setnodevector(L, t, 0);
  353. return t;
  354. }
  355. void luaH_free (lua_State *L, Table *t) {
  356. if (!isdummy(t->node))
  357. luaM_freearray(L, t->node, cast(size_t, sizenode(t)));
  358. luaM_freearray(L, t->array, t->sizearray);
  359. luaM_free(L, t);
  360. }
  361. static Node *getfreepos (Table *t) {
  362. while (t->lastfree > t->node) {
  363. t->lastfree--;
  364. if (ttisnil(gkey(t->lastfree)))
  365. return t->lastfree;
  366. }
  367. return NULL; /* could not find a free place */
  368. }
  369. /*
  370. ** inserts a new key into a hash table; first, check whether key's main
  371. ** position is free. If not, check whether colliding node is in its main
  372. ** position or not: if it is not, move colliding node to an empty place and
  373. ** put new key in its main position; otherwise (colliding node is in its main
  374. ** position), new key goes to an empty position.
  375. */
  376. TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
  377. Node *mp;
  378. TValue aux;
  379. if (ttisnil(key)) luaG_runerror(L, "table index is nil");
  380. else if (ttisfloat(key)) {
  381. lua_Number n = fltvalue(key);
  382. lua_Integer k;
  383. if (luai_numisnan(n))
  384. luaG_runerror(L, "table index is NaN");
  385. if (numisinteger(n, &k)) { /* index is int? */
  386. setivalue(&aux, k);
  387. key = &aux; /* insert it as an integer */
  388. }
  389. }
  390. mp = mainposition(t, key);
  391. if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
  392. Node *othern;
  393. Node *f = getfreepos(t); /* get a free place */
  394. if (f == NULL) { /* cannot find a free place? */
  395. rehash(L, t, key); /* grow table */
  396. /* whatever called 'newkey' takes care of TM cache and GC barrier */
  397. return luaH_set(L, t, key); /* insert key into grown table */
  398. }
  399. lua_assert(!isdummy(f));
  400. othern = mainposition(t, gkey(mp));
  401. if (othern != mp) { /* is colliding node out of its main position? */
  402. /* yes; move colliding node into free position */
  403. while (othern + gnext(othern) != mp) /* find previous */
  404. othern += gnext(othern);
  405. gnext(othern) = cast_int(f - othern); /* rechain to point to 'f' */
  406. *f = *mp; /* copy colliding node into free pos. (mp->next also goes) */
  407. if (gnext(mp) != 0) {
  408. gnext(f) += cast_int(mp - f); /* correct 'next' */
  409. gnext(mp) = 0; /* now 'mp' is free */
  410. }
  411. setnilvalue(gval(mp));
  412. }
  413. else { /* colliding node is in its own main position */
  414. /* new node will go into free position */
  415. if (gnext(mp) != 0)
  416. gnext(f) = cast_int((mp + gnext(mp)) - f); /* chain new position */
  417. else lua_assert(gnext(f) == 0);
  418. gnext(mp) = cast_int(f - mp);
  419. mp = f;
  420. }
  421. }
  422. setkey(L, &mp->i_key, key);
  423. luaC_barrierback(L, t, key);
  424. lua_assert(ttisnil(gval(mp)));
  425. return gval(mp);
  426. }
  427. /*
  428. ** search function for integers
  429. */
  430. const TValue *luaH_getint (Table *t, lua_Integer key) {
  431. /* (1 <= key && key <= t->sizearray) */
  432. if (l_castS2U(key - 1) < t->sizearray)
  433. return &t->array[key - 1];
  434. else {
  435. Node *n = hashint(t, key);
  436. for (;;) { /* check whether `key' is somewhere in the chain */
  437. if (ttisinteger(gkey(n)) && ivalue(gkey(n)) == key)
  438. return gval(n); /* that's it */
  439. else {
  440. int nx = gnext(n);
  441. if (nx == 0) break;
  442. n += nx;
  443. }
  444. };
  445. return luaO_nilobject;
  446. }
  447. }
  448. /*
  449. ** search function for short strings
  450. */
  451. const TValue *luaH_getstr (Table *t, TString *key) {
  452. Node *n = hashstr(t, key);
  453. lua_assert(key->tt == LUA_TSHRSTR);
  454. for (;;) { /* check whether `key' is somewhere in the chain */
  455. const TValue *k = gkey(n);
  456. if (ttisshrstring(k) && eqshrstr(tsvalue(k), key))
  457. return gval(n); /* that's it */
  458. else {
  459. int nx = gnext(n);
  460. if (nx == 0) break;
  461. n += nx;
  462. }
  463. };
  464. return luaO_nilobject;
  465. }
  466. /*
  467. ** main search function
  468. */
  469. const TValue *luaH_get (Table *t, const TValue *key) {
  470. switch (ttype(key)) {
  471. case LUA_TSHRSTR: return luaH_getstr(t, tsvalue(key));
  472. case LUA_TNUMINT: return luaH_getint(t, ivalue(key));
  473. case LUA_TNIL: return luaO_nilobject;
  474. case LUA_TNUMFLT: {
  475. lua_Integer k;
  476. if (numisinteger(fltvalue(key), &k)) /* index is int? */
  477. return luaH_getint(t, k); /* use specialized version */
  478. /* else go through */
  479. }
  480. default: {
  481. Node *n = mainposition(t, key);
  482. for (;;) { /* check whether `key' is somewhere in the chain */
  483. if (luaV_rawequalobj(gkey(n), key))
  484. return gval(n); /* that's it */
  485. else {
  486. int nx = gnext(n);
  487. if (nx == 0) break;
  488. n += nx;
  489. }
  490. };
  491. return luaO_nilobject;
  492. }
  493. }
  494. }
  495. /*
  496. ** beware: when using this function you probably need to check a GC
  497. ** barrier and invalidate the TM cache.
  498. */
  499. TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
  500. const TValue *p = luaH_get(t, key);
  501. if (p != luaO_nilobject)
  502. return cast(TValue *, p);
  503. else return luaH_newkey(L, t, key);
  504. }
  505. void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) {
  506. const TValue *p = luaH_getint(t, key);
  507. TValue *cell;
  508. if (p != luaO_nilobject)
  509. cell = cast(TValue *, p);
  510. else {
  511. TValue k;
  512. setivalue(&k, key);
  513. cell = luaH_newkey(L, t, &k);
  514. }
  515. setobj2t(L, cell, value);
  516. }
  517. static int unbound_search (Table *t, unsigned int j) {
  518. unsigned int i = j; /* i is zero or a present index */
  519. j++;
  520. /* find `i' and `j' such that i is present and j is not */
  521. while (!ttisnil(luaH_getint(t, j))) {
  522. i = j;
  523. if (j > cast(unsigned int, MAX_INT)/2) { /* overflow? */
  524. /* table was built with bad purposes: resort to linear search */
  525. i = 1;
  526. while (!ttisnil(luaH_getint(t, i))) i++;
  527. return i - 1;
  528. }
  529. j *= 2;
  530. }
  531. /* now do a binary search between them */
  532. while (j - i > 1) {
  533. unsigned int m = (i+j)/2;
  534. if (ttisnil(luaH_getint(t, m))) j = m;
  535. else i = m;
  536. }
  537. return i;
  538. }
  539. /*
  540. ** Try to find a boundary in table `t'. A `boundary' is an integer index
  541. ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
  542. */
  543. int luaH_getn (Table *t) {
  544. unsigned int j = t->sizearray;
  545. if (j > 0 && ttisnil(&t->array[j - 1])) {
  546. /* there is a boundary in the array part: (binary) search for it */
  547. unsigned int i = 0;
  548. while (j - i > 1) {
  549. unsigned int m = (i+j)/2;
  550. if (ttisnil(&t->array[m - 1])) j = m;
  551. else i = m;
  552. }
  553. return i;
  554. }
  555. /* else must find a boundary in hash part */
  556. else if (isdummy(t->node)) /* hash part is empty? */
  557. return j; /* that is easy... */
  558. else return unbound_search(t, j);
  559. }
  560. #if defined(LUA_DEBUG)
  561. Node *luaH_mainposition (const Table *t, const TValue *key) {
  562. return mainposition(t, key);
  563. }
  564. int luaH_isdummy (Node *n) { return isdummy(n); }
  565. #endif