MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / traversetable

Function traversetable

Source/Misc/lua/src/lua.c:6160–6198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6158
6159
6160static int traversetable (global_State *g, Table *h) {
6161int i;
6162int weakkey = 0;
6163int weakvalue = 0;
6164const TValue *mode;
6165if (h->metatable)
6166markobject(g, h->metatable);
6167mode = gfasttm(g, h->metatable, TM_MODE);
6168if (mode && ttisstring(mode)) { /* is there a weak mode? */
6169weakkey = (strchr(svalue(mode), 'k') != NULL);
6170weakvalue = (strchr(svalue(mode), 'v') != NULL);
6171if (weakkey || weakvalue) { /* is really weak? */
6172h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */
6173h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
6174(weakvalue << VALUEWEAKBIT));
6175h->gclist = g->weak; /* must be cleared after GC, ... */
6176g->weak = obj2gco(h); /* ... so put in the appropriate list */
6177}
6178}
6179if (weakkey && weakvalue) return 1;
6180if (!weakvalue) {
6181i = h->sizearray;
6182while (i--)
6183markvalue(g, &h->array[i]);
6184}
6185i = sizenode(h);
6186while (i--) {
6187Node *n = gnode(h, i);
6188lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n)));
6189if (ttisnil(gval(n)))
6190removeentry(n); /* remove empty entries */
6191else {
6192lua_assert(!ttisnil(gkey(n)));
6193if (!weakkey) markvalue(g, gkey(n));
6194if (!weakvalue) markvalue(g, gval(n));
6195}
6196}
6197return weakkey || weakvalue;
6198}
6199
6200
6201/*

Callers 1

propagatemarkFunction · 0.85

Calls 1

removeentryFunction · 0.85

Tested by

no test coverage detected