| 540 | |
| 541 | |
| 542 | static lu_mem traversetable (global_State *g, Table *h) { |
| 543 | const char *weakkey, *weakvalue; |
| 544 | const TValue *mode = gfasttm(g, h->metatable, TM_MODE); |
| 545 | TString *smode; |
| 546 | markobjectN(g, h->metatable); |
| 547 | if (mode && ttisshrstring(mode) && /* is there a weak mode? */ |
| 548 | (cast_void(smode = tsvalue(mode)), |
| 549 | cast_void(weakkey = strchr(getshrstr(smode), 'k')), |
| 550 | cast_void(weakvalue = strchr(getshrstr(smode), 'v')), |
| 551 | (weakkey || weakvalue))) { /* is really weak? */ |
| 552 | if (!weakkey) /* strong keys? */ |
| 553 | traverseweakvalue(g, h); |
| 554 | else if (!weakvalue) /* strong values? */ |
| 555 | traverseephemeron(g, h, 0); |
| 556 | else /* all weak */ |
| 557 | linkgclist(h, g->allweak); /* nothing to traverse now */ |
| 558 | } |
| 559 | else /* not weak */ |
| 560 | traversestrongtable(g, h); |
| 561 | return 1 + h->alimit + 2 * allocsizenode(h); |
| 562 | } |
| 563 | |
| 564 | |
| 565 | static int traverseudata (global_State *g, Udata *u) { |
no test coverage detected