DIRECTOR: LINGO: Implement grammar for setting object fields

This commit is contained in:
Eugene Sandulenko 2019-12-30 22:47:20 +01:00
parent c5b8aaa949
commit fa1ee74e02
6 changed files with 820 additions and 787 deletions

View File

@ -462,6 +462,15 @@ void Lingo::c_theentityassign() {
g_lingo->setTheEntity(entity, id, field, d);
}
void Lingo::c_objectfieldassign() {
Common::String object(g_lingo->readString());
int field = g_lingo->readInt();
Datum d = g_lingo->pop();
g_lingo->setObjectField(object, field, d);
}
void Lingo::c_swap() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();

File diff suppressed because it is too large Load Diff

View File

@ -70,10 +70,10 @@
STRING = 286,
HANDLER = 287,
SYMBOL = 288,
THEOBJECTFIELD = 289,
ENDCLAUSE = 290,
tPLAYACCEL = 291,
tMETHOD = 292,
ENDCLAUSE = 289,
tPLAYACCEL = 290,
tMETHOD = 291,
THEOBJECTFIELD = 292,
tDOWN = 293,
tELSE = 294,
tELSIF = 295,
@ -163,10 +163,10 @@
#define STRING 286
#define HANDLER 287
#define SYMBOL 288
#define THEOBJECTFIELD 289
#define ENDCLAUSE 290
#define tPLAYACCEL 291
#define tMETHOD 292
#define ENDCLAUSE 289
#define tPLAYACCEL 290
#define tMETHOD 291
#define THEOBJECTFIELD 292
#define tDOWN 293
#define tELSE 294
#define tELSIF 295

View File

@ -103,8 +103,9 @@ void checkEnd(Common::String *token, const char *expect, bool required) {
%token<f> FLOAT
%token<s> BLTIN BLTINNOARGS BLTINNOARGSORONE BLTINONEARG BLTINARGLIST TWOWORDBUILTIN
%token<s> FBLTIN FBLTINNOARGS FBLTINONEARG FBLTINARGLIST RBLTIN RBLTINONEARG
%token<s> ID STRING HANDLER SYMBOL THEOBJECTFIELD
%token<s> ID STRING HANDLER SYMBOL
%token<s> ENDCLAUSE tPLAYACCEL tMETHOD
%token<objectfield> THEOBJECTFIELD
%token tDOWN tELSE tELSIF tEXIT tGLOBAL tGO tIF tINTO tLOOP tMACRO
%token tMOVIE tNEXT tOF tPREVIOUS tPUT tREPEAT tSET tTHEN tTO tWHEN
%token tWITH tWHILE tNLELSE tFACTORY tOPEN tPLAY tDONE tINSTANCE
@ -186,6 +187,11 @@ asgn: tPUT expr tINTO ID {
g_lingo->codeInt($2[0]);
g_lingo->codeInt($2[1]);
$$ = $5; }
| tSET THEOBJECTFIELD tTO expr {
g_lingo->code1(g_lingo->c_objectfieldassign);
g_lingo->codeString($2.s->c_str());
g_lingo->codeInt($2.e);
$$ = $4; }
;
stmtoneliner: macro

View File

@ -842,4 +842,8 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
}
}
void Lingo::setObjectField(Common::String &obj, int field, Datum &d) {
warning("STUB: setObjectField(\"%s\", %d, ...)", obj.c_str(), field);
}
} // End of namespace Director

View File

@ -322,6 +322,7 @@ public:
static void c_theentitypush();
static void c_theentityassign();
static void c_objectfieldassign();
static void c_repeatwhilecode();
static void c_repeatwithcode();
@ -571,6 +572,7 @@ public:
Datum getTheEntity(int entity, Datum &id, int field);
Datum getTheSprite(Datum &id, int field);
Datum getTheCast(Datum &id, int field);
void setObjectField(Common::String &obj, int field, Datum &d);
public:
bool isInArgStack(Common::String *s);