[Scummvm-git-logs] scummvm master -> 3a4e6f867d7e84c8f926d75f09f62c54862df9bc

djsrv dservilla at gmail.com
Mon Jun 22 17:31:22 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:
9741d39d8d DIRECTOR: LINGO: Fix missed _assemblyContext
903f2ac491 DIRECTOR: LINGO: Implement local function calls
3a4e6f867d DIRECTOR: LINGO: Separate cast and field refs


Commit: 9741d39d8d21e62f1612febe7c73d340bab34652
    https://github.com/scummvm/scummvm/commit/9741d39d8d21e62f1612febe7c73d340bab34652
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-22T13:29:08-04:00

Commit Message:
DIRECTOR: LINGO: Fix missed _assemblyContext

Changed paths:
    engines/director/lingo/lingo.cpp


diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index dc4d61cc25..0e1d1107f4 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -364,7 +364,7 @@ ScriptContext *Lingo::addCode(const char *code, int archiveIndex, ScriptType typ
 	currentFunc.u.defn = _currentAssembly;
 	Common::String typeStr = Common::String(scriptType2str(type));
 	currentFunc.name = new Common::String("[" + typeStr + " " + _assemblyContext->_name + "]");
-	currentFunc.ctx = _currentScriptContext;
+	currentFunc.ctx = _assemblyContext;
 	currentFunc.archiveIndex = _assemblyArchive;
 	// arg names should be empty, but just in case
 	Common::Array<Common::String> *argNames = new Common::Array<Common::String>;


Commit: 903f2ac491db9f0cbef8265bb0571ff12a4cac80
    https://github.com/scummvm/scummvm/commit/903f2ac491db9f0cbef8265bb0571ff12a4cac80
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-22T13:29:08-04:00

Commit Message:
DIRECTOR: LINGO: Implement local function calls

Changed paths:
    engines/director/lingo/lingo.cpp


diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 0e1d1107f4..7243be6bb8 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -201,6 +201,10 @@ Common::String Lingo::getName(uint16 id) {
 Symbol Lingo::getHandler(const Common::String &name) {
 	Symbol result;
 	if (!_eventHandlerTypeIds.contains(name)) {
+		// local functions
+		if (_currentScriptContext && _currentScriptContext->_functionHandlers.contains(name))
+			return _currentScriptContext->_functionHandlers[name];
+
 		// local scripts
 		if (_archives[kArchMain].functionHandlers.contains(name))
 			return _archives[kArchMain].functionHandlers[name];


Commit: 3a4e6f867d7e84c8f926d75f09f62c54862df9bc
    https://github.com/scummvm/scummvm/commit/3a4e6f867d7e84c8f926d75f09f62c54862df9bc
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-22T13:29:08-04:00

Commit Message:
DIRECTOR: LINGO: Separate cast and field refs

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-gr.cpp
    engines/director/lingo/lingo-gr.h
    engines/director/lingo/lingo-gr.y
    engines/director/lingo/lingo-the.cpp
    engines/director/lingo/lingo.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 1a6771d19c..cc641a10b7 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -420,7 +420,7 @@ void LB::b_chars(int nargs) {
 	int to = g_lingo->pop().asInt();
 	int from = g_lingo->pop().asInt();
 	Datum s = g_lingo->pop();
-	TYPECHECK2(s, STRING, REFERENCE);
+	TYPECHECK2(s, STRING, FIELDREF);
 
 	Common::String src = s.asString();
 
@@ -472,7 +472,7 @@ void LB::b_hilite(int nargs) {
 
 void LB::b_length(int nargs) {
 	Datum d = g_lingo->pop();
-	TYPECHECK2(d, STRING, REFERENCE);
+	TYPECHECK2(d, STRING, FIELDREF);
 
 	int len = strlen(d.asString().c_str());
 
@@ -560,7 +560,7 @@ void LB::b_addProp(int nargs) {
 	Datum list = g_lingo->pop();
 
 	TYPECHECK(list, PARRAY);
-	if (prop.type == REFERENCE)
+	if (prop.type == FIELDREF)
 		prop = g_lingo->varFetch(prop);
 
 	PCell cell = PCell(prop, value);
@@ -991,7 +991,7 @@ void LB::b_setProp(int nargs) {
 	Datum prop = g_lingo->pop();
 	Datum list = g_lingo->pop();
 	TYPECHECK(list, PARRAY);
-	if (prop.type == REFERENCE)
+	if (prop.type == FIELDREF)
 		prop = g_lingo->varFetch(prop);
 
 	int index = LC::compareArrays(LC::eqData, list, prop, true).u.i;
@@ -2133,7 +2133,7 @@ void LB::b_cast(int nargs) {
 	Datum d = g_lingo->pop();
 
 	Datum res(g_lingo->castIdFetch(d));
-	res.type = REFERENCE;
+	res.type = CASTREF;
 	g_lingo->push(res);
 }
 
@@ -2141,7 +2141,7 @@ void LB::b_field(int nargs) {
 	Datum d = g_lingo->pop();
 
 	Datum res(g_lingo->castIdFetch(d));
-	res.type = REFERENCE;
+	res.type = FIELDREF;
 	g_lingo->push(res);
 }
 
@@ -2176,9 +2176,7 @@ void LB::b_window(int nargs) {
 
 	warning("STUB: b_window");
 
-	Datum res(0);
-	res.type = REFERENCE;
-	g_lingo->push(res);
+	g_lingo->push(Datum());
 }
 
 void LB::b_numberofchars(int nargs) {
diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp
index 47f5b8087a..6fca02a75d 100644
--- a/engines/director/lingo/lingo-gr.cpp
+++ b/engines/director/lingo/lingo-gr.cpp
@@ -232,7 +232,7 @@ extern int yydebug;
     RECT = 263,                    /* RECT  */
     ARRAY = 264,                   /* ARRAY  */
     OBJECT = 265,                  /* OBJECT  */
-    REFERENCE = 266,               /* REFERENCE  */
+    FIELDREF = 266,                /* FIELDREF  */
     LEXERROR = 267,                /* LEXERROR  */
     PARRAY = 268,                  /* PARRAY  */
     INT = 269,                     /* INT  */
@@ -360,7 +360,7 @@ enum yysymbol_kind_t
   YYSYMBOL_RECT = 8,                       /* RECT  */
   YYSYMBOL_ARRAY = 9,                      /* ARRAY  */
   YYSYMBOL_OBJECT = 10,                    /* OBJECT  */
-  YYSYMBOL_REFERENCE = 11,                 /* REFERENCE  */
+  YYSYMBOL_FIELDREF = 11,                  /* FIELDREF  */
   YYSYMBOL_LEXERROR = 12,                  /* LEXERROR  */
   YYSYMBOL_PARRAY = 13,                    /* PARRAY  */
   YYSYMBOL_INT = 14,                       /* INT  */
@@ -921,7 +921,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
   static const char *const yy_sname[] =
   {
   "end of file", "error", "invalid token", "UNARY", "CASTREF", "VOID",
-  "VAR", "POINT", "RECT", "ARRAY", "OBJECT", "REFERENCE", "LEXERROR",
+  "VAR", "POINT", "RECT", "ARRAY", "OBJECT", "FIELDREF", "LEXERROR",
   "PARRAY", "INT", "ARGC", "ARGCNORET", "THEENTITY", "THEENTITYWITHID",
   "THEMENUITEMENTITY", "THEMENUITEMSENTITY", "FLOAT", "BLTIN", "FBLTIN",
   "RBLTIN", "THEFBLTIN", "ID", "STRING", "HANDLER", "SYMBOL", "ENDCLAUSE",
diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h
index 002306654a..cf524c695f 100644
--- a/engines/director/lingo/lingo-gr.h
+++ b/engines/director/lingo/lingo-gr.h
@@ -62,7 +62,7 @@ extern int yydebug;
     RECT = 263,                    /* RECT  */
     ARRAY = 264,                   /* ARRAY  */
     OBJECT = 265,                  /* OBJECT  */
-    REFERENCE = 266,               /* REFERENCE  */
+    FIELDREF = 266,                /* FIELDREF  */
     LEXERROR = 267,                /* LEXERROR  */
     PARRAY = 268,                  /* PARRAY  */
     INT = 269,                     /* INT  */
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y
index 767b4456e6..c1776ba5b5 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -182,7 +182,7 @@ static void mVar(Common::String *s, VarType type) {
 %token UNARY
 
 // Datum types
-%token CASTREF VOID VAR POINT RECT ARRAY OBJECT REFERENCE LEXERROR PARRAY
+%token CASTREF VOID VAR POINT RECT ARRAY OBJECT FIELDREF LEXERROR PARRAY
 %token<i> INT ARGC ARGCNORET
 
 %token<e> THEENTITY THEENTITYWITHID THEMENUITEMENTITY THEMENUITEMSENTITY
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 28b1197c8d..e50612457e 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -840,7 +840,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 		sprite->setCast(d.asInt());
 		break;
 	case kTheConstraint:
-		if (d.type == REFERENCE) {
+		if (d.type == CASTREF) {
 			// Reference: Cast ID
 			// Find the first channel that uses this cast.
 			for (uint i = 0; i < score->_channels.size(); i++)
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 7243be6bb8..b05f755341 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -637,7 +637,7 @@ int Lingo::getAlignedType(Datum &d1, Datum &d2) {
 	int d1Type = d1.type;
 	int d2Type = d2.type;
 
-	if (d1Type == STRING) {
+	if (d1Type == STRING || d1Type == FIELDREF) {
 		Common::String src = d1.asString();
 		char *endPtr = 0;
 		strtod(src.c_str(), &endPtr);
@@ -645,7 +645,7 @@ int Lingo::getAlignedType(Datum &d1, Datum &d2) {
 			d1Type = FLOAT;
 		}
 	}
-	if (d2Type == STRING) {
+	if (d2Type == STRING || d2Type == FIELDREF) {
 		Common::String src = d1.asString();
 		char *endPtr = 0;
 		strtod(src.c_str(), &endPtr);
@@ -662,7 +662,7 @@ int Lingo::getAlignedType(Datum &d1, Datum &d2) {
 
 	if (d1Type == FLOAT || d2Type == FLOAT) {
 		opType = FLOAT;
-	} else if ((d1Type == INT || d1Type == REFERENCE) && (d2Type == INT || d2Type == REFERENCE)) {
+	} else if ((d1Type == INT || d1Type == CASTREF) && (d2Type == INT || d2Type == CASTREF)) {
 		opType = INT;
 	}
 
@@ -691,7 +691,8 @@ void Datum::reset() {
 		case OBJECT:
 			delete u.obj;
 			break;
-		case REFERENCE:
+		case CASTREF:
+		case FIELDREF:
 			// fallthrough
 		case INT:
 			// fallthrough
@@ -719,6 +720,7 @@ int Datum::asInt() {
 
 	switch (type) {
 	case STRING:
+	case FIELDREF:
 		{
 			Common::String src = asString();
 			char *endPtr = 0;
@@ -734,7 +736,7 @@ int Datum::asInt() {
 		// no-op
 		break;
 	case INT:
-	case REFERENCE:
+	case CASTREF:
 		res = u.i;
 		break;
 	case FLOAT:
@@ -752,6 +754,7 @@ double Datum::asFloat() {
 
 	switch (type) {
 	case STRING:
+	case FIELDREF:
 		{
 			Common::String src = asString();
 			char *endPtr = 0;
@@ -767,7 +770,7 @@ double Datum::asFloat() {
 		// no-op
 		break;
 	case INT:
-	case REFERENCE:
+	case CASTREF:
 		res = (double)u.i;
 		break;
 	case FLOAT:
@@ -824,7 +827,8 @@ Common::String Datum::asString(bool printonly) {
 	case VAR:
 		s = Common::String::format("var: #%s", u.s->c_str());
 		break;
-	case REFERENCE:
+	case CASTREF:
+	case FIELDREF:
 		{
 			int idx = u.i;
 			Cast *member = g_director->getCastMember(idx);
@@ -834,7 +838,7 @@ Common::String Datum::asString(bool printonly) {
 				break;
 			}
 
-			if (member->_type == kCastText) {
+			if (type == FIELDREF) {
 				if (!printonly) {
 					s = ((TextCast *)member)->getText();
 				} else {
@@ -905,8 +909,8 @@ const char *Datum::type2str(bool isk) {
 		return isk ? "#symbol" : "SYMBOL";
 	case OBJECT:
 		return isk ? "#object" : "OBJECT";
-	case REFERENCE:
-		return "REFERENCE";
+	case FIELDREF:
+		return "FIELDREF";
 	case VAR:
 		return isk ? "#var" : "VAR";
 	default:
@@ -1124,7 +1128,7 @@ void Lingo::varAssign(Datum &var, Datum &value, bool global, DatumHash *localvar
 		localvars = _localvars;
 	}
 
-	if (var.type != VAR && var.type != REFERENCE) {
+	if (var.type != VAR && var.type != FIELDREF) {
 		warning("varAssign: assignment to non-variable");
 		return;
 	}
@@ -1153,7 +1157,7 @@ void Lingo::varAssign(Datum &var, Datum &value, bool global, DatumHash *localvar
 		}
 
 		*d = value;
-	} else if (var.type == REFERENCE) {
+	} else if (var.type == FIELDREF) {
 		Score *score = g_director->getCurrentScore();
 		if (!score) {
 			warning("varAssign: Assigning to a reference to an empty score");
@@ -1183,7 +1187,7 @@ Datum Lingo::varFetch(Datum &var, bool global, DatumHash *localvars) {
 
 	Datum result;
 	result.type = VOID;
-	if (var.type != VAR && var.type != REFERENCE) {
+	if (var.type != VAR && var.type != FIELDREF) {
 		warning("varFetch: fetch from non-variable");
 		return result;
 	}
@@ -1218,7 +1222,7 @@ Datum Lingo::varFetch(Datum &var, bool global, DatumHash *localvars) {
 		}
 
 		return *d;
-	} else if (var.type == REFERENCE) {
+	} else if (var.type == FIELDREF) {
 		Cast *cast = _vm->getCastMember(var.u.i);
 		if (cast) {
 			switch (cast->_type) {




More information about the Scummvm-git-logs mailing list