/* Traverse a table with weak values and link it to proper list. During propagate phase, keep it in 'grayagain' list, to be revisited in the atomic phase. In the atomic phase, if table has any white value, put it in 'weak' list, to be cleared.  */
static void traverseweakvalue(global_State *g, Table *h)
/* Traverse a table with weak values and link it to proper list. During propagate phase, keep it in 'grayagain' list, to be revisited in the atomic phase. In the atomic phase, if table has any white value, put it in 'weak' list, to be cleared.  */
static void traverseweakvalue(global_State *g, Table *h)
{
    if (isempty(gval(n)))
      clearkey(n);
    else {
      lua_assert(!keyisnil(n));
      markkey(g, n);
      if (!hasclears && iscleared(g, gcvalueN(gval(n))))
        hasclears = 1;
    }
  }
  if (g->gcstate == GCSatomic && hasclears)
    linkgclist(h, g->weak);
  else
    linkgclist(h, g->grayagain);
}