comparison scn2k/scn2k_cmd.cc @ 43:01aa5ddf7dc8

A lot of very minor improvements (deleted some unused variables, and other things like that...)
author thib
date Tue, 24 Mar 2009 19:45:48 +0000
parents d229cce98f50
children a85cdca1980a
comparison
equal deleted inserted replaced
42:039d813d4cef 43:01aa5ddf7dc8
74 sys = 0; 74 sys = 0;
75 } 75 }
76 76
77 bool Flags::IsInt(int type) const { 77 bool Flags::IsInt(int type) const {
78 int v = type % 26; 78 int v = type % 26;
79 return v >= 0 && v < 7 || v == 25; 79 return (v >= 0 && v < 7) || v == 25;
80 } 80 }
81 81
82 int Flags::MaxIndex(int type) const { 82 int Flags::MaxIndex(int type) const {
83 switch (type / 26) { 83 switch (type / 26) {
84 case 1: 84 case 1:
370 SetStr(arg1, cmd.Str(cmd.args[1])); 370 SetStr(arg1, cmd.Str(cmd.args[1]));
371 } else if (cmd.cmd4 == 1) { 371 } else if (cmd.cmd4 == 1) {
372 string s = cmd.Str(cmd.args[1]); 372 string s = cmd.Str(cmd.args[1]);
373 const char* sc = s.c_str(); 373 const char* sc = s.c_str();
374 int len = cmd.args[2].value; 374 int len = cmd.args[2].value;
375 int i;for (i=0; i<sc[i]!=0 && len != 0; i++, len--) { 375 int i;
376 for (i=0; i < sc[i] && len != 0; i++, len--) {
376 if (sc[i]<0 && sc[i+1]!=0) i++; 377 if (sc[i]<0 && sc[i+1]!=0) i++;
377 } 378 }
378 s.erase(i); // 全角で len 文字まで切り詰める 379 s.erase(i); // 全角で len 文字まで切り詰める
379 SetStr(arg1, s); 380 SetStr(arg1, s);
380 // fprintf(stderr,"Set[%d,%d]<-%s\n",arg1.type,arg1.number,s.c_str()); 381 // fprintf(stderr,"Set[%d,%d]<-%s\n",arg1.type,arg1.number,s.c_str());
1064 1065
1065 int default_jmp = -1; int jmpto = -1; 1066 int default_jmp = -1; int jmpto = -1;
1066 int i; for (i=0; i<argc; i++) { 1067 int i; for (i=0; i<argc; i++) {
1067 dprintf("\t"); 1068 dprintf("\t");
1068 if (*d++ != 0x28) {SetError(); return -1;} 1069 if (*d++ != 0x28) {SetError(); return -1;}
1069 int item = -1; // default
1070 if (*d != 0x29) { 1070 if (*d != 0x29) {
1071 int item = GetExpression(d); 1071 int item = GetExpression(d);
1072 if (*d++ != 0x29) {SetError(); return -1;} 1072 if (*d++ != 0x29) {SetError(); return -1;}
1073 int jmp = read_little_endian_int(d); 1073 int jmp = read_little_endian_int(d);
1074 if (var == item) { 1074 if (var == item) {
1218 // if (arg_count != argc) SetError(); 1218 // if (arg_count != argc) SetError();
1219 dprintf("\n}\n"); 1219 dprintf("\n}\n");
1220 return; 1220 return;
1221 } 1221 }
1222 1222
1223 static char* op_str3[11] = { "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "="};
1224 void Cmd::GetCmd(Flags& flags_orig, const char*& d ) { 1223 void Cmd::GetCmd(Flags& flags_orig, const char*& d ) {
1225 if (d == 0) { SetError(); return;} 1224 if (d == 0) { SetError(); return;}
1226 if (cmd_type != CMD_NOP) return; 1225 if (cmd_type != CMD_NOP) return;
1227 1226
1228 cmdstr[0] = 0; 1227 cmdstr[0] = 0;
1300 if (cmd1 == 1 && cmd2 == 0x22 && (cmd3 == 0xc1c || cmd3 == 0x835)) GetArgsSpecial(3, d); 1299 if (cmd1 == 1 && cmd2 == 0x22 && (cmd3 == 0xc1c || cmd3 == 0x835)) GetArgsSpecial(3, d);
1301 else if (cmd1 == 1 && cmd2 == 0x0b && cmd3 == 0x65) GetArgsSpecial(0, d); 1300 else if (cmd1 == 1 && cmd2 == 0x0b && cmd3 == 0x65) GetArgsSpecial(0, d);
1302 else if (cmd1 == 1 && cmd2 == 0x15 && cmd3 == 0x28) GetArgsSpecial(0, d); 1301 else if (cmd1 == 1 && cmd2 == 0x15 && cmd3 == 0x28) GetArgsSpecial(0, d);
1303 else if (cmd1 == 1 && cmd2 == 4 && (cmd3 == 0x26c || cmd3 == 0x26d || cmd3 == 0x270 || cmd3 == 0x276)) GetArgsSpecial(0, d); 1302 else if (cmd1 == 1 && cmd2 == 4 && (cmd3 == 0x26c || cmd3 == 0x26d || cmd3 == 0x270 || cmd3 == 0x276)) GetArgsSpecial(0, d);
1304 else if (cmd1 == 1 && cmd2 == 4 && cmd3 == 0x586) GetArgsSpecial(1, d); 1303 else if (cmd1 == 1 && cmd2 == 4 && cmd3 == 0x586) GetArgsSpecial(1, d);
1305 else if (cmd1 == 1 && (cmd2 == 0x21 && cmd3 == 0x4b) || (cmd2 == 0x28 && cmd3 == 0x64)) GetArgsSpecial(2,d); 1304 else if (cmd1 == 1 && ((cmd2 == 0x21 && cmd3 == 0x4b) || (cmd2 == 0x28 && cmd3 == 0x64))) GetArgsSpecial(2,d);
1306 else GetArgs(d); 1305 else GetArgs(d);
1307 dprintf("\n"); 1306 dprintf("\n");
1308 1307
1309 } 1308 }
1310 } else if (*d == 0x24) { /* 代入演算 */ 1309 } else if (*d == 0x24) { /* 代入演算 */
1411 if (quote_flag) quote_flag = false; 1410 if (quote_flag) quote_flag = false;
1412 else quote_flag = true; 1411 else quote_flag = true;
1413 d++; 1412 d++;
1414 } else if (quote_flag) { 1413 } else if (quote_flag) {
1415 strheap[strend++] = *d++; 1414 strheap[strend++] = *d++;
1416 } else if (stype = StrType(d)) { 1415 } else if ((stype = StrType(d))) {
1417 strheap[strend++] = *d++; 1416 strheap[strend++] = *d++;
1418 if (stype == 2) strheap[strend++] = *d++; 1417 if (stype == 2) strheap[strend++] = *d++;
1419 } else break; 1418 } else break;
1420 } 1419 }
1421 strheap[strend++] = 0; 1420 strheap[strend++] = 0;