RCS file: /cvsroot/scummvm/scummvm/gob/parse.cpp,v
retrieving revision 1.19
diff -u -r1.19 parse.cpp
|
|
|
70 | 70 | return ptr + (n & 0x0FFFFFFF); |
71 | 71 | } |
72 | 72 | |
73 | | int16 Parse::parseExpr(char arg_0, byte *arg_2) { |
| 73 | int16 Parse::parseExpr(char stopToken, byte *arg_2) { |
74 | 74 | int32 values[20]; |
75 | 75 | byte operStack[20]; |
76 | 76 | int32 prevPrevVal; |
… |
… |
|
129 | 129 | *valPtr = encodePtr(_vm->_global->_inter_variables + temp, kInterVar); |
130 | 130 | if (*_vm->_global->_inter_execPtr == 13) { |
131 | 131 | _vm->_global->_inter_execPtr++; |
132 | | temp += parseValExpr(); |
| 132 | temp += parseValExpr(12); |
133 | 133 | *operPtr = 20; |
134 | 134 | *valPtr = (uint8)*(_vm->_global->_inter_variables + temp); |
135 | 135 | } |
… |
… |
|
145 | 145 | offset = 0; |
146 | 146 | dim = 0; |
147 | 147 | for (dim = 0; dim < dimCount; dim++) { |
148 | | temp2 = parseValExpr(); |
| 148 | temp2 = parseValExpr(12); |
149 | 149 | offset = offset * arrDescPtr[dim] + temp2; |
150 | 150 | } |
151 | 151 | |
… |
… |
|
156 | 156 | *valPtr = encodePtr(_vm->_global->_inter_variables + temp * 4 + offset * _vm->_global->_inter_animDataSize * 4, kInterVar); |
157 | 157 | if (*_vm->_global->_inter_execPtr == 13) { |
158 | 158 | _vm->_global->_inter_execPtr++; |
159 | | temp2 = parseValExpr(); |
| 159 | temp2 = parseValExpr(12); |
160 | 160 | *operPtr = 20; |
161 | 161 | *valPtr = (uint8)*(_vm->_global->_inter_variables + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); |
162 | 162 | } |
… |
… |
|
262 | 262 | continue; |
263 | 263 | } // op>= 19 && op <= 29 |
264 | 264 | |
265 | | if (operation == arg_0 || operation == 30 || operation == 31 || operation == 10) { |
| 265 | if (operation == stopToken || operation == 30 || operation == 31 || operation == 10) { |
266 | 266 | while (stkPos >= 2) { |
267 | 267 | var_1A = 0; |
268 | | if (operPtr[-2] == 9 && (operation == 10 || operation == arg_0)) { |
| 268 | if (operPtr[-2] == 9 && (operation == 10 || operation == stopToken)) { |
269 | 269 | operPtr[-2] = operPtr[-1]; |
270 | 270 | if (operPtr[-2] == 20 || operPtr[-2] == 22) |
271 | 271 | valPtr[-2] = valPtr[-1]; |
… |
… |
|
324 | 324 | } // switch |
325 | 325 | } // stkPos > 2 |
326 | 326 | |
327 | | if (operation != arg_0) |
| 327 | if (operation != stopToken) |
328 | 328 | break; |
329 | 329 | } // if (operPtr[-2] == 9 && ...) |
330 | 330 | |
… |
… |
|
549 | 549 | operPtr -= 2; |
550 | 550 | valPtr -= 2; |
551 | 551 | } else { |
552 | | skipExpr(arg_0); |
| 552 | skipExpr(stopToken); |
553 | 553 | } |
554 | 554 | operation = _vm->_global->_inter_execPtr[-1]; |
555 | 555 | if (stkPos > 0 && operPtr[-1] == 11) { |
… |
… |
|
570 | 570 | valPtr--; |
571 | 571 | } |
572 | 572 | |
573 | | if (operation != arg_0) |
| 573 | if (operation != stopToken) |
574 | 574 | continue; |
575 | 575 | |
576 | 576 | if (arg_2 != 0) |
… |
… |
|
602 | 602 | break; |
603 | 603 | } |
604 | 604 | return 0; |
605 | | } // operation == arg_0 || operation == 30 || operation == 31 || operation == 10 |
| 605 | } // operation == stopToken || operation == 30 || operation == 31 || operation == 10 |
606 | 606 | |
607 | 607 | if (operation < 1 || operation > 11) { |
608 | 608 | if (operation < 32 || operation > 37) |
… |
… |
|
640 | 640 | } |
641 | 641 | } |
642 | 642 | |
643 | | void Parse::skipExpr(char arg_0) { |
| 643 | void Parse::skipExpr(char stopToken) { |
644 | 644 | int16 dimCount; |
645 | 645 | char operation; |
646 | 646 | int16 num; |
… |
… |
|
707 | 707 | if (operation == 10) |
708 | 708 | num--; |
709 | 709 | |
710 | | if (operation != arg_0) |
| 710 | if (operation != stopToken) |
711 | 711 | continue; |
712 | 712 | |
713 | | if (arg_0 != 10 || num < 0) |
| 713 | if (stopToken != 10 || num < 0) |
714 | 714 | return; |
715 | 715 | } |
716 | 716 | } |
717 | 717 | |
718 | | int16 Parse::parseValExpr() { |
| 718 | int16 Parse::parseValExpr(unsigned stopToken) { |
719 | 719 | int16 values[20]; |
720 | 720 | byte operStack[20]; |
721 | 721 | int16 *valPtr; |
… |
… |
|
735 | 735 | oldflag = flag; |
736 | 736 | if (flag == 0) { |
737 | 737 | flag = 1; |
738 | | printExpr(99); |
| 738 | printExpr(stopToken); |
739 | 739 | } |
740 | 740 | |
741 | 741 | stkPos = -1; |
… |
… |
|
767 | 767 | case 25: |
768 | 768 | temp = _vm->_inter->load16() * 4; |
769 | 769 | _vm->_global->_inter_execPtr++; |
770 | | temp += parseValExpr(); |
| 770 | temp += parseValExpr(12); |
771 | 771 | *valPtr = (uint8)*(_vm->_global->_inter_variables + temp); |
772 | 772 | break; |
773 | 773 | |
… |
… |
|
779 | 779 | _vm->_global->_inter_execPtr += dimCount; |
780 | 780 | offset = 0; |
781 | 781 | for (dim = 0; dim < dimCount; dim++) { |
782 | | temp2 = parseValExpr(); |
| 782 | temp2 = parseValExpr(12); |
783 | 783 | offset = arrDesc[dim] * offset + temp2; |
784 | 784 | } |
785 | 785 | if (operation == 26) { |
786 | 786 | *valPtr = (uint16)VAR(temp + offset); |
787 | 787 | } else { |
788 | 788 | _vm->_global->_inter_execPtr++; |
789 | | temp2 = parseValExpr(); |
| 789 | temp2 = parseValExpr(12); |
790 | 790 | *valPtr = (uint8)*(_vm->_global->_inter_variables + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); |
791 | 791 | } |
792 | 792 | break; |
… |
… |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | if (operation != 10) { |
| 933 | if (operation != stopToken) { |
| 934 | debug(5, "stoptoken error: %d != %d", operation, stopToken); |
| 935 | } |
933 | 936 | flag = oldflag; |
934 | 937 | return values[0]; |
935 | 938 | } |
… |
… |
|
959 | 962 | debug(5, "oper = %d", (int16)*_vm->_global->_inter_execPtr); |
960 | 963 | if (operation == 25 && *_vm->_global->_inter_execPtr == 13) { |
961 | 964 | _vm->_global->_inter_execPtr++; |
962 | | val = parseValExpr(); |
| 965 | val = parseValExpr(12); |
963 | 966 | temp += val; |
964 | 967 | debug(5, "parse subscript = %d", val); |
965 | 968 | } |
… |
… |
|
973 | 976 | _vm->_global->_inter_execPtr += dimCount; |
974 | 977 | offset = 0; |
975 | 978 | for (dim = 0; dim < dimCount; dim++) { |
976 | | temp2 = parseValExpr(); |
| 979 | temp2 = parseValExpr(12); |
977 | 980 | offset = arrDesc[dim] * offset + temp2; |
978 | 981 | } |
979 | 982 | offset *= 4; |
… |
… |
|
982 | 985 | |
983 | 986 | if (*_vm->_global->_inter_execPtr == 13) { |
984 | 987 | _vm->_global->_inter_execPtr++; |
985 | | temp += parseValExpr(); |
| 988 | temp += parseValExpr(12); |
986 | 989 | } |
987 | 990 | return offset * _vm->_global->_inter_animDataSize + temp; |
988 | 991 | |
… |
… |
|
991 | 994 | } |
992 | 995 | } |
993 | 996 | |
994 | | void Parse::printExpr(char arg_0) { |
| 997 | void Parse::printExpr(char stopToken) { |
995 | 998 | int16 dimCount; |
996 | 999 | char operation; |
997 | 1000 | int16 num; |
… |
… |
|
1001 | 1004 | char saved = 0; |
1002 | 1005 | static char *savedPos = 0; |
1003 | 1006 | |
1004 | | // printExpr() is not safe function. It suffers from unability to process |
1005 | | // stopTokens. So enable it only temporary when you need debugging. |
| 1007 | // printExpr() is not a necessary function, and might |
| 1008 | // cause stability problems if it fails to parse an expression |
| 1009 | // Enable it only temporarily when you need debugging. |
1006 | 1010 | return; |
1007 | 1011 | |
1008 | 1012 | if (savedPos == 0) { |
… |
… |
|
1031 | 1035 | break; |
1032 | 1036 | |
1033 | 1037 | case 23: |
1034 | | debug(5, "var_%d", _vm->_inter->load16()); |
| 1038 | { |
| 1039 | int16 varnum = _vm->_inter->load16(); |
| 1040 | debug(5, "var_%d (val=%d)", varnum, READ_LE_UINT32(_vm->_global->_inter_variables + varnum * 4) ); |
1035 | 1041 | break; |
1036 | | |
| 1042 | } |
1037 | 1043 | case 25: |
1038 | 1044 | debug(5, "(&var_%d)", _vm->_inter->load16()); |
1039 | 1045 | if (*_vm->_global->_inter_execPtr == 13) { |
… |
… |
|
1086 | 1092 | printExpr(10); |
1087 | 1093 | break; |
1088 | 1094 | |
1089 | | case 12: |
1090 | | debug(5, "}"); |
1091 | | break; |
1092 | | |
1093 | 1095 | default: |
1094 | 1096 | debug(5, "<%d>", (int16)operation); |
1095 | 1097 | break; |
… |
… |
|
1179 | 1181 | |
1180 | 1182 | case 12: |
1181 | 1183 | debug(5, "}"); |
| 1184 | if (stopToken != 12) { |
| 1185 | debug(5, "Closing paren without opening?"); |
| 1186 | } |
1182 | 1187 | break; |
1183 | 1188 | |
1184 | 1189 | default: |
… |
… |
|
1200 | 1205 | if (operation == 10) |
1201 | 1206 | num--; |
1202 | 1207 | |
1203 | | if (operation == arg_0) { |
1204 | | if (arg_0 != 10 || num < 0) { |
| 1208 | if (operation == stopToken) { |
| 1209 | if (stopToken != 10 || num < 0) { |
1205 | 1210 | |
1206 | 1211 | if (saved != 0) { |
1207 | 1212 | _vm->_global->_inter_execPtr = savedPos; |
… |
… |
|
1231 | 1236 | if (operation == 25 && *_vm->_global->_inter_execPtr == 13) { |
1232 | 1237 | _vm->_global->_inter_execPtr++; |
1233 | 1238 | debug(5, "+"); |
1234 | | printExpr(99); |
| 1239 | printExpr(12); |
1235 | 1240 | } |
1236 | 1241 | break; |
1237 | 1242 | |
… |
… |
|
1252 | 1257 | if (operation == 28 && *_vm->_global->_inter_execPtr == 13) { |
1253 | 1258 | _vm->_global->_inter_execPtr++; |
1254 | 1259 | debug(5, "+"); |
1255 | | printExpr(99); |
| 1260 | printExpr(12); |
1256 | 1261 | } |
1257 | 1262 | break; |
1258 | 1263 | |
RCS file: /cvsroot/scummvm/scummvm/gob/parse.h,v
retrieving revision 1.6
diff -u -r1.6 parse.h
|
|
|
28 | 28 | public: |
29 | 29 | int16 parseExpr(char stopToken, byte *resultPtr); |
30 | 30 | void skipExpr(char stopToken); |
31 | | int16 parseValExpr(void); |
| 31 | int16 parseValExpr(unsigned stopToken=99); |
32 | 32 | int16 parseVarIndex(void); |
33 | 33 | void printExpr(char stopToken); |
34 | 34 | void printVarIndex(void); |