MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / checkpanic

Function checkpanic

Dependencies/lua/src/ltests.c:1255–1281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1253}
1254
1255static int checkpanic (lua_State *L) {
1256 struct Aux b;
1257 void *ud;
1258 lua_State *L1;
1259 const char *code = luaL_checkstring(L, 1);
1260 lua_Alloc f = lua_getallocf(L, &ud);
1261 b.paniccode = luaL_optstring(L, 2, "");
1262 b.L = L;
1263 L1 = lua_newstate(f, ud); /* create new state */
1264 if (L1 == NULL) { /* error? */
1265 lua_pushnil(L);
1266 return 1;
1267 }
1268 lua_atpanic(L1, panicback); /* set its panic function */
1269 lua_pushlightuserdata(L1, &b);
1270 lua_setfield(L1, LUA_REGISTRYINDEX, "_jmpbuf"); /* store 'Aux' struct */
1271 if (setjmp(b.jb) == 0) { /* set jump buffer */
1272 runC(L, L1, code); /* run code unprotected */
1273 lua_pushliteral(L, "no errors");
1274 }
1275 else { /* error handling */
1276 /* move error message to original state */
1277 lua_pushstring(L, lua_tostring(L1, -1));
1278 }
1279 lua_close(L1);
1280 return 1;
1281}
1282
1283
1284

Callers

nothing calls this directly

Calls 8

lua_getallocfFunction · 0.85
lua_newstateFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushlightuserdataFunction · 0.85
lua_setfieldFunction · 0.85
runCFunction · 0.85
lua_pushstringFunction · 0.85
lua_closeFunction · 0.85

Tested by

no test coverage detected