MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / checkclosemth

Function checkclosemth

lib/lua/src/lfunc.c:125–133  ·  view source on GitHub ↗

** Check whether object at given level has a close metamethod and raise ** an error if not. */

Source from the content-addressed store, hash-verified

123** an error if not.
124*/
125static void checkclosemth (lua_State *L, StkId level) {
126 const TValue *tm = luaT_gettmbyobj(L, s2v(level), TM_CLOSE);
127 if (ttisnil(tm)) { /* no metamethod? */
128 int idx = cast_int(level - L->ci->func.p); /* variable index */
129 const char *vname = luaG_findlocal(L, L->ci, idx, NULL);
130 if (vname == NULL) vname = "?";
131 luaG_runerror(L, "variable '%s' got a non-closable value", vname);
132 }
133}
134
135
136/*

Callers 1

luaF_newtbcupvalFunction · 0.85

Calls 3

luaT_gettmbyobjFunction · 0.85
luaG_findlocalFunction · 0.85
luaG_runerrorFunction · 0.85

Tested by

no test coverage detected