MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaC_checkfinalizer

Function luaC_checkfinalizer

third-party/lua-5.5.0/src/lgc.c:1068–1090  ·  view source on GitHub ↗

** if object 'o' has a finalizer, remove it from 'allgc' list (must ** search the list to find it) and link it in 'finobj' list. */

Source from the content-addressed store, hash-verified

1066** search the list to find it) and link it in 'finobj' list.
1067*/
1068void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
1069 global_State *g = G(L);
1070 if (tofinalize(o) || /* obj. is already marked... */
1071 gfasttm(g, mt, TM_GC) == NULL || /* or has no finalizer... */
1072 (g->gcstp & GCSTPCLS)) /* or closing state? */
1073 return; /* nothing to be done */
1074 else { /* move 'o' to 'finobj' list */
1075 GCObject **p;
1076 if (issweepphase(g)) {
1077 makewhite(g, o); /* "sweep" object 'o' */
1078 if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */
1079 g->sweepgc = sweeptolive(L, g->sweepgc); /* change 'sweepgc' */
1080 }
1081 else
1082 correctpointers(g, o);
1083 /* search for pointer pointing to 'o' */
1084 for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ }
1085 *p = o->next; /* remove 'o' from 'allgc' list */
1086 o->next = g->finobj; /* link it in 'finobj' list */
1087 g->finobj = o;
1088 l_setbit(o->marked, FINALIZEDBIT); /* mark it as such */
1089 }
1090}
1091
1092/* }====================================================== */
1093

Callers 1

lua_setmetatableFunction · 0.70

Calls 2

sweeptoliveFunction · 0.70
correctpointersFunction · 0.70

Tested by

no test coverage detected