mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 17:03:05 +00:00
GRIM: LUA: Cleanup variables name
This commit is contained in:
parent
be1e3a011a
commit
662481db00
@ -487,9 +487,9 @@ static void do_unprotectedrun(lua_CFunction f, int32 nParams, int32 nResults) {
|
||||
luaD_openstack(nParams);
|
||||
lua_state->stack.stack[base].ttype = LUA_T_CPROTO;
|
||||
lua_state->stack.stack[base].value.f = f;
|
||||
lua_state->state_counter1++;
|
||||
lua_state->preventBreakCounter++;
|
||||
luaD_call(base + 1, nResults);
|
||||
lua_state->state_counter1--;
|
||||
lua_state->preventBreakCounter--;
|
||||
}
|
||||
|
||||
lua_Object lua_setfallback(const char *name, lua_CFunction fallback) {
|
||||
|
@ -67,9 +67,9 @@ static void foreachvar() {
|
||||
luaA_pushobject(&f);
|
||||
pushstring(s);
|
||||
luaA_pushobject(&s->globalval);
|
||||
lua_state->state_counter1++;
|
||||
lua_state->preventBreakCounter++;
|
||||
luaD_call((lua_state->stack.top - lua_state->stack.stack) - 2, 1);
|
||||
lua_state->state_counter1--;
|
||||
lua_state->preventBreakCounter--;
|
||||
if (ttype(lua_state->stack.top - 1) != LUA_T_NIL)
|
||||
return;
|
||||
lua_state->stack.top--;
|
||||
@ -96,9 +96,9 @@ static void foreach() {
|
||||
luaA_pushobject(&f);
|
||||
luaA_pushobject(ref(nd));
|
||||
luaA_pushobject(val(nd));
|
||||
lua_state->state_counter1++;
|
||||
lua_state->preventBreakCounter++;
|
||||
luaD_call((lua_state->stack.top - lua_state->stack.stack) - 2, 1);
|
||||
lua_state->state_counter1--;
|
||||
lua_state->preventBreakCounter--;
|
||||
if (ttype(lua_state->stack.top - 1) != LUA_T_NIL)
|
||||
return;
|
||||
lua_state->stack.top--;
|
||||
|
@ -141,9 +141,9 @@ static StkId callC(lua_CFunction f, StkId base) {
|
||||
TObject *r = lua_state->stack.stack + base - 1;
|
||||
(*lua_callhook)(Ref(r), "(C)", -1);
|
||||
}
|
||||
lua_state->state_counter2++;
|
||||
lua_state->callLevelCounter++;
|
||||
(*f)(); // do the actual call
|
||||
lua_state->state_counter2--;
|
||||
lua_state->callLevelCounter--;
|
||||
// if (lua_callhook) // func may have changed lua_callhook
|
||||
// (*lua_callhook)(LUA_NOOBJECT, "(return)", 0);
|
||||
firstResult = CS->base;
|
||||
@ -167,21 +167,21 @@ static StkId callCclosure(struct Closure *cl, lua_CFunction f, StkId base) {
|
||||
void luaD_callTM(TObject *f, int32 nParams, int32 nResults) {
|
||||
luaD_openstack(nParams);
|
||||
*(lua_state->stack.top - nParams - 1) = *f;
|
||||
lua_state->state_counter1++;
|
||||
lua_state->state_counter2++;
|
||||
lua_state->preventBreakCounter++;
|
||||
lua_state->callLevelCounter++;
|
||||
luaD_call((lua_state->stack.top - lua_state->stack.stack) - nParams, nResults);
|
||||
lua_state->state_counter2--;
|
||||
lua_state->state_counter1--;
|
||||
lua_state->callLevelCounter--;
|
||||
lua_state->preventBreakCounter--;
|
||||
}
|
||||
|
||||
int32 luaD_call(StkId base, int32 nResults) {
|
||||
lua_Task *tmpTask = lua_state->task;
|
||||
if (!lua_state->task || lua_state->state_counter2) {
|
||||
if (!lua_state->task || lua_state->callLevelCounter) {
|
||||
lua_Task *t = luaM_new(lua_Task);
|
||||
lua_taskinit(t, lua_state->task, base, nResults);
|
||||
lua_state->task = t;
|
||||
} else {
|
||||
tmpTask = lua_state->some_task;
|
||||
tmpTask = lua_state->prevTask;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
@ -200,7 +200,7 @@ int32 luaD_call(StkId base, int32 nResults) {
|
||||
firstResult = luaV_execute(lua_state->task);
|
||||
}
|
||||
} else if (ttype(funcObj) == LUA_T_PMARK) {
|
||||
if (!lua_state->task->some_flag) {
|
||||
if (!lua_state->task->executed) {
|
||||
TObject *im = luaT_getimbyObj(funcObj, IM_FUNCTION);
|
||||
if (ttype(im) == LUA_T_NIL)
|
||||
lua_error("call expression not a function");
|
||||
@ -209,7 +209,7 @@ int32 luaD_call(StkId base, int32 nResults) {
|
||||
}
|
||||
firstResult = luaV_execute(lua_state->task);
|
||||
} else if (ttype(funcObj) == LUA_T_CMARK) {
|
||||
if (!lua_state->task->some_flag) {
|
||||
if (!lua_state->task->executed) {
|
||||
TObject *im = luaT_getimbyObj(funcObj, IM_FUNCTION);
|
||||
if (ttype(im) == LUA_T_NIL)
|
||||
lua_error("call expression not a function");
|
||||
@ -219,7 +219,7 @@ int32 luaD_call(StkId base, int32 nResults) {
|
||||
} else if (ttype(funcObj) == LUA_T_CLMARK) {
|
||||
Closure *c = clvalue(funcObj);
|
||||
TObject *proto = &(c->consts[0]);
|
||||
if (!lua_state->task->some_flag) {
|
||||
if (!lua_state->task->executed) {
|
||||
TObject *im = luaT_getimbyObj(funcObj, IM_FUNCTION);
|
||||
if (ttype(im) == LUA_T_NIL)
|
||||
lua_error("call expression not a function");
|
||||
@ -251,8 +251,8 @@ int32 luaD_call(StkId base, int32 nResults) {
|
||||
lua_taskinit(t, lua_state->task, base, nResults);
|
||||
lua_state->task = t;
|
||||
} else {
|
||||
nResults = lua_state->task->some_results;
|
||||
base = lua_state->task->some_base;
|
||||
nResults = lua_state->task->initResults;
|
||||
base = lua_state->task->initBase;
|
||||
if (nResults != 255)
|
||||
luaD_adjusttop(firstResult + nResults);
|
||||
base--;
|
||||
@ -265,13 +265,13 @@ int32 luaD_call(StkId base, int32 nResults) {
|
||||
lua_state->task = lua_state->task->next;
|
||||
luaM_free(tmp);
|
||||
if (lua_state->task) {
|
||||
nResults = lua_state->task->some_results;
|
||||
base = lua_state->task->some_base;
|
||||
nResults = lua_state->task->initResults;
|
||||
base = lua_state->task->initBase;
|
||||
}
|
||||
|
||||
if (function == break_here || function == sleep_for) {
|
||||
if (!lua_state->state_counter1) {
|
||||
lua_state->some_task = tmpTask;
|
||||
if (!lua_state->preventBreakCounter) {
|
||||
lua_state->prevTask = tmpTask;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -342,7 +342,7 @@ int32 luaD_protectedrun(int32 nResults) {
|
||||
struct C_Lua_Stack oldCLS = lua_state->Cstack;
|
||||
jmp_buf *oldErr = lua_state->errorJmp;
|
||||
lua_state->errorJmp = &myErrorJmp;
|
||||
lua_state->state_counter1++;
|
||||
lua_state->preventBreakCounter++;
|
||||
lua_Task *tmpTask = lua_state->task;
|
||||
if (setjmp(myErrorJmp) == 0) {
|
||||
do_callinc(nResults);
|
||||
@ -357,7 +357,7 @@ int32 luaD_protectedrun(int32 nResults) {
|
||||
}
|
||||
status = 1;
|
||||
}
|
||||
lua_state->state_counter1--;
|
||||
lua_state->preventBreakCounter--;
|
||||
lua_state->errorJmp = oldErr;
|
||||
return status;
|
||||
}
|
||||
|
@ -498,9 +498,9 @@ void lua_Restore(SaveGame *savedState) {
|
||||
task->tf = (TProtoFunc *)tempObj.value.tf;
|
||||
|
||||
task->base = savedState->readLESint32();
|
||||
task->some_base = savedState->readLESint32();
|
||||
task->some_results = savedState->readLESint32();
|
||||
task->some_flag = savedState->readBool();
|
||||
task->initBase = savedState->readLESint32();
|
||||
task->initResults = savedState->readLESint32();
|
||||
task->executed = savedState->readBool();
|
||||
int32 pcOffset = savedState->readLESint32();
|
||||
task->pc = task->tf->code + pcOffset;
|
||||
task->aux = savedState->readLESint32();
|
||||
@ -511,11 +511,11 @@ void lua_Restore(SaveGame *savedState) {
|
||||
}
|
||||
int32 n = savedState->readLESint32();
|
||||
if (n < 0) {
|
||||
state->some_task = nullptr;
|
||||
state->prevTask = nullptr;
|
||||
} else {
|
||||
state->some_task = state->task;
|
||||
state->prevTask = state->task;
|
||||
for (; n; n--)
|
||||
state->some_task = state->some_task->next;
|
||||
state->prevTask = state->prevTask->next;
|
||||
}
|
||||
|
||||
state->updated = savedState->readBool();
|
||||
@ -524,8 +524,8 @@ void lua_Restore(SaveGame *savedState) {
|
||||
state->all_paused = pauseState & LUA_SG_ALL_PAUSED;
|
||||
state->paused = (pauseState & LUA_SG_PAUSED) ? true : false;
|
||||
|
||||
state->state_counter1 = savedState->readLESint32();
|
||||
state->state_counter2 = savedState->readLESint32();
|
||||
state->preventBreakCounter = savedState->readLESint32();
|
||||
state->callLevelCounter = savedState->readLESint32();
|
||||
|
||||
int32 stackLastSize = savedState->readLESint32();
|
||||
if (state->stack.stack)
|
||||
|
@ -322,7 +322,7 @@ void lua_Save(SaveGame *savedState) {
|
||||
lua_Task *task = state->task;
|
||||
int32 countTasks = 0, n = -1;
|
||||
while (task) {
|
||||
if (state->some_task && state->some_task == task)
|
||||
if (state->prevTask && state->prevTask == task)
|
||||
n = countTasks;
|
||||
countTasks++;
|
||||
task = task->next;
|
||||
@ -333,9 +333,9 @@ void lua_Save(SaveGame *savedState) {
|
||||
savedState->writeLEUint64(makeIdFromPointer(task->cl).id);
|
||||
savedState->writeLEUint64(makeIdFromPointer(task->tf).id);
|
||||
savedState->writeLESint32(task->base);
|
||||
savedState->writeLESint32(task->some_base);
|
||||
savedState->writeLESint32(task->some_results);
|
||||
savedState->writeBool(task->some_flag);
|
||||
savedState->writeLESint32(task->initBase);
|
||||
savedState->writeLESint32(task->initResults);
|
||||
savedState->writeBool(task->executed);
|
||||
int32 pcOffset = task->pc - task->tf->code;
|
||||
savedState->writeLESint32(pcOffset);
|
||||
savedState->writeLESint32(task->aux);
|
||||
@ -351,8 +351,8 @@ void lua_Save(SaveGame *savedState) {
|
||||
pauseState |= state->paused ? LUA_SG_PAUSED : 0;
|
||||
savedState->writeByte(pauseState);
|
||||
|
||||
savedState->writeLESint32(state->state_counter1);
|
||||
savedState->writeLESint32(state->state_counter2);
|
||||
savedState->writeLESint32(state->preventBreakCounter);
|
||||
savedState->writeLESint32(state->callLevelCounter);
|
||||
|
||||
int32 stackLastSize = (state->stack.last - state->stack.stack) + 1;
|
||||
savedState->writeLESint32(stackLastSize);
|
||||
|
@ -77,8 +77,8 @@ void lua_stateinit(LState *state) {
|
||||
state->next = nullptr;
|
||||
state->all_paused = 0;
|
||||
state->paused = false;
|
||||
state->state_counter1 = 0;
|
||||
state->state_counter2 = 0;
|
||||
state->preventBreakCounter = 0;
|
||||
state->callLevelCounter = 0;
|
||||
state->updated = false;
|
||||
|
||||
state->numCblocks = 0;
|
||||
@ -88,7 +88,7 @@ void lua_stateinit(LState *state) {
|
||||
state->errorJmp = nullptr;
|
||||
state->id = globalTaskSerialId++;
|
||||
state->task = nullptr;
|
||||
state->some_task = nullptr;
|
||||
state->prevTask = nullptr;
|
||||
state->taskFunc.ttype = LUA_T_NIL;
|
||||
state->sleepFor = 0;
|
||||
|
||||
|
@ -91,8 +91,8 @@ struct LState {
|
||||
LState *next; // handle to next state in list
|
||||
int all_paused; // counter of often pause_scripts(TRUE) was called
|
||||
bool paused; // true if this particular script has been paused
|
||||
int32 state_counter1;
|
||||
int32 state_counter2;
|
||||
int32 preventBreakCounter;
|
||||
int32 callLevelCounter;
|
||||
bool updated;
|
||||
Stack stack; // Lua stack
|
||||
C_Lua_Stack Cstack; // C2lua struct
|
||||
@ -100,9 +100,9 @@ struct LState {
|
||||
struct LexState *lexstate; // point to local struct in yacc
|
||||
jmp_buf *errorJmp; // current error recover point
|
||||
lua_Task *task; // handle to task
|
||||
lua_Task *some_task;
|
||||
lua_Task *prevTask;
|
||||
uint32 id; // current id of task
|
||||
TObject taskFunc;
|
||||
TObject taskFunc;
|
||||
struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
|
||||
int numCblocks; // number of nested Cblocks
|
||||
int sleepFor;
|
||||
|
@ -14,10 +14,10 @@
|
||||
namespace Grim {
|
||||
|
||||
void lua_taskinit(lua_Task *task, lua_Task *next, StkId tbase, int results) {
|
||||
task->some_flag = 0;
|
||||
task->executed = false;
|
||||
task->next = next;
|
||||
task->some_base = tbase;
|
||||
task->some_results = results;
|
||||
task->initBase = tbase;
|
||||
task->initResults = results;
|
||||
}
|
||||
|
||||
void lua_taskresume(lua_Task *task, Closure *closure, TProtoFunc *protofunc, StkId tbase) {
|
||||
@ -341,7 +341,7 @@ void runtasks(LState *const rootState) {
|
||||
lua_state->task = nullptr;
|
||||
} else {
|
||||
if (lua_state->task) {
|
||||
stillRunning = luaD_call(lua_state->task->some_base, lua_state->task->some_results);
|
||||
stillRunning = luaD_call(lua_state->task->initBase, lua_state->task->initResults);
|
||||
} else {
|
||||
StkId base = lua_state->Cstack.base;
|
||||
luaD_openstack((lua_state->stack.top - lua_state->stack.stack) - base);
|
||||
|
@ -15,9 +15,9 @@ struct lua_Task {
|
||||
byte *pc;
|
||||
TObject *consts;
|
||||
int32 aux;
|
||||
bool some_flag;
|
||||
StkId some_base;
|
||||
int32 some_results;
|
||||
bool executed;
|
||||
StkId initBase;
|
||||
int32 initResults;
|
||||
};
|
||||
|
||||
void lua_taskinit(lua_Task *task, lua_Task *next, StkId tbase, int results);
|
||||
|
@ -242,7 +242,7 @@ static void adjust_varargs(StkId first_extra_arg) {
|
||||
}
|
||||
|
||||
StkId luaV_execute(lua_Task *task) {
|
||||
if (!task->some_flag) {
|
||||
if (!task->executed) {
|
||||
luaD_checkstack((*task->pc++) + EXTRA_STACK);
|
||||
if (*task->pc < ZEROVARARG) {
|
||||
luaD_adjusttop(task->base + *(task->pc++));
|
||||
@ -250,9 +250,9 @@ StkId luaV_execute(lua_Task *task) {
|
||||
luaC_checkGC();
|
||||
adjust_varargs(task->base + (*task->pc++) - ZEROVARARG);
|
||||
}
|
||||
task->some_flag = 1;
|
||||
task->executed = true;
|
||||
}
|
||||
lua_state->state_counter2++;
|
||||
lua_state->callLevelCounter++;
|
||||
|
||||
while (1) {
|
||||
switch ((OpCode)(task->aux = *task->pc++)) {
|
||||
@ -654,13 +654,13 @@ closure:
|
||||
case CALLFUNC1:
|
||||
task->aux -= CALLFUNC0;
|
||||
callfunc:
|
||||
lua_state->state_counter2--;
|
||||
lua_state->callLevelCounter--;
|
||||
return -((task->S->top - task->S->stack) - (*task->pc++));
|
||||
case ENDCODE:
|
||||
task->S->top = task->S->stack + task->base;
|
||||
// fall through
|
||||
case RETCODE:
|
||||
lua_state->state_counter2--;
|
||||
lua_state->callLevelCounter--;
|
||||
return (task->base + ((task->aux == 123) ? *task->pc : 0));
|
||||
case SETLINEW:
|
||||
task->aux = next_word(task->pc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user