DIRECTOR: Add changes from code review

This commit is contained in:
Scott Percival 2022-12-06 00:28:04 +08:00 committed by Eugene Sandulenko
parent 2674b628c4
commit 689d08a396
2 changed files with 15 additions and 10 deletions

View File

@ -673,15 +673,15 @@ void LB::b_deleteAt(int nargs) {
}
void LB::b_deleteOne(int nargs) {
Datum indexD = g_lingo->pop();
Datum val = g_lingo->pop();
Datum list = g_lingo->pop();
TYPECHECK3(indexD, INT, FLOAT, SYMBOL);
TYPECHECK3(val, INT, FLOAT, SYMBOL);
TYPECHECK2(list, ARRAY, PARRAY);
switch (list.type) {
case ARRAY: {
g_lingo->push(list);
g_lingo->push(indexD);
g_lingo->push(val);
b_getPos(nargs);
int index = g_lingo->pop().asInt();
if (index > 0) {
@ -691,7 +691,7 @@ void LB::b_deleteOne(int nargs) {
}
case PARRAY: {
Datum d;
int index = LC::compareArrays(LC::eqData, list, indexD, true, true).u.i;
int index = LC::compareArrays(LC::eqData, list, val, true, true).u.i;
if (index > 0) {
list.u.parr->arr.remove_at(index - 1);
}

View File

@ -292,12 +292,17 @@ struct LingoArchive {
};
struct LingoState {
Common::Array<CFrame *> callstack;
uint pc = 0;
ScriptData *script = nullptr;
ScriptContext *context = nullptr;
DatumHash *localVars = nullptr;
Datum me;
// Execution state for a Lingo process, created every time
// a top-level handler is called (e.g. on mouseDown).
// Can be swapped out when another script gets called with priority.
// Call frames are pushed and popped from the callstack with
// pushContext and popContext.
Common::Array<CFrame *> callstack; // call stack
uint pc = 0; // current program counter
ScriptData *script = nullptr; // current Lingo script
ScriptContext *context = nullptr; // current Lingo script context
DatumHash *localVars = nullptr; // current local variables
Datum me; // current me object
~LingoState();
};