/* ** Execute a protected call. Assumes that function is at lua_state->Cstack.base and ** parameters are on top of it. Leave nResults on the stack. */ int32 luaD_protectedrun(int32 nResults) { jmp_buf myErrorJmp; int32 status; struct C_Lua_Stack oldCLS = lua_state->Cstack; jmp_buf *oldErr = lua_state->errorJmp; lua_state->errorJmp = &myErrorJmp; lua_state->state_counter1++; lua_Task *tmpTask = lua_state->task; if (setjmp(myErrorJmp) == 0) { do_callinc(nResults); status = 0; } else { // an error occurred: restore lua_state->Cstack and lua_state->stack.top lua_state->Cstack = oldCLS; lua_state->stack.top = lua_state->stack.stack + lua_state->Cstack.base; while (tmpTask != lua_state->task) { lua_Task *t = lua_state->task; lua_state->task = lua_state->task->next; luaM_free(t); } status = 1; } lua_state->state_counter1--; lua_state->errorJmp = oldErr; return status; }
/* ** Execute a protected call. Assumes that function is at CLS_current.base and ** parameters are on top of it. Leave nResults on the stack. */ static int do_protectedrun (int nResults) { jmp_buf myErrorJmp; int status; struct C_Lua_Stack oldCLS = CLS_current; jmp_buf *oldErr = errorJmp; errorJmp = &myErrorJmp; if (setjmp(myErrorJmp) == 0) { do_callinc(nResults); status = 0; } else { /* an error occurred: restore CLS_current and top */ CLS_current = oldCLS; top = stack+CLS_current.base; status = 1; } errorJmp = oldErr; return status; }