Skip to content

Commit

Permalink
DIRECTOR: Lingo: Implement setting the entity fields
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 9763b62 commit d08e030
Show file tree
Hide file tree
Showing 6 changed files with 486 additions and 426 deletions.
7 changes: 7 additions & 0 deletions engines/director/lingo/lingo-code.cpp
Expand Up @@ -244,6 +244,13 @@ void Lingo::c_theentityassign() {
g_lingo->push(d); // Dummy value
}

void Lingo::c_swap() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
g_lingo->push(d2);
g_lingo->push(d1);
}

void Lingo::c_add() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
Expand Down
882 changes: 458 additions & 424 deletions engines/director/lingo/lingo-gr.cpp

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions engines/director/lingo/lingo-gr.y
Expand Up @@ -135,6 +135,14 @@ asgn: tPUT expr tINTO ID {
WRITE_UINT32(&f, $2[1]);
g_lingo->code2(e, f);
$$ = $4; }
| tSET THEENTITYWITHID expr '=' expr {
g_lingo->code1(g_lingo->c_swap);
g_lingo->code1(g_lingo->c_theentityassign);
inst e = 0, f = 0;
WRITE_UINT32(&e, $2[0]);
WRITE_UINT32(&f, $2[1]);
g_lingo->code2(e, f);
$$ = $5; }
| tSET ID tTO expr {
g_lingo->code1(g_lingo->c_varpush);
g_lingo->codeString($2->c_str());
Expand All @@ -149,6 +157,14 @@ asgn: tPUT expr tINTO ID {
WRITE_UINT32(&f, $2[1]);
g_lingo->code2(e, f);
$$ = $4; }
| tSET THEENTITYWITHID expr tTO expr {
g_lingo->code1(g_lingo->c_swap);
g_lingo->code1(g_lingo->c_theentityassign);
inst e = 0, f = 0;
WRITE_UINT32(&e, $2[0]);
WRITE_UINT32(&f, $2[1]);
g_lingo->code2(e, f);
$$ = $5; }
;
stmtoneliner: expr { g_lingo->code1(g_lingo->c_xpop); }
| func
Expand Down
4 changes: 2 additions & 2 deletions engines/director/lingo/lingo-the.cpp
Expand Up @@ -200,10 +200,10 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
else
warning("Unknown the sprite id type: %s", id1.type2str());

Sprite *sprite = _vm->_currentScore->getSpriteById(id);

d.toInt(); // Enforce Integer

Sprite *sprite = _vm->_currentScore->getSpriteById(id);

switch (field) {
case kTheCastNum:
if (_vm->_currentScore->_casts.contains(d.u.i)) {
Expand Down
2 changes: 2 additions & 0 deletions engines/director/lingo/lingo.h
Expand Up @@ -207,6 +207,8 @@ class Lingo {
bool verify(Symbol *s);
static void c_eval();

static void c_swap();

static void c_theentitypush();
static void c_theentityassign();

Expand Down
1 change: 1 addition & 0 deletions engines/director/lingo/tests/the.lingo
Expand Up @@ -2,3 +2,4 @@ put 1.0 / 3
set the floatPrecision to 6
put 1.0 / 3
put the loch of sprite 4
set the loch of sprite 5 to 10

0 comments on commit d08e030

Please sign in to comment.