** (result & 1) iff weak values; (result & 2) iff weak keys. */
| 593 | ** (result & 1) iff weak values; (result & 2) iff weak keys. |
| 594 | */ |
| 595 | static int getmode (global_State *g, Table *h) { |
| 596 | const TValue *mode = gfasttm(g, h->metatable, TM_MODE); |
| 597 | if (mode == NULL || !ttisstring(mode)) |
| 598 | return 0; /* ignore non-string modes */ |
| 599 | else { |
| 600 | const char *smode = getstr(tsvalue(mode)); |
| 601 | const char *weakkey = strchr(smode, 'k'); |
| 602 | const char *weakvalue = strchr(smode, 'v'); |
| 603 | return ((weakkey != NULL) << 1) | (weakvalue != NULL); |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | |
| 608 | static l_mem traversetable (global_State *g, Table *h) { |