** Mark an object. Userdata with no user values, strings, and closed ** upvalues are visited and turned black here. Open upvalues are ** already indirectly linked through their respective threads in the ** 'twups' list, so they don't go to the gray list; nevertheless, they ** are kept gray to avoid barriers, as their values will be revisited ** by the thread or by 'remarkupvals'. Other objects
| 289 | ** (only closures can), and a userdata's metatable must be a table. |
| 290 | */ |
| 291 | static void reallymarkobject (global_State *g, GCObject *o) { |
| 292 | switch (o->tt) { |
| 293 | case LUA_VSHRSTR: |
| 294 | case LUA_VLNGSTR: { |
| 295 | set2black(o); /* nothing to visit */ |
| 296 | break; |
| 297 | } |
| 298 | case LUA_VUPVAL: { |
| 299 | UpVal *uv = gco2upv(o); |
| 300 | if (upisopen(uv)) |
| 301 | set2gray(uv); /* open upvalues are kept gray */ |
| 302 | else |
| 303 | set2black(uv); /* closed upvalues are visited here */ |
| 304 | markvalue(g, uv->v); /* mark its content */ |
| 305 | break; |
| 306 | } |
| 307 | case LUA_VUSERDATA: { |
| 308 | Udata *u = gco2u(o); |
| 309 | if (u->nuvalue == 0) { /* no user values? */ |
| 310 | markobjectN(g, u->metatable); /* mark its metatable */ |
| 311 | set2black(u); /* nothing else to mark */ |
| 312 | break; |
| 313 | } |
| 314 | /* else... */ |
| 315 | } /* FALLTHROUGH */ |
| 316 | case LUA_VLCL: case LUA_VCCL: case LUA_VTABLE: |
| 317 | case LUA_VTHREAD: case LUA_VPROTO: { |
| 318 | linkobjgclist(o, g->gray); /* to be visited later */ |
| 319 | break; |
| 320 | } |
| 321 | default: lua_assert(0); break; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | |
| 326 | /* |
no outgoing calls
no test coverage detected