Changeset 76 in dev
- Timestamp:
- Mar 21, 2007, 9:26:56 PM (18 years ago)
- Files:
-
- 3 added
- 4 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/BasicCompiler.vcproj
r73 r76 600 600 </File> 601 601 <File 602 RelativePath="..\BasicCompiler_Common\OldStatement.cpp" 603 > 604 </File> 605 <File 602 606 RelativePath="..\BasicCompiler_Common\Overload.cpp" 603 607 > … … 1046 1050 > 1047 1051 </File> 1052 <File 1053 RelativePath="..\BasicCompiler_Common\VarList.cpp" 1054 > 1055 </File> 1056 <File 1057 RelativePath="..\BasicCompiler_Common\WatchList.cpp" 1058 > 1059 <FileConfiguration 1060 Name="Debug|Win32" 1061 > 1062 <Tool 1063 Name="VCCLCompilerTool" 1064 ObjectFile="$(IntDir)\$(InputName)1.obj" 1065 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 1066 /> 1067 </FileConfiguration> 1068 <FileConfiguration 1069 Name="Release|Win32" 1070 > 1071 <Tool 1072 Name="VCCLCompilerTool" 1073 ObjectFile="$(IntDir)\$(InputName)1.obj" 1074 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 1075 /> 1076 </FileConfiguration> 1077 <FileConfiguration 1078 Name="English_Rel|Win32" 1079 > 1080 <Tool 1081 Name="VCCLCompilerTool" 1082 ObjectFile="$(IntDir)\$(InputName)1.obj" 1083 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 1084 /> 1085 </FileConfiguration> 1086 </File> 1048 1087 </Filter> 1049 1088 <Filter … … 1227 1266 > 1228 1267 <File 1229 RelativePath="..\BasicCompiler_Common\Variable.cpp" 1230 > 1231 <FileConfiguration 1232 Name="Debug|Win32" 1233 > 1234 <Tool 1235 Name="VCCLCompilerTool" 1236 PreprocessorDefinitions="" 1237 /> 1238 </FileConfiguration> 1239 <FileConfiguration 1240 Name="Release|Win32" 1241 > 1242 <Tool 1243 Name="VCCLCompilerTool" 1244 PreprocessorDefinitions="" 1245 /> 1246 </FileConfiguration> 1247 <FileConfiguration 1248 Name="English_Rel|Win32" 1249 > 1250 <Tool 1251 Name="VCCLCompilerTool" 1252 PreprocessorDefinitions="" 1253 /> 1254 </FileConfiguration> 1255 </File> 1256 <File 1257 RelativePath="..\BasicCompiler_Common\Variable.h" 1268 RelativePath="..\BasicCompiler_Common\VariableOpe.cpp" 1269 > 1270 </File> 1271 <File 1272 RelativePath="..\BasicCompiler_Common\VariableOpe.h" 1258 1273 > 1259 1274 </File> … … 1861 1876 </Filter> 1862 1877 <Filter 1863 Name="Debug"1864 >1865 <File1866 RelativePath="VarList.cpp"1867 >1868 <FileConfiguration1869 Name="Debug|Win32"1870 >1871 <Tool1872 Name="VCCLCompilerTool"1873 PreprocessorDefinitions=""1874 />1875 </FileConfiguration>1876 <FileConfiguration1877 Name="Release|Win32"1878 >1879 <Tool1880 Name="VCCLCompilerTool"1881 PreprocessorDefinitions=""1882 />1883 </FileConfiguration>1884 <FileConfiguration1885 Name="English_Rel|Win32"1886 >1887 <Tool1888 Name="VCCLCompilerTool"1889 PreprocessorDefinitions=""1890 />1891 </FileConfiguration>1892 </File>1893 <File1894 RelativePath="WatchList.cpp"1895 >1896 <FileConfiguration1897 Name="Debug|Win32"1898 >1899 <Tool1900 Name="VCCLCompilerTool"1901 PreprocessorDefinitions=""1902 />1903 </FileConfiguration>1904 <FileConfiguration1905 Name="Release|Win32"1906 >1907 <Tool1908 Name="VCCLCompilerTool"1909 PreprocessorDefinitions=""1910 />1911 </FileConfiguration>1912 <FileConfiguration1913 Name="English_Rel|Win32"1914 >1915 <Tool1916 Name="VCCLCompilerTool"1917 PreprocessorDefinitions=""1918 />1919 </FileConfiguration>1920 </File>1921 </Filter>1922 <Filter1923 1878 Name="CommonClasses" 1924 1879 > … … 1929 1884 <File 1930 1885 RelativePath="..\BasicCompiler_Common\Type.cpp" 1886 > 1887 </File> 1888 <File 1889 RelativePath="..\BasicCompiler_Common\Variable.cpp" 1931 1890 > 1932 1891 </File> -
BasicCompiler32/CParameter.cpp
r75 r76 39 39 } 40 40 41 Type DummyTypeInfo;41 Type dummyType; 42 42 BOOL bByVal; 43 43 if(bEllipse){ 44 DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex);44 NumOpe_GetType( Parms[i2], Type(), dummyType ); 45 45 bByVal=1; 46 46 } 47 47 else{ 48 DummyTypeInfo.type=params[i2]->GetBasicType(); 49 DummyTypeInfo.u.lpIndex=params[i2]->GetIndex(); 48 dummyType = *params[i2]; 50 49 bByVal = ( params[i2]->IsRef() == false ) ? TRUE:FALSE; 51 50 } … … 59 58 } 60 59 61 LONG_PTR lpVarIndex; 62 if( GetVarType( Parms[i2], &lpVarIndex, FALSE ) == -1 ){ 60 if( !GetVarType( Parms[i2], Type(), FALSE ) ){ 63 61 //変数ではないとき 64 int reg = REG_RAX;65 int type = NumOpe( Parms[i2], DummyTypeInfo.type, DummyTypeInfo.u.lpIndex, &lpVarIndex);62 Type calcType; 63 NumOpe( Parms[i2], dummyType, calcType ); 66 64 //↑ここでスタックに積む 67 65 68 66 nCountOfTempObjects++; 69 67 70 if( type != DEF_STRUCT){68 if( !calcType.IsStruct() ){ 71 69 //一時参照を作成 72 70 … … 78 76 79 77 bool result = CheckDifferentType( 80 DummyTypeInfo.type, 81 DummyTypeInfo.u.lpIndex, 82 type, 83 lpVarIndex, 78 dummyType, 79 calcType, 84 80 procName.c_str(), 85 81 i2); … … 89 85 useTempObject = true; 90 86 91 types[i2].type = type; 92 types[i2].u.lpIndex = lpVarIndex; 87 types[i2] = calcType; 93 88 } 94 89 } … … 107 102 for(int i2=ParmsNum-1;i2>=0;i2--){ 108 103 if( useTempParameters[i2] ){ 109 if( types[i2]. type == DEF_STRUCT){104 if( types[i2].IsStruct() ){ 110 105 // 構造体の一時メモリ 111 106 … … 117 112 } 118 113 else{ 119 if( Is64Type( types[i2].type) ){114 if( types[i2].Is64() ){ 120 115 //pop ... 参照を消す 121 116 //pop ... 上位32ビット … … 133 128 } 134 129 135 void ParamImpl::SetStructParameter( CClass *pobj_Class,LPSTR Parameter){136 int object_size = pobj_Class->GetSize();130 void ParamImpl::SetStructParameter( const Type &baseType, const char *expression ){ 131 int object_size = baseType.GetClass().GetSize(); 137 132 138 133 //push object_size … … 143 138 op_call(pSub_calloc); 144 139 140 //push eax(ここでプッシュされた値が実際にパラメータとして引き渡される) 141 op_push(REG_EAX); 142 145 143 //push eax 146 144 op_push(REG_EAX); 147 145 148 149 Type BaseType={DEF_STRUCT,(LONG_PTR)pobj_Class}; 150 Type CalcType; 151 CalcType.type=NumOpe_GetType_Old(Parameter,&BaseType,&CalcType.u.lpIndex); 152 153 /* 154 TODO: 消す 155 if( pobj_Class->GetCopyConstructorMethod() 156 && CalcType.type==DEF_OBJECT&&CalcType.u.pobj_Class==pobj_Class){ 157 //////////////////////////////////// 158 // コピーコンストラクタを呼び出す 159 //////////////////////////////////// 160 161 //push eax 162 op_push(REG_EAX); 163 164 BOOL bUseHeap; 165 CalcType.type=NumOpe(Parameter,DEF_OBJECT,(LONG_PTR)pobj_Class,&CalcType.u.lpIndex,&bUseHeap); 166 167 //pop ecx 168 op_pop(REG_ECX); 169 170 //pop eax 171 op_pop(REG_EAX); 172 173 if(bUseHeap){ 174 //※解放用に退避 175 //mov esi,ecx 176 op_mov_RR(REG_ESI,REG_ECX); 177 } 178 179 //push ecx 180 op_push(REG_ECX); 181 182 //push eax 183 op_push(REG_EAX); 184 185 //call constructor 186 op_call(pobj_Class->GetCopyConstructorMethod()->pUserProc); 187 188 189 if(bUseHeap){ 190 FreeTempObject(REG_ESI,pobj_Class); 191 } 192 } 193 else{*/ 194 195 196 //push eax 197 op_push(REG_EAX); 198 199 /* 200 TODO: 消す 201 if( pobj_Class->GetConstructorMethod() ){ 202 //////////////////////////////// 203 // コンストラクタを呼び出す 204 //////////////////////////////// 205 206 //push this 207 op_push(REG_EAX); 208 209 //call constructor 210 op_call(pobj_Class->GetConstructorMethod()->pUserProc); 211 } 212 */ 213 214 BOOL bUseHeap; 215 CalcType.type=NumOpe(Parameter,DEF_STRUCT,(LONG_PTR)pobj_Class,&CalcType.u.lpIndex,&bUseHeap); 216 217 218 219 SetStructVariable((LONG_PTR)pobj_Class,CalcType.type,CalcType.u.lpIndex,bUseHeap); 220 //} 146 Type calcType; 147 BOOL bUseHeap; 148 NumOpe( expression, 149 baseType, 150 calcType, 151 &bUseHeap ); 152 153 // ※スタックにある二つのデータ(コピー先、コピー元)の値を必要とする 154 SetStructVariable( baseType, calcType, bUseHeap ); 221 155 } 222 156 … … 247 181 248 182 //パラメータをレジスタとスタックに格納 249 int CalcType;250 LONG_PTR lpCalcIndex;251 BOOL bCalcUseHeap;252 183 int ParmSize=0; 253 184 RELATIVE_VAR RelativeVar; … … 269 200 } 270 201 271 Type DummyTypeInfo;202 Type dummyType; 272 203 BOOL bByVal; 273 204 if(bEllipse){ 274 DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex);205 NumOpe_GetType( Parms[i2], Type(), dummyType ); 275 206 bByVal=1; 276 207 } 277 208 else{ 278 DummyTypeInfo.type=params[i2]->GetBasicType(); 279 DummyTypeInfo.u.lpIndex=params[i2]->GetIndex(); 280 bByVal = (params[i2]->IsRef() == false ) ? TRUE:FALSE; 209 dummyType = *params[i2]; 210 bByVal = ( params[i2]->IsRef() == false ) ? TRUE:FALSE; 281 211 } 282 212 … … 291 221 } 292 222 293 if( DummyTypeInfo.type==DEF_STRUCT){294 SetStructParameter( DummyTypeInfo.u.pobj_Class,Parms[i2]);223 if( dummyType.IsStruct() ){ 224 SetStructParameter( dummyType, Parms[i2] ); 295 225 goto next; 296 226 } 297 227 298 299 228 extern LONG_PTR ProcPtr_BaseIndex; 300 LONG_PTR back_ProcPtr_BaseIndex; 301 back_ProcPtr_BaseIndex=ProcPtr_BaseIndex; 302 if(DummyTypeInfo.type==DEF_PTR_PROC) ProcPtr_BaseIndex=DummyTypeInfo.u.lpIndex; 303 else ProcPtr_BaseIndex=-1; 304 305 CalcType=NumOpe(Parms[i2],DummyTypeInfo.type,DummyTypeInfo.u.lpIndex,&lpCalcIndex,&bCalcUseHeap); 229 LONG_PTR back_ProcPtr_BaseIndex = ProcPtr_BaseIndex; 230 if( dummyType.IsProcPtr() ){ 231 ProcPtr_BaseIndex = dummyType.GetIndex(); 232 } 233 else{ 234 ProcPtr_BaseIndex=-1; 235 } 236 237 BOOL bCalcUseHeap; 238 Type calcType; 239 if( !NumOpe( Parms[i2], dummyType, calcType, &bCalcUseHeap ) ){ 240 break; 241 } 306 242 307 243 ProcPtr_BaseIndex=back_ProcPtr_BaseIndex; 308 244 309 if(CalcType==-1) break; 310 311 if(CalcType==DEF_OBJECT){ 312 if( DummyTypeInfo.type != DEF_OBJECT 245 if( calcType.IsObject() ){ 246 if( !dummyType.IsObject() 313 247 || 314 DummyTypeInfo.type == DEF_OBJECT&&315 ! DummyTypeInfo.u.pobj_Class->IsEqualsOrSubClass( (CClass *)lpCalcIndex) ){248 dummyType.IsObject() && 249 !dummyType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) ){ 316 250 //キャスト演算子のオーバーロードに対応する 317 CallCastOperatorProc( CalcType,lpCalcIndex,bCalcUseHeap,DummyTypeInfo.type,DummyTypeInfo.u.lpIndex);251 CallCastOperatorProc( calcType, bCalcUseHeap,dummyType ); 318 252 } 319 253 } 320 254 321 255 if(!bEllipse){ 256 //型チェック 257 // TODO: _System_ReturnValueが考慮されていない? 258 if(bHas_System_LocalThis) i3=i2-1; 259 else i3=i2; 260 CheckDifferentType( 261 dummyType, 262 calcType, 263 procName.c_str(), 264 i3); 265 } 266 267 if( dummyType.IsDouble() ){ 268 ChangeTypeToDouble( calcType.GetBasicType() ); 269 ParmSize+=sizeof(long)*2; 270 } 271 else if( dummyType.IsSingle() ){ 272 ChangeTypeToSingle( calcType.GetBasicType() ); 273 ParmSize+=sizeof(long); 274 } 275 else if( dummyType.Is64() ){ 276 ChangeTypeToInt64( calcType.GetBasicType() ); 277 ParmSize+=sizeof(long)*2; 278 } 279 else if( dummyType.IsLong() || dummyType.IsDWord() 280 || dummyType.IsPointer() 281 || dummyType.IsObject() || dummyType.IsStruct() ){ 282 ChangeTypeToLong( calcType.GetBasicType() ); 283 ParmSize+=sizeof(long); 284 } 285 else if( dummyType.IsInteger() || dummyType.IsWord() ){ 286 ChangeTypeToInteger( calcType.GetBasicType() ); 287 ParmSize+=sizeof(long); 288 } 289 else if( dummyType.IsSByte() || dummyType.IsByte() || dummyType.IsBoolean() ){ 290 ChangeTypeToByte( calcType.GetBasicType() ); 291 ParmSize+=sizeof(long); 292 } 293 else{ 294 SetError(300,NULL,cp); 295 } 296 } 297 else{ 298 //ポインタ参照 299 if(Parms[i2][0]==1&&Parms[i2][1]==ESC_BYVAL){ 300 //ポインタ指定 301 302 Type calcType; 303 if( !NumOpe( Parms[i2]+2, dummyType, calcType) ){ 304 break; 305 } 306 307 ChangeTypeToLong( calcType.GetBasicType() ); 308 309 dummyType.PtrLevelUp(); 310 322 311 //型チェック 323 312 if(bHas_System_LocalThis) i3=i2-1; 324 313 else i3=i2; 325 314 CheckDifferentType( 326 DummyTypeInfo.type, 327 DummyTypeInfo.u.lpIndex, 328 CalcType, 329 lpCalcIndex, 315 dummyType, 316 calcType, 330 317 procName.c_str(), 331 318 i3); 332 }333 334 if(DummyTypeInfo.type==DEF_DOUBLE){335 ChangeTypeToDouble(CalcType);336 ParmSize+=sizeof(long)*2;337 }338 else if(DummyTypeInfo.type==DEF_SINGLE){339 ChangeTypeToSingle(CalcType);340 ParmSize+=sizeof(long);341 }342 else if(DummyTypeInfo.type==DEF_INT64||DummyTypeInfo.type==DEF_QWORD){343 ChangeTypeToInt64(CalcType);344 ParmSize+=sizeof(long)*2;345 }346 else if(DummyTypeInfo.type==DEF_LONG||DummyTypeInfo.type==DEF_DWORD||DummyTypeInfo.type==DEF_OBJECT||DummyTypeInfo.type==DEF_STRUCT||347 (IsPtrType(DummyTypeInfo.type)/*&&DummyTypeInfo.type!=DEF_PTR_VOID&&DummyTypeInfo.type!=DEF_PTR_BYTE*/)){348 ChangeTypeToLong(CalcType);349 ParmSize+=sizeof(long);350 }351 else if(DummyTypeInfo.type==DEF_INTEGER||DummyTypeInfo.type==DEF_WORD || (isUnicode&&DummyTypeInfo.type==DEF_CHAR)){352 ChangeTypeToInteger(CalcType);353 ParmSize+=sizeof(long);354 }355 else if(DummyTypeInfo.type==DEF_SBYTE||DummyTypeInfo.type==DEF_BYTE||DummyTypeInfo.type==DEF_BOOLEAN || (isUnicode==false&&DummyTypeInfo.type==DEF_CHAR)){356 ChangeTypeToByte(CalcType);357 ParmSize+=sizeof(long);358 }359 else{360 SetError(300,NULL,cp);361 }362 }363 else{364 //ポインタ参照365 if(Parms[i2][0]==1&&Parms[i2][1]==ESC_BYVAL){366 //ポインタ指定367 i3=NumOpe(Parms[i2]+2,0,0,0);368 369 ChangeTypeToLong(i3);370 319 } 371 320 else{ … … 373 322 //一時オブジェクトをコピー 374 323 375 if( types[i2].type != DEF_STRUCT){324 if( !types[i2].IsStruct() ){ 376 325 // 一時参照のための領域を考慮する 377 326 nCountOfNowTempObjects++; … … 393 342 else{ 394 343 //変数のアドレスを取得 395 int VarType; 396 LONG_PTR lpVarIndex; 344 Type varType; 397 345 if(GetVarOffset( 398 346 false, 399 347 false, 400 348 Parms[i2], 401 &VarType,402 349 &RelativeVar, 403 &lpVarIndex)){404 if( DummyTypeInfo.type!=DEF_ANY){350 varType)){ 351 if( !dummyType.IsAny() ){ 405 352 //型チェックを行う 406 if( DummyTypeInfo.type==VarType){407 if( DummyTypeInfo.type==DEF_OBJECT){408 if( ! DummyTypeInfo.u.pobj_Class->IsEqualsOrSubClass( (CClass *)lpVarIndex) ){353 if( dummyType.GetBasicType() == varType.GetBasicType() ){ 354 if( dummyType.IsObject() ){ 355 if( !dummyType.GetClass().IsEqualsOrSubClass( &varType.GetClass() ) ){ 409 356 SetError(11,Parms[i2],cp); 410 357 } 411 358 } 412 else if( DummyTypeInfo.type==DEF_STRUCT){413 if( ! DummyTypeInfo.u.pobj_Class->IsEquals( (CClass *)lpVarIndex) ){359 else if( dummyType.IsStruct() ){ 360 if( !dummyType.GetClass().IsEquals( &varType.GetClass() ) ){ 414 361 SetError(11,Parms[i2],cp); 415 362 } 416 363 } 417 364 } 418 else if((VarType&FLAG_PTR)&&((int)(VarType^FLAG_PTR)==DummyTypeInfo.type)){ 365 else if( (varType.GetBasicType()&FLAG_PTR) 366 &&((varType.GetBasicType()^FLAG_PTR)==dummyType.GetBasicType())){ 419 367 //仮引数がポインタ参照で、実引数が配列の先頭ポインタのとき 420 368 } -
BasicCompiler32/Compile_CallProc.cpp
r75 r76 32 32 33 33 34 int Opcode_CallProcPtr(char *variable,char *Parameter,ProcPointer *pProcPointer,LONG_PTR *plpIndex){ 35 extern HANDLE hHeap; 36 int i; 37 34 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer){ 38 35 39 36 extern BOOL bDebugCompile; … … 49 46 //パラメータオブジェクトを生成 50 47 ParamImpl *pobj_parameter=0; 51 pobj_parameter=new ParamImpl( Parameter);48 pobj_parameter=new ParamImpl(lpszParms); 52 49 53 50 //エラーチェック 54 51 if( !pobj_parameter->ErrorCheck(variable,pProcPointer->Params() ) ){ 55 52 //パラメータにエラーがあるときは処理を終える 56 return pProcPointer->ReturnType().GetBasicType();53 return false; 57 54 } 58 55 … … 69 66 //////////////////////// 70 67 RELATIVE_VAR RelativeVar; 71 LONG_PTR lp; 72 GetVarOffsetReadOnly(variable,&i,&RelativeVar,&lp); 68 GetVarOffsetReadOnly(variable,&RelativeVar,Type()); 73 69 SetVarPtrToEax(&RelativeVar); 74 70 … … 89 85 delete pobj_parameter; 90 86 91 if(plpIndex) *plpIndex=pProcPointer->ReturnType().GetIndex(); 92 93 return pProcPointer->ReturnType().GetBasicType(); 87 return true; 94 88 } 95 89 96 void Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,char *ObjectName,int RefType){90 bool Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){ 97 91 int i2; 98 92 … … 100 94 if( lstrcmpi( pUserProc->GetName().c_str(), "Print" ) == 0 ){ 101 95 Opcode_Print(Parameter,0); 102 return ;96 return true; 103 97 } 104 98 if( lstrcmpi( pUserProc->GetName().c_str(), "Input" ) == 0 ){ 105 99 Opcode_Input(Parameter); 106 return ;100 return true; 107 101 } 108 102 if( lstrcmpi( pUserProc->GetName().c_str(), "Write" ) == 0 ){ 109 103 Opcode_Print(Parameter,1); 110 return ;104 return true; 111 105 } 112 106 } … … 115 109 116 110 bool isStatic = false; 117 CClass *pobj_c = NULL;111 const CClass *pobj_c = NULL; 118 112 CMethod *pMethod = NULL; 119 113 if( pUserProc->GetParentClassPtr() ){ … … 126 120 else{ 127 121 //"->"によってオブジェクトを指定する通常のメンバ関数呼び出し 128 int type = GetVarType(ObjectName,(LONG_PTR *)&pobj_c,0); 129 if(!(NATURAL_TYPE(type)==DEF_OBJECT)){ 122 Type varType; 123 GetVarType( ObjectName, varType, false ); 124 pobj_c = &varType.GetClass(); 125 if( NATURAL_TYPE( varType.GetBasicType() ) != DEF_OBJECT ){ 130 126 pobj_c=pobj_DBClass->check(ObjectName); 131 127 if( pobj_c ){ … … 160 156 if( !pMethod ){ 161 157 SetError(300,NULL,cp); 162 return ;158 return false; 163 159 } 164 160 … … 179 175 if(dwAccess==ACCESS_NON){ 180 176 SetError(109,pUserProc->GetName(),cp); 181 return ;177 return false; 182 178 } 183 179 } … … 186 182 dwAccess==ACCESS_NON){ 187 183 SetError(109,pUserProc->GetName(),cp); 188 return ;184 return false; 189 185 } 190 186 if(dwAccess==ACCESS_PROTECTED){ 191 187 SetError(110,pUserProc->GetName(),cp); 192 return ;188 return false; 193 189 } 194 190 } … … 198 194 if(dwAccess==ACCESS_NON){ 199 195 SetError(109,pUserProc->GetName(),cp); 200 return; 201 } 202 } 203 } 204 196 return false; 197 } 198 } 199 } 205 200 206 201 … … 220 215 221 216 222 223 217 //////////////////////// 224 218 // パラメータをセット … … 232 226 if( !pobj_parameter->ErrorCheck(pUserProc->GetName(),pUserProc->RealParams(),pUserProc->GetSecondParmNum() ) ){ 233 227 //パラメータにエラーがあるときは処理を終える 234 return ;228 return false; 235 229 } 236 230 … … 278 272 if( pMethod->isConst ){ 279 273 //Constアクセスが可能なメソッドの場合 280 if( !GetVarOffsetReadOnly( ObjectName, &i2, &RelativeVar, 0 ) ) return; 274 if( !GetVarOffsetReadOnly( ObjectName, &RelativeVar, Type() ) ){ 275 return false; 276 } 281 277 } 282 278 else{ 283 279 //Constアクセスが不可能なメソッドの場合 284 if( !GetVarOffsetReadWrite( ObjectName, &i2, &RelativeVar, 0 ) ) return; 280 if( !GetVarOffsetReadWrite( ObjectName, &RelativeVar, Type() ) ){ 281 return false; 282 } 285 283 } 286 284 … … 351 349 //パラメータオブジェクトを破棄 352 350 delete pobj_parameter; 351 352 return true; 353 353 } 354 354 355 int Opcode_CallDllProc(char *Parameter,DllProc *pDllProc,LONG_PTR *plpIndex){ 356 char *temporary; 357 358 temporary=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter)+1); 355 bool Opcode_CallDllProc( const char *lpszParms, DllProc *pDllProc ){ 359 356 360 357 extern BOOL bDebugCompile; … … 371 368 //パラメータオブジェクトを生成 372 369 ParamImpl *pobj_parameter=0; 373 pobj_parameter=new ParamImpl( Parameter);370 pobj_parameter=new ParamImpl(lpszParms); 374 371 375 372 //エラーチェック 376 373 if( !pobj_parameter->ErrorCheck( pDllProc->GetName(), pDllProc->Params() ) ){ 377 374 //パラメータにエラーがあるときは処理を終える 378 return pDllProc->ReturnType().GetBasicType();375 return false; 379 376 } 380 377 … … 406 403 delete pobj_parameter; 407 404 408 if(plpIndex) *plpIndex=pDllProc->ReturnType().GetIndex(); 409 410 HeapDefaultFree(temporary); 411 412 return pDllProc->ReturnType().GetBasicType(); 405 return true; 413 406 } -
BasicCompiler32/Compile_Func.cpp
r75 r76 44 44 } 45 45 46 void Opcode_Func_Fix(const char *Parameter){ 47 int i; 48 49 i=NumOpe(Parameter,0,0,0); 50 51 if(i==DEF_DOUBLE){ 46 void Opcode_Func_Fix(const char *lpszParms){ 47 Type resultType; 48 if( !NumOpe( lpszParms, Type(), resultType ) ){ 49 return; 50 } 51 52 if( resultType.IsDouble() ){ 52 53 //fld qword ptr[esp] 53 54 op_fld_ptr_esp(DEF_DOUBLE); … … 96 97 op_add_esp(4); 97 98 } 98 else if( i==DEF_SINGLE){99 else if( resultType.IsSingle() ){ 99 100 //fld dword ptr[esp] 100 101 op_fld_ptr_esp(DEF_SINGLE); … … 146 147 op_add_esp(4); 147 148 } 148 else if( Is64Type(i)){149 else if( resultType.Is64() ){ 149 150 //pop eax 150 151 op_pop(REG_EAX); … … 162 163 163 164 void Opcode_Func_CUDbl(const char *Parameter){ 164 int i; 165 166 i=NumOpe(Parameter,0,0,0); 167 ChangeTypeToLong(i); 165 Type resultType; 166 if( !NumOpe(Parameter,Type(),resultType) ){ 167 return; 168 } 169 ChangeTypeToLong(resultType.GetBasicType()); 168 170 169 171 //pop eax … … 186 188 } 187 189 void Opcode_Func_Len(const char *Parameter){ 188 int type,TypeSize;189 LONG_PTR lpIndex;190 190 BOOL bArrayHead; 191 192 type=GetVarType(Parameter,&lpIndex,0);193 191 194 192 const char *tempParm=Parameter; 195 193 char temporary[VN_SIZE]; 196 194 char temp2[32]; 197 if(type==-1){ 195 Type type; 196 if( !GetVarType(Parameter,type,0) ){ 198 197 sprintf(temporary,"_System_DummyStr2=%s",Parameter); 199 198 OpcodeCalc(temporary); … … 203 202 204 203 extern CClass *pobj_StringClass; 205 type=DEF_OBJECT; 206 lpIndex=(LONG_PTR)pobj_StringClass; 207 } 208 209 Type TypeInfo={type,lpIndex}; 210 if(IsStringObjectType(TypeInfo)){ 204 type.SetType( DEF_OBJECT, pobj_StringClass ); 205 } 206 207 if( type.IsStringObject() ){ 211 208 //Stringオブジェクトの場合 212 char temporary[VN_SIZE];213 209 sprintf(temporary,"%s.Length",tempParm); 214 210 215 NumOpe(temporary,0,0,NULL,NULL); 211 int reg=REG_RAX; 212 NumOpe(temporary,Type(),Type()); 216 213 217 214 //pop eax … … 223 220 int SubScripts[MAX_ARRAYDIM]; 224 221 RELATIVE_VAR RelativeVar; 225 if(!GetVarOffsetReadOnly(tempParm,& type,&RelativeVar,&lpIndex,SubScripts)) return;226 227 if(type &FLAG_PTR){228 type &=~FLAG_PTR;222 if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,SubScripts)) return; 223 224 if(type.GetBasicType()&FLAG_PTR){ 225 type.SetBasicType( type.GetBasicType() & ( ~FLAG_PTR ) ); 229 226 230 227 bArrayHead=1; … … 232 229 else bArrayHead=0; 233 230 234 TypeSize=GetTypeSize(type,lpIndex);235 236 if(bArrayHead) TypeSize*=JumpSubScripts(SubScripts);231 int typeSize = type.GetSize(); 232 233 if(bArrayHead) typeSize*=JumpSubScripts(SubScripts); 237 234 238 235 //mov eax,TypeSize 239 236 OpBuffer[obp++]=(char)0xB8; 240 *((long *)(OpBuffer+obp))= TypeSize;237 *((long *)(OpBuffer+obp))=typeSize; 241 238 obp+=sizeof(long); 242 239 } 243 void Opcode_Func_AddressOf( const char *name){240 void Opcode_Func_AddressOf( const char *name ){ 244 241 extern int cp; 245 242 UserProc *pUserProc; … … 257 254 258 255 //オーバーロードを解決 259 extern ProcPointer **ppProcP trInfo;260 pUserProc=OverloadSolution(name,subs,ppProcP trInfo[ProcPtr_BaseIndex]->Params(), Type() );256 extern ProcPointer **ppProcPointer; 257 pUserProc=OverloadSolution(name,subs,ppProcPointer[ProcPtr_BaseIndex]->Params(), Type() ); 261 258 262 259 if(!pUserProc){ … … 289 286 else{ 290 287 RELATIVE_VAR RelativeVar; 291 inttype;292 if(!GetVarOffsetReadOnly(ObjectName,& type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;288 Type type; 289 if(!GetVarOffsetReadOnly(ObjectName,&RelativeVar,type)) return; 293 290 SetVarPtrToEax(&RelativeVar); 294 291 … … 297 294 298 295 //参照タイプが整合しているかをチェック 299 if(type !=RefType) SetError(104,ObjectName,cp);300 301 if(type ==DEF_PTR_OBJECT){296 if(type.GetBasicType()!=RefType) SetError(104,ObjectName,cp); 297 298 if(type.IsObjectPtr()){ 302 299 //mov ecx,dword ptr[ecx] 303 300 op_mov_RM(sizeof(long),REG_ECX,REG_ECX,0,MOD_BASE); … … 360 357 op_mov_RV( REG_EAX, size ); 361 358 } 362 void Opcode_Func_VarPtr( const char *Parameter, Type &ReturnTypeInfo ){ 359 void Opcode_Func_VarPtr( const char *Parameter, Type &resultType, bool isCallOn ){ 360 if( isCallOn == false ){ 361 // 戻り値の型を取得するだけ 362 363 //変数のアドレスを取得 364 if(!GetVarType( Parameter, resultType, true )) return; 365 366 resultType.PtrLevelUp(); 367 368 return; 369 } 370 363 371 RELATIVE_VAR RelativeVar; 364 372 365 373 //変数のアドレスを取得 366 if(!GetVarOffsetReadOnly( Parameter, &Re turnTypeInfo.type, &RelativeVar, &ReturnTypeInfo.u.lpIndex)) return;367 368 int beforeType = ReturnTypeInfo.type;369 370 PTR_LEVEL_UP( ReturnTypeInfo.type);374 if(!GetVarOffsetReadOnly( Parameter, &RelativeVar, resultType )) return; 375 376 int beforeType = resultType.GetBasicType(); 377 378 resultType.PtrLevelUp(); 371 379 372 380 SetVarPtrToEax(&RelativeVar); … … 380 388 } 381 389 void Opcode_Func_GetPtrData(const char *Parameter,const int type){ 382 int i2; 383 384 i2=NumOpe(Parameter,0,0,0); 385 ChangeTypeToLong(i2); 390 Type tempType; 391 if( !NumOpe(Parameter,Type(),tempType) ){ 392 return; 393 } 394 if(!tempType.IsWhole()){ 395 SetError(11,Parameter,cp); 396 return; 397 } 398 ChangeTypeToLong(tempType.GetBasicType()); 386 399 387 400 if(type==DEF_DOUBLE){ … … 438 451 } 439 452 440 void Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &ReturnTypeInfo){453 bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn ){ 441 454 switch(FuncNum){ 442 455 case FUNC_FIX: 443 Opcode_Func_Fix(Parameter);444 ReturnTypeInfo.type = DEF_LONG;456 if( isCallOn ) Opcode_Func_Fix(Parameter); 457 resultType.SetBasicType( DEF_LONG ); 445 458 break; 446 459 case FUNC_CUDBL: 447 Opcode_Func_CUDbl(Parameter);448 ReturnTypeInfo.type = DEF_DOUBLE;460 if( isCallOn ) Opcode_Func_CUDbl(Parameter); 461 resultType.SetBasicType( DEF_DOUBLE ); 449 462 break; 450 463 case FUNC_LEN: 451 Opcode_Func_Len(Parameter);452 ReturnTypeInfo.type = DEF_LONG;464 if( isCallOn ) Opcode_Func_Len(Parameter); 465 resultType.SetBasicType( DEF_LONG ); 453 466 break; 454 467 case FUNC_ADDRESSOF: 455 Opcode_Func_AddressOf(Parameter);456 ReturnTypeInfo.type = DEF_PTR_VOID;468 if( isCallOn ) Opcode_Func_AddressOf(Parameter); 469 resultType.SetBasicType( DEF_PTR_VOID ); 457 470 break; 458 471 case FUNC_SIZEOF: 459 Opcode_Func_SizeOf(Parameter);460 ReturnTypeInfo.type = DEF_LONG;472 if( isCallOn ) Opcode_Func_SizeOf(Parameter); 473 resultType.SetBasicType( DEF_LONG ); 461 474 break; 462 475 case FUNC_VARPTR: 463 Opcode_Func_VarPtr( Parameter, ReturnTypeInfo);476 Opcode_Func_VarPtr( Parameter, resultType, isCallOn ); 464 477 break; 465 478 466 479 case FUNC_GETDOUBLE: 467 Opcode_Func_GetPtrData(Parameter,DEF_DOUBLE);468 ReturnTypeInfo.type = DEF_DOUBLE;480 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_DOUBLE); 481 resultType.SetBasicType( DEF_DOUBLE ); 469 482 break; 470 483 case FUNC_GETSINGLE: 471 Opcode_Func_GetPtrData(Parameter,DEF_SINGLE);472 ReturnTypeInfo.type = DEF_SINGLE;484 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_SINGLE); 485 resultType.SetBasicType( DEF_SINGLE ); 473 486 break; 474 487 case FUNC_GETQWORD: 475 Opcode_Func_GetPtrData(Parameter,DEF_QWORD);476 ReturnTypeInfo.type = DEF_QWORD;488 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_QWORD); 489 resultType.SetBasicType( DEF_QWORD ); 477 490 break; 478 491 case FUNC_GETDWORD: 479 Opcode_Func_GetPtrData(Parameter,DEF_DWORD);480 ReturnTypeInfo.type = DEF_DWORD;492 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_DWORD); 493 resultType.SetBasicType( DEF_DWORD ); 481 494 break; 482 495 case FUNC_GETWORD: 483 Opcode_Func_GetPtrData(Parameter,DEF_WORD);484 ReturnTypeInfo.type = DEF_WORD;496 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_WORD); 497 resultType.SetBasicType( DEF_WORD ); 485 498 break; 486 499 case FUNC_GETBYTE: 487 Opcode_Func_GetPtrData(Parameter,DEF_BYTE); 488 ReturnTypeInfo.type = DEF_BYTE; 489 break; 490 } 491 } 500 if( isCallOn ) Opcode_Func_GetPtrData(Parameter,DEF_BYTE); 501 resultType.SetBasicType( DEF_BYTE ); 502 break; 503 default: 504 return false; 505 } 506 return true; 507 } -
BasicCompiler32/Compile_ProcOp.cpp
r75 r76 26 26 } 27 27 28 extern BOOL bCompilingGlobal; 29 BOOL bBackCompilingGlobal; 30 bBackCompilingGlobal=bCompilingGlobal; 31 bCompilingGlobal=1; 28 UserProc *pBackUserProc; 29 pBackUserProc = &UserProc::CompilingUserProc(); 30 UserProc::CompileStartForGlobalArea(); 32 31 33 32 int BackCp; … … 49 48 GetGlobalDataForDll(); 50 49 51 bCompilingGlobal=bBackCompilingGlobal;50 UserProc::CompileStartForUserProc( pBackUserProc ); 52 51 cp=BackCp; 53 52 … … 58 57 //静的ローカルオブジェクトのコンストラクタ呼び出し 59 58 60 extern int MaxGlobalVarNum; 61 extern VARIABLE *GlobalVar; 62 int i; 63 for(i=0;i<MaxGlobalVarNum;i++){ 64 if(_memicmp(GlobalVar[i].name,"Static%",7)==0){ 59 foreach( Variable *pVar, globalVars ){ 60 if(memicmp(pVar->GetName().c_str(),"Static%",7)==0){ 65 61 //コンストラクタ呼び出し 66 if( GlobalVar[i].type==DEF_OBJECT){62 if( pVar->IsObject() ){ 67 63 68 64 //エラー用 69 cp=GlobalVar[i].source_code_address; 70 71 Type TypeInfo; 72 TypeInfo.type=GlobalVar[i].type; 73 TypeInfo.u.lpIndex=GlobalVar[i].u.index; 65 cp=pVar->source_code_address; 66 74 67 CallConstructor( 75 GlobalVar[i].name,76 GlobalVar[i].SubScripts,77 TypeInfo,78 GlobalVar[i].ConstractParameter);68 pVar->GetName().c_str(), 69 pVar->GetSubScriptsPtr(), 70 *pVar, 71 pVar->paramStrForConstructor.c_str()); 79 72 } 80 73 } … … 86 79 else if(lstrcmp(name,"_System_Call_Destructor_of_GlobalObject")==0){ 87 80 88 extern BOOL bCompilingGlobal; 89 BOOL bBackCompilingGlobal; 90 bBackCompilingGlobal=bCompilingGlobal; 91 bCompilingGlobal=1; 81 UserProc *pBackUserProc; 82 pBackUserProc = &UserProc::CompilingUserProc(); 83 UserProc::CompileStartForGlobalArea(); 92 84 93 85 obj_LexScopes.CallDestructorsOfScopeEnd(); 94 86 95 bCompilingGlobal=bBackCompilingGlobal;87 UserProc::CompileStartForUserProc( pBackUserProc ); 96 88 97 89 … … 219 211 extern UserProc **ppSubHash; 220 212 extern BOOL bDebugCompile; 221 int i3,i4, VarSize,LocalVarSchedule,EspOffsetSchedule,BufferSize,BaseOffset;213 int i3,i4,LocalVarSchedule,EspOffsetSchedule,BaseOffset; 222 214 char temporary[VN_SIZE]; 223 215 224 BufferSize=128;225 226 216 if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return; 217 218 if( pUserProc->localVars.size() ){ 219 SetError(); 220 return; 221 } 227 222 228 223 pUserProc->CompleteCompile(); … … 235 230 if(memcmp(pUserProc->GetName().c_str(),"_DebugSys_",10)==0){ 236 231 if(!bDebugCompile){ 237 pUserProc->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);238 pUserProc->VarNum=0;239 232 return; 240 233 } … … 246 239 247 240 if(pUserProc->IsSystem()){ 248 extern int MaxLocalVarNum;249 241 extern int AllLocalVarSize; 250 MaxLocalVarNum=0;251 242 AllLocalVarSize=0; 252 243 … … 254 245 255 246 pUserProc->endOpAddress=obp; 256 pUserProc->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);257 pUserProc->VarNum=0;258 247 return; 259 248 } … … 266 255 267 256 //ローカル変数に関する情報 268 extern VARIABLE *LocalVar;269 extern int MaxLocalVarNum;270 257 extern int AllLocalVarSize; 271 LocalVar=(VARIABLE *)HeapAlloc(hHeap,0,1);272 MaxLocalVarNum=0;273 258 AllLocalVarSize=0; 274 259 … … 283 268 Parameter ¶m = *pUserProc->RealParams()[i3]; 284 269 285 //変数データを追加 286 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE)); 287 288 lstrcpy( LocalVar[MaxLocalVarNum].name,param.GetVarName().c_str() ); 289 290 // TODO: パラメータのConst定義の指定が未完成 291 LocalVar[MaxLocalVarNum].bConst=false; 292 293 LocalVar[MaxLocalVarNum].bArray=param.IsArray()?TRUE:FALSE; 294 memcpy(LocalVar[MaxLocalVarNum].SubScripts,param.GetSubScriptsPtr(),MAX_ARRAYDIM*sizeof(int)); 295 296 LocalVar[MaxLocalVarNum].type=param.GetBasicType(); 297 if(LocalVar[MaxLocalVarNum].type==DEF_OBJECT 298 ||LocalVar[MaxLocalVarNum].type==DEF_STRUCT){ 299 if(pUserProc->IsExport()) 300 SetError(24,NULL,cp); 301 } 302 303 LocalVar[MaxLocalVarNum].u.index=param.GetIndex(); 304 270 Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef() ); 271 272 if( param.IsArray() ){ 273 pVar->SetArray( param.GetSubScriptsPtr() ); 274 } 275 276 int varSize; 305 277 if( param.IsRef() == false && param.IsStruct() ){ 306 278 //構造体のByValパラメータ 307 LocalVar[MaxLocalVarNum].fRef=REF_PARAMETER | OBJECT_PARAMETER;308 VarSize=PTR_SIZE;279 pVar->ThisIsParameter(); 280 varSize=PTR_SIZE; 309 281 } 310 282 else{ 311 if( param.IsRef() == false && param.IsArray() == false ){ 312 LocalVar[MaxLocalVarNum].fRef=0; 313 VarSize=GetTypeSize(LocalVar[MaxLocalVarNum].type,LocalVar[MaxLocalVarNum].u.index); 314 if(VarSize%PTR_SIZE) VarSize+=PTR_SIZE-(VarSize%PTR_SIZE); 283 if( param.IsArray() == false ){ 284 varSize = pVar->GetMemorySize(); 315 285 } 316 286 else{ 317 LocalVar[MaxLocalVarNum].fRef=REF_PARAMETER; 318 VarSize=PTR_SIZE; 319 } 320 } 321 AllLocalVarSize+=VarSize; 322 LocalVar[MaxLocalVarNum].offset=AllLocalVarSize; 287 varSize=PTR_SIZE; 288 } 289 } 290 AllLocalVarSize+=varSize; 291 pVar->offset=AllLocalVarSize; 323 292 324 293 //レキシカルスコープ情報 325 LocalVar[MaxLocalVarNum].ScopeLevel=obj_LexScopes.GetNowLevel();326 LocalVar[MaxLocalVarNum].ScopeStartAddress=obj_LexScopes.GetStartAddress();327 LocalVar[MaxLocalVarNum].bLiving=TRUE;328 329 MaxLocalVarNum++;294 pVar->ScopeLevel=obj_LexScopes.GetNowLevel(); 295 pVar->ScopeStartAddress=obj_LexScopes.GetStartAddress(); 296 pVar->bLiving=TRUE; 297 298 pUserProc->localVars.push_back( pVar ); 330 299 } 331 300 … … 346 315 347 316 //コンパイル中の関数 348 extern UserProc *pCompilingUserProc; 349 pCompilingUserProc=pUserProc; 317 UserProc::CompileStartForUserProc( pUserProc ); 350 318 351 319 … … 507 475 } 508 476 509 510 477 //実体クラスを持つメンバのコンストラクタ(引数有りを除く)を呼び出す 511 478 for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){ 512 479 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3]; 513 if(pMember-> TypeInfo.type==DEF_OBJECT){480 if(pMember->IsObject()){ 514 481 // オブジェクトメンバを発見したとき 515 482 … … 517 484 pMember->name, 518 485 1, ESC_NEW, 519 pMember-> TypeInfo.u.pobj_Class->name );486 pMember->GetClass().name ); 520 487 OpcodeCalc( temporary ); 521 488 } 522 489 } 523 524 490 525 491 //仮想関数テーブルを初期化 … … 686 652 //戻り値をeax、edxに設定 687 653 RELATIVE_VAR RelativeVar; 688 LONG_PTR lpIndex;689 654 690 655 const char *temp = pUserProc->GetName().c_str(); … … 692 657 temp="_System_ReturnValue"; 693 658 } 694 GetVarOffsetReadWrite(temp,& i3,&RelativeVar,&lpIndex);659 GetVarOffsetReadWrite(temp,&RelativeVar,Type()); 695 660 696 661 i3=pUserProc->ReturnType().GetBasicType(); … … 773 738 } 774 739 HeapDefaultFree(pLocalVarAddrSchedule); 775 for(i3=0;i3<MaxLocalVarNum;i3++){ 776 LocalVar[i3].offset=AllLocalVarSize-LocalVar[i3].offset;//後にデバッグで利用する 740 foreach( Variable *pVar, pUserProc->localVars ){ 741 //後にデバッグで利用する 742 pVar->offset = AllLocalVarSize - pVar->offset; 777 743 } 778 744 … … 828 794 } 829 795 796 830 797 pUserProc->endOpAddress=obp; 831 pUserProc->pVar=LocalVar;832 pUserProc->VarNum=MaxLocalVarNum;833 798 834 799 -
BasicCompiler32/Compile_Statement.cpp
r75 r76 71 71 } 72 72 73 74 73 int idProc; 75 void *p Info;76 idProc=GetProc(buffer, &pInfo);74 void *pProc; 75 idProc=GetProc(buffer,(void **)&pProc); 77 76 78 77 int i4; … … 92 91 //////////////// 93 92 94 LONG_PTR lp;95 i2=CallProc(idProc,pInfo,buffer,temp2,&lp);93 Type resultType; 94 CallProc(idProc,pProc,buffer,temp2,resultType); 96 95 97 96 … … 100 99 ///////////////////// 101 100 102 if( i2==DEF_DOUBLE||i2==DEF_SINGLE){101 if( resultType.IsReal() ){ 103 102 //fstp st(0) 104 103 OpBuffer[obp++]=(char)0xDD; 105 104 OpBuffer[obp++]=(char)0xD8; 106 105 } 107 if(i2==DEF_STRUCT){106 else if( resultType.IsStruct() ){ 108 107 //mov ebx,eax 109 108 op_mov_RR(REG_EBX,REG_EAX); 110 109 111 FreeTempObject(REG_EBX, (CClass *)lp);110 FreeTempObject(REG_EBX,&resultType.GetClass()); 112 111 } 113 112 return; … … 122 121 123 122 void OpcodeIf(char *Parameter){ 124 int i,i2,i3,i4,type; 123 int i,i2,i3,i4; 124 Type tempType; 125 125 126 126 for(i=0;;i++){ … … 135 135 } 136 136 137 type=NumOpe(Parameter,0,0,0); 138 139 if(type==-1){ 137 if( !NumOpe(Parameter,Type(),tempType) ){ 140 138 //NumOpe内でエラー 141 139 i3=-1; //ダミー 142 140 } 143 else if( type==DEF_DOUBLE){141 else if( tempType.IsDouble() ){ 144 142 //fld qword ptr[esp] 145 143 op_fld_ptr_esp(DEF_DOUBLE); … … 175 173 i3=obp; 176 174 } 177 else if( type==DEF_SINGLE){175 else if( tempType.IsSingle() ){ 178 176 //fld dword ptr[esp] 179 177 op_fld_ptr_esp(DEF_SINGLE); … … 209 207 i3=obp; 210 208 } 211 else if( type==DEF_INT64||type==DEF_QWORD){209 else if( tempType.Is64() ){ 212 210 //64ビット型 213 211 … … 383 381 void OpcodeWhile(char *Parameter){ 384 382 extern HANDLE hHeap; 385 int i2,i3 ,type;383 int i2,i3 = 0; 386 384 387 385 //Continueアドレスのバックアップとセット … … 392 390 393 391 if(!Parameter[0]) SetError(10,"While",cp); 394 type=NumOpe(Parameter,0,0,0);395 392 396 393 int je_schedule; 397 if(type==DEF_DOUBLE){ 394 Type tempType; 395 if( !NumOpe(Parameter,Type(),tempType) ){ 396 //ダミー 397 i3=-1; 398 } 399 else if( tempType.IsDouble() ){ 398 400 //fld qword ptr[esp] 399 401 op_fld_ptr_esp(DEF_DOUBLE); … … 429 431 je_schedule=obp; 430 432 } 431 else if( type==DEF_SINGLE){433 else if( tempType.IsSingle() ){ 432 434 //fld dword ptr[esp] 433 435 op_fld_ptr_esp(DEF_SINGLE); … … 463 465 je_schedule=obp; 464 466 } 465 else if( type==DEF_INT64||type==DEF_QWORD){467 else if( tempType.Is64() ){ 466 468 //64ビット型 467 469 … … 533 535 534 536 obj_LexScopes.CallDestructorsOfScopeEnd(); 537 538 if( i3 == -1 ){ 539 return; 540 } 535 541 536 542 //jmp ... … … 605 611 //増加か減少かを区別する 606 612 sprintf(temporary,"(%s)>=0",StepNum); 607 NumOpe(temporary, 0,0,0);613 NumOpe(temporary,Type(),Type()); 608 614 609 615 //pop eax … … 623 629 //判定(カウンタ増加の場合) 624 630 sprintf(temporary,"%s<=(%s)",variable,JudgeNum); 625 NumOpe(temporary, 0,0,0);631 NumOpe(temporary,Type(),Type()); 626 632 627 633 //pop eax … … 637 643 //判定(カウンタ減少の場合) 638 644 sprintf(temporary,"%s>=(%s)",variable,JudgeNum); 639 NumOpe(temporary, 0,0,0);645 NumOpe(temporary,Type(),Type()); 640 646 641 647 //pop eax … … 687 693 void OpcodeDo(char *Parameter){ 688 694 extern HANDLE hHeap; 689 int i,i2,i3,i4 ,type;695 int i,i2,i3,i4; 690 696 691 697 if(Parameter[0]) SetError(10,"Do",cp); … … 724 730 } 725 731 726 type=NumOpe(temporary,0,0,0); 727 728 if(type==DEF_DOUBLE){ 732 Type tempType; 733 NumOpe(temporary,Type(),tempType); 734 735 if( tempType.IsDouble() ){ 729 736 //fld qword ptr[esp] 730 737 op_fld_ptr_esp(DEF_DOUBLE); … … 767 774 } 768 775 } 769 else if( type==DEF_SINGLE){776 else if( tempType.IsSingle() ){ 770 777 //fld dword ptr[esp] 771 778 op_fld_ptr_esp(DEF_SINGLE); … … 808 815 } 809 816 } 810 else if( type==DEF_INT64||type==DEF_QWORD){817 else if( tempType.Is64() ){ 811 818 //64ビット型 812 819 … … 933 940 extern HANDLE hHeap; 934 941 935 extern BOOL bCompilingGlobal; 936 if(bCompilingGlobal){ 942 if( UserProc::IsGlobalAreaCompiling() ){ 937 943 SetError(12,"Exit Sub/Function",cp); 938 944 return; … … 963 969 964 970 int CaseTypeSize; 965 void OpcodeSelect(const char *lpszPar ams){971 void OpcodeSelect(const char *lpszParms){ 966 972 extern DWORD *pCaseSchedule; 967 973 extern int CaseScheduleNum; … … 970 976 extern HANDLE hHeap; 971 977 extern char *basbuf; 972 int i,i2,i3,sw, type1,type2,NowCaseCp;978 int i,i2,i3,sw,NowCaseCp; 973 979 char temporary[VN_SIZE]; 974 980 … … 986 992 NowCaseSchedule=0; 987 993 988 LONG_PTR lpIndex; 989 type1=NumOpe(lpszParams,0,0,&lpIndex); 990 if(type1==DEF_INTEGER|| 991 type1==DEF_WORD|| 992 type1==DEF_SBYTE|| 993 type1==DEF_BYTE|| 994 type1==DEF_BOOLEAN|| 995 type1==DEF_CHAR) CaseTypeSize=sizeof(long); 996 else{ 997 CaseTypeSize=GetTypeSize(type1,lpIndex); 998 if(type1==DEF_OBJECT) CaseTypeSize=PTR_SIZE; 994 Type type1; 995 if( !NumOpe(lpszParms,Type(), type1 ) ){ 996 return; 997 } 998 999 CaseTypeSize = type1.GetSize(); 1000 if( CaseTypeSize < sizeof(long) ){ 1001 CaseTypeSize=sizeof(long); 999 1002 } 1000 1003 … … 1067 1070 cp=NowCaseCp; 1068 1071 1069 LONG_PTR lpIndex2; 1070 type2=NumOpe(temporary,type1,lpIndex,&lpIndex2); 1072 Type type2; 1073 if( !NumOpe(temporary,type1,type2) ){ 1074 return; 1075 } 1071 1076 1072 1077 cp=i2; 1073 1078 1074 if(type1==DEF_OBJECT){ 1075 CClass *pobj_c; 1076 pobj_c=(CClass *)lpIndex; 1077 1079 if(type1.IsObject()){ 1078 1080 std::vector<UserProc *> subs; 1079 pobj_c->EnumMethod( CALC_EQUAL, subs );1081 type1.GetClass().EnumMethod( CALC_EQUAL, subs ); 1080 1082 if( subs.size() == 0 ){ 1081 1083 return; … … 1083 1085 1084 1086 Parameters params; 1085 params.push_back( new Parameter( "", Type( type2 , lpIndex2) ) );1087 params.push_back( new Parameter( "", Type( type2 ) ) ); 1086 1088 1087 1089 //オーバーロードを解決 … … 1121 1123 obp+=sizeof(long); 1122 1124 } 1123 else if(type1 ==DEF_DOUBLE){1124 ChangeTypeToDouble(type2 );1125 else if(type1.IsDouble()){ 1126 ChangeTypeToDouble(type2.GetBasicType()); 1125 1127 1126 1128 //fld qword ptr[esp] … … 1152 1154 obp+=sizeof(long); 1153 1155 } 1154 else if(type1 ==DEF_SINGLE){1155 ChangeTypeToSingle(type2 );1156 else if(type1.IsSingle()){ 1157 ChangeTypeToSingle(type2.GetBasicType()); 1156 1158 1157 1159 //fld dword ptr[esp] … … 1314 1316 } 1315 1317 void OpcodeReturn(char *Parameter){ 1316 extern BOOL bCompilingGlobal; 1317 if(bCompilingGlobal){ 1318 if( UserProc::IsGlobalAreaCompiling() ){ 1318 1319 //Gosub~Returnとして扱う 1319 1320 … … 1324 1325 //戻り値をセット 1325 1326 if(Parameter[0]){ 1326 extern UserProc *pCompilingUserProc; 1327 UserProc &proc = UserProc::CompilingUserProc(); 1328 1327 1329 const char *temp = "_System_ReturnValue"; 1328 if(p CompilingUserProc->GetName()[0]==1&&pCompilingUserProc->GetName()[1]==ESC_OPERATOR)1330 if(proc.GetName()[0]==1&&proc.GetName()[1]==ESC_OPERATOR) 1329 1331 { 1330 1332 } 1331 else temp=pCompilingUserProc->GetName().c_str(); 1333 else{ 1334 temp=proc.GetName().c_str(); 1335 } 1332 1336 1333 1337 char temporary[VN_SIZE]; … … 1341 1345 } 1342 1346 1343 void Opcode_Input(const char *Parameter){1344 extern int cp;1345 int i2,i3,i4,i5,type;1346 BOOL bFile;1347 char temporary[VN_SIZE],temp2[VN_SIZE],buffer[VN_SIZE];1348 1349 if(Parameter[0]=='#'){1350 bFile=1;1351 for(i2=0,i3=1;;i2++,i3++){1352 buffer[i2]=Parameter[i3];1353 if(Parameter[i3]==','||Parameter[i3]=='\0') break;1354 }1355 buffer[i2+1]=0;1356 i2=i3+1;1357 }1358 else{1359 bFile=0;1360 i2=0;1361 buffer[0]=0;1362 1363 //表示用文字列パラメータをセット1364 if(Parameter[0]=='\"'){1365 buffer[0]='\"';1366 for(i2=1;;i2++){1367 if(Parameter[i2]=='\"'){1368 buffer[i2]=0;1369 break;1370 }1371 buffer[i2]=Parameter[i2];1372 }1373 if(Parameter[i2+1]==';') lstrcpy(buffer+i2,"? \"");1374 else if(Parameter[i2+1]==',') lstrcpy(buffer+i2,"\"");1375 else SetError(10,"Input",cp);1376 i2+=2;1377 }1378 else if((Parameter[0]=='e'||Parameter[0]=='E')&&1379 (Parameter[1]=='x'||Parameter[1]=='X')&&1380 Parameter[2]=='\"'){1381 memcpy(buffer,Parameter,3);1382 for(i2=3;;i2++){1383 if(Parameter[i2]=='\"'){1384 buffer[i2]=0;1385 break;1386 }1387 buffer[i2]=Parameter[i2];1388 }1389 if(Parameter[i2+1]==';') lstrcpy(buffer+i2,"? \"");1390 else if(Parameter[i2+1]==',') lstrcpy(buffer+i2,"\"");1391 else SetError(10,"Input",cp);1392 i2+=2;1393 }1394 else{1395 lstrcpy(buffer,"\"? \"");1396 i2=0;1397 }1398 }1399 1400 //変数ポインタ、変数のタイプをセット1401 i4=0;1402 while(1){1403 for(i3=0;;i2++,i3++){1404 if(Parameter[i2]=='('){1405 i5=GetStringInPare(temporary+i3,Parameter+i2);1406 i2+=i5-1;1407 i3+=i5-1;1408 }1409 if(Parameter[i2]=='['){1410 i5=GetStringInBracket(temporary+i3,Parameter+i2);1411 i2+=i5-1;1412 i3+=i5-1;1413 }1414 if(Parameter[i2]==','){1415 temporary[i3]=0;1416 i2++;1417 break;1418 }1419 temporary[i3]=Parameter[i2];1420 if(Parameter[i2]=='\0') break;1421 }1422 if(temporary[0]=='\0'){1423 SetError(10,"Input",cp);1424 return;1425 }1426 1427 LONG_PTR lpIndex;1428 type = GetVarType(temporary,&lpIndex,1);1429 1430 sprintf(temp2,"_System_InputDataPtr[%d]=VarPtr(%s)",i4,temporary);1431 OpcodeCalc(temp2);1432 1433 if(type==DEF_LONG) type=DEF_DWORD;1434 else if(type==DEF_INTEGER) type=DEF_WORD;1435 else if(type==DEF_OBJECT){1436 CClass *pobj_Class=(CClass *)lpIndex;1437 if(lstrcmp(pobj_Class->name,"String")==0) type=DEF_STRING;1438 }1439 sprintf(temp2,"_System_InputDataType[%d]=%d",i4,type);1440 OpcodeCalc(temp2);1441 1442 i4++;1443 if(Parameter[i2]=='\0') break;1444 }1445 sprintf(temp2,"_System_InputDataPtr[%d]=0",i4);1446 OpcodeCalc(temp2);1447 1448 UserProc *pUserProc;1449 if(bFile) pUserProc=GetSubHash("INPUT_FromFile");1450 else pUserProc=GetSubHash("INPUT_FromPrompt");1451 if(!pUserProc){1452 SetError(3,"Input",cp);1453 return;1454 }1455 Opcode_CallProc(buffer,pUserProc,0,"",0);1456 }1457 void Opcode_PrintUsing(const char *Parameter,char *buffer,BOOL bFile){1458 extern int cp;1459 int i2,i3,i4,i5;1460 char temporary[VN_SIZE],temp2[8192];1461 BOOL bReturnLine;1462 1463 char parms[8192];1464 lstrcpy( parms, Parameter );1465 1466 i2=lstrlen(parms);1467 if(parms[i2-1]==';'){1468 bReturnLine=0;1469 parms[i2-1]=0;1470 }1471 else bReturnLine=1;1472 1473 i3=lstrlen(buffer);1474 for(i2=0;;i2++,i3++){1475 if(parms[i2]==';'){1476 buffer[i3]=0;1477 break;1478 }1479 buffer[i3]=parms[i2];1480 if(parms[i2]=='\0') break;1481 }1482 if(parms[i2]==';') i2++;1483 1484 if(bReturnLine) lstrcat(buffer,"+Ex\"\\r\\n\"");1485 1486 //データポインタ、データのタイプをセット1487 i4=0;1488 while(1){1489 for(i3=0;;i2++,i3++){1490 if(parms[i2]=='\"'){1491 temporary[i3]=parms[i2];1492 for(i2++,i3++;;i2++,i3++){1493 temporary[i3]=parms[i2];1494 if(parms[i2]=='\"') break;1495 }1496 continue;1497 }1498 if(parms[i2]=='('){1499 i5=GetStringInPare(temporary+i3,parms+i2);1500 i2+=i5-1;1501 i3+=i5-1;1502 continue;1503 }1504 if(parms[i2]=='['){1505 i5=GetStringInBracket(temporary+i3,parms+i2);1506 i2+=i5-1;1507 i3+=i5-1;1508 continue;1509 }1510 if(parms[i2]==','){1511 temporary[i3]=0;1512 i2++;1513 break;1514 }1515 temporary[i3]=parms[i2];1516 if(parms[i2]=='\0') break;1517 }1518 if(temporary[0]=='\0'){1519 SetError(10,"Print",cp);1520 return;1521 }1522 1523 int iResult;1524 iResult=IsStrCalculation(temporary);1525 1526 if(iResult==1){1527 //文字列1528 sprintf(temp2,"_System_UsingStrData[%d]=%s",i4,temporary);1529 OpcodeCalc(temp2);1530 1531 sprintf(temp2,"_System_UsingDataType[%d]=%d",i4,DEF_STRING);1532 OpcodeCalc(temp2);1533 }1534 else if(iResult==0){1535 //数値1536 sprintf(temp2,"_System_UsingDblData[%d]=%s",i4,temporary);1537 OpcodeCalc(temp2);1538 1539 sprintf(temp2,"_System_UsingDataType[%d]=%d",i4,DEF_DOUBLE);1540 OpcodeCalc(temp2);1541 }1542 //else if(iResult==-1) エラー1543 1544 i4++;1545 if(parms[i2]=='\0') break;1546 }1547 sprintf(temp2,"_System_UsingDataType[%d]=-1",i4);1548 OpcodeCalc(temp2);1549 1550 UserProc *pUserProc;1551 if(bFile) pUserProc=GetSubHash("PRINTUSING_ToFile");1552 else pUserProc=GetSubHash("PRINTUSING_ToPrompt");1553 if(!pUserProc){1554 SetError(3,"Print",cp);1555 return;1556 }1557 Opcode_CallProc(buffer,pUserProc,0,"",0);1558 }1559 void Opcode_Print(const char *Parameter,BOOL bWrite){1560 int i2,i3,i4,sw;1561 char temporary[VN_SIZE],buffer[VN_SIZE];1562 BOOL bFile;1563 1564 if(Parameter[0]=='#'){1565 bFile=1;1566 for(i2=0,i3=1;;i2++,i3++){1567 buffer[i2]=Parameter[i3];1568 if(Parameter[i3]==','||Parameter[i3]=='\0') break;1569 }1570 buffer[i2+1]=0;1571 if(Parameter[i3]==',') i3++;1572 i2=i3;1573 }1574 else{1575 bFile=0;1576 i2=0;1577 buffer[0]=0;1578 }1579 if(Parameter[i2]==1&&Parameter[i2+1]==ESC_USING){1580 Opcode_PrintUsing(Parameter+i2+2,buffer,bFile);1581 return;1582 }1583 1584 lstrcat(buffer,"_System_DummyStr+");1585 1586 sw=1;1587 while(1){1588 for(i3=0;;i2++,i3++){1589 if(Parameter[i2]=='\"'){1590 temporary[i3]=Parameter[i2];1591 for(i2++,i3++;;i2++,i3++){1592 temporary[i3]=Parameter[i2];1593 if(Parameter[i2]=='\"') break;1594 }1595 continue;1596 }1597 if(Parameter[i2]=='('){1598 i4=GetStringInPare(temporary+i3,Parameter+i2);1599 i2+=i4-1;1600 i3+=i4-1;1601 continue;1602 }1603 if(Parameter[i2]=='['){1604 i4=GetStringInBracket(temporary+i3,Parameter+i2);1605 i2+=i4-1;1606 i3+=i4-1;1607 continue;1608 }1609 if(Parameter[i2]==','||Parameter[i2]==';'){1610 temporary[i3]=0;1611 break;1612 }1613 temporary[i3]=Parameter[i2];1614 if(Parameter[i2]=='\0') break;1615 }1616 1617 if(temporary[0]=='\0') lstrcat(buffer,"\"\"");1618 else{1619 int iResult;1620 iResult=IsStrCalculation(temporary);1621 if(iResult==-1){1622 //エラー1623 lstrcat(buffer,"\"\"");1624 }1625 else if(iResult){1626 //文字列1627 lstrcat(buffer,temporary);1628 }1629 else{1630 //数値1631 sprintf(buffer+lstrlen(buffer),"Str$(%s)",temporary);1632 }1633 }1634 1635 if(Parameter[i2]==','){1636 if(bWrite) lstrcat(buffer,"+\",\"+");1637 else lstrcat(buffer,"+\"\t\"+");1638 }1639 else if(Parameter[i2]==';'){1640 if(Parameter[i2+1]=='\0'){1641 sw=0;1642 break;1643 }1644 if(bWrite) lstrcat(buffer,"+\",\"+");1645 else lstrcat(buffer,"+\" \"+");1646 }1647 else if(Parameter[i2]=='\0') break;1648 1649 i2++;1650 }1651 1652 if(sw) lstrcat(buffer,"+Ex\"\\r\\n\"");1653 1654 UserProc *pUserProc;1655 if(bFile) pUserProc=GetSubHash("PRINT_ToFile");1656 else pUserProc=GetSubHash("PRINT_ToPrompt");1657 if(!pUserProc){1658 SetError(3,"Print",cp);1659 return;1660 }1661 Opcode_CallProc(buffer,pUserProc,0,"",0);1662 }1663 1664 1665 1666 1347 1667 1348 //////////// 1668 1349 // ポインタ 1669 1350 1670 void OpcodeCallPtr(char *Parameter){1671 extern HANDLE hHeap;1672 int i,i2,i3,num,types[255];1673 BOOL bCdecl;1674 char szFuncPtr[VN_SIZE],temporary[VN_SIZE],*Parms[255];1675 1676 //関数ポインタを取得1677 i=GetOneParameter(Parameter,0,szFuncPtr);1678 1679 if(lstrcmpi(szFuncPtr,"cdecl")==0){1680 //cdeclが指定された場合は、第2パラメータを関数ポインタとして扱う1681 bCdecl=1;1682 1683 i=GetOneParameter(Parameter,i,szFuncPtr);1684 }1685 else bCdecl=0;1686 1687 if(Parameter[0]=='\0'){1688 SetError(10,"CallPtr",cp);1689 }1690 1691 num=0;1692 while(Parameter[i]){1693 i=GetOneParameter(Parameter,i,temporary);1694 1695 types[num]=DEF_LONG;1696 1697 for(i2=0;;i2++){1698 if(temporary[i2]=='\0') break;1699 if(temporary[i2]==1&&temporary[i2+1]==ESC_AS){1700 LONG_PTR lp;1701 types[num]=GetTypeFixed(temporary+i2+2,&lp);1702 1703 if(types[num]==DEF_OBJECT){1704 SetError(11,temporary+i2+2,cp);1705 }1706 1707 temporary[i2]=0;1708 break;1709 }1710 }1711 1712 Parms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);1713 lstrcpy(Parms[num],temporary);1714 1715 num++;1716 }1717 1718 int ParmSize=0;1719 1720 for(i=num-1;i>=0;i--){1721 //スタックへプッシュ1722 i3=NumOpe(Parms[i],0,0,0);1723 1724 switch(types[i]){1725 case DEF_INT64:1726 case DEF_QWORD:1727 ChangeTypeToInt64(i3);1728 break;1729 case DEF_SINGLE:1730 ChangeTypeToSingle(i3);1731 break;1732 case DEF_DOUBLE:1733 ChangeTypeToDouble(i3);1734 break;1735 1736 default:1737 ChangeTypeToLong(i3);1738 break;1739 }1740 1741 ParmSize+=GetTypeSize(types[i],0);1742 1743 HeapDefaultFree(Parms[i]);1744 }1745 1746 i3=NumOpe(szFuncPtr,0,0,0);1747 ChangeTypeToLong(i3);1748 1749 //pop eax1750 op_pop(REG_EAX);1751 1752 //call eax1753 OpBuffer[obp++]=(char)0xFF;1754 OpBuffer[obp++]=(char)0xD0;1755 1756 if(bCdecl){1757 //スタックを戻す1758 1759 //add esp,ParmSize1760 op_add_esp(ParmSize);1761 }1762 }1763 1764 1351 void OpcodeSetPtrData(char *Parameter,int type){ 1765 int i ,i2;1352 int i; 1766 1353 char temporary[VN_SIZE]; 1767 1354 … … 1784 1371 } 1785 1372 1786 i2=NumOpe(temporary,0,0,0); 1787 ChangeTypeToLong(i2); 1373 Type resultType; 1374 if( !NumOpe(temporary,Type(),resultType) ){ 1375 return; 1376 } 1377 if(!resultType.IsWhole()){ 1378 SetError(11,Parameter,cp); 1379 return; 1380 } 1381 1382 ChangeTypeToLong( resultType.GetBasicType() ); 1788 1383 1789 1384 //第2パラメータを取得 … … 1794 1389 } 1795 1390 1796 i2=NumOpe(temporary,0,0,0); 1391 if( !NumOpe(temporary,Type(),resultType) ){ 1392 return; 1393 } 1394 1797 1395 if(type==DEF_DOUBLE){ 1798 ChangeTypeToDouble_ToFpuReg( i2);1396 ChangeTypeToDouble_ToFpuReg( resultType.GetBasicType() ); 1799 1397 1800 1398 //pop eax … … 1806 1404 } 1807 1405 else if(type==DEF_SINGLE){ 1808 ChangeTypeToSingle( i2);1406 ChangeTypeToSingle( resultType.GetBasicType() ); 1809 1407 1810 1408 //pop ebx … … 1819 1417 } 1820 1418 else if(type==DEF_QWORD){ 1821 ChangeTypeToInt64( i2);1419 ChangeTypeToInt64( resultType.GetBasicType() ); 1822 1420 1823 1421 //pop ecx … … 1840 1438 } 1841 1439 else if(type==DEF_DWORD){ 1842 ChangeTypeToLong( i2);1440 ChangeTypeToLong( resultType.GetBasicType() ); 1843 1441 1844 1442 //pop ebx … … 1853 1451 } 1854 1452 else if(type==DEF_WORD){ 1855 ChangeTypeToLong( i2);1453 ChangeTypeToLong( resultType.GetBasicType() ); 1856 1454 1857 1455 //pop ebx … … 1867 1465 } 1868 1466 else if(type==DEF_BYTE){ 1869 ChangeTypeToLong( i2);1467 ChangeTypeToLong( resultType.GetBasicType() ); 1870 1468 1871 1469 //pop ebx -
BasicCompiler32/Compile_Var.cpp
r75 r76 3 3 4 4 //変数 5 VARIABLE *GlobalVar; 6 int MaxGlobalVarNum; 5 Variables globalVars; 7 6 int AllGlobalVarSize; 8 7 int AllInitGlobalVarSize; 9 VARIABLE *LocalVar; 10 int MaxLocalVarNum; 8 11 9 int AllLocalVarSize; 10 12 11 13 12 void SetRelativeOffset( Type &resultType, RELATIVE_VAR *pRelativeVar,const char *lpPtrOffset){ … … 351 350 //自身のオブジェクトのThisポインタをregにコピー 352 351 353 extern VARIABLE *LocalVar;354 352 RELATIVE_VAR RelativeVar; 355 353 RelativeVar.dwKind=VAR_LOCAL; … … 466 464 } 467 465 468 if( _memicmp(variable,"This.",5)==0){466 if(memicmp(variable,"This.",5)==0){ 469 467 //Thisオブジェクトのメンバを参照するとき 470 468 SlideString(variable+5,-5); -
BasicCompiler32/MakePeHdr.cpp
r75 r76 150 150 151 151 //関数ポインタ情報を初期化 152 extern ProcPointer **ppProcP trInfo;152 extern ProcPointer **ppProcPointer; 153 153 extern int ProcPtrInfoNum; 154 ppProcP trInfo=(ProcPointer **)HeapAlloc(hHeap,0,1);154 ppProcPointer=(ProcPointer **)HeapAlloc(hHeap,0,1); 155 155 ProcPtrInfoNum=0; 156 156 … … 309 309 310 310 311 ///////////////////////////////////////////////////////////////// 312 // デバッグコンパイル用のログを生成する 313 ///////////////////////////////////////////////////////////////// 314 #ifdef _DEBUG 315 { 316 ofstream ofs("middle_code.txt"); 317 ofs << basbuf << endl; 318 ofs.close(); 319 } 320 #endif 321 311 322 312 323 ////////////////////// … … 315 326 316 327 cp=-1; 317 extern BOOL bCompilingGlobal; 318 bCompilingGlobal=1; 319 pobj_CompilingClass=0; 328 UserProc::CompileStartForGlobalArea(); 320 329 321 330 if(!bDll){ … … 434 443 // ローカル実行領域 435 444 ///////////////////// 436 437 bCompilingGlobal=0;438 445 439 446 //プロシージャをコンパイル開始 … … 736 743 //グローバル変数情報を扱う構造体も初期バッファの有無による配置を行う 737 744 //(デバッグ情報で利用される) 738 extern int MaxGlobalVarNum;739 extern VARIABLE *GlobalVar;740 745 extern int AllInitGlobalVarSize; 741 for (i=0;i<MaxGlobalVarNum;i++){742 if( GlobalVar[i].offset&0x80000000){743 GlobalVar[i].offset=(GlobalVar[i].offset&0x7FFFFFFF)+AllInitGlobalVarSize;746 foreach( Variable *pVar, globalVars ){ 747 if(pVar->offset&0x80000000){ 748 pVar->offset=(pVar->offset&0x7FFFFFFF)+AllInitGlobalVarSize; 744 749 } 745 750 } -
BasicCompiler32/NumOpe.cpp
r75 r76 67 67 } 68 68 69 void NewStringObject( LPSTR lpszText){69 void NewStringObject( const char *str ){ 70 70 /////////////////////////////////////////////////////// 71 71 // lpszTextを元にStringオブジェクトを生成し、 … … 73 73 /////////////////////////////////////////////////////// 74 74 75 char *parameter = (char *)malloc( lstrlen( lpszText) + 32 );76 sprintf( parameter, "\"%s\"%c%c*Char", lpszText, 1, ESC_AS );75 char *parameter = (char *)malloc( lstrlen( str ) + 32 ); 76 sprintf( parameter, "\"%s\"%c%c*Char", str, 1, ESC_AS ); 77 77 SetStringQuotes( parameter ); 78 78 79 79 extern CClass *pobj_StringClass; 80 Type baseTypeInfo = { DEF_OBJECT, (LONG_PTR)pobj_StringClass }; 81 Operator_New( *pobj_StringClass, "", parameter, baseTypeInfo ); 80 Operator_New( *pobj_StringClass, "", parameter, Type( DEF_OBJECT, *pobj_StringClass ) ); 82 81 83 82 free( parameter ); … … 85 84 86 85 87 int NumOpe(const char *Command,int BaseType,LONG_PTR lpBaseIndex,LONG_PTR *plpIndex,BOOL *pbUseHeap){ 88 extern HANDLE hHeap; 86 bool NumOpe( const char *expression, 87 const Type &baseType, 88 Type &resultType, 89 BOOL *pbUseHeap ){ 90 89 91 int i,i2,i3,i4; 90 char temporary[ 8192],temp2[1024],temp3[1024];91 92 if( Command[0]=='\0'){92 char temporary[1024],temp2[1024],temp3[1024]; 93 94 if(expression[0]=='\0'){ 93 95 SetError(1,NULL,cp); 94 return -1;95 } 96 97 if( Command[0]==1&& Command[1]==ESC_NEW ){96 return false; 97 } 98 99 if(expression[0]==1&& expression[1]==ESC_NEW ){ 98 100 //New演算子(オブジェクト生成) 99 Type baseTypeInfo = { BaseType, lpBaseIndex }; 100 int resultType = Operator_New(Command+2,plpIndex, baseTypeInfo ); 101 102 return resultType; 101 102 if( !Operator_New( expression+2, baseType, resultType ) ){ 103 return false; 104 } 105 106 return true; 103 107 } 104 108 … … 112 116 long stack[255]; 113 117 int pnum; 114 if(!GetNumOpeElements( Command,&pnum,values,calc,stack)){118 if(!GetNumOpeElements(expression,&pnum,values,calc,stack)){ 115 119 for(i=0;i<pnum;i++){ 116 120 if(values[i]) HeapDefaultFree(values[i]); 117 121 } 118 return 0;122 return false; 119 123 } 120 124 … … 146 150 double dbl; 147 151 int sp; 148 int type [255];152 int type_stack[255]; 149 153 LONG_PTR index_stack[255]; 150 154 BOOL bUseHeap[255]; … … 155 159 156 160 if(idCalc){ 157 if(type [sp-2]==DEF_OBJECT){161 if(type_stack[sp-2]==DEF_OBJECT){ 158 162 //オーバーロードされたオペレータを呼び出す 159 Type BaseTypeInfo={BaseType,lpBaseIndex}; 160 i2=CallOperatorProc(idCalc,&BaseTypeInfo,type,index_stack,bUseHeap,sp); 163 i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack,bUseHeap,sp); 161 164 if(i2==0){ 162 165 if(idCalc==CALC_EQUAL) lstrcpy(temp2,"=="); … … 171 174 } 172 175 173 if(!CheckCalcType(idCalc,type ,sp)) goto error;176 if(!CheckCalcType(idCalc,type_stack,sp)) goto error; 174 177 } 175 178 … … 192 195 StrLiteral: 193 196 194 if(BaseType==DEF_OBJECT){ 195 CClass *pobj_Class; 196 pobj_Class=(CClass *)lpBaseIndex; 197 Type BaseTypeInfo = {BaseType,lpBaseIndex}; 198 if(IsStringObjectType(BaseTypeInfo)){ 199 //要求タイプがオブジェクトであり、Stringの受け入れが可能な場合 197 if( baseType.IsObject() ){ 198 if( baseType.IsStringObject() ){ 199 //要求タイプがStringのとき 200 200 201 201 //String型オブジェクトを生成 … … 203 203 204 204 extern CClass *pobj_StringClass; 205 type [sp]=DEF_OBJECT;205 type_stack[sp]=DEF_OBJECT; 206 206 index_stack[sp]=(LONG_PTR)pobj_StringClass; 207 207 bLiteralCalculation=0; … … 213 213 214 214 215 type[sp]=typeOfPtrChar; 216 index_stack[sp]=LITERAL_STRING; 215 type_stack[sp]=typeOfPtrChar; 217 216 bLiteralCalculation=0; 218 217 … … 252 251 i4=GetStringInPare_RemovePare(temp2,term+i2+1); 253 252 254 int idProc;255 253 void *pInfo; 256 idProc=GetProc(temporary,&pInfo); 257 254 int idProc=GetProc(temporary,(void **)&pInfo); 255 256 Type resultType; 258 257 if(idProc){ 259 258 //閉じカッコ")"に続く文字がNULLでないとき … … 272 271 //////////////// 273 272 274 i2=CallProc(idProc,pInfo,temporary,temp2,&index_stack[sp]);275 if( i2==-1){273 CallProc(idProc,pInfo,temporary,temp2,resultType); 274 if(resultType.IsNull()){ 276 275 //戻り値が存在しないとき 277 276 for(i2=2;;i2++){ … … 292 291 293 292 //大きな型への暗黙の変換 294 type[sp]=AutoBigCast(BaseType,i2); 293 type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType()); 294 index_stack[sp] = resultType.GetIndex(); 295 295 bLiteralCalculation=0; 296 296 297 297 //スタックへプッシュ 298 PushReturnValue(i2); 299 300 if(Is64Type(type[sp])&&IsWholeNumberType(i2)&&GetTypeSize(i2,-1)<=sizeof(long)){ 301 //必要に応じて64ビット拡張 302 ExtendStackTo64(i2); 298 PushReturnValue( resultType.GetBasicType() ); 299 300 if( Is64Type(type_stack[sp]) 301 && resultType.IsWhole() 302 && resultType.GetBasicSize() <= sizeof(long) ){ 303 //必要に応じて64ビット拡張 304 ExtendStackTo64( resultType.GetBasicType() ); 303 305 } 304 306 305 if( i2==DEF_STRUCT){307 if( resultType.IsStruct() ){ 306 308 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 307 309 //※後にfreeする必要あり … … 321 323 322 324 //マクロ関数の場合 323 type[sp]=NumOpe(temp3,0,0,&index_stack[sp]);324 325 if(!IS_LITERAL( index_stack[sp])){325 NumOpe(temp3,Type(),resultType); 326 327 if(!IS_LITERAL(resultType.GetIndex())){ 326 328 //リテラル値ではなかったとき 327 329 bLiteralCalculation=0; 328 330 } 329 331 332 type_stack[sp] = resultType.GetBasicType(); 333 index_stack[sp] = resultType.GetIndex(); 334 330 335 sp++; 331 336 break; … … 335 340 336 341 337 342 //インデクサ(getアクセサ) 338 343 char variable[VN_SIZE],array_element[VN_SIZE]; 339 CClass *pobj_c;340 344 GetArrayElement(term,variable,array_element); 341 345 if(array_element[0]){ 342 i2=GetVarType(variable,(LONG_PTR *)&pobj_c,0);343 if(i2==DEF_OBJECT){344 Type RetTypeInfo;345 CallIndexerGetterProc( pobj_c,variable,array_element,RetTypeInfo);346 type [sp]=RetTypeInfo.type;347 index_stack[sp]= RetTypeInfo.u.lpIndex;346 Type resultType; 347 GetVarType(variable,resultType,0); 348 if( resultType.IsObject() ){ 349 CallIndexerGetterProc(&resultType.GetClass(),variable,array_element,resultType); 350 type_stack[sp]=resultType.GetBasicType(); 351 index_stack[sp]=resultType.GetIndex(); 348 352 bLiteralCalculation=0; 349 353 … … 359 363 // Nothing 360 364 if( lstrcmp( term, "Nothing" ) == 0 ){ 361 type [sp] = DEF_OBJECT;362 if( BaseType == DEF_OBJECT){363 index_stack[sp] = lpBaseIndex;365 type_stack[sp] = DEF_OBJECT; 366 if( baseType.IsObject() ){ 367 index_stack[sp] = baseType.GetIndex(); 364 368 } 365 369 else{ … … 377 381 378 382 383 if( (string)term=="value"){ 384 int test=0; 385 } 386 379 387 380 388 RELATIVE_VAR RelativeVar; 389 Type varType; 381 390 if(GetVarOffset( 382 391 false, //エラー表示あり 383 392 false, //読み込み専用 384 term,&i2,&RelativeVar,&index_stack[sp])){ 393 term, 394 &RelativeVar,varType)){ 385 395 ////////// 386 396 // 変数 … … 388 398 389 399 //大きな型への暗黙の変換 390 type[sp]=AutoBigCast(BaseType,i2); 400 type_stack[sp]=AutoBigCast(baseType.GetBasicType(),varType.GetBasicType()); 401 index_stack[sp] = varType.GetIndex(); 391 402 bLiteralCalculation=0; 392 403 393 if( i2&FLAG_PTR){404 if(varType.GetBasicType()&FLAG_PTR){ 394 405 //配列ポインタ 395 type [sp]=GetPtrType(i2^FLAG_PTR,index_stack[sp]);406 type_stack[sp]=GetPtrType(varType.GetBasicType()^FLAG_PTR); 396 407 397 408 SetVarPtrToEax(&RelativeVar); … … 400 411 op_push(REG_EAX); 401 412 } 402 else if(i2==DEF_DOUBLE|| 403 i2==DEF_INT64|| 404 i2==DEF_QWORD){ 413 else if( varType.IsStruct() ){ 414 //構造体ポインタをeaxへ格納(構造体は値型) 415 SetVarPtrToEax(&RelativeVar); 416 417 //push eax 418 op_push(REG_EAX); 419 } 420 else if( varType.GetBasicSize() == sizeof(_int64) ){ 405 421 //64ビット型 406 422 PushDoubleVariable(&RelativeVar); 407 423 } 408 else if(i2==DEF_LONG||i2==DEF_DWORD||i2==DEF_SINGLE|| 409 IsPtrType(i2) || i2==DEF_OBJECT){ 424 else if( varType.GetBasicSize() == sizeof(long) ){ 410 425 //32ビット型 411 426 PushLongVariable(&RelativeVar); 412 427 } 413 else if( i2==DEF_INTEGER || (isUnicode&&i2==DEF_CHAR)){428 else if( varType.IsInteger() ){ 414 429 PushIntegerVariable(&RelativeVar); 415 430 } 416 else if( i2==DEF_WORD){431 else if( varType.IsWord() ){ 417 432 PushWordVariable(&RelativeVar); 418 433 } 419 else if( i2==DEF_SBYTE || (isUnicode==false&&i2==DEF_CHAR)){434 else if( varType.IsSByte() ){ 420 435 PushCharVariable(&RelativeVar); 421 436 } 422 else if( i2==DEF_BYTE||i2==DEF_BOOLEAN){437 else if( varType.IsByte() || varType.IsBoolean() ){ 423 438 PushByteVariable(&RelativeVar); 424 439 } 425 else if(i2==DEF_STRUCT){426 //構造体ポインタをeaxへ格納(構造体は値型)427 SetVarPtrToEax(&RelativeVar);428 429 //push eax430 op_push(REG_EAX);431 }432 440 else SetError(11,term,cp); 433 441 434 if(Is64Type(type[sp])&&IsWholeNumberType(i2)&&GetTypeSize(i2,-1)<=sizeof(long)){ 442 if( Is64Type(type_stack[sp]) 443 && varType.IsWhole() 444 && varType.GetBasicSize()<=sizeof(long)){ 435 445 //必要に応じて64ビット拡張 436 ExtendStackTo64(i2);446 ExtendStackTo64( varType.GetBasicType() ); 437 447 } 438 448 … … 448 458 i3 = CDBConst::obj.GetType(term); 449 459 if(i3){ 450 type [sp]=i3;460 type_stack[sp]=i3; 451 461 if(IsRealNumberType(i3)){ 452 462 //実数 … … 483 493 i3=GetTypeFixed(term,&lp); 484 494 if(i3!=-1){ 485 type [sp]=i3|FLAG_CAST;495 type_stack[sp]=i3|FLAG_CAST; 486 496 index_stack[sp]=lp; 487 497 sp++; … … 500 510 501 511 if(GetSubHash(VarName,0)){ 502 Type RetTypeInfo;503 CallPropertyMethod(term,NULL, &RetTypeInfo);512 Type resultType; 513 CallPropertyMethod(term,NULL,resultType); 504 514 505 515 //大きな型への暗黙の変換 506 type[sp]=AutoBigCast(BaseType,RetTypeInfo.type); 507 508 index_stack[sp]=RetTypeInfo.u.lpIndex; 516 type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType()); 517 index_stack[sp]=resultType.GetIndex(); 509 518 bLiteralCalculation=0; 510 519 511 520 //スタックへプッシュ 512 PushReturnValue( RetTypeInfo.type);513 514 if(type [sp]==DEF_STRUCT){521 PushReturnValue( resultType.GetBasicType() ); 522 523 if(type_stack[sp]==DEF_STRUCT){ 515 524 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 516 525 //※後にfreeする必要あり … … 527 536 bError=1; 528 537 SetError(3,term,cp); 529 type [sp]=DEF_DOUBLE;538 type_stack[sp]=DEF_DOUBLE; 530 539 } 531 540 else{ 532 541 //リテラル値 533 type [sp]=GetLiteralValue(term,&i64data,BaseType);542 type_stack[sp]=GetLiteralValue(term,&i64data,baseType.GetBasicType()); 534 543 Literal: 535 if(type [sp]==DEF_INT64||536 type [sp]==DEF_QWORD||537 type [sp]==DEF_DOUBLE){544 if(type_stack[sp]==DEF_INT64|| 545 type_stack[sp]==DEF_QWORD|| 546 type_stack[sp]==DEF_DOUBLE){ 538 547 //64ビット(符号有り整数/実数) 539 548 … … 544 553 op_push_V(*(long *)(&i64data)); 545 554 } 546 else if(type [sp]==DEF_SINGLE){555 else if(type_stack[sp]==DEF_SINGLE){ 547 556 //single実数 548 557 … … 566 575 567 576 //リテラル値の種類 568 if(Is64Type(type [sp])==0&&IsRealNumberType(type[sp])==0){577 if(Is64Type(type_stack[sp])==0&&IsRealNumberType(type_stack[sp])==0){ 569 578 //整数(符号有り/無し) 570 579 … … 579 588 //value[sp-2] xor= value[sp-1] 580 589 //xor演算 581 if(!Calc_Xor(type ,index_stack,&sp)) goto error;590 if(!Calc_Xor(type_stack,index_stack,&sp)) goto error; 582 591 break; 583 592 case CALC_OR: 584 593 //value[sp-2] or= value[sp-1] 585 594 //or演算 586 if(!Calc_Or(type ,index_stack,&sp)) goto error;595 if(!Calc_Or(type_stack,index_stack,&sp)) goto error; 587 596 break; 588 597 case CALC_AND: 589 598 //value[sp-2] and= value[sp-1] 590 599 //and演算 591 if(!Calc_And(type ,index_stack,&sp)) goto error;600 if(!Calc_And(type_stack,index_stack,&sp)) goto error; 592 601 break; 593 602 case CALC_NOT: 594 603 //value[sp-1]=Not value[sp-1] 595 604 //NOT演算子 596 if(!Calc_Not(type ,sp)) goto error;605 if(!Calc_Not(type_stack,sp)) goto error; 597 606 break; 598 607 … … 600 609 case CALC_PE: 601 610 //value[sp-2]<=value[sp-1] 602 if(!Calc_Relation_PE(type ,index_stack,&sp)) goto error;611 if(!Calc_Relation_PE(type_stack,index_stack,&sp)) goto error; 603 612 break; 604 613 case CALC_QE: 605 614 //value[sp-2]>=value[sp-1] 606 if(!Calc_Relation_QE(type ,index_stack,&sp)) goto error;615 if(!Calc_Relation_QE(type_stack,index_stack,&sp)) goto error; 607 616 break; 608 617 case CALC_P: 609 618 //value[sp-2]<value[sp-1] 610 if(!Calc_Relation_P(type ,index_stack,&sp)) goto error;619 if(!Calc_Relation_P(type_stack,index_stack,&sp)) goto error; 611 620 break; 612 621 case CALC_Q: 613 622 //value[sp-2]>value[sp-1] 614 if(!Calc_Relation_Q(type ,index_stack,&sp)) goto error;623 if(!Calc_Relation_Q(type_stack,index_stack,&sp)) goto error; 615 624 break; 616 625 case CALC_NOTEQUAL: 617 626 //value[sp-2]<>value[sp-1] 618 if(!Calc_Relation_NotEqual(type ,&sp)) goto error;627 if(!Calc_Relation_NotEqual(type_stack,&sp)) goto error; 619 628 break; 620 629 case CALC_EQUAL: 621 630 //value[sp-2]=value[sp-1] 622 if(!Calc_Relation_Equal(type ,&sp)) goto error;631 if(!Calc_Relation_Equal(type_stack,&sp)) goto error; 623 632 break; 624 633 … … 626 635 case CALC_SHL: 627 636 //value[sp-2]=value[sp-2]<<value[sp-1] 628 if(!Calc_SHL(type ,&sp)) goto error;637 if(!Calc_SHL(type_stack,&sp)) goto error; 629 638 break; 630 639 case CALC_SHR: 631 640 //value[sp-2]=value[sp-2]>>value[sp-1] 632 if(!Calc_SHR(type ,&sp)) goto error;641 if(!Calc_SHR(type_stack,&sp)) goto error; 633 642 break; 634 643 … … 637 646 case CALC_SUBTRACTION: 638 647 case CALC_PRODUCT: 639 if(!CalcTwoTerm_Arithmetic(idCalc,type ,index_stack,&sp)) goto error;648 if(!CalcTwoTerm_Arithmetic(idCalc,type_stack,index_stack,&sp)) goto error; 640 649 break; 641 650 … … 643 652 //value[sp-2]%=value[sp-1] 644 653 //剰余演算 645 if(!Calc_Mod(type ,&sp)) goto error;654 if(!Calc_Mod(type_stack,&sp)) goto error; 646 655 break; 647 656 case CALC_QUOTIENT: 648 657 //value[sp-2]/=value[sp-1]; 649 658 //除算 650 if(!Calc_Divide(type ,&sp,BaseType)) goto error;659 if(!Calc_Divide(type_stack,&sp,baseType.GetBasicType())) goto error; 651 660 break; 652 661 case CALC_INTQUOTIENT: 653 662 //value[sp-2]/=value[sp-1] 654 663 //整数除算 655 if(!Calc_IntDivide(type ,index_stack,&sp)) goto error;664 if(!Calc_IntDivide(type_stack,index_stack,&sp)) goto error; 656 665 break; 657 666 case CALC_MINUSMARK: 658 667 //value[sp-1]=-value[sp-1] 659 668 //符号反転 660 if(!Calc_MinusMark(type ,sp)) goto error;669 if(!Calc_MinusMark(type_stack,sp)) goto error; 661 670 index_stack[sp-1]=-1; 662 671 break; 663 672 case CALC_POWER: 664 673 //べき乗演算(浮動小数点演算のみ) 665 if(!Calc_Power(type ,&sp)) goto error;674 if(!Calc_Power(type_stack,&sp)) goto error; 666 675 break; 667 676 case CALC_AS: 668 677 //キャスト 669 if(!Calc_Cast(type ,index_stack,&sp)) goto error;678 if(!Calc_Cast(type_stack,index_stack,&sp)) goto error; 670 679 break; 671 680 672 681 case CALC_BYVAL: 673 682 //ポインタ型→参照型 674 if( PTR_LEVEL( type [sp-1] ) <= 0 ){683 if( PTR_LEVEL( type_stack[sp-1] ) <= 0 ){ 675 684 //ポインタ型ではないとき 676 685 SetError( 3, NULL, cp ); … … 678 687 } 679 688 680 type [sp-1] = PTR_LEVEL_DOWN( type[sp-1] );689 type_stack[sp-1] = PTR_LEVEL_DOWN( type_stack[sp-1] ); 681 690 682 691 break; … … 697 706 if(bLiteralCalculation){ 698 707 //右辺値が数値の定数式の場合 699 LONG_PTR lpClassIndex;700 i2=StaticCalculation(true, Command,BaseType,&i64data,&lpClassIndex);708 Type resultType; 709 StaticCalculation(true, expression,baseType.GetBasicType(),&i64data,resultType); 701 710 702 711 obp=BeforeObp; … … 705 714 pobj_Reloc->copy(pobj_BackReloc); 706 715 707 if(i2==DEF_INT64|| 708 i2==DEF_QWORD|| 709 i2==DEF_DOUBLE){ 716 if( resultType.GetBasicSize() == sizeof(_int64) ){ 710 717 //64ビット(符号有り整数/実数) 711 718 … … 716 723 op_push_V(*(long *)(&i64data)); 717 724 } 718 else if( i2==DEF_SINGLE){725 else if( resultType.IsSingle() ){ 719 726 //single実数 720 727 … … 733 740 i3=(long)i64data; 734 741 735 if( i2==DEF_SBYTE||i2==DEF_BYTE||i2==DEF_BOOLEAN || (isUnicode==false&&i2==DEF_CHAR)) i3=i3&0x000000FF;736 if( i2==DEF_INTEGER||i2==DEF_WORD || (isUnicode&&i2==DEF_CHAR)) i3=i3&0x0000FFFF;742 if(resultType.GetBasicSize()==sizeof(char)) i3=i3&0x000000FF; 743 if(resultType.GetBasicSize()==sizeof(short)) i3=i3&0x0000FFFF; 737 744 738 745 //push term … … 740 747 } 741 748 742 type [0]=i2;743 index_stack[0]= lpClassIndex;749 type_stack[0]=resultType.GetBasicType(); 750 index_stack[0]=resultType.GetIndex(); 744 751 } 745 752 else{ … … 748 755 } 749 756 750 if(plpIndex) *plpIndex=index_stack[0];751 757 if(pbUseHeap) *pbUseHeap=bUseHeap[0]; 752 758 753 int RetType; 754 RetType=type[0]; 759 resultType.SetType( type_stack[0], index_stack[0] ); 760 761 bool isSuccessful = true; 755 762 goto finish; 756 763 757 764 758 765 error: 759 RetType=-1;766 isSuccessful = false; 760 767 goto finish; 761 768 … … 770 777 delete pobj_BackReloc; 771 778 772 return RetType;779 return isSuccessful; 773 780 } -
BasicCompiler32/Opcode.h
r75 r76 202 202 class ParamImpl{ 203 203 char *Parms[255]; 204 Type types[255];204 vector<Type> types; 205 205 int ParmsNum; 206 206 207 Type ReturnTypeInfo;207 Type returnType; 208 208 209 209 //一時オブジェクト管理用 … … 219 219 220 220 private: 221 BOOL _overload_check( const Parameters ¶ms,Type *pReturnTypeInfo,int overload_level);221 bool _overload_check( int level, const Parameters &targetParms, const Type &targetResultType ); 222 222 UserProc *OverloadSolutionWithReturnType( const char *name, std::vector<UserProc *> &subs ); 223 223 public: … … 226 226 bool ErrorCheck( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 ); 227 227 void MacroParameterSupport( const Parameters ¶ms ); 228 void SetStructParameter( CClass *pobj_Class,LPSTR Parameter);228 void SetStructParameter( const Type &baseType, const char *expression ); 229 229 int SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 ); 230 230 … … 237 237 void AddLocalVarAddrSchedule(); 238 238 #define PROCFLAG_NEW 1 239 int Opcode_CallProcPtr(char *variable,char *Parameter,ProcPointer *pProcPointer,LONG_PTR *plpIndex);240 void Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,char *ObjectName,int RefType);241 int Opcode_CallDllProc(char *Parameter,DllProc *pDllProc,LONG_PTR *plpIndex);239 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer); 240 bool Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType); 241 bool Opcode_CallDllProc( const char *lpszParms, DllProc *pDllProc ); 242 242 243 243 //Compile_ProcOp.cpp … … 247 247 int GetFunctionType(int FuncNum); 248 248 int GetFunctionFromName(char *FuncName); 249 void Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &ReturnTypeInfo);249 bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn = true ); 250 250 251 251 //OperatorProc.cpp 252 void FreeTempObject(int reg, CClass *pobj_c);253 int CallOperatorProc(int idCalc, Type *pBaseTypeInfo,int *type,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);252 void FreeTempObject(int reg,const CClass *pobj_c); 253 int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp); 254 254 void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType); 255 void CallIndexerGetterProc( CClass *pobj_Class,char *ObjectName,char *Parameter,Type &RetTypeInfo);255 void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType); 256 256 257 257 //Compile_Statement.cpp … … 264 264 void OpcodeContinue(void); 265 265 void OpcodeExitSub(void); 266 void OpcodeSelect(const char * Parameter);266 void OpcodeSelect(const char *lpszParms); 267 267 void OpcodeCase(char *Parameter); 268 268 void OpcodeGosub(char *Parameter); 269 269 void OpcodeReturn(char *Parameter); 270 void Opcode_Input(const char *Parameter);271 void Opcode_Print(const char *Parameter,BOOL bWrite);272 void OpcodeCallPtr(char *Parameter);273 270 void OpcodeSetPtrData(char *Parameter,int type); 274 271 -
BasicCompiler32/OperatorProc.cpp
r75 r76 2 2 #include "Opcode.h" 3 3 4 void FreeTempObject(int reg, CClass *pobj_c){4 void FreeTempObject(int reg,const CClass *pobj_c){ 5 5 if(!IsSafeReg(reg)) SetError(300,NULL,cp); 6 6 … … 22 22 } 23 23 24 int CallOperatorProc(int idCalc, Type *pBaseTypeInfo,int *type,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){24 int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){ 25 25 //オーバーロードされたオペレータ関数を呼び出す 26 26 CClass *pobj_c; … … 39 39 40 40 41 int i;42 BOOL bReturnTypeIsObject=1;43 Type ReturnType={DEF_OBJECT,subs[0]->ReturnType().GetIndex()};44 foreach( UserProc *pUserProc, subs ){45 if(pUserProc->ReturnType().IsObject())46 bReturnTypeIsObject=0;47 }48 49 if(bReturnTypeIsObject==0){50 if(pBaseTypeInfo){51 if(pBaseTypeInfo->type==DEF_OBJECT){52 ReturnType.u.lpIndex=pBaseTypeInfo->u.lpIndex;53 }54 }55 }56 57 58 59 41 ///////////////////////////////////////////// 60 42 // オーバーロード解決用のパラメータを設定 … … 64 46 65 47 if(bTwoTerm){ 66 params.push_back( new Parameter( "", Type( type [sp-1], index_stack[sp-1] ) ) );48 params.push_back( new Parameter( "", Type( type_stack[sp-1], index_stack[sp-1] ) ) ); 67 49 } 68 50 … … 71 53 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 72 54 else GetCalcName(idCalc,temporary); 73 Type returnType; 74 if( pBaseTypeInfo ){ 75 returnType.SetBasicType( pBaseTypeInfo->type ); 76 returnType.SetIndex( pBaseTypeInfo->u.lpIndex ); 77 } 78 UserProc *pUserProc = OverloadSolution( temporary, subs, params, returnType ); 55 UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType ); 79 56 80 57 if(!pUserProc){ … … 94 71 } 95 72 96 for(i =0;i<(int)params.size();i++){73 for(int i=0;i<(int)params.size();i++){ 97 74 CheckDifferentType( 98 75 pUserProc->Params()[i]->GetBasicType(), … … 108 85 } 109 86 110 int right_side_size = GetTypeSize(type [sp-1],index_stack[sp-1]);87 int right_side_size = GetTypeSize(type_stack[sp-1],index_stack[sp-1]); 111 88 112 89 if(bTwoTerm){ … … 224 201 225 202 sp--; 226 type [sp-1]=pUserProc->ReturnType().GetBasicType();203 type_stack[sp-1]=pUserProc->ReturnType().GetBasicType(); 227 204 index_stack[sp-1]=pUserProc->ReturnType().GetIndex(); 228 205 … … 237 214 } 238 215 239 void CallCastOperatorProc( int &CalcType,LONG_PTR &lpCalcIndex,BOOL bCalcUseHeap,int ToType,LONG_PTR lpToIndex){240 int type [10];216 void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType){ 217 int type_stack[10]; 241 218 LONG_PTR index_stack[10]; 242 219 BOOL array_bUseHeap[10]; … … 249 226 250 227 //左辺 251 type [0]=CalcType;252 index_stack[0]= lpCalcIndex;228 type_stack[0]=calcType.GetBasicType(); 229 index_stack[0]=calcType.GetIndex(); 253 230 array_bUseHeap[0]=0; 254 type [1]=ToType;255 index_stack[1]= lpToIndex;231 type_stack[1]=toType.GetBasicType(); 232 index_stack[1]=toType.GetIndex(); 256 233 array_bUseHeap[1]=0; 257 234 258 Type BaseTypeInfo={ToType,lpToIndex}; 259 260 int iRet; 261 iRet=CallOperatorProc(CALC_AS,&BaseTypeInfo,type,index_stack,array_bUseHeap,sp); 235 int iRet = CallOperatorProc(CALC_AS,toType,type_stack,index_stack,array_bUseHeap,sp); 236 262 237 if(iRet==1){ 263 238 //成功したとき 264 CalcType=type[0]; 265 lpCalcIndex=index_stack[0]; 239 calcType.SetType( type_stack[0], index_stack[0] ); 266 240 return; 267 241 } … … 274 248 SetError(-1,"キャスト演算子がオーバーロードされていません。",cp); 275 249 } 276 void CallIndexerGetterProc( CClass *pobj_Class,char *ObjectName,char *Parameter,Type &RetTypeInfo){250 void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType){ 277 251 std::vector<UserProc *> subs; 278 252 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); … … 282 256 283 257 Opcode_CallProc(Parameter,subs[0],0,ObjectName,DEF_OBJECT); 284 RetTypeInfo.type = subs[0]->ReturnType().GetBasicType(); 285 RetTypeInfo.u.lpIndex = subs[0]->ReturnType().GetIndex(); 286 } 258 resultType = subs[0]->ReturnType(); 259 } -
BasicCompiler64/BasicCompiler.vcproj
r75 r76 1258 1258 </Filter> 1259 1259 <Filter 1260 Name="Debug"1261 >1262 <File1263 RelativePath="VarList.cpp"1264 >1265 <FileConfiguration1266 Name="Debug|Win32"1267 >1268 <Tool1269 Name="VCCLCompilerTool"1270 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"1271 UsePrecompiledHeader="0"1272 BrowseInformation="0"1273 />1274 </FileConfiguration>1275 <FileConfiguration1276 Name="Release|Win32"1277 >1278 <Tool1279 Name="VCCLCompilerTool"1280 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"1281 UsePrecompiledHeader="0"1282 BrowseInformation="1"1283 />1284 </FileConfiguration>1285 <FileConfiguration1286 Name="English_Rel|Win32"1287 >1288 <Tool1289 Name="VCCLCompilerTool"1290 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;ENG;$(NoInherit)"1291 UsePrecompiledHeader="0"1292 />1293 </FileConfiguration>1294 <FileConfiguration1295 Name="Release2|Win32"1296 >1297 <Tool1298 Name="VCCLCompilerTool"1299 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"1300 UsePrecompiledHeader="0"1301 BrowseInformation="0"1302 />1303 </FileConfiguration>1304 </File>1305 <File1306 RelativePath="WatchList.cpp"1307 >1308 <FileConfiguration1309 Name="Debug|Win32"1310 >1311 <Tool1312 Name="VCCLCompilerTool"1313 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"1314 UsePrecompiledHeader="0"1315 BrowseInformation="0"1316 />1317 </FileConfiguration>1318 <FileConfiguration1319 Name="Release|Win32"1320 >1321 <Tool1322 Name="VCCLCompilerTool"1323 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"1324 UsePrecompiledHeader="0"1325 BrowseInformation="1"1326 />1327 </FileConfiguration>1328 <FileConfiguration1329 Name="English_Rel|Win32"1330 >1331 <Tool1332 Name="VCCLCompilerTool"1333 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;ENG;$(NoInherit)"1334 UsePrecompiledHeader="0"1335 />1336 </FileConfiguration>1337 <FileConfiguration1338 Name="Release2|Win32"1339 >1340 <Tool1341 Name="VCCLCompilerTool"1342 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"1343 UsePrecompiledHeader="0"1344 BrowseInformation="0"1345 />1346 </FileConfiguration>1347 </File>1348 </Filter>1349 <Filter1350 1260 Name="32及び64共通" 1351 1261 > … … 1384 1294 <File 1385 1295 RelativePath="..\BasicCompiler_Common\Object.cpp" 1296 > 1297 </File> 1298 <File 1299 RelativePath="..\BasicCompiler_Common\OldStatement.cpp" 1386 1300 > 1387 1301 </File> … … 1472 1386 RelativePath="..\BasicCompiler_Common\DebugSection.h" 1473 1387 > 1388 </File> 1389 <File 1390 RelativePath="..\BasicCompiler_Common\VarList.cpp" 1391 > 1392 </File> 1393 <File 1394 RelativePath="..\BasicCompiler_Common\WatchList.cpp" 1395 > 1396 <FileConfiguration 1397 Name="Debug|Win32" 1398 > 1399 <Tool 1400 Name="VCCLCompilerTool" 1401 ObjectFile="$(IntDir)\$(InputName)1.obj" 1402 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 1403 /> 1404 </FileConfiguration> 1405 <FileConfiguration 1406 Name="Release|Win32" 1407 > 1408 <Tool 1409 Name="VCCLCompilerTool" 1410 ObjectFile="$(IntDir)\$(InputName)1.obj" 1411 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 1412 /> 1413 </FileConfiguration> 1414 <FileConfiguration 1415 Name="English_Rel|Win32" 1416 > 1417 <Tool 1418 Name="VCCLCompilerTool" 1419 ObjectFile="$(IntDir)\$(InputName)1.obj" 1420 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 1421 /> 1422 </FileConfiguration> 1423 <FileConfiguration 1424 Name="Release2|Win32" 1425 > 1426 <Tool 1427 Name="VCCLCompilerTool" 1428 ObjectFile="$(IntDir)\$(InputName)1.obj" 1429 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 1430 /> 1431 </FileConfiguration> 1474 1432 </File> 1475 1433 </Filter> -
BasicCompiler64/Compile_Func.cpp
r75 r76 62 62 63 63 int reg=REG_RAX; 64 NumOpe(®,temporary,Type(),Type() ,NULL);64 NumOpe(®,temporary,Type(),Type()); 65 65 return; 66 66 } 67 68 67 69 68 int SubScripts[MAX_ARRAYDIM]; 70 69 RELATIVE_VAR RelativeVar; 71 70 if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,SubScripts)) return; 72 73 71 74 72 if(type.GetBasicType()&FLAG_PTR){ -
BasicCompiler64/Compile_ProcOp.cpp
r75 r76 201 201 extern UserProc **ppSubHash; 202 202 extern BOOL bDebugCompile; 203 int i3,i4 ,BufferSize;203 int i3,i4; 204 204 char temporary[VN_SIZE]; 205 205 206 BufferSize=128;207 208 206 if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return; 207 208 if( pUserProc->localVars.size() ){ 209 SetError(); 210 return; 211 } 209 212 210 213 pUserProc->CompleteCompile(); … … 217 220 if(memcmp(pUserProc->GetName().c_str(),"_DebugSys_",10)==0){ 218 221 if(!bDebugCompile){ 219 pUserProc->localVars.clear();220 222 return; 221 223 } … … 231 233 //////////////////// 232 234 233 extern int MaxLocalVarNum;234 235 extern int AllLocalVarSize; 235 MaxLocalVarNum=0;236 236 AllLocalVarSize=0; 237 237 … … 247 247 248 248 pUserProc->endOpAddress=obp; 249 pUserProc->localVars.clear();250 249 return; 251 250 } … … 294 293 extern int AllLocalVarSize; 295 294 AllLocalVarSize=0; 296 pUserProc->localVars.clear();297 295 298 296 //ローカル変数アドレススケジュール -
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 //////////// -
BasicCompiler64/Compile_Var.cpp
r75 r76 4 4 //変数 5 5 Variables globalVars; 6 int MaxGlobalVarNum;7 6 int AllGlobalVarSize; 8 7 int AllInitGlobalVarSize; 9 8 10 int MaxLocalVarNum;11 9 int AllLocalVarSize; 12 10 -
BasicCompiler64/MakePeHdr.cpp
r75 r76 264 264 obj_LexScopes.Init(obp); 265 265 266 267 ///////////////////////////////////////////////////////////////// 268 // デバッグコンパイル用のログを生成する 269 ///////////////////////////////////////////////////////////////// 270 #ifdef _DEBUG 271 { 272 ofstream ofs("middle_code.txt"); 273 ofs << basbuf << endl; 274 ofs.close(); 275 } 276 #endif 266 277 267 278 … … 1090 1101 delete pobj_GlobalVarSchedule; 1091 1102 1092 //グローバル変数情報を扱う構造体も初期バッファの有無による配置を行う1093 //(デバッグ情報で利用される)1094 foreach( Variable *pVar, globalVars ){1095 if(pVar->offset&0x80000000){1096 pVar->offset=(pVar->offset&0x7FFFFFFF)+AllInitGlobalVarSize;1097 }1098 }1099 1100 1103 1101 1104 //////////////////////////////// -
BasicCompiler64/NumOpe.cpp
r75 r76 2 2 #include "Opcode.h" 3 3 4 void NewStringObject(int reg, LPSTR lpszText){4 void NewStringObject(int reg, const char *str){ 5 5 /////////////////////////////////////////////////////// 6 6 // lpszTextを元にStringオブジェクトを生成し、 … … 14 14 ////////////////////////////////////////////////////// 15 15 16 char *parameter = (char *)malloc( lstrlen( lpszText) + 32 );17 sprintf( parameter, "\"%s\"%c%c*Char", lpszText, 1, ESC_AS );16 char *parameter = (char *)malloc( lstrlen( str ) + 32 ); 17 sprintf( parameter, "\"%s\"%c%c*Char", str, 1, ESC_AS ); 18 18 SetStringQuotes( parameter ); 19 19 … … 226 226 i3=lstrlen(term); 227 227 StrLiteral: 228 228 229 229 if( baseType.IsObject() ){ 230 230 if( baseType.IsStringObject() ){ … … 290 290 i4=GetStringInPare_RemovePare(temp2,term+i2+1); 291 291 292 int idProc;293 292 void *pInfo; 294 i dProc=GetProc(temporary,(void **)&pInfo);293 int idProc=GetProc(temporary,(void **)&pInfo); 295 294 296 295 Type resultType; … … 550 549 } 551 550 } 552 553 551 554 552 -
BasicCompiler64/Opcode.h
r75 r76 416 416 void OpcodeGosub(char *Parameter); 417 417 void OpcodeReturn(char *Parameter); 418 void Opcode_Input(const char *Parameter);419 void Opcode_Print(const char *Parameter,BOOL bWrite);420 void OpcodeCallPtr(char *Parameter);421 418 void OpcodeSetPtrData(char *Parameter,int type); 422 419 -
BasicCompiler64/OperatorProc.cpp
r75 r76 42 42 BOOL bTwoTerm=1; 43 43 if(idCalc==CALC_AS) bTwoTerm=0; 44 45 46 int i;47 44 48 45 … … 79 76 } 80 77 81 for(i =0;i<(int)params.size();i++){78 for(int i=0;i<(int)params.size();i++){ 82 79 CheckDifferentType( 83 80 pUserProc->Params()[i]->GetBasicType(), -
BasicCompiler_Common/Class.cpp
r75 r76 784 784 i+=2; 785 785 //アラインメント修飾子 786 if( _memicmp(basbuf+i,"Align(",6)==0){786 if(memicmp(basbuf+i,"Align(",6)==0){ 787 787 i+=6; 788 788 i=JumpStringInPare(basbuf,i)+1; … … 1130 1130 //アラインメント修飾子 1131 1131 int iAlign=0; 1132 if( _memicmp(basbuf+i,"Align(",6)==0){1132 if(memicmp(basbuf+i,"Align(",6)==0){ 1133 1133 i+=6; 1134 1134 i+=GetStringInPare_RemovePare(temporary,basbuf+i)+1; -
BasicCompiler_Common/DebugMiddleFile.cpp
r75 r76 832 832 //プロセスメモリにコピー 833 833 extern HANDLE hDebugProcess; 834 SIZE_T stAccBytes;834 SIZE_T accessBytes; 835 835 WriteProcessMemory(hDebugProcess,(void *)(ULONG_PTR)(dwImageBase+dwRVA_CodeSection), 836 836 BreakStepCodeBuffer, 837 SizeOf_CodeSection,& stAccBytes);837 SizeOf_CodeSection,&accessBytes); 838 838 839 839 … … 849 849 850 850 extern HANDLE hDebugProcess; 851 SIZE_T stAccBytes;851 SIZE_T accessBytes; 852 852 IMAGE_DOS_HEADER ImageDosHeader; 853 ReadProcessMemory(hDebugProcess,hModule,&ImageDosHeader,sizeof(IMAGE_DOS_HEADER),& stAccBytes);853 ReadProcessMemory(hDebugProcess,hModule,&ImageDosHeader,sizeof(IMAGE_DOS_HEADER),&accessBytes); 854 854 855 855 int pe_size; … … 861 861 pe_size=sizeof(IMAGE_NT_HEADERS); 862 862 #endif 863 ReadProcessMemory(hDebugProcess,(void *)(((ULONG_PTR)hModule)+ImageDosHeader.e_lfanew),&pe_hdr,pe_size,& stAccBytes);863 ReadProcessMemory(hDebugProcess,(void *)(((ULONG_PTR)hModule)+ImageDosHeader.e_lfanew),&pe_hdr,pe_size,&accessBytes); 864 864 865 865 IMAGE_SECTION_HEADER *pSectionHdr; … … 869 869 pSectionHdr, 870 870 pe_hdr.FileHeader.NumberOfSections*sizeof(IMAGE_SECTION_HEADER), 871 & stAccBytes);871 &accessBytes); 872 872 873 873 int i; … … 894 894 buffer, 895 895 length, 896 & stAccBytes);896 &accessBytes); 897 897 buffer[length]=0; 898 898 } … … 913 913 ReadProcessMemory(hDebugProcess, 914 914 (void *)(ULONG_PTR)(dwImageBase+dwRVA_CodeSection),OpBuffer, 915 SizeOf_CodeSection,& stAccBytes);915 SizeOf_CodeSection,&accessBytes); 916 916 917 917 -
BasicCompiler_Common/MakeExe.cpp
r75 r76 182 182 183 183 //グローバル変数に関する情報 184 extern int MaxGlobalVarNum;185 184 extern int AllGlobalVarSize; 186 185 extern int AllInitGlobalVarSize; 187 186 globalVars.clear(); 188 MaxGlobalVarNum=0;189 187 AllGlobalVarSize=0; 190 188 AllInitGlobalVarSize=0; -
BasicCompiler_Common/Procedure.h
r75 r76 1 2 struct VARIABLE;3 1 4 2 class Procedure{ -
BasicCompiler_Common/Type.cpp
r75 r76 173 173 int Type::GetBasicSize() const 174 174 { 175 GetBasicSize( basicType ); 176 return 0; 175 return GetBasicSize( basicType ); 177 176 } 178 177 int Type::GetSize() const -
BasicCompiler_Common/VariableOpe.cpp
r75 r76 770 770 } 771 771 772 if( _memicmp(variable,"This.",5)==0){772 if(memicmp(variable,"This.",5)==0){ 773 773 //Thisオブジェクトのメンバを参照するとき 774 774 SlideString(variable+5,-5); … … 1115 1115 // グローバル変数を追加 1116 1116 ///////////////////////// 1117 extern int MaxGlobalVarNum;1118 1117 extern int AllInitGlobalVarSize; 1119 1118 extern int AllGlobalVarSize; -
BasicCompiler_Common/calculation.cpp
r75 r76 555 555 void *offset; 556 556 DWORD dwData; 557 SIZE_T stAccBytes;557 SIZE_T accessBytes; 558 558 float flt; 559 559 … … 579 579 580 580 if(tempType.IsDouble()){ 581 i3=ReadProcessMemory(hDebugProcess,offset,&nums[pnum],sizeof(double),& stAccBytes);581 i3=ReadProcessMemory(hDebugProcess,offset,&nums[pnum],sizeof(double),&accessBytes); 582 582 } 583 583 else if(tempType.IsSingle()){ 584 if(i3=ReadProcessMemory(hDebugProcess,offset,&flt,sizeof(float),& stAccBytes)){584 if(i3=ReadProcessMemory(hDebugProcess,offset,&flt,sizeof(float),&accessBytes)){ 585 585 nums[pnum]=(double)flt; 586 586 } … … 588 588 else if(tempType.IsPointer()){ 589 589 LONG_PTR lpData; 590 if(i3=ReadProcessMemory(hDebugProcess,offset,&lpData,sizeof(LONG_PTR),& stAccBytes)){590 if(i3=ReadProcessMemory(hDebugProcess,offset,&lpData,sizeof(LONG_PTR),&accessBytes)){ 591 591 i64nums[pnum]=(_int64)lpData; 592 592 } … … 595 595 type[pnum]=DEF_INT64; 596 596 597 i3=ReadProcessMemory(hDebugProcess,offset,&i64nums[pnum],sizeof(_int64),& stAccBytes);597 i3=ReadProcessMemory(hDebugProcess,offset,&i64nums[pnum],sizeof(_int64),&accessBytes); 598 598 } 599 599 600 600 else if(tempType.IsLong()){ 601 601 long lData; 602 if(i3=ReadProcessMemory(hDebugProcess,offset,&lData,sizeof(long),& stAccBytes)){602 if(i3=ReadProcessMemory(hDebugProcess,offset,&lData,sizeof(long),&accessBytes)){ 603 603 i64nums[pnum]=(_int64)lData; 604 604 } 605 605 } 606 606 else if(tempType.IsDWord()){ 607 if(i3=ReadProcessMemory(hDebugProcess,offset,&dwData,sizeof(DWORD),& stAccBytes)){607 if(i3=ReadProcessMemory(hDebugProcess,offset,&dwData,sizeof(DWORD),&accessBytes)){ 608 608 i64nums[pnum]=(_int64)dwData; 609 609 } … … 611 611 else if(tempType.IsInteger()){ 612 612 short shortData; 613 if(i3=ReadProcessMemory(hDebugProcess,offset,&shortData,sizeof(short),& stAccBytes)){613 if(i3=ReadProcessMemory(hDebugProcess,offset,&shortData,sizeof(short),&accessBytes)){ 614 614 i64nums[pnum]=(_int64)shortData; 615 615 } … … 617 617 else if(tempType.IsWord()){ 618 618 WORD wData; 619 if(i3=ReadProcessMemory(hDebugProcess,offset,&wData,sizeof(WORD),& stAccBytes)){619 if(i3=ReadProcessMemory(hDebugProcess,offset,&wData,sizeof(WORD),&accessBytes)){ 620 620 i64nums[pnum]=(_int64)wData; 621 621 } … … 623 623 else if(tempType.IsSByte()){ 624 624 char charData; 625 if(i3=ReadProcessMemory(hDebugProcess,offset,&charData,sizeof(char),& stAccBytes)){625 if(i3=ReadProcessMemory(hDebugProcess,offset,&charData,sizeof(char),&accessBytes)){ 626 626 i64nums[pnum]=(_int64)charData; 627 627 } … … 629 629 else if(tempType.IsByte()){ 630 630 BYTE byteData; 631 if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),& stAccBytes)){631 if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&accessBytes)){ 632 632 i64nums[pnum]=(_int64)byteData; 633 633 } … … 635 635 else if(tempType.IsBoolean()){ 636 636 BYTE byteData; 637 if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),& stAccBytes)){637 if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&accessBytes)){ 638 638 i64nums[pnum]=(_int64)byteData; 639 639 } -
BasicCompiler_Common/common.h
r75 r76 12 12 #include <vector> 13 13 #include <string> 14 #include <fstream> 14 15 15 16 //boost libraries … … 172 173 int FilesNum; 173 174 int LineOfFile[MAX_LEN]; 174 };175 176 177 //変数178 struct VARIABLE{179 char name[255];180 int type;181 union{182 LONG_PTR index;183 CClass *pobj_c;184 }u;185 186 DWORD fRef;187 188 //定数変数かどうか189 bool bConst;190 191 BOOL bArray;192 int SubScripts[MAX_ARRAYDIM];193 194 //コンストラクタ用パラメータ195 char *ConstractParameter;196 197 /* --- オフセット ---198 199 ※グローバル変数で初期バッファがない場合は最上位ビットに1がセットされ、200 初期バッファの有無が識別される。201 (その後、スケジュール実行により、実際の配置に並び替えられる)*/202 int offset;203 204 205 //レキシカルスコープ用206 int ScopeStartAddress;207 int ScopeEndAddress;208 int ScopeLevel;209 BOOL bLiving;210 211 212 int source_code_address;213 175 }; 214 176 … … 482 444 void DeleteProcPtrInfo(void); 483 445 446 //OldStatement.cpp 447 void Opcode_Input(const char *Parameter); 448 void Opcode_Print(const char *Parameter,BOOL bWrite); 449 484 450 //LoopRefCheck.cpp 485 451 class CLoopRefCheck{ -
BasicCompiler_Common/preprocessor.cpp
r69 r76 171 171 172 172 if(buffer[i-1]=='\n'){ 173 if( _memicmp(buffer+i,"#ifdef",6)==0||_memicmp(buffer+i,"#ifndef",7)==0){173 if(memicmp(buffer+i,"#ifdef",6)==0||memicmp(buffer+i,"#ifndef",7)==0){ 174 174 i=Search_endif(buffer,i+6, pLine); 175 175 if(buffer[i]=='\0') break; 176 176 continue; 177 177 } 178 else if( _memicmp(buffer+i,"#endif",6)==0){178 else if(memicmp(buffer+i,"#endif",6)==0){ 179 179 break; 180 180 } … … 222 222 223 223 if(i==0||buffer[i-1]=='\n'){ 224 if( _memicmp(buffer+i,"#ifdef",6)==0||_memicmp(buffer+i,"#ifndef",7)==0){224 if(memicmp(buffer+i,"#ifdef",6)==0||memicmp(buffer+i,"#ifndef",7)==0){ 225 225 i=Search_endif(buffer,i+6); 226 226 if(buffer[i]=='\0') break; 227 227 continue; 228 228 } 229 else if( _memicmp(buffer+i,"#else",5)==0){229 else if(memicmp(buffer+i,"#else",5)==0){ 230 230 i2=5; 231 231 bElse=1; 232 232 break; 233 233 } 234 else if( _memicmp(buffer+i,"#endif",6)==0){234 else if(memicmp(buffer+i,"#endif",6)==0){ 235 235 i2=6; 236 236 bElse=0; … … 252 252 253 253 if(i2==0||buffer[i2-1]=='\n'){ 254 if( _memicmp(buffer+i2,"#ifdef",6)==0||_memicmp(buffer+i2,"#ifndef",7)==0){254 if(memicmp(buffer+i2,"#ifdef",6)==0||memicmp(buffer+i2,"#ifndef",7)==0){ 255 255 i2=Search_endif(buffer,i2+6, &i3 ); 256 256 if(buffer[i2]=='\0') break; 257 257 continue; 258 258 } 259 if( _memicmp(buffer+i2,"#endif",6)==0){259 if(memicmp(buffer+i2,"#endif",6)==0){ 260 260 i2+=6; 261 261 break; … … 279 279 280 280 if(i2==0||buffer[i2-1]=='\n'){ 281 if( _memicmp(buffer+i2,"#ifdef",6)==0||_memicmp(buffer+i2,"#ifndef",7)==0){281 if(memicmp(buffer+i2,"#ifdef",6)==0||memicmp(buffer+i2,"#ifndef",7)==0){ 282 282 i2=Search_endif(buffer,i2+6, &i3 ); 283 283 if(buffer[i2]=='\0') break; 284 284 continue; 285 285 } 286 else if( _memicmp(buffer+i2,"#else",5)==0){286 else if(memicmp(buffer+i2,"#else",5)==0){ 287 287 i2+=5; 288 288 bElse=1; 289 289 break; 290 290 } 291 else if( _memicmp(buffer+i2,"#endif",6)==0){291 else if(memicmp(buffer+i2,"#endif",6)==0){ 292 292 i2+=6; 293 293 bElse=0; … … 307 307 308 308 if(i==0||buffer[i-1]=='\n'){ 309 if( _memicmp(buffer+i,"#ifdef",6)==0||_memicmp(buffer+i,"#ifndef",7)==0){309 if(memicmp(buffer+i,"#ifdef",6)==0||memicmp(buffer+i,"#ifndef",7)==0){ 310 310 i=Search_endif(buffer,i+6); 311 311 if(buffer[i]=='\0') break; 312 312 continue; 313 313 } 314 else if( _memicmp(buffer+i,"#endif",6)==0){314 else if(memicmp(buffer+i,"#endif",6)==0){ 315 315 i2=6; 316 316 bElse=0; … … 336 336 if(i==0||buffer[i-1]=='\n'){ 337 337 sw=0; 338 if( _memicmp(buffer+i,"#define",7)==0){338 if(memicmp(buffer+i,"#define",7)==0){ 339 339 i2=i+7; 340 340 while(buffer[i2]==' '||buffer[i2]=='\t') i2++; … … 355 355 SlideString(buffer+i+i2,-i2); 356 356 } 357 if( _memicmp(buffer+i,"#undef",6)==0){357 if(memicmp(buffer+i,"#undef",6)==0){ 358 358 i2=i+7; 359 359 while(buffer[i2]==' '||buffer[i2]=='\t') i2++; … … 374 374 SlideString(buffer+i+i2,-i2); 375 375 } 376 else if( _memicmp(buffer+i,"#ifdef",6)==0){376 else if(memicmp(buffer+i,"#ifdef",6)==0){ 377 377 preprocessor_ifdef(buffer+i,false); 378 378 continue; 379 379 } 380 else if( _memicmp(buffer+i,"#ifndef",7)==0){380 else if(memicmp(buffer+i,"#ifndef",7)==0){ 381 381 preprocessor_ifdef(buffer+i,true); 382 382 continue;
Note:
See TracChangeset
for help on using the changeset viewer.