[Scummvm-git-logs] scummvm master -> 755ebb995ccbc198a21c32785f480374d0db7c98

sev- noreply at scummvm.org
Wed Jul 12 20:49:39 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a683a1f340 DIRECTOR: LINGO: Fix m_perform returning multiple values
755ebb995c DIRECTOR: LINGO: Add mperform.lingo to lingo tests


Commit: a683a1f340554f6701bd5dde3eb0d34a9ef641b3
    https://github.com/scummvm/scummvm/commit/a683a1f340554f6701bd5dde3eb0d34a9ef641b3
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-07-12T22:49:36+02:00

Commit Message:
DIRECTOR: LINGO: Fix m_perform returning multiple values

mPerform calls LC:Call which executes immediately and pushes context
for next handler, however as a result some <Void> were being pushed
into stack and accumulated. fixes the problem where multiple mPerform
calls inside mAtFrame were giving error of extra values in stack, also
pushes a dummy value to satisfy stack checking if in case a return value
is expected.

Fixed m_perform calls in `ATD\HD\FOGTRWAR.DXR` of 'totaldistortion-win'

Changed paths:
    engines/director/lingo/lingo-code.cpp
    engines/director/lingo/lingo-object.cpp


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 8bb595840f4..6ae01ef3f1d 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1645,6 +1645,11 @@ void LC::call(const Symbol &funcSym, int nargs, bool allowRetVal) {
 			// Pushing an entire stack frame is not necessary
 			Datum retMe = g_lingo->_state->me;
 			g_lingo->_state->me = target;
+
+			// WORKAROUND: m_Perform needs to know if value should be returned or not (to create a new context frames for handles)
+			if (funcSym.name->equals("perform"))
+				g_lingo->push(Datum(allowRetVal));
+
 			(*funcSym.u.bltin)(nargs);
 			g_lingo->_state->me = retMe;
 		} else {
diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index fd1988b7fca..e23cecf4ff9 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -490,6 +490,8 @@ void LM::m_put(int nargs) {
 // Other
 
 void LM::m_perform(int nargs) {
+	bool allowRetVal = g_lingo->pop().asInt() != 0; // Pop allowRetVal that should be used for the LC::Call
+
 	// Lingo doesn't seem to bother cloning the object when
 	// mNew is called with mPerform
 	Datum d(g_lingo->_state->me);
@@ -498,7 +500,12 @@ void LM::m_perform(int nargs) {
 	Symbol funcSym = me->getMethod(*methodName.u.s);
 	// Object methods expect the first argument to be the object
 	g_lingo->_stack.insert_at(g_lingo->_stack.size() - nargs + 1, d);
-	LC::call(funcSym, nargs, true);
+	LC::call(funcSym, nargs, allowRetVal);
+
+	if (allowRetVal) {
+		// If the method expects a return value, push dummy on stack
+		g_lingo->pushVoid();
+	}
 }
 
 // XObject


Commit: 755ebb995ccbc198a21c32785f480374d0db7c98
    https://github.com/scummvm/scummvm/commit/755ebb995ccbc198a21c32785f480374d0db7c98
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-07-12T22:49:36+02:00

Commit Message:
DIRECTOR: LINGO: Add mperform.lingo to lingo tests

Changed paths:
  A engines/director/lingo/tests/mperform.lingo


diff --git a/engines/director/lingo/tests/mperform.lingo b/engines/director/lingo/tests/mperform.lingo
new file mode 100644
index 00000000000..9232eb802a2
--- /dev/null
+++ b/engines/director/lingo/tests/mperform.lingo
@@ -0,0 +1,25 @@
+abc(mNew)
+abc(callPerform)
+
+factory abc
+method mnew
+  put "init"
+
+method callMe
+  put "Am i called?"
+  return "a1"
+
+method callMe2
+  put "Am i called2?"
+
+method callMe3
+  put "Am I called3?"
+
+method callPerform
+  put "stepped into matFrame"
+  set retval to me(mPerform, "callMe")
+  me(mPerform, "callMe2")
+  me(mPerform, "callMe3")
+  put "returned" && retval
+
+  scummvmAssertEqual(retval, "a1")




More information about the Scummvm-git-logs mailing list