MCPcopy Create free account
hub / github.com/DFHack/dfhack / traversetable

Function traversetable

depends/lua/src/lgc.c:451–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449
450
451static lu_mem traversetable (global_State *g, Table *h) {
452 const char *weakkey, *weakvalue;
453 const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
454 markobjectN(g, h->metatable);
455 if (mode && ttisstring(mode) && /* is there a weak mode? */
456 ((weakkey = strchr(svalue(mode), 'k')),
457 (weakvalue = strchr(svalue(mode), 'v')),
458 (weakkey || weakvalue))) { /* is really weak? */
459 black2gray(h); /* keep table gray */
460 if (!weakkey) /* strong keys? */
461 traverseweakvalue(g, h);
462 else if (!weakvalue) /* strong values? */
463 traverseephemeron(g, h);
464 else /* all weak */
465 linkgclist(h, g->allweak); /* nothing to traverse now */
466 }
467 else /* not weak */
468 traversestrongtable(g, h);
469 return sizeof(Table) + sizeof(TValue) * h->sizearray +
470 sizeof(Node) * cast(size_t, allocsizenode(h));
471}
472
473
474/*

Callers 1

propagatemarkFunction · 0.85

Calls 4

traverseweakvalueFunction · 0.85
traverseephemeronFunction · 0.85
traversestrongtableFunction · 0.85
castFunction · 0.85

Tested by

no test coverage detected