aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2016-06-27 00:40:22 +0200
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commitb2a152dd54e86247a06fa91c5c0ff6f092acc943 (patch)
treee523fbc12e9d910bc0b81897088d1ef36d757dba /engines/director
parent9ba86b960c9e18c2ee021e6ef81e4ca6e71803b1 (diff)
downloadscummvm-rg350-b2a152dd54e86247a06fa91c5c0ff6f092acc943.tar.gz
scummvm-rg350-b2a152dd54e86247a06fa91c5c0ff6f092acc943.tar.bz2
scummvm-rg350-b2a152dd54e86247a06fa91c5c0ff6f092acc943.zip
DIRECTOR: Lingo: Fix handler calling
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/director.cpp8
-rw-r--r--engines/director/lingo/lingo-code.cpp17
-rw-r--r--engines/director/lingo/lingo-gr.cpp195
-rw-r--r--engines/director/lingo/lingo-gr.y6
-rw-r--r--engines/director/lingo/lingo.h2
5 files changed, 112 insertions, 116 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 3c82fd9e91..6d8e51ccb8 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -85,6 +85,7 @@ end if\n\
if x >1 then\n\
exit\n\
end if\n\
+put 100\n\
\n\
--\n\
macro ZIPX\n\
@@ -104,9 +105,14 @@ if par1 = 3 then\n\
else\n\
put 9\n\
end if\n\
-shipx\n\
", kMovieScript, 1);
+_lingo->addCode("shipx\n\
+put x\n\
+", kMovieScript, 2);
+
+_lingo->executeScript(kMovieScript, 2);
+
return Common::kNoError;
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 1423534512..8d047e466a 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -376,27 +376,27 @@ void Lingo::c_gotoprevious() {
warning("STUB: c_gotoprevious()");
}
-void Lingo::define(Common::String &name, int start, int end, int nargs) {
- warning("STUB: define(\"%s\", %d, %d, %d)", name.c_str(), start, end, nargs);
+void Lingo::define(Common::String &name, int start, int nargs) {
+ debug(3, "define(\"%s\", %d, %d, %d)", name.c_str(), start, _currentScript->size() - 1, nargs);
Symbol *sym;
if (!_handlers.contains(name)) { // Create variable if it was not defined
sym = new Symbol;
- warning("Redefining handler '%s'", name.c_str());
- delete sym->u.defn;
+ sym->name = (char *)calloc(name.size() + 1, 1);
+ Common::strlcpy(sym->name, name.c_str(), name.size() + 1);
+ sym->type = HANDLER;
_handlers[name] = sym;
} else {
sym = g_lingo->_handlers[name];
- sym->name = (char *)calloc(name.size() + 1, 1);
- Common::strlcpy(sym->name, name.c_str(), name.size() + 1);
- sym->type = HANDLER;
+ warning("Redefining handler '%s'", name.c_str());
+ delete sym->u.defn;
}
- sym->u.defn = new ScriptData(&(*_currentScript)[start], end - start + 1);
+ sym->u.defn = new ScriptData(&(*_currentScript)[start], _currentScript->size() - start + 1);
sym->nargs = nargs;
}
@@ -427,7 +427,6 @@ int Lingo::codeId_(Common::String &name) {
return ret;
}
-
void Lingo::c_call() {
Common::String name((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]);
g_lingo->_pc += g_lingo->calcStringAlignment(name.c_str());
diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp
index ec98d25c1d..3968b5607a 100644
--- a/engines/director/lingo/lingo-gr.cpp
+++ b/engines/director/lingo/lingo-gr.cpp
@@ -420,7 +420,7 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 51
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 315
+#define YYLAST 298
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 51
@@ -429,7 +429,7 @@ union yyalloc
/* YYNRULES -- Number of rules. */
#define YYNRULES 76
/* YYNRULES -- Number of states. */
-#define YYNSTATES 156
+#define YYNSTATES 155
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
@@ -485,7 +485,7 @@ static const yytype_uint16 yyprhs[] =
144, 148, 152, 156, 160, 164, 168, 171, 174, 178,
184, 187, 190, 193, 195, 197, 200, 203, 206, 209,
213, 216, 220, 223, 226, 228, 232, 235, 239, 240,
- 248, 249, 251, 255, 260, 261, 263
+ 247, 248, 250, 254, 259, 260, 262
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
@@ -515,9 +515,9 @@ static const yytype_int8 yyrhs[] =
66, 67, -1, 15, 67, -1, 30, 14, 8, -1,
14, 8, -1, 30, 8, -1, 8, -1, 24, 22,
8, -1, 22, 8, -1, 30, 22, 8, -1, -1,
- 19, 7, 69, 60, 70, 62, 61, -1, -1, 7,
- -1, 70, 50, 7, -1, 70, 50, 45, 7, -1,
- -1, 63, -1, 71, 50, 63, -1
+ 19, 7, 69, 60, 70, 62, -1, -1, 7, -1,
+ 70, 50, 7, -1, 70, 50, 45, 7, -1, -1,
+ 63, -1, 71, 50, 63, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
@@ -588,7 +588,7 @@ static const yytype_uint8 yyr2[] =
0, 0, 2, 2, 1, 1, 1, 3, 3, 3,
3, 3, 3, 3, 3, 3, 2, 2, 3, 5,
2, 2, 2, 1, 1, 2, 2, 2, 2, 3,
- 2, 3, 2, 2, 1, 3, 2, 3, 0, 7,
+ 2, 3, 2, 2, 1, 3, 2, 3, 0, 6,
0, 1, 3, 4, 0, 1, 3
};
@@ -609,10 +609,10 @@ static const yytype_uint8 yydefact[] =
0, 44, 45, 43, 37, 38, 39, 40, 41, 42,
75, 0, 65, 61, 67, 70, 13, 15, 14, 31,
0, 25, 30, 24, 49, 0, 71, 31, 30, 0,
- 0, 32, 33, 0, 16, 17, 76, 0, 30, 0,
- 0, 30, 31, 0, 72, 0, 69, 0, 30, 31,
- 30, 18, 73, 20, 31, 30, 0, 30, 0, 0,
- 0, 0, 19, 0, 21, 22
+ 0, 32, 33, 0, 16, 17, 76, 0, 69, 0,
+ 0, 30, 31, 0, 72, 0, 0, 30, 31, 30,
+ 18, 73, 20, 31, 30, 0, 30, 0, 0, 0,
+ 0, 19, 0, 21, 22
};
/* YYDEFGOTO[NTERM-NUM]. */
@@ -625,33 +625,33 @@ static const yytype_int8 yydefgoto[] =
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -43
+#define YYPACT_NINF -98
static const yytype_int16 yypact[] =
{
- 72, -43, -43, -42, -43, 213, -43, 9, 13, 18,
- -2, 15, 22, -2, -2, -2, 32, 121, 254, -43,
- -12, 12, 118, 242, -43, -43, -43, 4, -43, 49,
- -43, 61, -43, 48, -43, 23, 11, -43, -43, -43,
- -43, -43, -2, -43, 177, 67, -43, -19, 142, 142,
- 218, -43, 72, -43, 118, -2, 118, 46, 230, -2,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -43,
- -43, 68, -43, 70, 75, 58, -43, -43, 177, 77,
- -43, -2, -2, -43, -43, 39, 242, 42, 206, -43,
- -2, 242, 242, 242, 266, 266, 142, 142, 242, 242,
- 242, -38, -43, -43, -43, 87, -43, 242, 242, -43,
- -3, -43, 158, 242, -43, -2, -43, 45, 158, 66,
- -2, -43, -43, 37, 242, -43, 242, -5, 158, 85,
- -2, 242, -43, 86, -43, 94, -43, 76, 242, -43,
- 158, -43, -43, -43, -43, 158, 92, 158, 93, 90,
- 95, 82, -43, 83, -43, -43
+ 72, -98, -98, -25, -98, 208, -98, 38, -4, 43,
+ -2, 74, 67, -2, -2, -2, 34, 121, 159, -98,
+ 32, 41, 118, 237, -98, -98, -98, 40, -98, 76,
+ -98, 86, -98, 79, -98, 61, 27, -98, -98, -98,
+ -98, -98, -2, -98, 172, 89, -98, -14, -1, -1,
+ 213, -98, 72, -98, 118, -2, 118, 78, 225, -2,
+ -2, -2, -2, -2, -2, -2, -2, -2, -2, -98,
+ -98, 95, -98, 100, 101, 88, -98, -98, 172, 104,
+ -98, -2, -2, -98, -98, 69, 237, 77, 201, -98,
+ -2, 237, 237, 237, 249, 249, -1, -1, 237, 237,
+ 237, -19, -98, -98, -98, 107, -98, 237, 237, -98,
+ -3, -98, 158, 237, -98, -2, -98, 81, 158, 97,
+ -2, -98, -98, 18, 237, -98, 237, -5, 158, 117,
+ -2, 237, -98, 103, -98, 125, 106, 237, -98, 158,
+ -98, -98, -98, -98, 158, 123, 158, 126, 127, 133,
+ 112, -98, 124, -98, -98
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -43, -9, -43, 1, 6, -26, -43, -43, -43, 34,
- 69, -1, 0, 19, -43, -43, 78, -43, -43, -43,
- -43
+ -98, -9, -98, 1, 6, -45, -98, -98, -98, 73,
+ -42, -97, 0, 19, -98, -98, 116, -98, -98, -98,
+ -98
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@@ -661,74 +661,70 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -37
static const yytype_int16 yytable[] =
{
- 23, 18, 134, 2, -29, 41, 19, 119, 53, 114,
- 44, 81, 115, 48, 49, 50, 38, 23, 18, 24,
- 82, 39, 58, 19, 42, 40, 12, 120, 85, 47,
- 87, 72, 51, 31, 54, 33, 24, 73, 13, 14,
- 135, 75, 78, 84, 15, 74, 45, 46, 132, 133,
- 68, 55, 23, 18, 58, 86, 88, 69, 19, 91,
- 92, 93, 94, 95, 96, 97, 98, 99, 100, 70,
- 71, 24, -5, 1, 80, 89, 102, 2, 103, 3,
- 74, 107, 108, 104, 106, 4, 109, 5, 6, 111,
- 113, 7, 8, 9, 116, 127, 130, 137, 10, 11,
- 12, 142, 141, 143, 149, 151, 152, 153, 118, 154,
- 155, 105, 13, 14, 76, 126, 128, -5, 15, 0,
- 131, -4, 1, 2, 0, 41, 2, 0, 3, 0,
- 138, 140, 0, 0, 4, 0, 5, 6, 145, 0,
- 7, 8, 9, 147, 42, 0, 12, 10, 11, 12,
- 0, 0, 0, 0, 0, 0, 0, 0, 13, 14,
+ 23, 18, 134, 2, 39, 41, 19, 119, 53, 85,
+ 44, 87, 118, 48, 49, 50, 81, 23, 18, 24,
+ 128, -29, 58, 19, 42, 82, 12, 120, 114, 132,
+ 133, 115, 59, 60, 51, 139, 24, 61, 13, 14,
+ 135, 144, 78, 84, 15, 38, 146, 66, 67, 31,
+ 40, 33, 23, 18, 58, 86, 88, 75, 19, 91,
+ 92, 93, 94, 95, 96, 97, 98, 99, 100, 72,
+ 123, 24, -5, 1, 47, 73, 129, 2, 54, 3,
+ 55, 107, 108, 74, 69, 4, 68, 5, 6, 138,
+ 113, 7, 8, 9, 70, 143, 80, 145, 10, 11,
+ 12, 71, 147, 102, 149, 45, 46, 89, 103, 104,
+ 74, 106, 13, 14, 116, 126, 109, -5, 15, 140,
+ 131, -4, 1, 2, 111, 41, 2, 130, 3, 136,
+ 137, 127, 141, 142, 4, 148, 5, 6, 150, 153,
+ 7, 8, 9, 151, 42, 152, 12, 10, 11, 12,
+ 105, 154, 76, 0, 0, 0, 0, 0, 13, 14,
0, 13, 14, 2, 56, 3, 52, 15, 0, 0,
- 0, 4, 0, 5, 6, 59, 60, 0, 8, 9,
- 61, 123, 0, 0, 10, 11, 12, 129, 0, 0,
- 66, 67, 0, 0, 79, 0, 0, 136, 13, 14,
- 139, 0, 0, 121, 15, 0, 0, 144, 0, 146,
- 59, 60, 0, 0, 148, 61, 150, 62, 63, 64,
- 65, 28, 0, 0, 0, 66, 67, 29, 0, 0,
- 0, 30, 0, 0, 0, 31, 32, 33, 34, 59,
- 60, 0, 0, 35, 61, 90, 62, 63, 64, 65,
- 0, 59, 60, 83, 66, 67, 61, 0, 62, 63,
- 64, 65, 0, 59, 60, 83, 66, 67, 61, 90,
- 62, 63, 64, 65, 0, 59, 60, 0, 66, 67,
- 61, 0, 62, 63, 64, 65, 0, -36, -36, 0,
- 66, 67, -36, 0, 0, 0, -36, -36, 0, 59,
- 60, 0, -36, -36, 61, 0, 0, 0, 64, 65,
- 0, 0, 0, 0, 66, 67
+ 0, 4, 0, 5, 6, 0, 0, 0, 8, 9,
+ 0, 0, 0, 0, 10, 11, 12, 0, 0, 79,
+ 0, 0, -36, -36, 0, 0, 0, -36, 13, 14,
+ 0, -36, -36, 121, 15, 59, 60, -36, -36, 0,
+ 61, 0, 62, 63, 64, 65, 28, 0, 0, 0,
+ 66, 67, 29, 0, 0, 0, 30, 0, 0, 0,
+ 31, 32, 33, 34, 59, 60, 0, 0, 35, 61,
+ 90, 62, 63, 64, 65, 0, 59, 60, 83, 66,
+ 67, 61, 0, 62, 63, 64, 65, 0, 59, 60,
+ 83, 66, 67, 61, 90, 62, 63, 64, 65, 0,
+ 59, 60, 0, 66, 67, 61, 0, 62, 63, 64,
+ 65, 0, 59, 60, 0, 66, 67, 61, 0, 0,
+ 0, 64, 65, 0, 0, 0, 0, 66, 67
};
static const yytype_int16 yycheck[] =
{
- 0, 0, 7, 5, 46, 7, 0, 10, 17, 47,
- 10, 30, 50, 13, 14, 15, 7, 17, 17, 0,
- 39, 8, 22, 17, 26, 7, 28, 30, 54, 7,
- 56, 8, 0, 22, 46, 24, 17, 14, 40, 41,
- 45, 30, 42, 52, 46, 22, 31, 32, 11, 12,
- 46, 39, 52, 52, 54, 55, 56, 8, 52, 59,
+ 0, 0, 7, 5, 8, 7, 0, 10, 17, 54,
+ 10, 56, 109, 13, 14, 15, 30, 17, 17, 0,
+ 117, 46, 22, 17, 26, 39, 28, 30, 47, 11,
+ 12, 50, 33, 34, 0, 132, 17, 38, 40, 41,
+ 45, 138, 42, 52, 46, 7, 143, 48, 49, 22,
+ 7, 24, 52, 52, 54, 55, 56, 30, 52, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 8,
- 22, 52, 0, 1, 7, 29, 8, 5, 8, 7,
- 22, 81, 82, 8, 7, 13, 47, 15, 16, 47,
- 90, 19, 20, 21, 7, 50, 30, 12, 26, 27,
- 28, 7, 16, 27, 12, 12, 16, 12, 109, 27,
- 27, 77, 40, 41, 36, 115, 117, 45, 46, -1,
- 120, 0, 1, 5, -1, 7, 5, -1, 7, -1,
- 130, 132, -1, -1, 13, -1, 15, 16, 139, -1,
- 19, 20, 21, 144, 26, -1, 28, 26, 27, 28,
- -1, -1, -1, -1, -1, -1, -1, -1, 40, 41,
+ 112, 52, 0, 1, 7, 14, 118, 5, 46, 7,
+ 39, 81, 82, 22, 8, 13, 46, 15, 16, 131,
+ 90, 19, 20, 21, 8, 137, 7, 139, 26, 27,
+ 28, 22, 144, 8, 146, 31, 32, 29, 8, 8,
+ 22, 7, 40, 41, 7, 115, 47, 45, 46, 16,
+ 120, 0, 1, 5, 47, 7, 5, 30, 7, 12,
+ 130, 50, 7, 27, 13, 12, 15, 16, 12, 27,
+ 19, 20, 21, 16, 26, 12, 28, 26, 27, 28,
+ 77, 27, 36, -1, -1, -1, -1, -1, 40, 41,
-1, 40, 41, 5, 46, 7, 45, 46, -1, -1,
- -1, 13, -1, 15, 16, 33, 34, -1, 20, 21,
- 38, 112, -1, -1, 26, 27, 28, 118, -1, -1,
- 48, 49, -1, -1, 17, -1, -1, 128, 40, 41,
- 131, -1, -1, 45, 46, -1, -1, 138, -1, 140,
- 33, 34, -1, -1, 145, 38, 147, 40, 41, 42,
- 43, 8, -1, -1, -1, 48, 49, 14, -1, -1,
- -1, 18, -1, -1, -1, 22, 23, 24, 25, 33,
- 34, -1, -1, 30, 38, 39, 40, 41, 42, 43,
- -1, 33, 34, 47, 48, 49, 38, -1, 40, 41,
- 42, 43, -1, 33, 34, 47, 48, 49, 38, 39,
- 40, 41, 42, 43, -1, 33, 34, -1, 48, 49,
- 38, -1, 40, 41, 42, 43, -1, 33, 34, -1,
- 48, 49, 38, -1, -1, -1, 42, 43, -1, 33,
- 34, -1, 48, 49, 38, -1, -1, -1, 42, 43,
- -1, -1, -1, -1, 48, 49
+ -1, 13, -1, 15, 16, -1, -1, -1, 20, 21,
+ -1, -1, -1, -1, 26, 27, 28, -1, -1, 17,
+ -1, -1, 33, 34, -1, -1, -1, 38, 40, 41,
+ -1, 42, 43, 45, 46, 33, 34, 48, 49, -1,
+ 38, -1, 40, 41, 42, 43, 8, -1, -1, -1,
+ 48, 49, 14, -1, -1, -1, 18, -1, -1, -1,
+ 22, 23, 24, 25, 33, 34, -1, -1, 30, 38,
+ 39, 40, 41, 42, 43, -1, 33, 34, 47, 48,
+ 49, 38, -1, 40, 41, 42, 43, -1, 33, 34,
+ 47, 48, 49, 38, 39, 40, 41, 42, 43, -1,
+ 33, 34, -1, 48, 49, 38, -1, 40, 41, 42,
+ 43, -1, 33, 34, -1, 48, 49, 38, -1, -1,
+ -1, 42, 43, -1, -1, -1, -1, 48, 49
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -748,9 +744,9 @@ static const yytype_uint8 yystos[] =
63, 71, 8, 8, 8, 60, 7, 63, 63, 47,
61, 47, 62, 63, 47, 50, 7, 70, 62, 10,
30, 45, 55, 61, 63, 64, 63, 50, 62, 61,
- 30, 63, 11, 12, 7, 45, 61, 12, 63, 61,
- 62, 16, 7, 27, 61, 62, 61, 62, 61, 12,
- 61, 12, 16, 12, 27, 27
+ 30, 63, 11, 12, 7, 45, 12, 63, 61, 62,
+ 16, 7, 27, 61, 62, 61, 62, 61, 12, 61,
+ 12, 16, 12, 27, 27
};
#define yyerrok (yyerrstatus = 0)
@@ -1569,11 +1565,6 @@ yyreduce:
{ g_lingo->code1(g_lingo->c_xpop); ;}
break;
- case 10:
-#line 102 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->c_printtop); ;}
- break;
-
case 11:
#line 103 "engines/director/lingo/lingo-gr.y"
{ yyerrok; ;}
@@ -1915,7 +1906,7 @@ yyreduce:
#line 313 "engines/director/lingo/lingo-gr.y"
{
g_lingo->code1(g_lingo->c_procret);
- g_lingo->define(*(yyvsp[(2) - (7)].s), (yyvsp[(4) - (7)].code), (yyvsp[(7) - (7)].code), (yyvsp[(5) - (7)].narg));
+ g_lingo->define(*(yyvsp[(2) - (6)].s), (yyvsp[(4) - (6)].code), (yyvsp[(5) - (6)].narg));
g_lingo->_indef = false; ;}
break;
@@ -1956,7 +1947,7 @@ yyreduce:
/* Line 1267 of yacc.c. */
-#line 1960 "engines/director/lingo/lingo-gr.cpp"
+#line 1951 "engines/director/lingo/lingo-gr.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y
index cd3fc7a200..c87b17e380 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -99,7 +99,7 @@ programline:
| func
| asgn { g_lingo->code1(g_lingo->c_xpop); }
| stmt
- | expr { g_lingo->code1(g_lingo->c_printtop); }
+ | expr
| error { yyerrok; }
| /* empty */
;
@@ -310,9 +310,9 @@ gotomovie: tOF tMOVIE STRING { $$ = $3; }
// See also:
// on keyword
defn: tMACRO ID { g_lingo->_indef = true; }
- begin argdef stmtlist end {
+ begin argdef stmtlist {
g_lingo->code1(g_lingo->c_procret);
- g_lingo->define(*$2, $4, $7, $5);
+ g_lingo->define(*$2, $4, $5);
g_lingo->_indef = false; }
;
argdef: /* nothing */ { $$ = 0; }
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index b270860380..67c56fa0bc 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -129,7 +129,7 @@ public:
public:
void execute(int pc);
Symbol *lookupVar(const char *name);
- void define(Common::String &s, int start, int end, int nargs);
+ void define(Common::String &s, int start, int nargs);
void codeArg(Common::String &s);
int codeId(Common::String &s);
int codeId_(Common::String &s);