From 7995def290ac572c8bdf7f95b07694eeda891409 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 1 Jan 2020 02:10:30 +0100 Subject: DIRECTOR: LINGO: Moved all codes to separate class to lessen Lingo class pollution --- engines/director/lingo/lingo-builtins.cpp | 7 +- engines/director/lingo/lingo-bytecode.cpp | 115 +++---- engines/director/lingo/lingo-code.cpp | 351 ++++++++++----------- engines/director/lingo/lingo-code.h | 143 +++++++++ engines/director/lingo/lingo-codegen.cpp | 13 +- engines/director/lingo/lingo-events.cpp | 3 +- engines/director/lingo/lingo-gr.cpp | 495 +++++++++++++++--------------- engines/director/lingo/lingo-gr.h | 2 +- engines/director/lingo/lingo-gr.y | 193 ++++++------ engines/director/lingo/lingo.cpp | 5 + engines/director/lingo/lingo.h | 116 +------ 11 files changed, 751 insertions(+), 692 deletions(-) create mode 100644 engines/director/lingo/lingo-code.h diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index ecd78e21b4..b0cfef469f 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -24,6 +24,7 @@ #include "director/director.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" #include "director/frame.h" #include "director/score.h" #include "director/sprite.h" @@ -935,7 +936,7 @@ void Lingo::b_quit(int nargs) { void Lingo::b_return(int nargs) { // We do not touch the top of the stack, it will be returned - c_procret(); + g_lc->c_procret(); } void Lingo::b_restart(int nargs) { @@ -1135,7 +1136,7 @@ void Lingo::b_importFileInto(int nargs) { void menuCommandsCallback(int action, Common::String &text, void *data) { Common::String name = Common::String::format("scummvmMenu%d", action); - g_lingo->call(name, 0); + g_lc->call(name, 0); } void Lingo::b_installMenu(int nargs) { @@ -1686,7 +1687,7 @@ void Lingo::factoryCall(Common::String &name, int nargs) { s = name + "-" + *method.u.s; debugC(3, kDebugLingoExec, "Stack size before call: %d, nargs: %d", _stack.size(), nargs); - call(s, nargs); + _lc->call(s, nargs); debugC(3, kDebugLingoExec, "Stack size after call: %d", _stack.size()); if (!method.u.s->compareToIgnoreCase("mNew")) { diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp index 9500997457..b6d3939d5f 100644 --- a/engines/director/lingo/lingo-bytecode.cpp +++ b/engines/director/lingo/lingo-bytecode.cpp @@ -24,6 +24,7 @@ #include "director/director.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" #include "director/lingo/lingo-bytecode.h" #include "director/lingo/lingo-the.h" @@ -31,53 +32,53 @@ namespace Director { static LingoV4Bytecode lingoV4[] = { { 0x01, STOP, "" }, - { 0x03, Lingo::c_voidpush, "" }, - { 0x04, Lingo::c_mul, "" }, - { 0x05, Lingo::c_add, "" }, - { 0x06, Lingo::c_sub, "" }, - { 0x07, Lingo::c_div, "" }, - { 0x08, Lingo::c_mod, "" }, - { 0x09, Lingo::c_negate, "" }, - { 0x0a, Lingo::c_ampersand, "" }, - { 0x0b, Lingo::c_concat, "" }, - { 0x0c, Lingo::c_lt, "" }, - { 0x0d, Lingo::c_le, "" }, - { 0x0e, Lingo::c_neq, "" }, - { 0x0f, Lingo::c_eq, "" }, - { 0x10, Lingo::c_gt, "" }, - { 0x11, Lingo::c_ge, "" }, - { 0x12, Lingo::c_and, "" }, - { 0x13, Lingo::c_or, "" }, - { 0x14, Lingo::c_not, "" }, - { 0x15, Lingo::c_contains, "" }, - { 0x16, Lingo::c_starts, "" }, - { 0x17, Lingo::c_of, "" }, - { 0x18, Lingo::c_hilite, "" }, - { 0x19, Lingo::c_intersects, "" }, - { 0x1a, Lingo::c_within, "" }, - { 0x1b, Lingo::c_field, "" }, - { 0x1c, Lingo::c_tell, "" }, - { 0x1d, Lingo::c_telldone, "" }, - { 0x41, Lingo::c_intpush, "b" }, - { 0x42, Lingo::c_argcpush, "b" }, - { 0x43, Lingo::c_argcnoretpush, "b" }, + { 0x03, LC::c_voidpush, "" }, + { 0x04, LC::c_mul, "" }, + { 0x05, LC::c_add, "" }, + { 0x06, LC::c_sub, "" }, + { 0x07, LC::c_div, "" }, + { 0x08, LC::c_mod, "" }, + { 0x09, LC::c_negate, "" }, + { 0x0a, LC::c_ampersand, "" }, + { 0x0b, LC::c_concat, "" }, + { 0x0c, LC::c_lt, "" }, + { 0x0d, LC::c_le, "" }, + { 0x0e, LC::c_neq, "" }, + { 0x0f, LC::c_eq, "" }, + { 0x10, LC::c_gt, "" }, + { 0x11, LC::c_ge, "" }, + { 0x12, LC::c_and, "" }, + { 0x13, LC::c_or, "" }, + { 0x14, LC::c_not, "" }, + { 0x15, LC::c_contains, "" }, + { 0x16, LC::c_starts, "" }, + { 0x17, LC::c_of, "" }, + { 0x18, LC::c_hilite, "" }, + { 0x19, LC::c_intersects, "" }, + { 0x1a, LC::c_within, "" }, + { 0x1b, LC::c_field, "" }, + { 0x1c, LC::c_tell, "" }, + { 0x1d, LC::c_telldone, "" }, + { 0x41, LC::c_intpush, "b" }, + { 0x42, LC::c_argcpush, "b" }, + { 0x43, LC::c_argcnoretpush, "b" }, // 0x44, push a constant - { 0x45, Lingo::c_namepush, "b" }, - { 0x53, Lingo::c_jump, "jb" }, - { 0x54, Lingo::c_jump, "jbn" }, - { 0x55, Lingo::c_jumpifz, "jb" }, - { 0x56, Lingo::cb_localcall, "b" }, - { 0x57, Lingo::cb_call, "b" }, - { 0x5c, Lingo::cb_v4theentitypush, "b" }, - { 0x5d, Lingo::cb_v4theentityassign, "b" }, - { 0x66, Lingo::cb_v4theentitynamepush, "b" }, - { 0x81, Lingo::c_intpush, "w" }, - { 0x82, Lingo::c_argcpush, "w" }, - { 0x83, Lingo::c_argcnoretpush, "w" }, + { 0x45, LC::c_namepush, "b" }, + { 0x53, LC::c_jump, "jb" }, + { 0x54, LC::c_jump, "jbn" }, + { 0x55, LC::c_jumpifz, "jb" }, + { 0x56, LC::cb_localcall, "b" }, + { 0x57, LC::cb_call, "b" }, + { 0x5c, LC::cb_v4theentitypush, "b" }, + { 0x5d, LC::cb_v4theentityassign, "b" }, + { 0x66, LC::cb_v4theentitynamepush, "b" }, + { 0x81, LC::c_intpush, "w" }, + { 0x82, LC::c_argcpush, "w" }, + { 0x83, LC::c_argcnoretpush, "w" }, // 0x84, push a constant - { 0x93, Lingo::c_jump, "jw" }, - { 0x94, Lingo::c_jump, "jwn" }, - { 0x95, Lingo::c_jumpifz, "jw" }, + { 0x93, LC::c_jump, "jw" }, + { 0x94, LC::c_jump, "jwn" }, + { 0x95, LC::c_jumpifz, "jw" }, { 0, 0, 0 } }; @@ -189,7 +190,7 @@ void Lingo::initBytecode() { } -void Lingo::cb_localcall() { +void LC::cb_localcall() { int nameId = g_lingo->readInt(); Common::String name = g_lingo->_namelist[nameId]; @@ -207,13 +208,13 @@ void Lingo::cb_localcall() { } -void Lingo::cb_call() { +void LC::cb_call() { int nameId = g_lingo->readInt(); Common::String name = g_lingo->_namelist[nameId]; Datum nargs = g_lingo->pop(); if ((nargs.type == ARGC) || (nargs.type == ARGCNORET)) { - g_lingo->call(name, nargs.u.i); + g_lc->call(name, nargs.u.i); } else { warning("cb_call: first arg should be of type ARGC or ARGCNORET, not %s", nargs.type2str()); @@ -222,7 +223,7 @@ void Lingo::cb_call() { } -void Lingo::cb_v4theentitypush() { +void LC::cb_v4theentitypush() { int bank = g_lingo->readInt(); Datum firstArg = g_lingo->pop(); @@ -282,7 +283,7 @@ void Lingo::cb_v4theentitypush() { } -void Lingo::cb_v4theentitynamepush() { +void LC::cb_v4theentitynamepush() { Datum nargs = g_lingo->pop(); if ((nargs.type == ARGC) || (nargs.type == ARGCNORET)) { if (nargs.u.i > 0) { @@ -312,7 +313,7 @@ void Lingo::cb_v4theentitynamepush() { } -void Lingo::cb_v4theentityassign() { +void LC::cb_v4theentityassign() { int bank = g_lingo->readInt(); Datum firstArg = g_lingo->pop(); @@ -585,13 +586,13 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty Datum constant = _currentScriptContext->constants[arg]; switch (constant.type) { case INT: - g_lingo->code1(Lingo::c_intpush); + g_lingo->code1(LC::c_intpush); break; case FLOAT: - g_lingo->code1(Lingo::c_floatpush); + g_lingo->code1(LC::c_floatpush); break; case STRING: - g_lingo->code1(Lingo::c_stringpush); + g_lingo->code1(LC::c_stringpush); break; default: error("Unknown constant type %d", constant.type); @@ -658,12 +659,12 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty if (opcode < 0x40) { // 1 byte instruction debugC(5, kDebugLingoCompile, "Unimplemented opcode: 0x%02x", opcode); offsetList.push_back(_currentScript->size()); - g_lingo->code1(Lingo::c_unk); + g_lingo->code1(LC::c_unk); g_lingo->codeInt(opcode); } else if (opcode < 0x80) { // 2 byte instruction debugC(5, kDebugLingoCompile, "Unimplemented opcode: 0x%02x (%d)", opcode, (uint)codeStore[pointer]); offsetList.push_back(_currentScript->size()); - g_lingo->code1(Lingo::c_unk1); + g_lingo->code1(LC::c_unk1); g_lingo->codeInt(opcode); offsetList.push_back(_currentScript->size()); g_lingo->codeInt((uint)codeStore[pointer]); @@ -671,7 +672,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty } else { // 3 byte instruction debugC(5, kDebugLingoCompile, "Unimplemented opcode: 0x%02x (%d, %d)", opcode, (uint)codeStore[pointer], (uint)codeStore[pointer+1]); offsetList.push_back(_currentScript->size()); - g_lingo->code1(Lingo::c_unk2); + g_lingo->code1(LC::c_unk2); g_lingo->codeInt(opcode); offsetList.push_back(_currentScript->size()); g_lingo->codeInt((uint)codeStore[pointer]); diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 53e1cd98af..d0805c9662 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -48,99 +48,102 @@ #include "director/score.h" #include "director/util.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" namespace Director { +LC *g_lc; + static struct FuncDescr { const inst func; const char *name; const char *args; } funcDescr[] = { { 0, "STOP", "" }, - { Lingo::c_xpop, "c_xpop", "" }, - { Lingo::c_argcpush, "c_argcpush", "i" }, - { Lingo::c_argcnoretpush, "c_argcnoretpush", "i" }, - { Lingo::c_arraypush, "c_arraypush", "i" }, - { Lingo::c_printtop, "c_printtop", "" }, - { Lingo::c_intpush, "c_intpush", "i" }, - { Lingo::c_voidpush, "c_voidpush", "" }, - { Lingo::c_floatpush, "c_floatpush", "f" }, - { Lingo::c_stringpush, "c_stringpush", "s" }, - { Lingo::c_symbolpush, "c_symbolpush", "s" }, // D3 - { Lingo::c_namepush, "c_namepush", "i" }, - { Lingo::c_varpush, "c_varpush", "s" }, - { Lingo::c_setImmediate,"c_setImmediate","i" }, - { Lingo::c_assign, "c_assign", "" }, - { Lingo::c_eval, "c_eval", "s" }, - { Lingo::c_theentitypush,"c_theentitypush","ii" }, // entity, field - { Lingo::c_theentityassign,"c_theentityassign","ii" }, - { Lingo::c_objectfieldpush,"c_objectfieldpush","si" }, // object, field - { Lingo::c_objectfieldassign,"c_objectfieldassign","si" }, - { Lingo::c_swap, "c_swap", "" }, - { Lingo::c_add, "c_add", "" }, - { Lingo::c_sub, "c_sub", "" }, - { Lingo::c_mul, "c_mul", "" }, - { Lingo::c_div, "c_div", "" }, - { Lingo::c_mod, "c_mod", "" }, - { Lingo::c_negate, "c_negate", "" }, - { Lingo::c_ampersand, "c_ampersand", "" }, - { Lingo::c_after, "c_after", "" }, // D3 - { Lingo::c_before, "c_before", "" }, // D3 - { Lingo::c_concat, "c_concat", "" }, - { Lingo::c_contains, "c_contains", "" }, - { Lingo::c_starts, "c_starts", "" }, - { Lingo::c_intersects, "c_intersects", "" }, - { Lingo::c_within, "c_within", "" }, - { Lingo::c_field, "c_field", "" }, - { Lingo::c_of, "c_of", "" }, - { Lingo::c_charOf, "c_charOf", "" }, // D3 - { Lingo::c_charToOf, "c_charToOf", "" }, // D3 - { Lingo::c_itemOf, "c_itemOf", "" }, // D3 - { Lingo::c_itemToOf, "c_itemToOf", "" }, // D3 - { Lingo::c_lineOf, "c_lineOf", "" }, // D3 - { Lingo::c_lineToOf, "c_lineToOf", "" }, // D3 - { Lingo::c_wordOf, "c_wordOf", "" }, // D3 - { Lingo::c_wordToOf, "c_wordToOf", "" }, // D3 - { Lingo::c_and, "c_and", "" }, - { Lingo::c_or, "c_or", "" }, - { Lingo::c_not, "c_not", "" }, - { Lingo::c_eq, "c_eq", "" }, - { Lingo::c_neq, "c_neq", "" }, - { Lingo::c_gt, "c_gt", "" }, - { Lingo::c_lt, "c_lt", "" }, - { Lingo::c_ge, "c_ge", "" }, - { Lingo::c_le, "c_le", "" }, - { Lingo::c_jump, "c_jump", "i" }, - { Lingo::c_jumpifz, "c_jumpifz", "i" }, - { Lingo::c_repeatwhilecode,"c_repeatwhilecode","oo" }, - { Lingo::c_repeatwithcode,"c_repeatwithcode","ooooos" }, - { Lingo::c_exitRepeat, "c_exitRepeat", "" }, - { Lingo::c_ifcode, "c_ifcode", "oooi" }, - { Lingo::c_tellcode, "c_tellcode", "o" }, - { Lingo::c_tell, "c_tell", "" }, - { Lingo::c_telldone, "c_telldone", "" }, - { Lingo::c_whencode, "c_whencode", "os" }, - { Lingo::c_goto, "c_goto", "" }, - { Lingo::c_gotoloop, "c_gotoloop", "" }, - { Lingo::c_gotonext, "c_gotonext", "" }, - { Lingo::c_gotoprevious,"c_gotoprevious","" }, - { Lingo::c_play, "c_play", "" }, - { Lingo::c_playdone, "c_playdone", "" }, - { Lingo::c_call, "c_call", "si" }, - { Lingo::c_procret, "c_procret", "" }, - { Lingo::c_global, "c_global", "s" }, - { Lingo::c_property, "c_property", "s" }, - { Lingo::c_instance, "c_instance", "s" }, - { Lingo::c_open, "c_open", "" }, - { Lingo::c_hilite, "c_hilite", "" }, - { Lingo::c_unk, "c_unk", "i" }, - { Lingo::c_unk1, "c_unk1", "ii" }, - { Lingo::c_unk2, "c_unk2", "iii" }, - { Lingo::cb_call, "cb_call", "i" }, - { Lingo::cb_localcall, "cb_localcall", "i" }, - { Lingo::cb_v4theentitypush,"c_v4theentitypush","i" }, - { Lingo::cb_v4theentitynamepush,"c_v4theentitynamepush","i" }, - { Lingo::cb_v4theentityassign,"c_v4theentityassign","i" }, + { LC::c_xpop, "c_xpop", "" }, + { LC::c_argcpush, "c_argcpush", "i" }, + { LC::c_argcnoretpush, "c_argcnoretpush", "i" }, + { LC::c_arraypush, "c_arraypush", "i" }, + { LC::c_printtop, "c_printtop", "" }, + { LC::c_intpush, "c_intpush", "i" }, + { LC::c_voidpush, "c_voidpush", "" }, + { LC::c_floatpush, "c_floatpush", "f" }, + { LC::c_stringpush, "c_stringpush", "s" }, + { LC::c_symbolpush, "c_symbolpush", "s" }, // D3 + { LC::c_namepush, "c_namepush", "i" }, + { LC::c_varpush, "c_varpush", "s" }, + { LC::c_setImmediate,"c_setImmediate","i" }, + { LC::c_assign, "c_assign", "" }, + { LC::c_eval, "c_eval", "s" }, + { LC::c_theentitypush,"c_theentitypush","ii" }, // entity, field + { LC::c_theentityassign,"c_theentityassign","ii" }, + { LC::c_objectfieldpush,"c_objectfieldpush","si" }, // object, field + { LC::c_objectfieldassign,"c_objectfieldassign","si" }, + { LC::c_swap, "c_swap", "" }, + { LC::c_add, "c_add", "" }, + { LC::c_sub, "c_sub", "" }, + { LC::c_mul, "c_mul", "" }, + { LC::c_div, "c_div", "" }, + { LC::c_mod, "c_mod", "" }, + { LC::c_negate, "c_negate", "" }, + { LC::c_ampersand, "c_ampersand", "" }, + { LC::c_after, "c_after", "" }, // D3 + { LC::c_before, "c_before", "" }, // D3 + { LC::c_concat, "c_concat", "" }, + { LC::c_contains, "c_contains", "" }, + { LC::c_starts, "c_starts", "" }, + { LC::c_intersects, "c_intersects", "" }, + { LC::c_within, "c_within", "" }, + { LC::c_field, "c_field", "" }, + { LC::c_of, "c_of", "" }, + { LC::c_charOf, "c_charOf", "" }, // D3 + { LC::c_charToOf, "c_charToOf", "" }, // D3 + { LC::c_itemOf, "c_itemOf", "" }, // D3 + { LC::c_itemToOf, "c_itemToOf", "" }, // D3 + { LC::c_lineOf, "c_lineOf", "" }, // D3 + { LC::c_lineToOf, "c_lineToOf", "" }, // D3 + { LC::c_wordOf, "c_wordOf", "" }, // D3 + { LC::c_wordToOf, "c_wordToOf", "" }, // D3 + { LC::c_and, "c_and", "" }, + { LC::c_or, "c_or", "" }, + { LC::c_not, "c_not", "" }, + { LC::c_eq, "c_eq", "" }, + { LC::c_neq, "c_neq", "" }, + { LC::c_gt, "c_gt", "" }, + { LC::c_lt, "c_lt", "" }, + { LC::c_ge, "c_ge", "" }, + { LC::c_le, "c_le", "" }, + { LC::c_jump, "c_jump", "i" }, + { LC::c_jumpifz, "c_jumpifz", "i" }, + { LC::c_repeatwhilecode,"c_repeatwhilecode","oo" }, + { LC::c_repeatwithcode,"c_repeatwithcode","ooooos" }, + { LC::c_exitRepeat, "c_exitRepeat", "" }, + { LC::c_ifcode, "c_ifcode", "oooi" }, + { LC::c_tellcode, "c_tellcode", "o" }, + { LC::c_tell, "c_tell", "" }, + { LC::c_telldone, "c_telldone", "" }, + { LC::c_whencode, "c_whencode", "os" }, + { LC::c_goto, "c_goto", "" }, + { LC::c_gotoloop, "c_gotoloop", "" }, + { LC::c_gotonext, "c_gotonext", "" }, + { LC::c_gotoprevious,"c_gotoprevious","" }, + { LC::c_play, "c_play", "" }, + { LC::c_playdone, "c_playdone", "" }, + { LC::c_call, "c_call", "si" }, + { LC::c_procret, "c_procret", "" }, + { LC::c_global, "c_global", "s" }, + { LC::c_property, "c_property", "s" }, + { LC::c_instance, "c_instance", "s" }, + { LC::c_open, "c_open", "" }, + { LC::c_hilite, "c_hilite", "" }, + { LC::c_unk, "c_unk", "i" }, + { LC::c_unk1, "c_unk1", "ii" }, + { LC::c_unk2, "c_unk2", "iii" }, + { LC::cb_call, "cb_call", "i" }, + { LC::cb_localcall, "cb_localcall", "i" }, + { LC::cb_v4theentitypush,"c_v4theentitypush","i" }, + { LC::cb_v4theentitynamepush,"c_v4theentitynamepush","i" }, + { LC::cb_v4theentityassign,"c_v4theentityassign","i" }, { 0, 0, 0 } }; @@ -172,11 +175,11 @@ Datum Lingo::pop(void) { return ret; } -void Lingo::c_xpop() { +void LC::c_xpop() { g_lingo->pop(); } -void Lingo::c_printtop(void) { +void LC::c_printtop(void) { Datum d = g_lingo->pop(); switch (d.type) { @@ -216,34 +219,34 @@ void Lingo::c_printtop(void) { } } -void Lingo::c_intpush() { +void LC::c_intpush() { Datum d; d.u.i = g_lingo->readInt(); d.type = INT; g_lingo->push(d); } -void Lingo::c_voidpush() { +void LC::c_voidpush() { Datum d; d.u.s = NULL; d.type = VOID; g_lingo->push(d); } -void Lingo::c_floatpush() { +void LC::c_floatpush() { Datum d; d.u.f = g_lingo->readFloat(); d.type = FLOAT; g_lingo->push(d); } -void Lingo::c_stringpush() { +void LC::c_stringpush() { char *s = g_lingo->readString(); g_lingo->push(Datum(new Common::String(s))); } -void Lingo::c_symbolpush() { +void LC::c_symbolpush() { char *s = g_lingo->readString(); warning("STUB: c_symbolpush()"); @@ -252,13 +255,13 @@ void Lingo::c_symbolpush() { g_lingo->push(Datum(new Common::String(s))); } -void Lingo::c_namepush() { +void LC::c_namepush() { Datum d; int i = g_lingo->readInt(); g_lingo->push(Datum(new Common::String(g_lingo->_namelist[i]))); } -void Lingo::c_argcpush() { +void LC::c_argcpush() { Datum d; int argsSize = g_lingo->readInt(); @@ -267,7 +270,7 @@ void Lingo::c_argcpush() { g_lingo->push(d); } -void Lingo::c_argcnoretpush() { +void LC::c_argcnoretpush() { Datum d; int argsSize = g_lingo->readInt(); @@ -276,7 +279,7 @@ void Lingo::c_argcnoretpush() { g_lingo->push(d); } -void Lingo::c_arraypush() { +void LC::c_arraypush() { Datum d; int arraySize = g_lingo->readInt(); @@ -290,7 +293,7 @@ void Lingo::c_arraypush() { g_lingo->push(d); } -void Lingo::c_varpush() { +void LC::c_varpush() { Common::String name(g_lingo->readString()); Datum d; @@ -324,11 +327,11 @@ void Lingo::c_varpush() { g_lingo->push(d); } -void Lingo::c_setImmediate() { +void LC::c_setImmediate() { g_lingo->_immediateMode = g_lingo->readInt(); } -void Lingo::c_assign() { +void LC::c_assign() { Datum d1, d2; d1 = g_lingo->pop(); d2 = g_lingo->pop(); @@ -391,7 +394,7 @@ void Lingo::c_assign() { d1.u.sym->type = d2.type; } -bool Lingo::verify(Symbol *s) { +bool LC::verify(Symbol *s) { if (s->type != INT && s->type != VOID && s->type != FLOAT && s->type != STRING && s->type != POINT && s->type != SYMBOL) { warning("attempt to evaluate non-variable '%s'", s->name.c_str()); @@ -404,14 +407,14 @@ bool Lingo::verify(Symbol *s) { return true; } -void Lingo::c_eval() { - g_lingo->c_varpush(); +void LC::c_eval() { + g_lc->c_varpush(); Datum d; d = g_lingo->pop(); if (d.type == HANDLER) { - g_lingo->call(*d.u.s, 0); + g_lc->call(*d.u.s, 0); delete d.u.s; return; } @@ -421,7 +424,7 @@ void Lingo::c_eval() { return; } - if (!g_lingo->verify(d.u.sym)) + if (!g_lc->verify(d.u.sym)) return; d.type = d.u.sym->type; @@ -444,7 +447,7 @@ void Lingo::c_eval() { g_lingo->push(d); } -void Lingo::c_theentitypush() { +void LC::c_theentitypush() { Datum id = g_lingo->pop(); int entity = g_lingo->readInt(); @@ -454,7 +457,7 @@ void Lingo::c_theentitypush() { g_lingo->push(d); } -void Lingo::c_theentityassign() { +void LC::c_theentityassign() { Datum id = g_lingo->pop(); int entity = g_lingo->readInt(); @@ -464,7 +467,7 @@ void Lingo::c_theentityassign() { g_lingo->setTheEntity(entity, id, field, d); } -void Lingo::c_objectfieldpush() { +void LC::c_objectfieldpush() { Common::String object(g_lingo->readString()); int field = g_lingo->readInt(); @@ -472,7 +475,7 @@ void Lingo::c_objectfieldpush() { g_lingo->push(d); } -void Lingo::c_objectfieldassign() { +void LC::c_objectfieldassign() { Common::String object(g_lingo->readString()); int field = g_lingo->readInt(); @@ -481,14 +484,14 @@ void Lingo::c_objectfieldassign() { g_lingo->setObjectField(object, field, d); } -void Lingo::c_swap() { +void LC::c_swap() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); g_lingo->push(d2); g_lingo->push(d1); } -void Lingo::c_add() { +void LC::c_add() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -500,7 +503,7 @@ void Lingo::c_add() { g_lingo->push(d1); } -void Lingo::c_sub() { +void LC::c_sub() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -512,7 +515,7 @@ void Lingo::c_sub() { g_lingo->push(d1); } -void Lingo::c_mul() { +void LC::c_mul() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -524,7 +527,7 @@ void Lingo::c_mul() { g_lingo->push(d1); } -void Lingo::c_div() { +void LC::c_div() { Datum d2 = g_lingo->pop(); if ((d2.type == INT && d2.u.i == 0) || @@ -541,7 +544,7 @@ void Lingo::c_div() { g_lingo->push(d1); } -void Lingo::c_mod() { +void LC::c_mod() { Datum d2 = g_lingo->pop(); d2.toInt(); @@ -556,7 +559,7 @@ void Lingo::c_mod() { g_lingo->push(d1); } -void Lingo::c_negate() { +void LC::c_negate() { Datum d = g_lingo->pop(); if (d.type == INT) @@ -567,7 +570,7 @@ void Lingo::c_negate() { g_lingo->push(d); } -void Lingo::c_ampersand() { +void LC::c_ampersand() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -581,7 +584,7 @@ void Lingo::c_ampersand() { g_lingo->push(d1); } -void Lingo::c_after() { +void LC::c_after() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -595,7 +598,7 @@ void Lingo::c_after() { g_lingo->push(d1); } -void Lingo::c_before() { +void LC::c_before() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -609,7 +612,7 @@ void Lingo::c_before() { g_lingo->push(d1); } -void Lingo::c_concat() { +void LC::c_concat() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -624,7 +627,7 @@ void Lingo::c_concat() { g_lingo->push(d1); } -void Lingo::c_contains() { +void LC::c_contains() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -647,7 +650,7 @@ void Lingo::c_contains() { g_lingo->push(d1); } -void Lingo::c_starts() { +void LC::c_starts() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -670,7 +673,7 @@ void Lingo::c_starts() { g_lingo->push(d1); } -void Lingo::c_intersects() { +void LC::c_intersects() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -679,7 +682,7 @@ void Lingo::c_intersects() { g_lingo->push(d1); } -void Lingo::c_within() { +void LC::c_within() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -688,7 +691,7 @@ void Lingo::c_within() { g_lingo->push(d1); } -void Lingo::c_field() { +void LC::c_field() { Datum d1 = g_lingo->pop(); warning("STUB: c_field: %d", d1.u.i); @@ -696,7 +699,7 @@ void Lingo::c_field() { g_lingo->push(d1); } -void Lingo::c_of() { +void LC::c_of() { Datum first_char = g_lingo->pop(); Datum last_char = g_lingo->pop(); Datum first_word = g_lingo->pop(); @@ -716,7 +719,7 @@ void Lingo::c_of() { } -void Lingo::c_charOf() { +void LC::c_charOf() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -725,7 +728,7 @@ void Lingo::c_charOf() { g_lingo->push(d1); } -void Lingo::c_charToOf() { +void LC::c_charToOf() { Datum d3 = g_lingo->pop(); Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -735,7 +738,7 @@ void Lingo::c_charToOf() { g_lingo->push(d1); } -void Lingo::c_itemOf() { +void LC::c_itemOf() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -744,7 +747,7 @@ void Lingo::c_itemOf() { g_lingo->push(d1); } -void Lingo::c_itemToOf() { +void LC::c_itemToOf() { Datum d3 = g_lingo->pop(); Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -754,7 +757,7 @@ void Lingo::c_itemToOf() { g_lingo->push(d1); } -void Lingo::c_lineOf() { +void LC::c_lineOf() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -763,7 +766,7 @@ void Lingo::c_lineOf() { g_lingo->push(d1); } -void Lingo::c_lineToOf() { +void LC::c_lineToOf() { Datum d3 = g_lingo->pop(); Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -773,7 +776,7 @@ void Lingo::c_lineToOf() { g_lingo->push(d1); } -void Lingo::c_wordOf() { +void LC::c_wordOf() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -782,7 +785,7 @@ void Lingo::c_wordOf() { g_lingo->push(d1); } -void Lingo::c_wordToOf() { +void LC::c_wordToOf() { Datum d3 = g_lingo->pop(); Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -792,7 +795,7 @@ void Lingo::c_wordToOf() { g_lingo->push(d1); } -void Lingo::c_and() { +void LC::c_and() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -804,7 +807,7 @@ void Lingo::c_and() { g_lingo->push(d1); } -void Lingo::c_or() { +void LC::c_or() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -816,7 +819,7 @@ void Lingo::c_or() { g_lingo->push(d1); } -void Lingo::c_not() { +void LC::c_not() { Datum d = g_lingo->pop(); d.toInt(); @@ -826,7 +829,7 @@ void Lingo::c_not() { g_lingo->push(d); } -void Lingo::c_eq() { +void LC::c_eq() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -842,7 +845,7 @@ void Lingo::c_eq() { g_lingo->push(d1); } -void Lingo::c_neq() { +void LC::c_neq() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -858,7 +861,7 @@ void Lingo::c_neq() { g_lingo->push(d1); } -void Lingo::c_gt() { +void LC::c_gt() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -871,7 +874,7 @@ void Lingo::c_gt() { g_lingo->push(d1); } -void Lingo::c_lt() { +void LC::c_lt() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -884,7 +887,7 @@ void Lingo::c_lt() { g_lingo->push(d1); } -void Lingo::c_ge() { +void LC::c_ge() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -897,7 +900,7 @@ void Lingo::c_ge() { g_lingo->push(d1); } -void Lingo::c_le() { +void LC::c_le() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -910,12 +913,12 @@ void Lingo::c_le() { g_lingo->push(d1); } -void Lingo::c_jump() { +void LC::c_jump() { uint jump = g_lingo->readInt(); g_lingo->_pc = jump; } -void Lingo::c_jumpifz() { +void LC::c_jumpifz() { uint jump = g_lingo->readInt(); Datum test = g_lingo->pop(); test.toInt(); @@ -924,7 +927,7 @@ void Lingo::c_jumpifz() { } } -void Lingo::c_repeatwhilecode(void) { +void LC::c_repeatwhilecode(void) { Datum d; int savepc = g_lingo->_pc; @@ -954,7 +957,7 @@ void Lingo::c_repeatwhilecode(void) { g_lingo->_pc = end + savepc - 1; /* next stmt */ } -void Lingo::c_repeatwithcode(void) { +void LC::c_repeatwithcode(void) { Datum d; int savepc = g_lingo->_pc; @@ -999,11 +1002,11 @@ void Lingo::c_repeatwithcode(void) { g_lingo->_pc = end + savepc - 1; /* next stmt */ } -void Lingo::c_exitRepeat(void) { +void LC::c_exitRepeat(void) { g_lingo->_exitRepeat = true; } -void Lingo::c_ifcode() { +void LC::c_ifcode() { Datum d; int savepc = g_lingo->_pc; /* then part */ @@ -1035,7 +1038,7 @@ void Lingo::c_ifcode() { } } -void Lingo::c_whencode() { +void LC::c_whencode() { Datum d; uint start = g_lingo->_pc; uint end = g_lingo->readInt() + start - 1; @@ -1064,16 +1067,16 @@ void Lingo::c_whencode() { g_lingo->_pc = end + 1; } -void Lingo::c_tellcode() { +void LC::c_tellcode() { warning("STUB: c_tellcode"); } -void Lingo::c_tell() { +void LC::c_tell() { Datum d1 = g_lingo->pop(); warning("STUB: c_tell %d", d1.u.i); } -void Lingo::c_telldone() { +void LC::c_telldone() { warning("STUB: c_telldone"); } @@ -1081,7 +1084,7 @@ void Lingo::c_telldone() { //************************ // Built-in functions //************************ -void Lingo::c_goto() { +void LC::c_goto() { Datum mode = g_lingo->pop(); Datum frame, movie; @@ -1094,19 +1097,19 @@ void Lingo::c_goto() { g_lingo->func_goto(frame, movie); } -void Lingo::c_gotoloop() { +void LC::c_gotoloop() { g_lingo->func_gotoloop(); } -void Lingo::c_gotonext() { +void LC::c_gotonext() { g_lingo->func_gotonext(); } -void Lingo::c_gotoprevious() { +void LC::c_gotoprevious() { g_lingo->func_gotoprevious(); } -void Lingo::c_play() { +void LC::c_play() { Datum mode = g_lingo->pop(); Datum frame, movie; @@ -1119,23 +1122,23 @@ void Lingo::c_play() { g_lingo->func_play(frame, movie); } -void Lingo::c_playdone() { +void LC::c_playdone() { g_lingo->func_playdone(); } -void Lingo::c_call() { +void LC::c_call() { Common::String name(g_lingo->readString()); int nargs = g_lingo->readInt(); - g_lingo->call(name, nargs); + g_lc->call(name, nargs); } -void Lingo::call(Common::String name, int nargs) { +void LC::call(Common::String name, int nargs) { bool dropArgs = false; if (debugChannelSet(3, kDebugLingoExec)) - printSTUBWithArglist(name.c_str(), nargs, "call:"); + g_lingo->printSTUBWithArglist(name.c_str(), nargs, "call:"); Symbol *sym = g_lingo->getHandler(name); @@ -1181,14 +1184,14 @@ void Lingo::call(Common::String name, int nargs) { } if (sym->type == BLTIN || sym->type == FBLTIN || sym->type == RBLTIN) { - if (sym->u.bltin == b_factory) { + if (sym->u.bltin == g_lingo->b_factory) { g_lingo->factoryCall(name, nargs); } else { - int stackSize = _stack.size() - nargs; + int stackSize = g_lingo->_stack.size() - nargs; (*sym->u.bltin)(nargs); - int stackNewSize = _stack.size(); + int stackNewSize = g_lingo->_stack.size(); if (sym->type == FBLTIN || sym->type == RBLTIN) { if (stackNewSize - stackSize != 1) @@ -1229,7 +1232,7 @@ void Lingo::call(Common::String name, int nargs) { g_lingo->_returning = false; } -void Lingo::c_procret() { +void LC::c_procret() { if (!g_lingo->_callstack.size()) { warning("c_procret: Call stack underflow"); g_lingo->_returning = true; @@ -1254,7 +1257,7 @@ void Lingo::c_procret() { g_lingo->_returning = true; } -void Lingo::c_global() { +void LC::c_global() { Common::String name(g_lingo->readString()); Symbol *s = g_lingo->lookupVar(name.c_str(), false); @@ -1266,19 +1269,19 @@ void Lingo::c_global() { s->global = true; } -void Lingo::c_property() { +void LC::c_property() { Common::String name(g_lingo->readString()); warning("STUB: c_property()"); } -void Lingo::c_instance() { +void LC::c_instance() { Common::String name(g_lingo->readString()); warning("STUB: c_instance(%s)", name.c_str()); } -void Lingo::c_factory() { +void LC::c_factory() { Common::String name(g_lingo->readString()); Datum d; @@ -1290,7 +1293,7 @@ void Lingo::c_factory() { g_lingo->push(d); } -void Lingo::c_open() { +void LC::c_open() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); @@ -1300,7 +1303,7 @@ void Lingo::c_open() { warning("STUB: c_open(%s, %s)", d1.u.s->c_str(), d2.u.s->c_str()); } -void Lingo::c_hilite() { +void LC::c_hilite() { Datum first_char = g_lingo->pop(); Datum last_char = g_lingo->pop(); Datum first_word = g_lingo->pop(); @@ -1317,18 +1320,18 @@ void Lingo::c_hilite() { cast_id.u.i); } -void Lingo::c_unk() { +void LC::c_unk() { uint opcode = g_lingo->readInt(); warning("STUB: opcode 0x%02x", opcode); } -void Lingo::c_unk1() { +void LC::c_unk1() { uint opcode = g_lingo->readInt(); uint arg1 = g_lingo->readInt(); warning("STUB: opcode 0x%02x (%d)", opcode, arg1); } -void Lingo::c_unk2() { +void LC::c_unk2() { uint opcode = g_lingo->readInt(); uint arg1 = g_lingo->readInt(); uint arg2 = g_lingo->readInt(); diff --git a/engines/director/lingo/lingo-code.h b/engines/director/lingo/lingo-code.h new file mode 100644 index 0000000000..d4107e828c --- /dev/null +++ b/engines/director/lingo/lingo-code.h @@ -0,0 +1,143 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef DIRECTOR_LINGO_LINGO_CODE_H +#define DIRECTOR_LINGO_LINGO_CODE_H + +namespace Director { + +class LC { +public: + static void c_xpop(); + static void c_printtop(); + + static void c_add(); + static void c_sub(); + static void c_mul(); + static void c_div(); + static void c_mod(); + static void c_negate(); + + static void c_and(); + static void c_or(); + static void c_not(); + + static void c_ampersand(); + static void c_after(); + static void c_before(); + static void c_concat(); + static void c_contains(); + static void c_starts(); + + static void c_intersects(); + static void c_within(); + static void c_field(); + static void c_of(); + static void c_charOf(); + static void c_charToOf(); + static void c_itemOf(); + static void c_itemToOf(); + static void c_lineOf(); + static void c_lineToOf(); + static void c_wordOf(); + static void c_wordToOf(); + + static void c_intpush(); + static void c_voidpush(); + static void c_floatpush(); + static void c_stringpush(); + static void c_symbolpush(); + static void c_namepush(); + static void c_varpush(); + static void c_argcpush(); + static void c_argcnoretpush(); + static void c_arraypush(); + static void c_assign(); + static bool verify(Symbol *s); + static void c_eval(); + static void c_setImmediate(); + + static void c_swap(); + + static void c_theentitypush(); + static void c_theentityassign(); + static void c_objectfieldpush(); + static void c_objectfieldassign(); + + static void c_repeatwhilecode(); + static void c_repeatwithcode(); + static void c_ifcode(); + static void c_whencode(); + static void c_tellcode(); + static void c_tell(); + static void c_telldone(); + static void c_exitRepeat(); + static void c_eq(); + static void c_neq(); + static void c_gt(); + static void c_lt(); + static void c_ge(); + static void c_le(); + static void c_jump(); + static void c_jumpifz(); + static void c_call(); + + static void call(Common::String name, int nargs); + + static void c_procret(); + + static void c_mci(); + static void c_mciwait(); + static void c_goto(); + static void c_gotoloop(); + static void c_gotonext(); + static void c_gotoprevious(); + static void c_global(); + static void c_instance(); + static void c_factory(); + static void c_property(); + + static void c_play(); + static void c_playdone(); + + static void c_open(); + static void c_hilite(); + + // stubs for unknown instructions + static void c_unk(); + static void c_unk1(); + static void c_unk2(); + + // bytecode-related instructions + static void cb_localcall(); + static void cb_call(); + static void cb_v4theentitypush(); + static void cb_v4theentitynamepush(); + static void cb_v4theentityassign(); + +}; + +extern LC *g_lc; + +} // End of namespace Director + +#endif diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 7d9f1577e1..fe452b277d 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -45,6 +45,7 @@ #include "director/director.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" #include "director/util.h" @@ -355,16 +356,16 @@ void Lingo::clearArgStack() { void Lingo::codeArgStore() { for (int i = _argstack.size() - 1; i >= 0; i--) { - code1(c_varpush); + code1(g_lc->c_varpush); codeString(_argstack[i]->c_str()); - code1(c_assign); + code1(g_lc->c_assign); } } int Lingo::codeSetImmediate(bool state) { g_lingo->_immediateMode = state; - int res = g_lingo->code1(g_lingo->c_setImmediate); + int res = g_lingo->code1(g_lc->c_setImmediate); inst i = 0; WRITE_UINT32(&i, state); g_lingo->code1(i); @@ -373,7 +374,7 @@ int Lingo::codeSetImmediate(bool state) { } int Lingo::codeFunc(Common::String *s, int numpar) { - int ret = g_lingo->code1(g_lingo->c_call); + int ret = g_lingo->code1(g_lc->c_call); g_lingo->codeString(s->c_str()); @@ -387,13 +388,13 @@ int Lingo::codeFunc(Common::String *s, int numpar) { int Lingo::codeMe(Common::String *method, int numpar) { // Check if need to encode reference to the factory if (method == nullptr) { - int ret = g_lingo->code1(g_lingo->c_factory); + int ret = g_lingo->code1(g_lc->c_factory); g_lingo->codeString(g_lingo->_currentFactory.c_str()); return ret; } - int ret = g_lingo->code1(g_lingo->c_call); + int ret = g_lingo->code1(g_lc->c_call); Common::String m(g_lingo->_currentFactory); diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp index 56f43fd714..3436d68ede 100644 --- a/engines/director/lingo/lingo-events.cpp +++ b/engines/director/lingo/lingo-events.cpp @@ -22,6 +22,7 @@ #include "director/director.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" #include "director/frame.h" #include "director/score.h" #include "director/sprite.h" @@ -315,7 +316,7 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) { if (_handlers.contains(ENTITY_INDEX(event, entityId))) { debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), _eventHandler", _eventHandlerTypes[event], scriptType2str(st), entityId); - call(_eventHandlerTypes[event], 0); // D4+ Events + g_lc->call(_eventHandlerTypes[event], 0); // D4+ Events } else if (event == kEventNone && _scriptContexts[st].contains(entityId)) { debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), script", _eventHandlerTypes[event], scriptType2str(st), entityId); diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index c371c4afbc..9df284f47b 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -263,6 +263,7 @@ #include "common/rect.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" #include "director/lingo/lingo-gr.h" extern int yylex(); @@ -307,7 +308,7 @@ void checkEnd(Common::String *token, const char *expect, bool required) { #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 84 "engines/director/lingo/lingo-gr.y" +#line 85 "engines/director/lingo/lingo-gr.y" { Common::String *s; int i; @@ -323,7 +324,7 @@ typedef union YYSTYPE } objectfield; } /* Line 193 of yacc.c. */ -#line 327 "engines/director/lingo/lingo-gr.cpp" +#line 328 "engines/director/lingo/lingo-gr.cpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -336,7 +337,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 340 "engines/director/lingo/lingo-gr.cpp" +#line 341 "engines/director/lingo/lingo-gr.cpp" #ifdef short # undef short @@ -701,23 +702,23 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 131, 131, 132, 133, 136, 137, 138, 141, 147, - 150, 151, 152, 158, 165, 171, 178, 184, 190, 197, - 198, 199, 202, 203, 204, 205, 208, 209, 214, 225, - 242, 254, 259, 261, 266, 276, 288, 289, 292, 300, - 310, 323, 326, 333, 340, 348, 351, 354, 355, 356, - 359, 365, 369, 372, 375, 378, 381, 387, 388, 389, - 392, 395, 396, 399, 407, 413, 417, 418, 419, 420, - 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, - 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, - 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, - 451, 452, 455, 460, 461, 462, 463, 464, 465, 466, - 467, 468, 471, 474, 477, 481, 482, 483, 484, 487, - 488, 491, 492, 495, 496, 507, 508, 509, 510, 514, - 518, 524, 525, 528, 529, 533, 537, 541, 541, 571, - 571, 577, 578, 578, 584, 592, 599, 601, 602, 603, - 604, 607, 608, 609, 612, 615, 623, 624, 625, 628, - 629 + 0, 132, 132, 133, 134, 137, 138, 139, 142, 148, + 151, 152, 153, 159, 166, 172, 179, 185, 191, 198, + 199, 200, 203, 204, 205, 206, 209, 210, 215, 226, + 243, 255, 260, 262, 267, 277, 289, 290, 293, 301, + 311, 324, 327, 334, 341, 349, 352, 355, 356, 357, + 360, 366, 370, 373, 376, 379, 382, 388, 389, 390, + 393, 396, 397, 400, 408, 414, 418, 419, 420, 421, + 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, + 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, + 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, + 452, 453, 456, 461, 462, 463, 464, 465, 466, 467, + 468, 469, 472, 475, 478, 482, 483, 484, 485, 488, + 489, 492, 493, 496, 497, 508, 509, 510, 511, 515, + 519, 525, 526, 529, 530, 534, 538, 542, 542, 572, + 572, 578, 579, 579, 585, 593, 600, 602, 603, 604, + 605, 608, 609, 610, 613, 616, 624, 625, 626, 629, + 630 }; #endif @@ -2113,110 +2114,110 @@ yyreduce: switch (yyn) { case 4: -#line 133 "engines/director/lingo/lingo-gr.y" +#line 134 "engines/director/lingo/lingo-gr.y" { yyerrok; ;} break; case 8: -#line 141 "engines/director/lingo/lingo-gr.y" +#line 142 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_varpush); + g_lingo->code1(g_lc->c_varpush); g_lingo->codeString((yyvsp[(4) - (4)].s)->c_str()); - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); (yyval.code) = (yyvsp[(2) - (4)].code); delete (yyvsp[(4) - (4)].s); ;} break; case 9: -#line 147 "engines/director/lingo/lingo-gr.y" +#line 148 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); (yyval.code) = (yyvsp[(2) - (4)].code); ;} break; case 10: -#line 150 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->code1(g_lingo->c_after); ;} +#line 151 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->code1(g_lc->c_after); ;} break; case 11: -#line 151 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->code1(g_lingo->c_before); ;} +#line 152 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->code1(g_lc->c_before); ;} break; case 12: -#line 152 "engines/director/lingo/lingo-gr.y" +#line 153 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_varpush); + g_lingo->code1(g_lc->c_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); (yyval.code) = (yyvsp[(4) - (4)].code); delete (yyvsp[(2) - (4)].s); ;} break; case 13: -#line 158 "engines/director/lingo/lingo-gr.y" +#line 159 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(0); // Put dummy id - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt((yyvsp[(2) - (4)].e)[0]); g_lingo->codeInt((yyvsp[(2) - (4)].e)[1]); (yyval.code) = (yyvsp[(4) - (4)].code); ;} break; case 14: -#line 165 "engines/director/lingo/lingo-gr.y" +#line 166 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_varpush); + g_lingo->code1(g_lc->c_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); (yyval.code) = (yyvsp[(4) - (4)].code); delete (yyvsp[(2) - (4)].s); ;} break; case 15: -#line 171 "engines/director/lingo/lingo-gr.y" +#line 172 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(0); // Put dummy id - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt((yyvsp[(2) - (4)].e)[0]); g_lingo->codeInt((yyvsp[(2) - (4)].e)[1]); (yyval.code) = (yyvsp[(4) - (4)].code); ;} break; case 16: -#line 178 "engines/director/lingo/lingo-gr.y" +#line 179 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_swap); - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_swap); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt((yyvsp[(2) - (5)].e)[0]); g_lingo->codeInt((yyvsp[(2) - (5)].e)[1]); (yyval.code) = (yyvsp[(5) - (5)].code); ;} break; case 17: -#line 184 "engines/director/lingo/lingo-gr.y" +#line 185 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_swap); - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_swap); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt((yyvsp[(2) - (5)].e)[0]); g_lingo->codeInt((yyvsp[(2) - (5)].e)[1]); (yyval.code) = (yyvsp[(5) - (5)].code); ;} break; case 18: -#line 190 "engines/director/lingo/lingo-gr.y" +#line 191 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_objectfieldassign); + g_lingo->code1(g_lc->c_objectfieldassign); g_lingo->codeString((yyvsp[(2) - (4)].objectfield).s->c_str()); g_lingo->codeInt((yyvsp[(2) - (4)].objectfield).e); (yyval.code) = (yyvsp[(4) - (4)].code); ;} break; case 28: -#line 214 "engines/director/lingo/lingo-gr.y" +#line 215 "engines/director/lingo/lingo-gr.y" { inst body = 0, end = 0; WRITE_UINT32(&body, (yyvsp[(3) - (6)].code) - (yyvsp[(1) - (6)].code)); @@ -2226,7 +2227,7 @@ yyreduce: break; case 29: -#line 225 "engines/director/lingo/lingo-gr.y" +#line 226 "engines/director/lingo/lingo-gr.y" { inst init = 0, finish = 0, body = 0, end = 0, inc = 0; WRITE_UINT32(&init, (yyvsp[(3) - (10)].code) - (yyvsp[(1) - (10)].code)); @@ -2242,7 +2243,7 @@ yyreduce: break; case 30: -#line 242 "engines/director/lingo/lingo-gr.y" +#line 243 "engines/director/lingo/lingo-gr.y" { inst init = 0, finish = 0, body = 0, end = 0, inc = 0; WRITE_UINT32(&init, (yyvsp[(3) - (11)].code) - (yyvsp[(1) - (11)].code)); @@ -2258,7 +2259,7 @@ yyreduce: break; case 31: -#line 254 "engines/director/lingo/lingo-gr.y" +#line 255 "engines/director/lingo/lingo-gr.y" { inst end = 0; WRITE_UINT32(&end, (yyvsp[(3) - (3)].code) - (yyvsp[(1) - (3)].code)); @@ -2267,20 +2268,20 @@ yyreduce: break; case 32: -#line 259 "engines/director/lingo/lingo-gr.y" +#line 260 "engines/director/lingo/lingo-gr.y" { warning("STUB: TELL is not implemented"); ;} break; case 33: -#line 261 "engines/director/lingo/lingo-gr.y" +#line 262 "engines/director/lingo/lingo-gr.y" { warning("STUB: TELL is not implemented"); ;} break; case 34: -#line 266 "engines/director/lingo/lingo-gr.y" +#line 267 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(3) - (9)].code) - (yyvsp[(1) - (9)].code)); @@ -2294,7 +2295,7 @@ yyreduce: break; case 35: -#line 276 "engines/director/lingo/lingo-gr.y" +#line 277 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(3) - (12)].code) - (yyvsp[(1) - (12)].code)); @@ -2308,7 +2309,7 @@ yyreduce: break; case 38: -#line 292 "engines/director/lingo/lingo-gr.y" +#line 293 "engines/director/lingo/lingo-gr.y" { inst then = 0; WRITE_UINT32(&then, (yyvsp[(3) - (6)].code) - (yyvsp[(1) - (6)].code)); @@ -2318,7 +2319,7 @@ yyreduce: break; case 39: -#line 300 "engines/director/lingo/lingo-gr.y" +#line 301 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(3) - (11)].code) - (yyvsp[(1) - (11)].code)); @@ -2332,7 +2333,7 @@ yyreduce: break; case 40: -#line 310 "engines/director/lingo/lingo-gr.y" +#line 311 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(3) - (7)].code) - (yyvsp[(1) - (7)].code)); @@ -2346,142 +2347,142 @@ yyreduce: break; case 41: -#line 323 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->code3(g_lingo->c_repeatwhilecode, STOP, STOP); ;} +#line 324 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->code3(g_lc->c_repeatwhilecode, STOP, STOP); ;} break; case 42: -#line 326 "engines/director/lingo/lingo-gr.y" +#line 327 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code3(g_lingo->c_repeatwithcode, STOP, STOP); + (yyval.code) = g_lingo->code3(g_lc->c_repeatwithcode, STOP, STOP); g_lingo->code3(STOP, STOP, STOP); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} break; case 43: -#line 333 "engines/director/lingo/lingo-gr.y" +#line 334 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_ifcode); + (yyval.code) = g_lingo->code1(g_lc->c_ifcode); g_lingo->code3(STOP, STOP, STOP); g_lingo->code1(0); // Do not skip end g_lingo->codeLabel(0); ;} break; case 44: -#line 340 "engines/director/lingo/lingo-gr.y" +#line 341 "engines/director/lingo/lingo-gr.y" { inst skipEnd; WRITE_UINT32(&skipEnd, 1); // We have to skip end to avoid multiple executions - (yyval.code) = g_lingo->code1(g_lingo->c_ifcode); + (yyval.code) = g_lingo->code1(g_lc->c_ifcode); g_lingo->code3(STOP, STOP, STOP); g_lingo->code1(skipEnd); ;} break; case 45: -#line 348 "engines/director/lingo/lingo-gr.y" +#line 349 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->_currentScript->size(); ;} break; case 46: -#line 351 "engines/director/lingo/lingo-gr.y" +#line 352 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;} break; case 47: -#line 354 "engines/director/lingo/lingo-gr.y" +#line 355 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->_currentScript->size(); ;} break; case 50: -#line 359 "engines/director/lingo/lingo-gr.y" +#line 360 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_whencode); + (yyval.code) = g_lingo->code1(g_lc->c_whencode); g_lingo->code1(STOP); g_lingo->codeString((yyvsp[(2) - (3)].s)->c_str()); delete (yyvsp[(2) - (3)].s); ;} break; case 51: -#line 365 "engines/director/lingo/lingo-gr.y" +#line 366 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_tellcode); + (yyval.code) = g_lingo->code1(g_lc->c_tellcode); g_lingo->code1(STOP); ;} break; case 52: -#line 369 "engines/director/lingo/lingo-gr.y" +#line 370 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_intpush); + (yyval.code) = g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt((yyvsp[(1) - (1)].i)); ;} break; case 53: -#line 372 "engines/director/lingo/lingo-gr.y" +#line 373 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_floatpush); + (yyval.code) = g_lingo->code1(g_lc->c_floatpush); g_lingo->codeFloat((yyvsp[(1) - (1)].f)); ;} break; case 54: -#line 375 "engines/director/lingo/lingo-gr.y" +#line 376 "engines/director/lingo/lingo-gr.y" { // D3 - (yyval.code) = g_lingo->code1(g_lingo->c_symbolpush); + (yyval.code) = g_lingo->code1(g_lc->c_symbolpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); ;} break; case 55: -#line 378 "engines/director/lingo/lingo-gr.y" +#line 379 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_stringpush); + (yyval.code) = g_lingo->code1(g_lc->c_stringpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); ;} break; case 56: -#line 381 "engines/director/lingo/lingo-gr.y" +#line 382 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_eval); + (yyval.code) = g_lingo->code1(g_lc->c_eval); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} break; case 57: -#line 387 "engines/director/lingo/lingo-gr.y" +#line 388 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(1) - (1)].code); ;} break; case 59: -#line 389 "engines/director/lingo/lingo-gr.y" +#line 390 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (1)].s), 0); delete (yyvsp[(1) - (1)].s); ;} break; case 60: -#line 392 "engines/director/lingo/lingo-gr.y" +#line 393 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (2)].s), 1); delete (yyvsp[(1) - (2)].s); ;} break; case 61: -#line 395 "engines/director/lingo/lingo-gr.y" +#line 396 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (2)].s), (yyvsp[(2) - (2)].narg)); ;} break; case 62: -#line 396 "engines/director/lingo/lingo-gr.y" +#line 397 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->codeFunc((yyvsp[(1) - (4)].s), (yyvsp[(3) - (4)].narg)); delete (yyvsp[(1) - (4)].s); ;} break; case 63: -#line 399 "engines/director/lingo/lingo-gr.y" +#line 400 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_intpush); + (yyval.code) = g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(0); // Put dummy id - g_lingo->code1(g_lingo->c_theentitypush); + g_lingo->code1(g_lc->c_theentitypush); inst e = 0, f = 0; WRITE_UINT32(&e, (yyvsp[(1) - (1)].e)[0]); WRITE_UINT32(&f, (yyvsp[(1) - (1)].e)[1]); @@ -2489,9 +2490,9 @@ yyreduce: break; case 64: -#line 407 "engines/director/lingo/lingo-gr.y" +#line 408 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code1(g_lingo->c_theentitypush); + (yyval.code) = g_lingo->code1(g_lc->c_theentitypush); inst e = 0, f = 0; WRITE_UINT32(&e, (yyvsp[(1) - (2)].e)[0]); WRITE_UINT32(&f, (yyvsp[(1) - (2)].e)[1]); @@ -2499,406 +2500,406 @@ yyreduce: break; case 65: -#line 413 "engines/director/lingo/lingo-gr.y" +#line 414 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_objectfieldpush); + g_lingo->code1(g_lc->c_objectfieldpush); g_lingo->codeString((yyvsp[(1) - (1)].objectfield).s->c_str()); g_lingo->codeInt((yyvsp[(1) - (1)].objectfield).e); ;} break; case 67: -#line 418 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_add); ;} +#line 419 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_add); ;} break; case 68: -#line 419 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_sub); ;} +#line 420 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_sub); ;} break; case 69: -#line 420 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_mul); ;} +#line 421 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_mul); ;} break; case 70: -#line 421 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_div); ;} +#line 422 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_div); ;} break; case 71: -#line 422 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_mod); ;} +#line 423 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_mod); ;} break; case 72: -#line 423 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_gt); ;} +#line 424 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_gt); ;} break; case 73: -#line 424 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_lt); ;} +#line 425 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_lt); ;} break; case 74: -#line 425 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_eq); ;} +#line 426 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_eq); ;} break; case 75: -#line 426 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_neq); ;} +#line 427 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_neq); ;} break; case 76: -#line 427 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_ge); ;} +#line 428 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_ge); ;} break; case 77: -#line 428 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_le); ;} +#line 429 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_le); ;} break; case 78: -#line 429 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_and); ;} +#line 430 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_and); ;} break; case 79: -#line 430 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_or); ;} +#line 431 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_or); ;} break; case 80: -#line 431 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_not); ;} +#line 432 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_not); ;} break; case 81: -#line 432 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_ampersand); ;} +#line 433 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_ampersand); ;} break; case 82: -#line 433 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_concat); ;} +#line 434 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_concat); ;} break; case 83: -#line 434 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_contains); ;} +#line 435 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_contains); ;} break; case 84: -#line 435 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_starts); ;} +#line 436 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_starts); ;} break; case 85: -#line 436 "engines/director/lingo/lingo-gr.y" +#line 437 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (2)].code); ;} break; case 86: -#line 437 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;} +#line 438 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lc->c_negate); ;} break; case 87: -#line 438 "engines/director/lingo/lingo-gr.y" +#line 439 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (3)].code); ;} break; case 88: -#line 439 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->code1(g_lingo->c_arraypush); g_lingo->codeArray((yyvsp[(2) - (3)].narg)); ;} +#line 440 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->code1(g_lc->c_arraypush); g_lingo->codeArray((yyvsp[(2) - (3)].narg)); ;} break; case 89: -#line 440 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_intersects); ;} +#line 441 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_intersects); ;} break; case 90: -#line 441 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_within); ;} +#line 442 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_within); ;} break; case 91: -#line 442 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_charOf); ;} +#line 443 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_charOf); ;} break; case 92: -#line 443 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_charToOf); ;} +#line 444 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_charToOf); ;} break; case 93: -#line 444 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_itemOf); ;} +#line 445 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_itemOf); ;} break; case 94: -#line 445 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_itemToOf); ;} +#line 446 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_itemToOf); ;} break; case 95: -#line 446 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_lineOf); ;} +#line 447 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_lineOf); ;} break; case 96: -#line 447 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_lineToOf); ;} +#line 448 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_lineToOf); ;} break; case 97: -#line 448 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_wordOf); ;} +#line 449 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_wordOf); ;} break; case 98: -#line 449 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_wordToOf); ;} +#line 450 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_wordToOf); ;} break; case 99: -#line 450 "engines/director/lingo/lingo-gr.y" +#line 451 "engines/director/lingo/lingo-gr.y" { g_lingo->codeMe((yyvsp[(3) - (4)].s), 0); ;} break; case 100: -#line 451 "engines/director/lingo/lingo-gr.y" +#line 452 "engines/director/lingo/lingo-gr.y" { g_lingo->codeMe((yyvsp[(3) - (6)].s), (yyvsp[(5) - (6)].narg)); ;} break; case 101: -#line 452 "engines/director/lingo/lingo-gr.y" +#line 453 "engines/director/lingo/lingo-gr.y" { g_lingo->codeMe(nullptr, 0); ;} break; case 102: -#line 455 "engines/director/lingo/lingo-gr.y" +#line 456 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (2)].s), 1); delete (yyvsp[(1) - (2)].s); ;} break; case 103: -#line 460 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_printtop); ;} +#line 461 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_printtop); ;} break; case 106: -#line 463 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_exitRepeat); ;} +#line 464 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_exitRepeat); ;} break; case 107: -#line 464 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_procret); ;} +#line 465 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_procret); ;} break; case 111: -#line 468 "engines/director/lingo/lingo-gr.y" +#line 469 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (1)].s), 0); delete (yyvsp[(1) - (1)].s); ;} break; case 112: -#line 471 "engines/director/lingo/lingo-gr.y" +#line 472 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (2)].s), 1); delete (yyvsp[(1) - (2)].s); ;} break; case 113: -#line 474 "engines/director/lingo/lingo-gr.y" +#line 475 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (2)].s), 1); delete (yyvsp[(1) - (2)].s); ;} break; case 114: -#line 477 "engines/director/lingo/lingo-gr.y" +#line 478 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_voidpush); + g_lingo->code1(g_lc->c_voidpush); g_lingo->codeFunc((yyvsp[(1) - (1)].s), 1); delete (yyvsp[(1) - (1)].s); ;} break; case 115: -#line 481 "engines/director/lingo/lingo-gr.y" +#line 482 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFunc((yyvsp[(1) - (2)].s), (yyvsp[(2) - (2)].narg)); ;} break; case 116: -#line 482 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_open); ;} +#line 483 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_open); ;} break; case 117: -#line 483 "engines/director/lingo/lingo-gr.y" - { g_lingo->code2(g_lingo->c_voidpush, g_lingo->c_open); ;} +#line 484 "engines/director/lingo/lingo-gr.y" + { g_lingo->code2(g_lc->c_voidpush, g_lc->c_open); ;} break; case 118: -#line 484 "engines/director/lingo/lingo-gr.y" +#line 485 "engines/director/lingo/lingo-gr.y" { Common::String s(*(yyvsp[(1) - (3)].s)); s += '-'; s += *(yyvsp[(2) - (3)].s); g_lingo->codeFunc(&s, (yyvsp[(3) - (3)].narg)); ;} break; case 119: -#line 487 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_global); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} +#line 488 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_global); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} break; case 120: -#line 488 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_global); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} +#line 489 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_global); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} break; case 121: -#line 491 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_property); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} +#line 492 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_property); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} break; case 122: -#line 492 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_property); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} +#line 493 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_property); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} break; case 123: -#line 495 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_instance); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} +#line 496 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_instance); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} break; case 124: -#line 496 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_instance); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} +#line 497 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_instance); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} break; case 125: -#line 507 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_gotoloop); ;} +#line 508 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_gotoloop); ;} break; case 126: -#line 508 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_gotonext); ;} +#line 509 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_gotonext); ;} break; case 127: -#line 509 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_gotoprevious); ;} +#line 510 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_gotoprevious); ;} break; case 128: -#line 510 "engines/director/lingo/lingo-gr.y" +#line 511 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(1); - g_lingo->code1(g_lingo->c_goto); ;} + g_lingo->code1(g_lc->c_goto); ;} break; case 129: -#line 514 "engines/director/lingo/lingo-gr.y" +#line 515 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(3); - g_lingo->code1(g_lingo->c_goto); ;} + g_lingo->code1(g_lc->c_goto); ;} break; case 130: -#line 518 "engines/director/lingo/lingo-gr.y" +#line 519 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(2); - g_lingo->code1(g_lingo->c_goto); ;} + g_lingo->code1(g_lc->c_goto); ;} break; case 133: -#line 528 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_playdone); ;} +#line 529 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lc->c_playdone); ;} break; case 134: -#line 529 "engines/director/lingo/lingo-gr.y" +#line 530 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(1); - g_lingo->code1(g_lingo->c_play); ;} + g_lingo->code1(g_lc->c_play); ;} break; case 135: -#line 533 "engines/director/lingo/lingo-gr.y" +#line 534 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(3); - g_lingo->code1(g_lingo->c_play); ;} + g_lingo->code1(g_lc->c_play); ;} break; case 136: -#line 537 "engines/director/lingo/lingo-gr.y" +#line 538 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(2); - g_lingo->code1(g_lingo->c_play); ;} + g_lingo->code1(g_lc->c_play); ;} break; case 137: -#line 541 "engines/director/lingo/lingo-gr.y" +#line 542 "engines/director/lingo/lingo-gr.y" { g_lingo->codeSetImmediate(true); ;} break; case 138: -#line 541 "engines/director/lingo/lingo-gr.y" +#line 542 "engines/director/lingo/lingo-gr.y" { g_lingo->codeSetImmediate(false); g_lingo->codeFunc((yyvsp[(1) - (3)].s), (yyvsp[(3) - (3)].narg)); ;} break; case 139: -#line 571 "engines/director/lingo/lingo-gr.y" +#line 572 "engines/director/lingo/lingo-gr.y" { g_lingo->_indef = kStateInArgs; g_lingo->_currentFactory.clear(); ;} break; case 140: -#line 572 "engines/director/lingo/lingo-gr.y" +#line 573 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*(yyvsp[(2) - (8)].s), (yyvsp[(4) - (8)].code), (yyvsp[(5) - (8)].narg)); g_lingo->clearArgStack(); g_lingo->_indef = kStateNone; ;} break; case 141: -#line 577 "engines/director/lingo/lingo-gr.y" +#line 578 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFactory(*(yyvsp[(2) - (2)].s)); ;} break; case 142: -#line 578 "engines/director/lingo/lingo-gr.y" +#line 579 "engines/director/lingo/lingo-gr.y" { g_lingo->_indef = kStateInArgs; ;} break; case 143: -#line 579 "engines/director/lingo/lingo-gr.y" +#line 580 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*(yyvsp[(1) - (7)].s), (yyvsp[(3) - (7)].code), (yyvsp[(4) - (7)].narg) + 1, &g_lingo->_currentFactory); g_lingo->clearArgStack(); g_lingo->_indef = kStateNone; ;} break; case 144: -#line 584 "engines/director/lingo/lingo-gr.y" +#line 585 "engines/director/lingo/lingo-gr.y" { // D3 - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*(yyvsp[(1) - (8)].s), (yyvsp[(2) - (8)].code), (yyvsp[(3) - (8)].narg)); g_lingo->clearArgStack(); g_lingo->_indef = kStateNone; @@ -2908,9 +2909,9 @@ yyreduce: break; case 145: -#line 592 "engines/director/lingo/lingo-gr.y" +#line 593 "engines/director/lingo/lingo-gr.y" { // D4. No 'end' clause - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*(yyvsp[(1) - (6)].s), (yyvsp[(2) - (6)].code), (yyvsp[(3) - (6)].narg)); g_lingo->_indef = kStateNone; g_lingo->clearArgStack(); @@ -2918,39 +2919,39 @@ yyreduce: break; case 146: -#line 599 "engines/director/lingo/lingo-gr.y" +#line 600 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); g_lingo->_indef = kStateInArgs; g_lingo->_currentFactory.clear(); g_lingo->_ignoreMe = true; ;} break; case 147: -#line 601 "engines/director/lingo/lingo-gr.y" +#line 602 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; case 148: -#line 602 "engines/director/lingo/lingo-gr.y" +#line 603 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(1) - (1)].s)); (yyval.narg) = 1; ;} break; case 149: -#line 603 "engines/director/lingo/lingo-gr.y" +#line 604 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(3) - (3)].s)); (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; case 150: -#line 604 "engines/director/lingo/lingo-gr.y" +#line 605 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(4) - (4)].s)); (yyval.narg) = (yyvsp[(1) - (4)].narg) + 1; ;} break; case 154: -#line 612 "engines/director/lingo/lingo-gr.y" +#line 613 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArgStore(); g_lingo->_indef = kStateInDef; ;} break; case 155: -#line 615 "engines/director/lingo/lingo-gr.y" +#line 616 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_call); + g_lingo->code1(g_lc->c_call); g_lingo->codeString((yyvsp[(1) - (2)].s)->c_str()); inst numpar = 0; WRITE_UINT32(&numpar, (yyvsp[(2) - (2)].narg)); @@ -2958,33 +2959,33 @@ yyreduce: break; case 156: -#line 623 "engines/director/lingo/lingo-gr.y" +#line 624 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; case 157: -#line 624 "engines/director/lingo/lingo-gr.y" +#line 625 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 1; ;} break; case 158: -#line 625 "engines/director/lingo/lingo-gr.y" +#line 626 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; case 159: -#line 628 "engines/director/lingo/lingo-gr.y" +#line 629 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 1; ;} break; case 160: -#line 629 "engines/director/lingo/lingo-gr.y" +#line 630 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; /* Line 1267 of yacc.c. */ -#line 2988 "engines/director/lingo/lingo-gr.cpp" +#line 2989 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -3198,6 +3199,6 @@ yyreturn: } -#line 632 "engines/director/lingo/lingo-gr.y" +#line 633 "engines/director/lingo/lingo-gr.y" diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h index 0441764eb3..d73b6f4294 100644 --- a/engines/director/lingo/lingo-gr.h +++ b/engines/director/lingo/lingo-gr.h @@ -228,7 +228,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 84 "engines/director/lingo/lingo-gr.y" +#line 85 "engines/director/lingo/lingo-gr.y" { Common::String *s; int i; diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index e8b667d67c..697d6f1e7e 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -57,6 +57,7 @@ #include "common/rect.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" #include "director/lingo/lingo-gr.h" extern int yylex(); @@ -139,56 +140,56 @@ programline: /* empty */ ; asgn: tPUT expr tINTO ID { - g_lingo->code1(g_lingo->c_varpush); + g_lingo->code1(g_lc->c_varpush); g_lingo->codeString($4->c_str()); - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); $$ = $2; delete $4; } | tPUT expr tINTO reference { - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); $$ = $2; } - | tPUT expr tAFTER expr { $$ = g_lingo->code1(g_lingo->c_after); } // D3 - | tPUT expr tBEFORE expr { $$ = g_lingo->code1(g_lingo->c_before); } // D3 + | tPUT expr tAFTER expr { $$ = g_lingo->code1(g_lc->c_after); } // D3 + | tPUT expr tBEFORE expr { $$ = g_lingo->code1(g_lc->c_before); } // D3 | tSET ID tEQ expr { - g_lingo->code1(g_lingo->c_varpush); + g_lingo->code1(g_lc->c_varpush); g_lingo->codeString($2->c_str()); - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); $$ = $4; delete $2; } | tSET THEENTITY tEQ expr { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(0); // Put dummy id - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt($2[0]); g_lingo->codeInt($2[1]); $$ = $4; } | tSET ID tTO expr { - g_lingo->code1(g_lingo->c_varpush); + g_lingo->code1(g_lc->c_varpush); g_lingo->codeString($2->c_str()); - g_lingo->code1(g_lingo->c_assign); + g_lingo->code1(g_lc->c_assign); $$ = $4; delete $2; } | tSET THEENTITY tTO expr { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(0); // Put dummy id - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt($2[0]); g_lingo->codeInt($2[1]); $$ = $4; } | tSET THEENTITYWITHID expr tTO expr { - g_lingo->code1(g_lingo->c_swap); - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_swap); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt($2[0]); g_lingo->codeInt($2[1]); $$ = $5; } | tSET THEENTITYWITHID simpleexpr tEQ expr { - g_lingo->code1(g_lingo->c_swap); - g_lingo->code1(g_lingo->c_theentityassign); + g_lingo->code1(g_lc->c_swap); + g_lingo->code1(g_lc->c_theentityassign); g_lingo->codeInt($2[0]); g_lingo->codeInt($2[1]); $$ = $5; } | tSET THEOBJECTFIELD tTO expr { - g_lingo->code1(g_lingo->c_objectfieldassign); + g_lingo->code1(g_lc->c_objectfieldassign); g_lingo->codeString($2.s->c_str()); g_lingo->codeInt($2.e); $$ = $4; } @@ -320,18 +321,18 @@ ifoneliner: if expr end tTHEN stmtoneliner end tELSE begin stmtoneliner end tEND ; -repeatwhile: tREPEAT tWHILE { $$ = g_lingo->code3(g_lingo->c_repeatwhilecode, STOP, STOP); } +repeatwhile: tREPEAT tWHILE { $$ = g_lingo->code3(g_lc->c_repeatwhilecode, STOP, STOP); } ; repeatwith: tREPEAT tWITH ID { - $$ = g_lingo->code3(g_lingo->c_repeatwithcode, STOP, STOP); + $$ = g_lingo->code3(g_lc->c_repeatwithcode, STOP, STOP); g_lingo->code3(STOP, STOP, STOP); g_lingo->codeString($3->c_str()); delete $3; } ; if: tIF { - $$ = g_lingo->code1(g_lingo->c_ifcode); + $$ = g_lingo->code1(g_lc->c_ifcode); g_lingo->code3(STOP, STOP, STOP); g_lingo->code1(0); // Do not skip end g_lingo->codeLabel(0); } // Mark beginning of the if() statement @@ -340,7 +341,7 @@ if: tIF { elseif: tELSIF { inst skipEnd; WRITE_UINT32(&skipEnd, 1); // We have to skip end to avoid multiple executions - $$ = g_lingo->code1(g_lingo->c_ifcode); + $$ = g_lingo->code1(g_lc->c_ifcode); g_lingo->code3(STOP, STOP, STOP); g_lingo->code1(skipEnd); } ; @@ -357,29 +358,29 @@ stmtlist: { $$ = g_lingo->_currentScript->size(); } ; when: tWHEN ID tTHEN { - $$ = g_lingo->code1(g_lingo->c_whencode); + $$ = g_lingo->code1(g_lc->c_whencode); g_lingo->code1(STOP); g_lingo->codeString($2->c_str()); delete $2; } tell: tTELL { - $$ = g_lingo->code1(g_lingo->c_tellcode); + $$ = g_lingo->code1(g_lc->c_tellcode); g_lingo->code1(STOP); } simpleexpr: INT { - $$ = g_lingo->code1(g_lingo->c_intpush); + $$ = g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt($1); } | FLOAT { - $$ = g_lingo->code1(g_lingo->c_floatpush); + $$ = g_lingo->code1(g_lc->c_floatpush); g_lingo->codeFloat($1); } | SYMBOL { // D3 - $$ = g_lingo->code1(g_lingo->c_symbolpush); + $$ = g_lingo->code1(g_lc->c_symbolpush); g_lingo->codeString($1->c_str()); } | STRING { - $$ = g_lingo->code1(g_lingo->c_stringpush); + $$ = g_lingo->code1(g_lc->c_stringpush); g_lingo->codeString($1->c_str()); } | ID { - $$ = g_lingo->code1(g_lingo->c_eval); + $$ = g_lingo->code1(g_lc->c_eval); g_lingo->codeString($1->c_str()); delete $1; } ; @@ -397,56 +398,56 @@ expr: simpleexpr { $$ = $1; } $$ = g_lingo->codeFunc($1, $3); delete $1; } | THEENTITY { - $$ = g_lingo->code1(g_lingo->c_intpush); + $$ = g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(0); // Put dummy id - g_lingo->code1(g_lingo->c_theentitypush); + g_lingo->code1(g_lc->c_theentitypush); inst e = 0, f = 0; WRITE_UINT32(&e, $1[0]); WRITE_UINT32(&f, $1[1]); g_lingo->code2(e, f); } | THEENTITYWITHID expr { - $$ = g_lingo->code1(g_lingo->c_theentitypush); + $$ = g_lingo->code1(g_lc->c_theentitypush); inst e = 0, f = 0; WRITE_UINT32(&e, $1[0]); WRITE_UINT32(&f, $1[1]); g_lingo->code2(e, f); } | THEOBJECTFIELD { - g_lingo->code1(g_lingo->c_objectfieldpush); + g_lingo->code1(g_lc->c_objectfieldpush); g_lingo->codeString($1.s->c_str()); g_lingo->codeInt($1.e); } | asgn - | expr '+' expr { g_lingo->code1(g_lingo->c_add); } - | expr '-' expr { g_lingo->code1(g_lingo->c_sub); } - | expr '*' expr { g_lingo->code1(g_lingo->c_mul); } - | expr '/' expr { g_lingo->code1(g_lingo->c_div); } - | expr tMOD expr { g_lingo->code1(g_lingo->c_mod); } - | expr '>' expr { g_lingo->code1(g_lingo->c_gt); } - | expr '<' expr { g_lingo->code1(g_lingo->c_lt); } - | expr tEQ expr { g_lingo->code1(g_lingo->c_eq); } - | expr tNEQ expr { g_lingo->code1(g_lingo->c_neq); } - | expr tGE expr { g_lingo->code1(g_lingo->c_ge); } - | expr tLE expr { g_lingo->code1(g_lingo->c_le); } - | expr tAND expr { g_lingo->code1(g_lingo->c_and); } - | expr tOR expr { g_lingo->code1(g_lingo->c_or); } - | tNOT expr %prec UNARY { g_lingo->code1(g_lingo->c_not); } - | expr '&' expr { g_lingo->code1(g_lingo->c_ampersand); } - | expr tCONCAT expr { g_lingo->code1(g_lingo->c_concat); } - | expr tCONTAINS expr { g_lingo->code1(g_lingo->c_contains); } - | expr tSTARTS expr { g_lingo->code1(g_lingo->c_starts); } + | expr '+' expr { g_lingo->code1(g_lc->c_add); } + | expr '-' expr { g_lingo->code1(g_lc->c_sub); } + | expr '*' expr { g_lingo->code1(g_lc->c_mul); } + | expr '/' expr { g_lingo->code1(g_lc->c_div); } + | expr tMOD expr { g_lingo->code1(g_lc->c_mod); } + | expr '>' expr { g_lingo->code1(g_lc->c_gt); } + | expr '<' expr { g_lingo->code1(g_lc->c_lt); } + | expr tEQ expr { g_lingo->code1(g_lc->c_eq); } + | expr tNEQ expr { g_lingo->code1(g_lc->c_neq); } + | expr tGE expr { g_lingo->code1(g_lc->c_ge); } + | expr tLE expr { g_lingo->code1(g_lc->c_le); } + | expr tAND expr { g_lingo->code1(g_lc->c_and); } + | expr tOR expr { g_lingo->code1(g_lc->c_or); } + | tNOT expr %prec UNARY { g_lingo->code1(g_lc->c_not); } + | expr '&' expr { g_lingo->code1(g_lc->c_ampersand); } + | expr tCONCAT expr { g_lingo->code1(g_lc->c_concat); } + | expr tCONTAINS expr { g_lingo->code1(g_lc->c_contains); } + | expr tSTARTS expr { g_lingo->code1(g_lc->c_starts); } | '+' expr %prec UNARY { $$ = $2; } - | '-' expr %prec UNARY { $$ = $2; g_lingo->code1(g_lingo->c_negate); } + | '-' expr %prec UNARY { $$ = $2; g_lingo->code1(g_lc->c_negate); } | '(' expr ')' { $$ = $2; } - | '[' arglist ']' { $$ = g_lingo->code1(g_lingo->c_arraypush); g_lingo->codeArray($2); } - | tSPRITE expr tINTERSECTS expr { g_lingo->code1(g_lingo->c_intersects); } - | tSPRITE expr tWITHIN expr { g_lingo->code1(g_lingo->c_within); } - | tCHAR expr tOF expr { g_lingo->code1(g_lingo->c_charOf); } - | tCHAR expr tTO expr tOF expr { g_lingo->code1(g_lingo->c_charToOf); } - | tITEM expr tOF expr { g_lingo->code1(g_lingo->c_itemOf); } - | tITEM expr tTO expr tOF expr { g_lingo->code1(g_lingo->c_itemToOf); } - | tLINE expr tOF expr { g_lingo->code1(g_lingo->c_lineOf); } - | tLINE expr tTO expr tOF expr { g_lingo->code1(g_lingo->c_lineToOf); } - | tWORD expr tOF expr { g_lingo->code1(g_lingo->c_wordOf); } - | tWORD expr tTO expr tOF expr { g_lingo->code1(g_lingo->c_wordToOf); } + | '[' arglist ']' { $$ = g_lingo->code1(g_lc->c_arraypush); g_lingo->codeArray($2); } + | tSPRITE expr tINTERSECTS expr { g_lingo->code1(g_lc->c_intersects); } + | tSPRITE expr tWITHIN expr { g_lingo->code1(g_lc->c_within); } + | tCHAR expr tOF expr { g_lingo->code1(g_lc->c_charOf); } + | tCHAR expr tTO expr tOF expr { g_lingo->code1(g_lc->c_charToOf); } + | tITEM expr tOF expr { g_lingo->code1(g_lc->c_itemOf); } + | tITEM expr tTO expr tOF expr { g_lingo->code1(g_lc->c_itemToOf); } + | tLINE expr tOF expr { g_lingo->code1(g_lc->c_lineOf); } + | tLINE expr tTO expr tOF expr { g_lingo->code1(g_lc->c_lineToOf); } + | tWORD expr tOF expr { g_lingo->code1(g_lc->c_wordOf); } + | tWORD expr tTO expr tOF expr { g_lingo->code1(g_lc->c_wordToOf); } | tME '(' ID ')' { g_lingo->codeMe($3, 0); } | tME '(' ID ',' arglist ')' { g_lingo->codeMe($3, $5); } | tME { g_lingo->codeMe(nullptr, 0); } @@ -457,11 +458,11 @@ reference: RBLTINONEARG simpleexpr { delete $1; } ; -proc: tPUT expr { g_lingo->code1(g_lingo->c_printtop); } +proc: tPUT expr { g_lingo->code1(g_lc->c_printtop); } | gotofunc | playfunc - | tEXIT tREPEAT { g_lingo->code1(g_lingo->c_exitRepeat); } - | tEXIT { g_lingo->code1(g_lingo->c_procret); } + | tEXIT tREPEAT { g_lingo->code1(g_lc->c_exitRepeat); } + | tEXIT { g_lingo->code1(g_lc->c_procret); } | tGLOBAL globallist | tPROPERTY propertylist | tINSTANCE instancelist @@ -475,25 +476,25 @@ proc: tPUT expr { g_lingo->code1(g_lingo->c_printtop); } g_lingo->codeFunc($1, 1); delete $1; } | BLTINNOARGSORONE { - g_lingo->code1(g_lingo->c_voidpush); + g_lingo->code1(g_lc->c_voidpush); g_lingo->codeFunc($1, 1); delete $1; } | BLTINARGLIST arglist { g_lingo->codeFunc($1, $2); } - | tOPEN expr tWITH expr { g_lingo->code1(g_lingo->c_open); } - | tOPEN expr { g_lingo->code2(g_lingo->c_voidpush, g_lingo->c_open); } + | tOPEN expr tWITH expr { g_lingo->code1(g_lc->c_open); } + | tOPEN expr { g_lingo->code2(g_lc->c_voidpush, g_lc->c_open); } | TWOWORDBUILTIN ID arglist { Common::String s(*$1); s += '-'; s += *$2; g_lingo->codeFunc(&s, $3); } ; -globallist: ID { g_lingo->code1(g_lingo->c_global); g_lingo->codeString($1->c_str()); delete $1; } - | globallist ',' ID { g_lingo->code1(g_lingo->c_global); g_lingo->codeString($3->c_str()); delete $3; } +globallist: ID { g_lingo->code1(g_lc->c_global); g_lingo->codeString($1->c_str()); delete $1; } + | globallist ',' ID { g_lingo->code1(g_lc->c_global); g_lingo->codeString($3->c_str()); delete $3; } ; -propertylist: ID { g_lingo->code1(g_lingo->c_property); g_lingo->codeString($1->c_str()); delete $1; } - | propertylist ',' ID { g_lingo->code1(g_lingo->c_property); g_lingo->codeString($3->c_str()); delete $3; } +propertylist: ID { g_lingo->code1(g_lc->c_property); g_lingo->codeString($1->c_str()); delete $1; } + | propertylist ',' ID { g_lingo->code1(g_lc->c_property); g_lingo->codeString($3->c_str()); delete $3; } ; -instancelist: ID { g_lingo->code1(g_lingo->c_instance); g_lingo->codeString($1->c_str()); delete $1; } - | instancelist ',' ID { g_lingo->code1(g_lingo->c_instance); g_lingo->codeString($3->c_str()); delete $3; } +instancelist: ID { g_lingo->code1(g_lc->c_instance); g_lingo->codeString($1->c_str()); delete $1; } + | instancelist ',' ID { g_lingo->code1(g_lc->c_instance); g_lingo->codeString($3->c_str()); delete $3; } ; // go {to} {frame} whichFrame {of movie whichMovie} @@ -504,40 +505,40 @@ instancelist: ID { g_lingo->code1(g_lingo->c_instance); g_lingo->codeString($ // go to {frame} whichFrame {of movie whichMovie} // go to {frame whichFrame of} movie whichMovie -gotofunc: tGO tLOOP { g_lingo->code1(g_lingo->c_gotoloop); } - | tGO tNEXT { g_lingo->code1(g_lingo->c_gotonext); } - | tGO tPREVIOUS { g_lingo->code1(g_lingo->c_gotoprevious); } +gotofunc: tGO tLOOP { g_lingo->code1(g_lc->c_gotoloop); } + | tGO tNEXT { g_lingo->code1(g_lc->c_gotonext); } + | tGO tPREVIOUS { g_lingo->code1(g_lc->c_gotoprevious); } | tGO expr { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(1); - g_lingo->code1(g_lingo->c_goto); } + g_lingo->code1(g_lc->c_goto); } | tGO expr gotomovie { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(3); - g_lingo->code1(g_lingo->c_goto); } + g_lingo->code1(g_lc->c_goto); } | tGO gotomovie { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(2); - g_lingo->code1(g_lingo->c_goto); } + g_lingo->code1(g_lc->c_goto); } ; gotomovie: tOF tMOVIE expr | tMOVIE expr ; -playfunc: tPLAY tDONE { g_lingo->code1(g_lingo->c_playdone); } +playfunc: tPLAY tDONE { g_lingo->code1(g_lc->c_playdone); } | tPLAY expr { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(1); - g_lingo->code1(g_lingo->c_play); } + g_lingo->code1(g_lc->c_play); } | tPLAY expr gotomovie { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(3); - g_lingo->code1(g_lingo->c_play); } + g_lingo->code1(g_lc->c_play); } | tPLAY gotomovie { - g_lingo->code1(g_lingo->c_intpush); + g_lingo->code1(g_lc->c_intpush); g_lingo->codeInt(2); - g_lingo->code1(g_lingo->c_play); } + g_lingo->code1(g_lc->c_play); } | tPLAYACCEL { g_lingo->codeSetImmediate(true); } arglist { g_lingo->codeSetImmediate(false); g_lingo->codeFunc($1, $3); } @@ -570,19 +571,19 @@ playfunc: tPLAY tDONE { g_lingo->code1(g_lingo->c_playdone); } // on keyword defn: tMACRO ID { g_lingo->_indef = kStateInArgs; g_lingo->_currentFactory.clear(); } begin argdef '\n' argstore stmtlist { - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*$2, $4, $5); g_lingo->clearArgStack(); g_lingo->_indef = kStateNone; } | tFACTORY ID { g_lingo->codeFactory(*$2); } | tMETHOD { g_lingo->_indef = kStateInArgs; } begin argdef '\n' argstore stmtlist { - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*$1, $3, $4 + 1, &g_lingo->_currentFactory); g_lingo->clearArgStack(); g_lingo->_indef = kStateNone; } | on begin argdef '\n' argstore stmtlist ENDCLAUSE endargdef { // D3 - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*$1, $2, $3); g_lingo->clearArgStack(); g_lingo->_indef = kStateNone; @@ -590,7 +591,7 @@ defn: tMACRO ID { g_lingo->_indef = kStateInArgs; g_lingo->_currentFactory.clear checkEnd($7, $1->c_str(), false); } | on begin argdef '\n' argstore stmtlist { // D4. No 'end' clause - g_lingo->code1(g_lingo->c_procret); + g_lingo->code1(g_lc->c_procret); g_lingo->define(*$1, $2, $3); g_lingo->_indef = kStateNone; g_lingo->clearArgStack(); @@ -613,7 +614,7 @@ argstore: /* nothing */ { g_lingo->codeArgStore(); g_lingo->_indef = kStateIn ; macro: ID nonemptyarglist { - g_lingo->code1(g_lingo->c_call); + g_lingo->code1(g_lc->c_call); g_lingo->codeString($1->c_str()); inst numpar = 0; WRITE_UINT32(&numpar, $2); diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index 3f9f4fc204..1db39272f0 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -25,6 +25,7 @@ #include "director/director.h" #include "director/lingo/lingo.h" +#include "director/lingo/lingo-code.h" #include "director/cast.h" #include "director/frame.h" #include "director/score.h" @@ -46,6 +47,10 @@ Symbol::Symbol() { Lingo::Lingo(DirectorEngine *vm) : _vm(vm) { g_lingo = this; + _lc = new LC; + + g_lc = _lc; + _currentScript = 0; _currentScriptType = kMovieScript; _currentEntityId = 0; diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 644089ddcf..264ceb30d4 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -42,6 +42,7 @@ struct TheEntityField; struct LingoV4Bytecode; struct LingoV4TheEntity; class DirectorEngine; +class LC; class Frame; @@ -178,6 +179,9 @@ struct CFrame { /* proc/func call stack frame */ }; class Lingo { + +friend class LC; + public: Lingo(DirectorEngine *vm); ~Lingo(); @@ -269,113 +273,6 @@ public: void pushVoid(); - static void c_xpop(); - static void c_printtop(); - - static void c_add(); - static void c_sub(); - static void c_mul(); - static void c_div(); - static void c_mod(); - static void c_negate(); - - static void c_and(); - static void c_or(); - static void c_not(); - - static void c_ampersand(); - static void c_after(); - static void c_before(); - static void c_concat(); - static void c_contains(); - static void c_starts(); - - static void c_intersects(); - static void c_within(); - static void c_field(); - static void c_of(); - static void c_charOf(); - static void c_charToOf(); - static void c_itemOf(); - static void c_itemToOf(); - static void c_lineOf(); - static void c_lineToOf(); - static void c_wordOf(); - static void c_wordToOf(); - - static void c_intpush(); - static void c_voidpush(); - static void c_floatpush(); - static void c_stringpush(); - static void c_symbolpush(); - static void c_namepush(); - static void c_varpush(); - static void c_argcpush(); - static void c_argcnoretpush(); - static void c_arraypush(); - static void c_assign(); - bool verify(Symbol *s); - static void c_eval(); - static void c_setImmediate(); - - static void c_swap(); - - static void c_theentitypush(); - static void c_theentityassign(); - static void c_objectfieldpush(); - static void c_objectfieldassign(); - - static void c_repeatwhilecode(); - static void c_repeatwithcode(); - static void c_ifcode(); - static void c_whencode(); - static void c_tellcode(); - static void c_tell(); - static void c_telldone(); - static void c_exitRepeat(); - static void c_eq(); - static void c_neq(); - static void c_gt(); - static void c_lt(); - static void c_ge(); - static void c_le(); - static void c_jump(); - static void c_jumpifz(); - static void c_call(); - - void call(Common::String name, int nargs); - - static void c_procret(); - - static void c_mci(); - static void c_mciwait(); - static void c_goto(); - static void c_gotoloop(); - static void c_gotonext(); - static void c_gotoprevious(); - static void c_global(); - static void c_instance(); - static void c_factory(); - static void c_property(); - - static void c_play(); - static void c_playdone(); - - static void c_open(); - static void c_hilite(); - - // stubs for unknown instructions - static void c_unk(); - static void c_unk1(); - static void c_unk2(); - - // bytecode-related instructions - static void cb_localcall(); - static void cb_call(); - static void cb_v4theentitypush(); - static void cb_v4theentitynamepush(); - static void cb_v4theentityassign(); - void printSTUBWithArglist(const char *funcname, int nargs, const char *prefix = "STUB:"); void convertVOIDtoString(int arg, int nargs); void dropStack(int nargs); @@ -631,9 +528,11 @@ private: void parseMenu(const char *code); Common::String genMenuHandler(int *commandId, Common::String &command); +public: void push(Datum d); Datum pop(void); +private: Common::HashMap _eventHandlerTypes; Common::HashMap _eventHandlerTypeIds; Common::HashMap _audioAliases; @@ -645,14 +544,17 @@ private: FuncHash _functions; +protected: Common::HashMap _lingoV4; Common::HashMap _lingoV4TheEntity; +private: uint _pc; StackData _stack; DirectorEngine *_vm; + LC *_lc; int _floatPrecision; -- cgit v1.2.3