Changeset 76 in dev for BasicCompiler64/Compile_Statement.cpp
- Timestamp:
- Mar 21, 2007, 9:26:56 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/Compile_Statement.cpp
r75 r76 964 964 } 965 965 966 void Opcode_Input(const char *Parameter){967 extern int cp;968 int i2,i3,i4,i5;969 BOOL bFile;970 char temporary[VN_SIZE],temp2[VN_SIZE],buffer[VN_SIZE];971 972 if(Parameter[0]=='#'){973 bFile=1;974 for(i2=0,i3=1;;i2++,i3++){975 buffer[i2]=Parameter[i3];976 if(Parameter[i3]==','||Parameter[i3]=='\0') break;977 }978 buffer[i2+1]=0;979 i2=i3+1;980 }981 else{982 bFile=0;983 i2=0;984 buffer[0]=0;985 986 //表示用文字列パラメータをセット987 if(Parameter[0]=='\"'){988 buffer[0]='\"';989 for(i2=1;;i2++){990 if(Parameter[i2]=='\"'){991 buffer[i2]=0;992 break;993 }994 buffer[i2]=Parameter[i2];995 }996 if(Parameter[i2+1]==';') lstrcpy(buffer+i2,"? \"");997 else if(Parameter[i2+1]==',') lstrcpy(buffer+i2,"\"");998 else SetError(10,"Input",cp);999 i2+=2;1000 }1001 else if((Parameter[0]=='e'||Parameter[0]=='E')&&1002 (Parameter[1]=='x'||Parameter[1]=='X')&&1003 Parameter[2]=='\"'){1004 memcpy(buffer,Parameter,3);1005 for(i2=3;;i2++){1006 if(Parameter[i2]=='\"'){1007 buffer[i2]=0;1008 break;1009 }1010 buffer[i2]=Parameter[i2];1011 }1012 if(Parameter[i2+1]==';') lstrcpy(buffer+i2,"? \"");1013 else if(Parameter[i2+1]==',') lstrcpy(buffer+i2,"\"");1014 else SetError(10,"Input",cp);1015 i2+=2;1016 }1017 else{1018 lstrcpy(buffer,"\"? \"");1019 i2=0;1020 }1021 }1022 1023 //変数ポインタ、変数のタイプをセット1024 i4=0;1025 while(1){1026 for(i3=0;;i2++,i3++){1027 if(Parameter[i2]=='('){1028 i5=GetStringInPare(temporary+i3,Parameter+i2);1029 i2+=i5-1;1030 i3+=i5-1;1031 }1032 if(Parameter[i2]=='['){1033 i5=GetStringInBracket(temporary+i3,Parameter+i2);1034 i2+=i5-1;1035 i3+=i5-1;1036 }1037 if(Parameter[i2]==','){1038 temporary[i3]=0;1039 i2++;1040 break;1041 }1042 temporary[i3]=Parameter[i2];1043 if(Parameter[i2]=='\0') break;1044 }1045 if(temporary[0]=='\0'){1046 SetError(10,"Input",cp);1047 return;1048 }1049 1050 Type varType;1051 if( !GetVarType(temporary, varType, 1) ){1052 return;1053 }1054 1055 sprintf(temp2,"_System_InputDataPtr[%d]=VarPtr(%s)",i4,temporary);1056 OpcodeCalc(temp2);1057 1058 if(varType.IsLong()) varType.SetBasicType( DEF_DWORD );1059 else if(varType.IsInteger()) varType.SetBasicType( DEF_WORD );1060 else if(varType.IsObject()){1061 varType.SetBasicType( DEF_OBJECT );1062 if( varType.IsStringObject() ){1063 varType.SetBasicType( DEF_STRING );1064 }1065 }1066 sprintf(temp2,"_System_InputDataType[%d]=%d",i4,varType.GetBasicType());1067 OpcodeCalc(temp2);1068 1069 i4++;1070 if(Parameter[i2]=='\0') break;1071 }1072 sprintf(temp2,"_System_InputDataPtr[%d]=0",i4);1073 OpcodeCalc(temp2);1074 1075 UserProc *pUserProc;1076 if(bFile) pUserProc=GetSubHash("INPUT_FromFile");1077 else pUserProc=GetSubHash("INPUT_FromPrompt");1078 if(!pUserProc){1079 SetError(3,"Input",cp);1080 return;1081 }1082 Opcode_CallProc(buffer,pUserProc,0,"",0);1083 }1084 void Opcode_PrintUsing(const char *Parameter,char *buffer,BOOL bFile){1085 extern int cp;1086 int i2,i3,i4,i5;1087 char temporary[VN_SIZE],temp2[8192];1088 BOOL bReturnLine;1089 1090 char parms[8192];1091 lstrcpy( parms, Parameter );1092 1093 i2=lstrlen(parms);1094 if(parms[i2-1]==';'){1095 bReturnLine=0;1096 parms[i2-1]=0;1097 }1098 else bReturnLine=1;1099 1100 i3=lstrlen(buffer);1101 for(i2=0;;i2++,i3++){1102 if(parms[i2]==';'){1103 buffer[i3]=0;1104 break;1105 }1106 buffer[i3]=parms[i2];1107 if(parms[i2]=='\0') break;1108 }1109 if(parms[i2]==';') i2++;1110 1111 if(bReturnLine) lstrcat(buffer,"+Ex\"\\r\\n\"");1112 1113 //データポインタ、データのタイプをセット1114 i4=0;1115 while(1){1116 for(i3=0;;i2++,i3++){1117 if(parms[i2]=='\"'){1118 temporary[i3]=parms[i2];1119 for(i2++,i3++;;i2++,i3++){1120 temporary[i3]=parms[i2];1121 if(parms[i2]=='\"') break;1122 }1123 continue;1124 }1125 if(parms[i2]=='('){1126 i5=GetStringInPare(temporary+i3,parms+i2);1127 i2+=i5-1;1128 i3+=i5-1;1129 continue;1130 }1131 if(parms[i2]=='['){1132 i5=GetStringInBracket(temporary+i3,parms+i2);1133 i2+=i5-1;1134 i3+=i5-1;1135 continue;1136 }1137 if(parms[i2]==','){1138 temporary[i3]=0;1139 i2++;1140 break;1141 }1142 temporary[i3]=parms[i2];1143 if(parms[i2]=='\0') break;1144 }1145 if(temporary[0]=='\0'){1146 SetError(10,"Print",cp);1147 return;1148 }1149 1150 int iResult;1151 iResult=IsStrCalculation(temporary);1152 1153 if(iResult==1){1154 //文字列1155 sprintf(temp2,"_System_UsingStrData[%d]=%s",i4,temporary);1156 OpcodeCalc(temp2);1157 1158 sprintf(temp2,"_System_UsingDataType[%d]=%d",i4,DEF_STRING);1159 OpcodeCalc(temp2);1160 }1161 else if(iResult==0){1162 //数値1163 sprintf(temp2,"_System_UsingDblData[%d]=%s",i4,temporary);1164 OpcodeCalc(temp2);1165 1166 sprintf(temp2,"_System_UsingDataType[%d]=%d",i4,DEF_DOUBLE);1167 OpcodeCalc(temp2);1168 }1169 //else if(iResult==-1) エラー1170 1171 i4++;1172 if(parms[i2]=='\0') break;1173 }1174 sprintf(temp2,"_System_UsingDataType[%d]=-1",i4);1175 OpcodeCalc(temp2);1176 1177 UserProc *pUserProc;1178 if(bFile) pUserProc=GetSubHash("PRINTUSING_ToFile");1179 else pUserProc=GetSubHash("PRINTUSING_ToPrompt");1180 if(!pUserProc){1181 SetError(3,"Print",cp);1182 return;1183 }1184 Opcode_CallProc(buffer,pUserProc,0,"",0);1185 }1186 void Opcode_Print(const char *Parameter,BOOL bWrite){1187 int i2,i3,i4,sw;1188 char temporary[VN_SIZE],buffer[VN_SIZE];1189 BOOL bFile;1190 1191 if(Parameter[0]=='#'){1192 bFile=1;1193 for(i2=0,i3=1;;i2++,i3++){1194 buffer[i2]=Parameter[i3];1195 if(Parameter[i3]==','||Parameter[i3]=='\0') break;1196 }1197 buffer[i2+1]=0;1198 if(Parameter[i3]==',') i3++;1199 i2=i3;1200 }1201 else{1202 bFile=0;1203 i2=0;1204 buffer[0]=0;1205 }1206 if(Parameter[i2]==1&&Parameter[i2+1]==ESC_USING){1207 Opcode_PrintUsing(Parameter+i2+2,buffer,bFile);1208 return;1209 }1210 1211 lstrcat(buffer,"_System_DummyStr+");1212 1213 sw=1;1214 while(1){1215 for(i3=0;;i2++,i3++){1216 if(Parameter[i2]=='\"'){1217 temporary[i3]=Parameter[i2];1218 for(i2++,i3++;;i2++,i3++){1219 temporary[i3]=Parameter[i2];1220 if(Parameter[i2]=='\"') break;1221 }1222 continue;1223 }1224 if(Parameter[i2]=='('){1225 i4=GetStringInPare(temporary+i3,Parameter+i2);1226 i2+=i4-1;1227 i3+=i4-1;1228 continue;1229 }1230 if(Parameter[i2]=='['){1231 i4=GetStringInBracket(temporary+i3,Parameter+i2);1232 i2+=i4-1;1233 i3+=i4-1;1234 continue;1235 }1236 if(Parameter[i2]==','||Parameter[i2]==';'){1237 temporary[i3]=0;1238 break;1239 }1240 temporary[i3]=Parameter[i2];1241 if(Parameter[i2]=='\0') break;1242 }1243 1244 if(temporary[0]=='\0') lstrcat(buffer,"\"\"");1245 else{1246 int iResult;1247 iResult=IsStrCalculation(temporary);1248 if(iResult==-1){1249 //エラー1250 lstrcat(buffer,"\"\"");1251 }1252 else if(iResult){1253 //文字列1254 lstrcat(buffer,temporary);1255 }1256 else{1257 //数値1258 sprintf(buffer+lstrlen(buffer),"Str$(%s)",temporary);1259 }1260 }1261 1262 if(Parameter[i2]==','){1263 if(bWrite) lstrcat(buffer,"+\",\"+");1264 else lstrcat(buffer,"+\"\t\"+");1265 }1266 else if(Parameter[i2]==';'){1267 if(Parameter[i2+1]=='\0'){1268 sw=0;1269 break;1270 }1271 if(bWrite) lstrcat(buffer,"+\",\"+");1272 else lstrcat(buffer,"+\" \"+");1273 }1274 else if(Parameter[i2]=='\0') break;1275 1276 i2++;1277 }1278 1279 if(sw) lstrcat(buffer,"+Ex\"\\r\\n\"");1280 1281 UserProc *pUserProc;1282 if(bFile) pUserProc=GetSubHash("PRINT_ToFile");1283 else pUserProc=GetSubHash("PRINT_ToPrompt");1284 if(!pUserProc){1285 SetError(3,"Print",cp);1286 return;1287 }1288 Opcode_CallProc(buffer,pUserProc,0,"",0);1289 }1290 1291 1292 1293 966 1294 967 ////////////
Note:
See TracChangeset
for help on using the changeset viewer.