From 8883a03e21394de1667aac0fc0c74b4bc558b032 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 4 Aug 2016 22:52:44 +0200 Subject: DIRECTOR: Lingo: Simplified code generation for constants --- engines/director/lingo/lingo-codegen.cpp | 9 ++ engines/director/lingo/lingo-gr.cpp | 196 ++++++++++++++----------------- engines/director/lingo/lingo-gr.y | 40 ++----- engines/director/lingo/lingo.h | 1 + 4 files changed, 112 insertions(+), 134 deletions(-) diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 6c5b5e6bc7..217ca562e4 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -184,6 +184,15 @@ int Lingo::codeFloat(double f) { return _currentScript->size(); } +int Lingo::codeConst(int val) { + int res = g_lingo->code1(g_lingo->c_constpush); + inst i = 0; + WRITE_UINT32(&i, val); + g_lingo->code1(i); + + return res; +} + void Lingo::codeArg(Common::String *s) { _argstack.push_back(s); } diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 64dd7089df..b3eec3f055 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -620,14 +620,14 @@ static const yytype_uint16 yyrline[] = 174, 176, 177, 182, 193, 209, 221, 226, 233, 242, 251, 261, 271, 282, 283, 286, 287, 290, 291, 294, 302, 303, 311, 312, 313, 315, 317, 323, 329, 336, - 338, 340, 341, 342, 345, 350, 353, 356, 360, 363, - 367, 374, 380, 381, 382, 383, 384, 385, 386, 387, - 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, - 398, 399, 400, 401, 404, 405, 406, 407, 408, 410, - 411, 412, 418, 424, 425, 431, 432, 440, 441, 452, - 453, 454, 455, 460, 466, 473, 474, 475, 476, 479, - 480, 481, 509, 509, 515, 518, 518, 524, 525, 526, - 527, 529, 533, 541, 542, 543 + 338, 340, 341, 342, 345, 346, 349, 352, 356, 359, + 363, 370, 376, 377, 378, 379, 380, 381, 382, 383, + 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 400, 401, 402, 403, 404, 406, + 407, 408, 411, 414, 415, 418, 419, 424, 425, 436, + 437, 438, 439, 444, 450, 457, 458, 459, 460, 463, + 464, 465, 493, 493, 499, 502, 502, 508, 509, 510, + 511, 513, 517, 525, 526, 527 }; #endif @@ -1855,7 +1855,7 @@ yyreduce: case 14: #line 134 "engines/director/lingo/lingo-gr.y" { - g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy id + g_lingo->codeConst(0); // Put dummy id g_lingo->code1(g_lingo->c_theentityassign); inst e = 0, f = 0; WRITE_UINT32(&e, (yyvsp[(2) - (4)].e)[0]); @@ -1889,7 +1889,7 @@ yyreduce: case 17: #line 156 "engines/director/lingo/lingo-gr.y" { - g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy id + g_lingo->codeConst(0); // Put dummy id g_lingo->code1(g_lingo->c_theentityassign); inst e = 0, f = 0; WRITE_UINT32(&e, (yyvsp[(2) - (4)].e)[0]); @@ -2133,44 +2133,40 @@ yyreduce: case 54: #line 345 "engines/director/lingo/lingo-gr.y" - { - (yyval.code) = g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, (yyvsp[(1) - (1)].i)); - g_lingo->code1(i); ;} + { (yyval.code) = g_lingo->codeConst((yyvsp[(1) - (1)].i)); ;} break; case 55: -#line 350 "engines/director/lingo/lingo-gr.y" +#line 346 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_fconstpush); g_lingo->codeFloat((yyvsp[(1) - (1)].f)); ;} break; case 56: -#line 353 "engines/director/lingo/lingo-gr.y" +#line 349 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_stringpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); ;} break; case 57: -#line 356 "engines/director/lingo/lingo-gr.y" +#line 352 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->_handlers[*(yyvsp[(1) - (1)].s)]->u.func); - (yyval.code) = g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy value + g_lingo->codeConst(0); // Put dummy value delete (yyvsp[(1) - (1)].s); ;} break; case 58: -#line 360 "engines/director/lingo/lingo-gr.y" +#line 356 "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 59: -#line 363 "engines/director/lingo/lingo-gr.y" +#line 359 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_eval); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); @@ -2178,9 +2174,9 @@ yyreduce: break; case 60: -#line 367 "engines/director/lingo/lingo-gr.y" +#line 363 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy id + (yyval.code) = g_lingo->codeConst(0); // Put dummy id g_lingo->code1(g_lingo->c_theentitypush); inst e = 0, f = 0; WRITE_UINT32(&e, (yyvsp[(1) - (1)].e)[0]); @@ -2189,7 +2185,7 @@ yyreduce: break; case 61: -#line 374 "engines/director/lingo/lingo-gr.y" +#line 370 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_theentitypush); inst e = 0, f = 0; @@ -2199,213 +2195,201 @@ yyreduce: break; case 63: -#line 381 "engines/director/lingo/lingo-gr.y" +#line 377 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_add); ;} break; case 64: -#line 382 "engines/director/lingo/lingo-gr.y" +#line 378 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_sub); ;} break; case 65: -#line 383 "engines/director/lingo/lingo-gr.y" +#line 379 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_mul); ;} break; case 66: -#line 384 "engines/director/lingo/lingo-gr.y" +#line 380 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_div); ;} break; case 67: -#line 385 "engines/director/lingo/lingo-gr.y" +#line 381 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gt); ;} break; case 68: -#line 386 "engines/director/lingo/lingo-gr.y" +#line 382 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_lt); ;} break; case 69: -#line 387 "engines/director/lingo/lingo-gr.y" +#line 383 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_neq); ;} break; case 70: -#line 388 "engines/director/lingo/lingo-gr.y" +#line 384 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_ge); ;} break; case 71: -#line 389 "engines/director/lingo/lingo-gr.y" +#line 385 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_le); ;} break; case 72: -#line 390 "engines/director/lingo/lingo-gr.y" +#line 386 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_and); ;} break; case 73: -#line 391 "engines/director/lingo/lingo-gr.y" +#line 387 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_or); ;} break; case 74: -#line 392 "engines/director/lingo/lingo-gr.y" +#line 388 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_not); ;} break; case 75: -#line 393 "engines/director/lingo/lingo-gr.y" +#line 389 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_ampersand); ;} break; case 76: -#line 394 "engines/director/lingo/lingo-gr.y" +#line 390 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_concat); ;} break; case 77: -#line 395 "engines/director/lingo/lingo-gr.y" +#line 391 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_contains); ;} break; case 78: -#line 396 "engines/director/lingo/lingo-gr.y" +#line 392 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_starts); ;} break; case 79: -#line 397 "engines/director/lingo/lingo-gr.y" +#line 393 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (2)].code); ;} break; case 80: -#line 398 "engines/director/lingo/lingo-gr.y" +#line 394 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;} break; case 81: -#line 399 "engines/director/lingo/lingo-gr.y" +#line 395 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (3)].code); ;} break; case 82: -#line 400 "engines/director/lingo/lingo-gr.y" +#line 396 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_intersects); ;} break; case 83: -#line 401 "engines/director/lingo/lingo-gr.y" +#line 397 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_within); ;} break; case 84: -#line 404 "engines/director/lingo/lingo-gr.y" +#line 400 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_mci); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;} break; case 85: -#line 405 "engines/director/lingo/lingo-gr.y" +#line 401 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_mciwait); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;} break; case 86: -#line 406 "engines/director/lingo/lingo-gr.y" +#line 402 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_printtop); ;} break; case 88: -#line 408 "engines/director/lingo/lingo-gr.y" - { g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack +#line 404 "engines/director/lingo/lingo-gr.y" + { g_lingo->codeConst(0); // Push fake value on stack g_lingo->code1(g_lingo->c_procret); ;} break; case 90: -#line 411 "engines/director/lingo/lingo-gr.y" +#line 407 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_alert); ;} break; case 91: -#line 412 "engines/director/lingo/lingo-gr.y" +#line 408 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, (yyvsp[(2) - (2)].i)); - g_lingo->code1(i); + g_lingo->codeConst((yyvsp[(2) - (2)].i)); g_lingo->code1(g_lingo->c_beep); ;} break; case 92: -#line 418 "engines/director/lingo/lingo-gr.y" +#line 411 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, 0); - g_lingo->code1(i); + g_lingo->codeConst(0); g_lingo->code1(g_lingo->c_beep); ;} break; case 93: -#line 424 "engines/director/lingo/lingo-gr.y" +#line 414 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_closeResFile); ;} break; case 94: -#line 425 "engines/director/lingo/lingo-gr.y" +#line 415 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, 0); - g_lingo->code1(i); + g_lingo->codeConst(0); g_lingo->code1(g_lingo->c_closeResFile); ;} break; case 95: -#line 431 "engines/director/lingo/lingo-gr.y" +#line 418 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_closeXlib); ;} break; case 96: -#line 432 "engines/director/lingo/lingo-gr.y" +#line 419 "engines/director/lingo/lingo-gr.y" { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, 0); - g_lingo->code1(i); + g_lingo->codeConst(0); g_lingo->code1(g_lingo->c_closeXlib); ;} break; case 97: -#line 440 "engines/director/lingo/lingo-gr.y" +#line 424 "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); ;} break; case 98: -#line 441 "engines/director/lingo/lingo-gr.y" +#line 425 "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); ;} break; case 99: -#line 452 "engines/director/lingo/lingo-gr.y" +#line 436 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoloop); ;} break; case 100: -#line 453 "engines/director/lingo/lingo-gr.y" +#line 437 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotonext); ;} break; case 101: -#line 454 "engines/director/lingo/lingo-gr.y" +#line 438 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoprevious); ;} break; case 102: -#line 455 "engines/director/lingo/lingo-gr.y" +#line 439 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); @@ -2414,7 +2398,7 @@ yyreduce: break; case 103: -#line 460 "engines/director/lingo/lingo-gr.y" +#line 444 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (3)].s)->c_str()); @@ -2424,7 +2408,7 @@ yyreduce: break; case 104: -#line 466 "engines/director/lingo/lingo-gr.y" +#line 450 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString(""); @@ -2433,102 +2417,102 @@ yyreduce: break; case 105: -#line 473 "engines/director/lingo/lingo-gr.y" +#line 457 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; case 106: -#line 474 "engines/director/lingo/lingo-gr.y" +#line 458 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; case 107: -#line 475 "engines/director/lingo/lingo-gr.y" +#line 459 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; case 108: -#line 476 "engines/director/lingo/lingo-gr.y" +#line 460 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(1) - (1)].s); ;} break; case 109: -#line 479 "engines/director/lingo/lingo-gr.y" +#line 463 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; case 110: -#line 480 "engines/director/lingo/lingo-gr.y" +#line 464 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; case 111: -#line 481 "engines/director/lingo/lingo-gr.y" +#line 465 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; case 112: -#line 509 "engines/director/lingo/lingo-gr.y" +#line 493 "engines/director/lingo/lingo-gr.y" { g_lingo->_indef = true; g_lingo->_currentFactory.clear(); ;} break; case 113: -#line 510 "engines/director/lingo/lingo-gr.y" +#line 494 "engines/director/lingo/lingo-gr.y" { - g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack + g_lingo->codeConst(0); // Push fake value on stack g_lingo->code1(g_lingo->c_procret); g_lingo->define(*(yyvsp[(2) - (8)].s), (yyvsp[(4) - (8)].code), (yyvsp[(5) - (8)].narg)); g_lingo->_indef = false; ;} break; case 114: -#line 515 "engines/director/lingo/lingo-gr.y" +#line 499 "engines/director/lingo/lingo-gr.y" { g_lingo->codeFactory(*(yyvsp[(2) - (2)].s)); ;} break; case 115: -#line 518 "engines/director/lingo/lingo-gr.y" +#line 502 "engines/director/lingo/lingo-gr.y" { g_lingo->_indef = true; ;} break; case 116: -#line 519 "engines/director/lingo/lingo-gr.y" +#line 503 "engines/director/lingo/lingo-gr.y" { - g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack + g_lingo->codeConst(0); // Push fake value on stack g_lingo->code1(g_lingo->c_procret); g_lingo->define(*(yyvsp[(2) - (8)].s), (yyvsp[(4) - (8)].code), (yyvsp[(5) - (8)].narg), &g_lingo->_currentFactory); g_lingo->_indef = false; ;} break; case 117: -#line 524 "engines/director/lingo/lingo-gr.y" +#line 508 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; case 118: -#line 525 "engines/director/lingo/lingo-gr.y" +#line 509 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(1) - (1)].s)); (yyval.narg) = 1; ;} break; case 119: -#line 526 "engines/director/lingo/lingo-gr.y" +#line 510 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(3) - (3)].s)); (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; case 120: -#line 527 "engines/director/lingo/lingo-gr.y" +#line 511 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(4) - (4)].s)); (yyval.narg) = (yyvsp[(1) - (4)].narg) + 1; ;} break; case 121: -#line 529 "engines/director/lingo/lingo-gr.y" +#line 513 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArgStore(); ;} break; case 122: -#line 533 "engines/director/lingo/lingo-gr.y" +#line 517 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_call); g_lingo->codeString((yyvsp[(1) - (3)].s)->c_str()); @@ -2538,23 +2522,23 @@ yyreduce: break; case 123: -#line 541 "engines/director/lingo/lingo-gr.y" +#line 525 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; case 124: -#line 542 "engines/director/lingo/lingo-gr.y" +#line 526 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 1; ;} break; case 125: -#line 543 "engines/director/lingo/lingo-gr.y" +#line 527 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; /* Line 1267 of yacc.c. */ -#line 2558 "engines/director/lingo/lingo-gr.cpp" +#line 2542 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2768,6 +2752,6 @@ yyreturn: } -#line 546 "engines/director/lingo/lingo-gr.y" +#line 530 "engines/director/lingo/lingo-gr.y" diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index a85644f38a..882a1532b5 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -132,7 +132,7 @@ asgn: tPUT expr tINTO ID { $$ = $4; delete $2; } | tSET vTHEENTITY '=' expr { - g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy id + g_lingo->codeConst(0); // Put dummy id g_lingo->code1(g_lingo->c_theentityassign); inst e = 0, f = 0; WRITE_UINT32(&e, $2[0]); @@ -154,7 +154,7 @@ asgn: tPUT expr tINTO ID { $$ = $4; delete $2; } | tSET vTHEENTITY tTO expr { - g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy id + g_lingo->codeConst(0); // Put dummy id g_lingo->code1(g_lingo->c_theentityassign); inst e = 0, f = 0; WRITE_UINT32(&e, $2[0]); @@ -342,11 +342,7 @@ stmtlist: /* nothing */ { $$ = g_lingo->_currentScript->size(); } | stmtlist stmt ; -expr: vINT { - $$ = g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, $1); - g_lingo->code1(i); } +expr: vINT { $$ = g_lingo->codeConst($1); } | vFLOAT { $$ = g_lingo->code1(g_lingo->c_fconstpush); g_lingo->codeFloat($1); } @@ -355,7 +351,7 @@ expr: vINT { g_lingo->codeString($1->c_str()); } | vBLTINNOARGS { $$ = g_lingo->code1(g_lingo->_handlers[*$1]->u.func); - $$ = g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy value + g_lingo->codeConst(0); // Put dummy value delete $1; } | ID '(' arglist ')' { $$ = g_lingo->codeFunc($1, $3); @@ -365,7 +361,7 @@ expr: vINT { g_lingo->codeString($1->c_str()); delete $1; } | vTHEENTITY { - $$ = g_lingo->code2(g_lingo->c_constpush, 0); // Put dummy id + $$ = g_lingo->codeConst(0); // Put dummy id g_lingo->code1(g_lingo->c_theentitypush); inst e = 0, f = 0; WRITE_UINT32(&e, $1[0]); @@ -405,35 +401,23 @@ func: tMCI vSTRING { g_lingo->code1(g_lingo->c_mci); g_lingo->codeString($2->c | tMCIWAIT ID { g_lingo->code1(g_lingo->c_mciwait); g_lingo->codeString($2->c_str()); delete $2; } | tPUT expr { g_lingo->code1(g_lingo->c_printtop); } | gotofunc - | tEXIT { g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack + | tEXIT { g_lingo->codeConst(0); // Push fake value on stack g_lingo->code1(g_lingo->c_procret); } | tGLOBAL globallist | tALERT expr { g_lingo->code1(g_lingo->c_alert); } | tBEEP vINT { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, $2); - g_lingo->code1(i); + g_lingo->codeConst($2); g_lingo->code1(g_lingo->c_beep); } | tBEEP { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, 0); - g_lingo->code1(i); + g_lingo->codeConst(0); g_lingo->code1(g_lingo->c_beep); } | tCLOSERESFILE expr { g_lingo->code1(g_lingo->c_closeResFile); } | tCLOSERESFILE { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, 0); - g_lingo->code1(i); + g_lingo->codeConst(0); g_lingo->code1(g_lingo->c_closeResFile); } | tCLOSEXLIB expr { g_lingo->code1(g_lingo->c_closeXlib); } | tCLOSEXLIB { - g_lingo->code1(g_lingo->c_constpush); - inst i = 0; - WRITE_UINT32(&i, 0); - g_lingo->code1(i); + g_lingo->codeConst(0); g_lingo->code1(g_lingo->c_closeXlib); } ; @@ -508,7 +492,7 @@ gotomovie: tOF tMOVIE vSTRING { $$ = $3; } // on keyword defn: tMACRO ID { g_lingo->_indef = true; g_lingo->_currentFactory.clear(); } begin argdef nl argstore stmtlist { - g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack + g_lingo->codeConst(0); // Push fake value on stack g_lingo->code1(g_lingo->c_procret); g_lingo->define(*$2, $4, $5); g_lingo->_indef = false; } @@ -517,7 +501,7 @@ defn: tMACRO ID { g_lingo->_indef = true; g_lingo->_currentFactory.clear(); } } | 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->codeConst(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; } ; diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 4b25a57c49..d2c5f32175 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -173,6 +173,7 @@ public: int code3(inst code_1, inst code_2, inst code_3) { int o = code1(code_1); code1(code_2); code1(code_3); return o; } int codeString(const char *s); void codeLabel(int label); + int codeConst(int val); int calcStringAlignment(const char *s) { return calcCodeAlignment(strlen(s) + 1); -- cgit v1.2.3