[Scummvm-git-logs] scummvm master -> 596ca65eff4aec8a5019a9e4c41afbd1113b9205
djsrv
dservilla at gmail.com
Thu Jun 18 20:09:01 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4e401e42f5 DIRECTOR: LINGO: Improve method call debugging
9dbfd35021 DIRECTOR: LINGO: Fix 'me' in kScriptObj handlers
596ca65eff DIRECTOR: LINGO: Fix LC::call local var creation
Commit: 4e401e42f58a41d74cc3d201543746f7521070af
https://github.com/scummvm/scummvm/commit/4e401e42f58a41d74cc3d201543746f7521070af
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-18T16:08:15-04:00
Commit Message:
DIRECTOR: LINGO: Improve method call debugging
Changed paths:
engines/director/lingo/lingo-code.cpp
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 5b1ed00298..d8db08edb7 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1303,7 +1303,7 @@ void LC::call(const Common::String &name, int nargs) {
if (nargs > 0) {
Datum target = g_lingo->peek(nargs - 1);
if (target.type == OBJECT && (target.u.obj->type & (kScriptObj | kXtraObj))) {
- debugC(3, kDebugLingoExec, "Dereferencing object reference: %s to <%s>", name.c_str(), target.asString(true).c_str());
+ debugC(3, kDebugLingoExec, "Method called on object: <%s>", target.asString(true).c_str());
g_lingo->_stack.remove_at(g_lingo->_stack.size() - nargs); // Take object out of stack
nargs -= 1;
if (name.equalsIgnoreCase("birth") || name.equalsIgnoreCase("new")) {
@@ -1324,7 +1324,7 @@ void LC::call(const Common::String &name, int nargs) {
objName.type = VAR;
Datum target = g_lingo->varFetch(objName);
if (target.type == OBJECT && (target.u.obj->type & (kFactoryObj | kXObj))) {
- debugC(3, kDebugLingoExec, "Dereferencing object reference: %s to <%s>", name.c_str(), target.asString(true).c_str());
+ debugC(3, kDebugLingoExec, "Method called on object: <%s>", target.asString(true).c_str());
Datum methodName = g_lingo->_stack.remove_at(g_lingo->_stack.size() - nargs); // Take method name out of stack
nargs -= 1;
if (methodName.u.s->equalsIgnoreCase("mNew")) {
Commit: 9dbfd350219f75e0965fd3cac7b013c0e46db739
https://github.com/scummvm/scummvm/commit/9dbfd350219f75e0965fd3cac7b013c0e46db739
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-18T16:08:15-04:00
Commit Message:
DIRECTOR: LINGO: Fix 'me' in kScriptObj handlers
Changed paths:
engines/director/lingo/lingo-code.cpp
engines/director/lingo/lingo.cpp
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index d8db08edb7..2df217280d 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1304,12 +1304,18 @@ void LC::call(const Common::String &name, int nargs) {
Datum target = g_lingo->peek(nargs - 1);
if (target.type == OBJECT && (target.u.obj->type & (kScriptObj | kXtraObj))) {
debugC(3, kDebugLingoExec, "Method called on object: <%s>", target.asString(true).c_str());
- g_lingo->_stack.remove_at(g_lingo->_stack.size() - nargs); // Take object out of stack
- nargs -= 1;
if (name.equalsIgnoreCase("birth") || name.equalsIgnoreCase("new")) {
target = Datum(target.u.obj->clone());
}
funcSym = target.u.obj->getMethod(name);
+ if (target.u.obj->type == kScriptObj && funcSym.type == HANDLER) {
+ // For kScriptObj handlers the target is the first argument
+ g_lingo->_stack[g_lingo->_stack.size() - nargs] = target;
+ } else {
+ // Otherwise, take the target object out of the stack
+ g_lingo->_stack.remove_at(g_lingo->_stack.size() - nargs);
+ nargs -= 1;
+ }
call(funcSym, nargs, target);
return;
}
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 8e6dcccaeb..5c0fa0e0e0 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -1171,7 +1171,9 @@ Datum Lingo::varFetch(Datum &var, bool global, DatumHash *localvars) {
Datum *d = nullptr;
Common::String name = *var.u.s;
- if (_currentMe.type == OBJECT && name.equalsIgnoreCase("me")) {
+ // For kScriptObj handlers the target is an argument
+ // (and can be renamed from 'me)
+ if (_currentMe.type == OBJECT && _currentMe.u.obj->type != kScriptObj && name.equalsIgnoreCase("me")) {
result = _currentMe;
return result;
}
Commit: 596ca65eff4aec8a5019a9e4c41afbd1113b9205
https://github.com/scummvm/scummvm/commit/596ca65eff4aec8a5019a9e4c41afbd1113b9205
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-18T16:08:15-04:00
Commit Message:
DIRECTOR: LINGO: Fix LC::call local var creation
Arguments were totally ignored in anonymous functions, which could have
caused future problems.
Changed paths:
engines/director/lingo/lingo-code.cpp
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 2df217280d..34a42498d6 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1416,47 +1416,51 @@ void LC::call(const Symbol &funcSym, int nargs, Datum target) {
g_lingo->pushContext(&funcSym, true);
+ DatumHash *localvars = g_lingo->_localvars;
if (funcSym.archiveIndex >= 0) {
// Create new set of local variables
- DatumHash *localvars = new DatumHash;
- if (funcSym.argNames) {
- int symNArgs = funcSym.nargs;
- if ((int)funcSym.argNames->size() < symNArgs) {
- int dropSize = symNArgs - funcSym.argNames->size();
- warning("%d arg names defined for %d args! Dropping the last %d values", funcSym.argNames->size(), symNArgs, dropSize);
- for (int i = 0; i < dropSize; i++) {
- g_lingo->pop();
- symNArgs -= 1;
- }
- } else if ((int)funcSym.argNames->size() > symNArgs) {
- warning("%d arg names defined for %d args! Ignoring the last %d names", funcSym.argNames->size(), symNArgs, funcSym.argNames->size() - symNArgs);
+ // g_lingo->_localvars is not set until later so any lazy arguments
+ // can be evaluated within the current variable frame
+ localvars = new DatumHash;
+ }
+
+ if (funcSym.argNames) {
+ int symNArgs = funcSym.nargs;
+ if ((int)funcSym.argNames->size() < symNArgs) {
+ int dropSize = symNArgs - funcSym.argNames->size();
+ warning("%d arg names defined for %d args! Dropping the last %d values", funcSym.argNames->size(), symNArgs, dropSize);
+ for (int i = 0; i < dropSize; i++) {
+ g_lingo->pop();
+ symNArgs -= 1;
}
- for (int i = symNArgs - 1; i >= 0; i--) {
- Common::String name = (*funcSym.argNames)[i];
- if (!localvars->contains(name)) {
- g_lingo->varCreate(name, false, localvars);
- Datum arg(name);
- arg.type = VAR;
- Datum value = g_lingo->pop();
- g_lingo->varAssign(arg, value, false, localvars);
- } else {
- warning("Argument %s already defined", name.c_str());
- g_lingo->pop();
- }
+ } else if ((int)funcSym.argNames->size() > symNArgs) {
+ warning("%d arg names defined for %d args! Ignoring the last %d names", funcSym.argNames->size(), symNArgs, funcSym.argNames->size() - symNArgs);
+ }
+ for (int i = symNArgs - 1; i >= 0; i--) {
+ Common::String name = (*funcSym.argNames)[i];
+ if (!localvars->contains(name)) {
+ g_lingo->varCreate(name, false, localvars);
+ Datum arg(name);
+ arg.type = VAR;
+ Datum value = g_lingo->pop();
+ g_lingo->varAssign(arg, value, false, localvars);
+ } else {
+ warning("Argument %s already defined", name.c_str());
+ g_lingo->pop();
}
}
- if (funcSym.varNames) {
- for (Common::Array<Common::String>::iterator it = funcSym.varNames->begin(); it != funcSym.varNames->end(); ++it) {
- Common::String name = *it;
- if (!localvars->contains(name)) {
- (*localvars)[name] = Datum();
- } else {
- warning("Variable %s already defined", name.c_str());
- }
+ }
+ if (funcSym.varNames) {
+ for (Common::Array<Common::String>::iterator it = funcSym.varNames->begin(); it != funcSym.varNames->end(); ++it) {
+ Common::String name = *it;
+ if (!localvars->contains(name)) {
+ (*localvars)[name] = Datum();
+ } else {
+ warning("Variable %s already defined", name.c_str());
}
}
- g_lingo->_localvars = localvars;
}
+ g_lingo->_localvars = localvars;
if (target.type == OBJECT) {
g_lingo->_currentMe = target;
More information about the Scummvm-git-logs
mailing list