diff options
author | Eugene Sandulenko | 2016-06-28 11:00:57 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | ad9e955b1e1645aae2561a2b5263ae69d4d367a3 (patch) | |
tree | 8a745ccd0d39cea5d13f09d107a2c0c52511f145 /engines/director/lingo | |
parent | 3e0bf3a03c1b0e88620e483e2390e23015ff9afd (diff) | |
download | scummvm-rg350-ad9e955b1e1645aae2561a2b5263ae69d4d367a3.tar.gz scummvm-rg350-ad9e955b1e1645aae2561a2b5263ae69d4d367a3.tar.bz2 scummvm-rg350-ad9e955b1e1645aae2561a2b5263ae69d4d367a3.zip |
DIRECTOR: Lingo: Add type to stack
Diffstat (limited to 'engines/director/lingo')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 84 | ||||
-rw-r--r-- | engines/director/lingo/lingo-codegen.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.cpp | 404 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.h | 140 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 16 |
6 files changed, 345 insertions, 303 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 065848d23b..4407bb8829 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -72,13 +72,36 @@ void Lingo::c_xpop() { void Lingo::c_printtop(void) { Datum d = g_lingo->pop(); - warning("%d", d.val); + switch (d.type) { + case VOID: + warning("Void"); + break; + case INT: + warning("%d", d.u.i); + break; + case FLOAT: + warning("%f", d.u.f); + break; + case VAR: + if (!d.u.sym) { + warning("Inconsistent stack: var, val: %d", d.u.i); + } else { + if (d.u.sym->name) + warning("var: %s", d.u.sym->name); + else + warning("Nameless var. val: %d", d.u.sym->u.val); + } + break; + default: + warning("--unknown--"); + } } void Lingo::c_constpush() { Datum d; inst i = (*g_lingo->_currentScript)[g_lingo->_pc++]; - d.val = READ_UINT32(&i); + d.u.i = READ_UINT32(&i); + d.type = INT; g_lingo->push(d); } @@ -86,7 +109,8 @@ void Lingo::c_varpush() { char *name = (char *)&(*g_lingo->_currentScript)[g_lingo->_pc]; Datum d; - d.sym = g_lingo->lookupVar(name); + d.u.sym = g_lingo->lookupVar(name); + d.type = VAR; g_lingo->_pc += g_lingo->calcStringAlignment(name); @@ -98,13 +122,19 @@ void Lingo::c_assign() { d1 = g_lingo->pop(); d2 = g_lingo->pop(); - if (d1.sym->type != INT && d1.sym->type != VOID) { - warning("assignment to non-variable '%s'", d1.sym->name); + if (d1.type != VAR) { + warning("assignment to non-variable"); return; } - d1.sym->u.val = d2.val; - d1.sym->type = INT; + if (d1.u.sym->type != INT && d1.u.sym->type != VOID) { + warning("assignment to non-variable '%s'", d1.u.sym->name); + return; + } + + d1.u.sym->u.val = d2.u.i; + d1.u.sym->type = d2.type; + g_lingo->push(d2); } @@ -128,10 +158,11 @@ void Lingo::c_eval() { Datum d; d = g_lingo->pop(); - if (!g_lingo->verify(d.sym)) + if (!g_lingo->verify(d.u.sym)) return; - d.val = d.sym->u.val; + d.type = d.u.sym->type; + d.u.i = d.u.sym->u.val; g_lingo->push(d); } @@ -140,7 +171,7 @@ void Lingo::c_add() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val += d2.val; + d1.u.i += d2.u.i; g_lingo->push(d1); } @@ -148,7 +179,7 @@ void Lingo::c_sub() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val -= d2.val; + d1.u.i -= d2.u.i; g_lingo->push(d1); } @@ -156,26 +187,26 @@ void Lingo::c_mul() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val *= d2.val; + d1.u.i *= d2.u.i; g_lingo->push(d1); } void Lingo::c_div() { Datum d2 = g_lingo->pop(); - if (d2.val == 0) + if (d2.u.i == 0) error("division by zero"); Datum d1 = g_lingo->pop(); - d1.val /= d2.val; + d1.u.i /= d2.u.i; g_lingo->push(d1); } void Lingo::c_negate() { Datum d = g_lingo->pop(); - d.val -= d.val; + d.u.i -= d.u.i; g_lingo->push(d); } @@ -183,7 +214,7 @@ void Lingo::c_eq() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val = (d1.val == d2.val) ? 1 : 0; + d1.u.i = (d1.u.i == d2.u.i) ? 1 : 0; g_lingo->push(d1); } @@ -191,7 +222,7 @@ void Lingo::c_neq() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val = (d1.val != d2.val) ? 1 : 0; + d1.u.i = (d1.u.i != d2.u.i) ? 1 : 0; g_lingo->push(d1); } @@ -199,7 +230,7 @@ void Lingo::c_gt() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val = (d1.val > d2.val) ? 1 : 0; + d1.u.i = (d1.u.i > d2.u.i) ? 1 : 0; g_lingo->push(d1); } @@ -207,7 +238,7 @@ void Lingo::c_lt() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val = (d1.val < d2.val) ? 1 : 0; + d1.u.i = (d1.u.i < d2.u.i) ? 1 : 0; g_lingo->push(d1); } @@ -215,7 +246,7 @@ void Lingo::c_ge() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val = (d1.val >= d2.val) ? 1 : 0; + d1.u.i = (d1.u.i >= d2.u.i) ? 1 : 0; g_lingo->push(d1); } @@ -223,7 +254,7 @@ void Lingo::c_le() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - d1.val = (d1.val <= d2.val) ? 1 : 0; + d1.u.i = (d1.u.i <= d2.u.i) ? 1 : 0; g_lingo->push(d1); } @@ -237,7 +268,7 @@ void Lingo::c_repeatwhilecode(void) { g_lingo->execute(savepc + 2); /* condition */ d = g_lingo->pop(); - while (d.val) { + while (d.u.i) { g_lingo->execute(body); /* body */ if (g_lingo->_returning) break; @@ -264,7 +295,7 @@ void Lingo::c_repeatwithcode(void) { g_lingo->execute(init); /* condition */ d = g_lingo->pop(); - counter->u.val = d.val; + counter->u.val = d.u.i; counter->type = INT; while (true) { @@ -276,7 +307,7 @@ void Lingo::c_repeatwithcode(void) { g_lingo->execute(finish); /* condition */ d = g_lingo->pop(); - if (counter->u.val == d.val + inc) + if (counter->u.val == d.u.i + inc) break; } @@ -296,7 +327,7 @@ void Lingo::c_ifcode() { d = g_lingo->pop(); - if (d.val) { + if (d.u.i) { g_lingo->execute(then); } else if (elsep) { /* else part? */ g_lingo->execute(elsep); @@ -366,7 +397,8 @@ void Lingo::c_call() { for (int i = nargs; i < sym->nargs; i++) { Datum d; - d.val = 0; // TODO, FIXME: Must be VOID + d.u.i = 0; + d.type = VOID; g_lingo->push(d); } diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 945da38b77..ca8374a76f 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -55,7 +55,7 @@ void Lingo::execute(int pc) { for(_pc = pc; (*_currentScript)[_pc] != STOP && !_returning;) { for (int i = 0; i < _stack.size(); i++) { - debugN(5, "%d ", _stack[i].val); + debugN(5, "%d ", _stack[i].u.i); } debug(5, ""); diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 996f7cc21a..ac54174bdf 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -68,79 +68,81 @@ enum yytokentype { UNARY = 258, VOID = 259, - INT = 260, - FLOAT = 261, - ID = 262, - STRING = 263, - HANDLER = 264, - tDOWN = 265, - tELSE = 266, - tEND = 267, - tEXIT = 268, - tFRAME = 269, - tGO = 270, - tIF = 271, - tINTO = 272, - tLOOP = 273, - tMACRO = 274, - tMCI = 275, - tMCIWAIT = 276, - tMOVIE = 277, - tNEXT = 278, - tOF = 279, - tPREVIOUS = 280, - tPUT = 281, - tREPEAT = 282, - tSET = 283, - tTHEN = 284, - tTO = 285, - tWITH = 286, - tWHILE = 287, - tGE = 288, - tLE = 289, - tGT = 290, - tLT = 291, - tEQ = 292, - tNEQ = 293 + VAR = 260, + INT = 261, + FLOAT = 262, + ID = 263, + STRING = 264, + HANDLER = 265, + tDOWN = 266, + tELSE = 267, + tEND = 268, + tEXIT = 269, + tFRAME = 270, + tGO = 271, + tIF = 272, + tINTO = 273, + tLOOP = 274, + tMACRO = 275, + tMCI = 276, + tMCIWAIT = 277, + tMOVIE = 278, + tNEXT = 279, + tOF = 280, + tPREVIOUS = 281, + tPUT = 282, + tREPEAT = 283, + tSET = 284, + tTHEN = 285, + tTO = 286, + tWITH = 287, + tWHILE = 288, + tGE = 289, + tLE = 290, + tGT = 291, + tLT = 292, + tEQ = 293, + tNEQ = 294 }; #endif /* Tokens. */ #define UNARY 258 #define VOID 259 -#define INT 260 -#define FLOAT 261 -#define ID 262 -#define STRING 263 -#define HANDLER 264 -#define tDOWN 265 -#define tELSE 266 -#define tEND 267 -#define tEXIT 268 -#define tFRAME 269 -#define tGO 270 -#define tIF 271 -#define tINTO 272 -#define tLOOP 273 -#define tMACRO 274 -#define tMCI 275 -#define tMCIWAIT 276 -#define tMOVIE 277 -#define tNEXT 278 -#define tOF 279 -#define tPREVIOUS 280 -#define tPUT 281 -#define tREPEAT 282 -#define tSET 283 -#define tTHEN 284 -#define tTO 285 -#define tWITH 286 -#define tWHILE 287 -#define tGE 288 -#define tLE 289 -#define tGT 290 -#define tLT 291 -#define tEQ 292 -#define tNEQ 293 +#define VAR 260 +#define INT 261 +#define FLOAT 262 +#define ID 263 +#define STRING 264 +#define HANDLER 265 +#define tDOWN 266 +#define tELSE 267 +#define tEND 268 +#define tEXIT 269 +#define tFRAME 270 +#define tGO 271 +#define tIF 272 +#define tINTO 273 +#define tLOOP 274 +#define tMACRO 275 +#define tMCI 276 +#define tMCIWAIT 277 +#define tMOVIE 278 +#define tNEXT 279 +#define tOF 280 +#define tPREVIOUS 281 +#define tPUT 282 +#define tREPEAT 283 +#define tSET 284 +#define tTHEN 285 +#define tTO 286 +#define tWITH 287 +#define tWHILE 288 +#define tGE 289 +#define tLE 290 +#define tGT 291 +#define tLT 292 +#define tEQ 293 +#define tNEQ 294 @@ -192,7 +194,7 @@ typedef union YYSTYPE int narg; /* number of arguments */ } /* Line 193 of yacc.c. */ -#line 196 "engines/director/lingo/lingo-gr.cpp" +#line 198 "engines/director/lingo/lingo-gr.cpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -205,7 +207,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 209 "engines/director/lingo/lingo-gr.cpp" +#line 211 "engines/director/lingo/lingo-gr.cpp" #ifdef short # undef short @@ -423,7 +425,7 @@ union yyalloc #define YYLAST 264 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 51 +#define YYNTOKENS 52 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 22 /* YYNRULES -- Number of rules. */ @@ -433,7 +435,7 @@ union yyalloc /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 293 +#define YYMAXUTOK 294 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -442,12 +444,12 @@ union yyalloc static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 45, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 46, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 44, 2, 2, - 46, 47, 42, 40, 50, 41, 2, 43, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 45, 2, 2, + 47, 48, 43, 41, 51, 42, 2, 44, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 49, 39, 48, 2, 2, 2, 2, 2, 2, 2, + 50, 40, 49, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -470,7 +472,7 @@ static const yytype_uint8 yytranslate[] = 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38 + 35, 36, 37, 38, 39 }; #if YYDEBUG @@ -491,33 +493,33 @@ static const yytype_uint16 yyprhs[] = /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 52, 0, -1, 53, 45, 52, -1, 53, -1, -1, - 69, -1, 64, -1, 65, -1, 54, -1, 55, -1, - 1, -1, -1, 26, 63, 17, 7, -1, 28, 7, - 39, 63, -1, 28, 7, 30, 63, -1, 63, -1, - 64, -1, 59, 56, 29, 62, 61, 12, 16, -1, - 59, 56, 29, 62, 61, 11, 62, 61, 12, 16, - -1, 57, 46, 56, 47, 62, 61, 12, 27, -1, - 58, 39, 63, 61, 30, 63, 61, 62, 61, 12, - 27, -1, 58, 39, 63, 61, 10, 30, 63, 61, - 62, 61, 12, 27, -1, 63, -1, 63, 39, 63, - -1, 46, 56, 47, -1, 27, 32, -1, 27, 31, - 7, -1, 16, -1, -1, -1, -1, 62, 45, -1, - 62, 55, -1, 5, -1, 7, -1, 54, -1, 63, - 40, 63, -1, 63, 41, 63, -1, 63, 42, 63, - -1, 63, 43, 63, -1, 63, 48, 63, -1, 63, - 49, 63, -1, 63, 38, 63, -1, 63, 33, 63, - -1, 63, 34, 63, -1, 40, 63, -1, 41, 63, - -1, 46, 63, 47, -1, 7, 46, 72, 47, -1, - 20, 8, -1, 21, 7, -1, 26, 63, -1, 66, - -1, 13, -1, 7, 60, 72, -1, 7, -1, 15, - 18, -1, 15, 23, -1, 15, 25, -1, 15, 67, - -1, 15, 67, 68, -1, 15, 68, -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, 70, 60, 71, 45, 62, -1, - -1, 7, -1, 71, 50, 7, -1, 71, 45, 50, - 7, -1, -1, 63, -1, 72, 50, 63, -1 + 53, 0, -1, 54, 46, 53, -1, 54, -1, -1, + 70, -1, 65, -1, 66, -1, 55, -1, 56, -1, + 1, -1, -1, 27, 64, 18, 8, -1, 29, 8, + 40, 64, -1, 29, 8, 31, 64, -1, 64, -1, + 65, -1, 60, 57, 30, 63, 62, 13, 17, -1, + 60, 57, 30, 63, 62, 12, 63, 62, 13, 17, + -1, 58, 47, 57, 48, 63, 62, 13, 28, -1, + 59, 40, 64, 62, 31, 64, 62, 63, 62, 13, + 28, -1, 59, 40, 64, 62, 11, 31, 64, 62, + 63, 62, 13, 28, -1, 64, -1, 64, 40, 64, + -1, 47, 57, 48, -1, 28, 33, -1, 28, 32, + 8, -1, 17, -1, -1, -1, -1, 63, 46, -1, + 63, 56, -1, 6, -1, 8, -1, 55, -1, 64, + 41, 64, -1, 64, 42, 64, -1, 64, 43, 64, + -1, 64, 44, 64, -1, 64, 49, 64, -1, 64, + 50, 64, -1, 64, 39, 64, -1, 64, 34, 64, + -1, 64, 35, 64, -1, 41, 64, -1, 42, 64, + -1, 47, 64, 48, -1, 8, 47, 73, 48, -1, + 21, 9, -1, 22, 8, -1, 27, 64, -1, 67, + -1, 14, -1, 8, 61, 73, -1, 8, -1, 16, + 19, -1, 16, 24, -1, 16, 26, -1, 16, 68, + -1, 16, 68, 69, -1, 16, 69, -1, 31, 15, + 9, -1, 15, 9, -1, 31, 9, -1, 9, -1, + 25, 23, 9, -1, 23, 9, -1, 31, 23, 9, + -1, -1, 20, 8, 71, 61, 72, 46, 63, -1, + -1, 8, -1, 72, 51, 8, -1, 72, 46, 51, + 8, -1, -1, 64, -1, 73, 51, 64, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -539,13 +541,13 @@ static const yytype_uint16 yyrline[] = First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "UNARY", "VOID", "INT", "FLOAT", "ID", - "STRING", "HANDLER", "tDOWN", "tELSE", "tEND", "tEXIT", "tFRAME", "tGO", - "tIF", "tINTO", "tLOOP", "tMACRO", "tMCI", "tMCIWAIT", "tMOVIE", "tNEXT", - "tOF", "tPREVIOUS", "tPUT", "tREPEAT", "tSET", "tTHEN", "tTO", "tWITH", - "tWHILE", "tGE", "tLE", "tGT", "tLT", "tEQ", "tNEQ", "'='", "'+'", "'-'", - "'*'", "'/'", "'%'", "'\\n'", "'('", "')'", "'>'", "'<'", "','", - "$accept", "program", "programline", "asgn", "stmt", "cond", + "$end", "error", "$undefined", "UNARY", "VOID", "VAR", "INT", "FLOAT", + "ID", "STRING", "HANDLER", "tDOWN", "tELSE", "tEND", "tEXIT", "tFRAME", + "tGO", "tIF", "tINTO", "tLOOP", "tMACRO", "tMCI", "tMCIWAIT", "tMOVIE", + "tNEXT", "tOF", "tPREVIOUS", "tPUT", "tREPEAT", "tSET", "tTHEN", "tTO", + "tWITH", "tWHILE", "tGE", "tLE", "tGT", "tLT", "tEQ", "tNEQ", "'='", + "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('", "')'", "'>'", "'<'", + "','", "$accept", "program", "programline", "asgn", "stmt", "cond", "repeatwhile", "repeatwith", "if", "begin", "end", "stmtlist", "expr", "func", "macro", "gotofunc", "gotoframe", "gotomovie", "defn", "@1", "argdef", "arglist", 0 @@ -560,23 +562,23 @@ static const yytype_uint16 yytoknum[] = 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 61, - 43, 45, 42, 47, 37, 10, 40, 41, 62, 60, - 44 + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 61, 43, 45, 42, 47, 37, 10, 40, 41, 62, + 60, 44 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 51, 52, 52, 53, 53, 53, 53, 53, 53, - 53, 53, 54, 54, 54, 55, 55, 55, 55, 55, - 55, 55, 56, 56, 56, 57, 58, 59, 60, 61, - 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, - 64, 64, 64, 64, 65, 65, 66, 66, 66, 66, - 66, 66, 67, 67, 67, 67, 68, 68, 68, 70, - 69, 71, 71, 71, 71, 72, 72, 72 + 0, 52, 53, 53, 54, 54, 54, 54, 54, 54, + 54, 54, 55, 55, 55, 56, 56, 56, 56, 56, + 56, 56, 57, 57, 57, 58, 59, 60, 61, 62, + 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, + 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, + 67, 67, 68, 68, 68, 68, 69, 69, 69, 71, + 70, 72, 72, 72, 72, 73, 73, 73 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -625,33 +627,33 @@ static const yytype_int8 yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -105 +#define YYPACT_NINF -107 static const yytype_int16 yypact[] = { - 65, -105, -105, 196, -105, 155, -105, -5, 28, 32, - 62, 9, 56, 62, 62, 62, 64, 23, 14, -105, - 25, 34, 109, 184, -105, -105, -105, -105, 62, 62, - -105, 68, -105, 69, -105, 57, -105, 1, 3, -105, - -105, -105, -105, -105, 62, -105, 119, 75, -105, -17, - 215, 215, 160, -105, 65, 109, 62, 109, 58, 172, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 184, - -30, 39, -105, -105, 87, -105, 88, 89, 76, -105, - -105, 119, 92, -105, 62, 62, -105, -105, 53, 184, - 54, 148, -105, 62, 184, 184, 184, 213, 213, 215, - 215, 184, 184, -105, 62, -105, -105, -105, 97, -105, - 184, 184, -105, -9, -105, 102, 184, 184, -105, -21, - 102, 83, 62, 73, -105, -105, 37, -105, 70, 117, - 113, 62, 184, -105, 110, 120, 102, -105, 104, 184, - -105, 102, -105, -105, -105, -105, 102, 121, 102, 122, - 116, 126, 112, -105, 114, -105, -105 + 64, -107, -107, 195, -107, 154, -107, -7, 22, 9, + 61, 5, 41, 61, 61, 61, 59, 17, 2, -107, + 19, 28, 108, 183, -107, -107, -107, -107, 61, 61, + -107, 62, -107, 67, -107, 50, -107, 13, -2, -107, + -107, -107, -107, -107, 61, -107, 118, 69, -107, -16, + 214, 214, 159, -107, 64, 108, 61, 108, 49, 171, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 183, + -35, 31, -107, -107, 78, -107, 80, 88, 75, -107, + -107, 118, 91, -107, 61, 61, -107, -107, 52, 183, + 53, 147, -107, 61, 183, 183, 183, 212, 212, 214, + 214, 183, 183, -107, 61, -107, -107, -107, 96, -107, + 183, 183, -107, -1, -107, 101, 183, 183, -107, -26, + 101, 82, 61, 72, -107, -107, 83, -107, 73, 112, + 113, 61, 183, -107, 110, 117, 101, -107, 103, 183, + -107, 101, -107, -107, -107, -107, 101, 119, 101, 120, + 121, 126, 106, -107, 116, -107, -107 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -105, 86, -105, 6, 7, -25, -105, -105, -105, 66, - -104, -102, -10, 8, -105, -105, -105, 106, -105, -105, - -105, 125 + -107, 86, -107, 6, 7, -14, -107, -107, -107, 65, + -106, -101, -10, 8, -107, -107, -107, 127, -107, -107, + -107, 122 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -661,23 +663,23 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -35 static const yytype_int16 yytable[] = { - 46, 121, 40, 50, 51, 52, 18, 19, 24, 75, - 120, 126, 59, 84, -8, 76, 130, 103, 69, 69, - 104, 122, 85, 77, 128, 33, 136, 35, 140, 129, - 88, 141, 90, 78, 81, 145, 41, 147, 146, 42, - 47, 48, 149, 148, 151, 59, 89, 91, 133, 134, - 94, 95, 96, 97, 98, 99, 100, 101, 102, -8, - 18, 19, 24, 49, 53, -4, 1, 2, 54, 43, - 2, 55, 3, 56, 110, 111, 72, 73, 4, 74, - 5, 6, 83, 116, 7, 8, 9, 92, 44, 104, - 12, 10, 11, 12, 117, 105, 106, 107, 77, 109, + 46, 40, -8, 50, 51, 52, 18, 19, 24, 126, + 121, 120, 59, 103, 130, 84, 104, 42, 69, 69, + 128, 33, 75, 35, 85, 129, 140, 136, 76, 78, + 122, 41, 141, 145, 81, 147, 77, 47, 48, 146, + 149, 88, 151, 90, 148, 59, 89, 91, -8, 49, + 94, 95, 96, 97, 98, 99, 100, 101, 102, 53, + 18, 19, 24, 54, -4, 1, 55, 2, 56, 43, + 2, 72, 3, 74, 110, 111, 73, 83, 4, 92, + 5, 6, 104, 116, 7, 8, 9, 105, 44, 106, + 12, 10, 11, 12, 117, 133, 134, 107, 77, 109, 112, 114, 13, 14, 118, 13, 14, 2, 15, 123, -4, 15, 132, 131, 2, 4, 43, 5, 6, 28, - 135, 139, 8, 9, 137, 138, 142, 143, 10, 11, - 12, 144, 153, 150, 152, 44, 82, 12, 154, 155, - 87, 156, 13, 14, 79, 0, 108, 124, 15, 13, - 14, 0, 60, 61, 71, 57, 0, 62, 0, 63, - 64, 65, 66, 30, 0, 0, 0, 67, 68, 31, + 137, 139, 8, 9, 135, 143, 138, 142, 10, 11, + 12, 144, 150, 152, 155, 44, 82, 12, 153, 154, + 87, 0, 13, 14, 156, 108, 0, 124, 15, 13, + 14, 71, 60, 61, 0, 57, 0, 62, 0, 63, + 64, 65, 66, 30, 0, 79, 0, 67, 68, 31, 0, 0, 0, 32, 0, 0, 0, 33, 34, 35, 36, 60, 61, 0, 0, 37, 62, 93, 63, 64, 65, 66, 0, 60, 61, 86, 67, 68, 62, 0, @@ -692,55 +694,55 @@ static const yytype_int16 yytable[] = static const yytype_int16 yycheck[] = { - 10, 10, 7, 13, 14, 15, 0, 0, 0, 8, - 112, 115, 22, 30, 0, 14, 120, 47, 28, 29, - 50, 30, 39, 22, 45, 22, 128, 24, 132, 50, - 55, 133, 57, 30, 44, 139, 8, 141, 140, 7, - 31, 32, 146, 145, 148, 55, 56, 57, 11, 12, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 45, - 54, 54, 54, 7, 0, 0, 1, 5, 45, 7, - 5, 46, 7, 39, 84, 85, 8, 8, 13, 22, - 15, 16, 7, 93, 19, 20, 21, 29, 26, 50, - 28, 26, 27, 28, 104, 8, 8, 8, 22, 7, - 47, 47, 40, 41, 7, 40, 41, 5, 46, 7, - 45, 46, 122, 30, 5, 13, 7, 15, 16, 46, - 50, 131, 20, 21, 7, 12, 16, 7, 26, 27, - 28, 27, 16, 12, 12, 26, 17, 28, 12, 27, - 54, 27, 40, 41, 38, -1, 80, 45, 46, 40, - 41, -1, 33, 34, 29, 46, -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, 46, -1, 48, 49, 33, 34, 33, 34, - -1, 38, -1, 38, -1, 42, 43, -1, -1, -1, - -1, 48, 49, 48, 49 + 10, 8, 0, 13, 14, 15, 0, 0, 0, 115, + 11, 112, 22, 48, 120, 31, 51, 8, 28, 29, + 46, 23, 9, 25, 40, 51, 132, 128, 15, 31, + 31, 9, 133, 139, 44, 141, 23, 32, 33, 140, + 146, 55, 148, 57, 145, 55, 56, 57, 46, 8, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 0, + 54, 54, 54, 46, 0, 1, 47, 6, 40, 8, + 6, 9, 8, 23, 84, 85, 9, 8, 14, 30, + 16, 17, 51, 93, 20, 21, 22, 9, 27, 9, + 29, 27, 28, 29, 104, 12, 13, 9, 23, 8, + 48, 48, 41, 42, 8, 41, 42, 6, 47, 8, + 46, 47, 122, 31, 6, 14, 8, 16, 17, 47, + 8, 131, 21, 22, 51, 8, 13, 17, 27, 28, + 29, 28, 13, 13, 28, 27, 18, 29, 17, 13, + 54, -1, 41, 42, 28, 80, -1, 46, 47, 41, + 42, 29, 34, 35, -1, 47, -1, 39, -1, 41, + 42, 43, 44, 9, -1, 38, -1, 49, 50, 15, + -1, -1, -1, 19, -1, -1, -1, 23, 24, 25, + 26, 34, 35, -1, -1, 31, 39, 40, 41, 42, + 43, 44, -1, 34, 35, 48, 49, 50, 39, -1, + 41, 42, 43, 44, -1, 34, 35, 48, 49, 50, + 39, 40, 41, 42, 43, 44, -1, 34, 35, -1, + 49, 50, 39, -1, 41, 42, 43, 44, -1, 34, + 35, -1, 49, 50, 39, -1, -1, -1, 43, 44, + -1, -1, 47, -1, 49, 50, 34, 35, 34, 35, + -1, 39, -1, 39, -1, 43, 44, -1, -1, -1, + -1, 49, 50, 49, 50 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 1, 5, 7, 13, 15, 16, 19, 20, 21, - 26, 27, 28, 40, 41, 46, 52, 53, 54, 55, - 57, 58, 59, 63, 64, 65, 66, 69, 46, 60, - 8, 14, 18, 22, 23, 24, 25, 30, 67, 68, - 7, 8, 7, 7, 26, 54, 63, 31, 32, 7, - 63, 63, 63, 0, 45, 46, 39, 46, 56, 63, - 33, 34, 38, 40, 41, 42, 43, 48, 49, 63, - 72, 72, 8, 8, 22, 8, 14, 22, 30, 68, - 70, 63, 17, 7, 30, 39, 47, 52, 56, 63, - 56, 63, 29, 39, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 47, 50, 8, 8, 8, 60, 7, - 63, 63, 47, 61, 47, 62, 63, 63, 7, 71, - 62, 10, 30, 7, 45, 55, 61, 64, 45, 50, - 61, 30, 63, 11, 12, 50, 62, 7, 12, 63, - 61, 62, 16, 7, 27, 61, 62, 61, 62, 61, - 12, 61, 12, 16, 12, 27, 27 + 0, 1, 6, 8, 14, 16, 17, 20, 21, 22, + 27, 28, 29, 41, 42, 47, 53, 54, 55, 56, + 58, 59, 60, 64, 65, 66, 67, 70, 47, 61, + 9, 15, 19, 23, 24, 25, 26, 31, 68, 69, + 8, 9, 8, 8, 27, 55, 64, 32, 33, 8, + 64, 64, 64, 0, 46, 47, 40, 47, 57, 64, + 34, 35, 39, 41, 42, 43, 44, 49, 50, 64, + 73, 73, 9, 9, 23, 9, 15, 23, 31, 69, + 71, 64, 18, 8, 31, 40, 48, 53, 57, 64, + 57, 64, 30, 40, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 48, 51, 9, 9, 9, 61, 8, + 64, 64, 48, 62, 48, 63, 64, 64, 8, 72, + 63, 11, 31, 8, 46, 56, 62, 65, 46, 51, + 62, 31, 64, 12, 13, 51, 63, 8, 13, 64, + 62, 63, 17, 8, 28, 62, 63, 62, 63, 62, + 13, 62, 13, 17, 13, 28, 28 }; #define yyerrok (yyerrstatus = 0) @@ -1959,7 +1961,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 1963 "engines/director/lingo/lingo-gr.cpp" +#line 1965 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h index 2bf7d7aa12..bdef89f889 100644 --- a/engines/director/lingo/lingo-gr.h +++ b/engines/director/lingo/lingo-gr.h @@ -41,79 +41,81 @@ enum yytokentype { UNARY = 258, VOID = 259, - INT = 260, - FLOAT = 261, - ID = 262, - STRING = 263, - HANDLER = 264, - tDOWN = 265, - tELSE = 266, - tEND = 267, - tEXIT = 268, - tFRAME = 269, - tGO = 270, - tIF = 271, - tINTO = 272, - tLOOP = 273, - tMACRO = 274, - tMCI = 275, - tMCIWAIT = 276, - tMOVIE = 277, - tNEXT = 278, - tOF = 279, - tPREVIOUS = 280, - tPUT = 281, - tREPEAT = 282, - tSET = 283, - tTHEN = 284, - tTO = 285, - tWITH = 286, - tWHILE = 287, - tGE = 288, - tLE = 289, - tGT = 290, - tLT = 291, - tEQ = 292, - tNEQ = 293 + VAR = 260, + INT = 261, + FLOAT = 262, + ID = 263, + STRING = 264, + HANDLER = 265, + tDOWN = 266, + tELSE = 267, + tEND = 268, + tEXIT = 269, + tFRAME = 270, + tGO = 271, + tIF = 272, + tINTO = 273, + tLOOP = 274, + tMACRO = 275, + tMCI = 276, + tMCIWAIT = 277, + tMOVIE = 278, + tNEXT = 279, + tOF = 280, + tPREVIOUS = 281, + tPUT = 282, + tREPEAT = 283, + tSET = 284, + tTHEN = 285, + tTO = 286, + tWITH = 287, + tWHILE = 288, + tGE = 289, + tLE = 290, + tGT = 291, + tLT = 292, + tEQ = 293, + tNEQ = 294 }; #endif /* Tokens. */ #define UNARY 258 #define VOID 259 -#define INT 260 -#define FLOAT 261 -#define ID 262 -#define STRING 263 -#define HANDLER 264 -#define tDOWN 265 -#define tELSE 266 -#define tEND 267 -#define tEXIT 268 -#define tFRAME 269 -#define tGO 270 -#define tIF 271 -#define tINTO 272 -#define tLOOP 273 -#define tMACRO 274 -#define tMCI 275 -#define tMCIWAIT 276 -#define tMOVIE 277 -#define tNEXT 278 -#define tOF 279 -#define tPREVIOUS 280 -#define tPUT 281 -#define tREPEAT 282 -#define tSET 283 -#define tTHEN 284 -#define tTO 285 -#define tWITH 286 -#define tWHILE 287 -#define tGE 288 -#define tLE 289 -#define tGT 290 -#define tLT 291 -#define tEQ 292 -#define tNEQ 293 +#define VAR 260 +#define INT 261 +#define FLOAT 262 +#define ID 263 +#define STRING 264 +#define HANDLER 265 +#define tDOWN 266 +#define tELSE 267 +#define tEND 268 +#define tEXIT 269 +#define tFRAME 270 +#define tGO 271 +#define tIF 272 +#define tINTO 273 +#define tLOOP 274 +#define tMACRO 275 +#define tMCI 276 +#define tMCIWAIT 277 +#define tMOVIE 278 +#define tNEXT 279 +#define tOF 280 +#define tPREVIOUS 281 +#define tPUT 282 +#define tREPEAT 283 +#define tSET 284 +#define tTHEN 285 +#define tTO 286 +#define tWITH 287 +#define tWHILE 288 +#define tGE 289 +#define tLE 290 +#define tGT 291 +#define tLT 292 +#define tEQ 293 +#define tNEQ 294 @@ -129,7 +131,7 @@ typedef union YYSTYPE int narg; /* number of arguments */ } /* Line 1529 of yacc.c. */ -#line 133 "engines/director/lingo/lingo-gr.hpp" +#line 135 "engines/director/lingo/lingo-gr.hpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index 09523e3521..e77293d0f6 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -70,7 +70,7 @@ using namespace Director; int narg; /* number of arguments */ } -%token UNARY VOID +%token UNARY VOID VAR %token<i> INT %token<f> FLOAT %token<s> ID STRING HANDLER diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 67c56fa0bc..cfa25d71f1 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -30,6 +30,7 @@ #include "common/str.h" #include "engines/director/director.h" #include "engines/director/score.h" +#include "director/lingo/lingo-gr.h" namespace Director { @@ -77,7 +78,7 @@ typedef Common::Array<inst> ScriptData; typedef struct Symbol { /* symbol table entry */ char *name; - long type; + int type; union { int val; /* VAR */ float fval; /* FLOAT */ @@ -89,11 +90,16 @@ typedef struct Symbol { /* symbol table entry */ Symbol(); } Symbol; -typedef union Datum { /* interpreter stack type */ - int val; - Symbol *sym; +typedef struct Datum { /* interpreter stack type */ + int type; - Datum() { val = 0; sym = NULL; } + union { + int i; + float f; + Symbol *sym; + } u; + + Datum() { u.sym = NULL; type = VOID; } } Datum; typedef struct CFrame { /* proc/func call stack frame */ |