Skip to content

Commit

Permalink
DIRECTOR: Lingo: Initial code for factory/method definition
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 2676e25 commit e1b2759
Show file tree
Hide file tree
Showing 7 changed files with 647 additions and 578 deletions.
9 changes: 8 additions & 1 deletion engines/director/lingo/lingo-codegen.cpp
Expand Up @@ -123,11 +123,14 @@ void Lingo::cleanLocalVars() {
delete g_lingo->_localvars;
}

void Lingo::define(Common::String &name, int start, int nargs) {
void Lingo::define(Common::String &name, int start, int nargs, Common::String *prefix) {
debug(3, "define(\"%s\", %d, %d, %d)", name.c_str(), start, _currentScript->size() - 1, nargs);

Symbol *sym;

if (prefix)
name = *prefix + "-" + name;

if (!_handlers.contains(name)) { // Create variable if it was not defined
sym = new Symbol;

Expand Down Expand Up @@ -249,4 +252,8 @@ void Lingo::processIf(int elselabel, int endlabel) {
}
}

void Lingo::codeFactory(Common::String &name) {
_currentFactory = name;
}

}
678 changes: 353 additions & 325 deletions engines/director/lingo/lingo-gr.cpp

Large diffs are not rendered by default.

54 changes: 29 additions & 25 deletions engines/director/lingo/lingo-gr.h
Expand Up @@ -77,18 +77,20 @@
tWITH = 293,
tWHILE = 294,
tNLELSE = 295,
tGE = 296,
tLE = 297,
tGT = 298,
tLT = 299,
tEQ = 300,
tNEQ = 301,
tAND = 302,
tOR = 303,
tNOT = 304,
tCONCAT = 305,
tCONTAINS = 306,
tSTARTS = 307
tFACTORY = 296,
tMETHOD = 297,
tGE = 298,
tLE = 299,
tGT = 300,
tLT = 301,
tEQ = 302,
tNEQ = 303,
tAND = 304,
tOR = 305,
tNOT = 306,
tCONCAT = 307,
tCONTAINS = 308,
tSTARTS = 309
};
#endif
/* Tokens. */
Expand Down Expand Up @@ -130,18 +132,20 @@
#define tWITH 293
#define tWHILE 294
#define tNLELSE 295
#define tGE 296
#define tLE 297
#define tGT 298
#define tLT 299
#define tEQ 300
#define tNEQ 301
#define tAND 302
#define tOR 303
#define tNOT 304
#define tCONCAT 305
#define tCONTAINS 306
#define tSTARTS 307
#define tFACTORY 296
#define tMETHOD 297
#define tGE 298
#define tLE 299
#define tGT 300
#define tLT 301
#define tEQ 302
#define tNEQ 303
#define tAND 304
#define tOR 305
#define tNOT 306
#define tCONCAT 307
#define tCONTAINS 308
#define tSTARTS 309



Expand All @@ -158,7 +162,7 @@ typedef union YYSTYPE
int narg; /* number of arguments */
}
/* Line 1529 of yacc.c. */
#line 162 "engines/director/lingo/lingo-gr.hpp"
#line 166 "engines/director/lingo/lingo-gr.hpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
Expand Down
15 changes: 12 additions & 3 deletions engines/director/lingo/lingo-gr.y
Expand Up @@ -82,7 +82,7 @@ void yyerror(char *s) {
%token<s> BLTIN ID STRING HANDLER
%token tDOWN tELSE tNLELSIF tEND tEXIT tFRAME tGLOBAL tGO tIF tINTO tLOOP tMACRO
%token tMCI tMCIWAIT tMOVIE tNEXT tOF tPREVIOUS tPUT tREPEAT tSET tTHEN tTO
%token tWITH tWHILE tNLELSE
%token tWITH tWHILE tNLELSE tFACTORY tMETHOD
%token tGE tLE tGT tLT tEQ tNEQ tAND tOR tNOT
%token tCONCAT tCONTAINS tSTARTS

Expand Down Expand Up @@ -477,12 +477,20 @@ gotomovie: tOF tMOVIE STRING { $$ = $3; }
// See also:
// on keyword
defn: tMACRO ID { g_lingo->_indef = true; }
begin argdef nl argstore stmtlist {
begin argdef nl argstore stmtlist {
g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack
g_lingo->code1(g_lingo->c_procret);
g_lingo->define(*$2, $4, $5);
g_lingo->_indef = false; }
;
| tFACTORY ID {
g_lingo->codeFactory(*$2);
}
| tMETHOD ID { g_lingo->_indef = true; }
begin argdef nl argstore stmtlist {
g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack
g_lingo->code1(g_lingo->c_procret);
g_lingo->define(*$2, $4, $5, &g_lingo->_currentFactory);
g_lingo->_indef = false; } ;
argdef: /* nothing */ { $$ = 0; }
| ID { g_lingo->codeArg($1); $$ = 1; }
| argdef ',' ID { g_lingo->codeArg($3); $$ = $1 + 1; }
Expand All @@ -491,6 +499,7 @@ argdef: /* nothing */ { $$ = 0; }
argstore: /* nothing */ { g_lingo->codeArgStore(); }
;


macro: ID begin arglist {
g_lingo->code1(g_lingo->c_call);
g_lingo->codeString($1->c_str());
Expand Down

0 comments on commit e1b2759

Please sign in to comment.