DIRECTOR: Lingo: Fix factory method execution

This commit is contained in:
Eugene Sandulenko 2016-08-22 19:16:23 +02:00
parent 9517c39397
commit ec23290df1
2 changed files with 12 additions and 1 deletions

View file

@ -183,6 +183,14 @@ void Lingo::dropStack(int nargs) {
pop();
}
void Lingo::drop(int num) {
if (num > _stack.size() - 1) {
warning("Incorrect number of elements to drop from stack: %d > %d", num, _stack.size() - 1);
return;
}
_stack.remove_at(_stack.size() - 1 - num);
}
///////////////////
// Math
@ -794,9 +802,11 @@ void Lingo::factoryCall(Common::String &name, int nargs) {
Datum method = _stack[_stack.size() - nargs + 0];
drop(nargs - 1);
s = name + "-" + *method.u.s;
debugC(3, kDebugLingoExec, "Stack size before call: %d", _stack.size());
debugC(3, kDebugLingoExec, "Stack size before call: %d, nargs: %d", _stack.size(), nargs);
call(s, nargs);
debugC(3, kDebugLingoExec, "Stack size after call: %d", _stack.size());

View file

@ -295,6 +295,7 @@ public:
void printStubWithArglist(const char *funcname, int nargs);
void convertVOIDtoString(int arg, int nargs);
void dropStack(int nargs);
void drop(int num);
static void b_abs(int nargs);
static void b_atan(int nargs);