Changeset 75 in dev for BasicCompiler_Common/calculation.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/calculation.cpp
r73 r75 390 390 } 391 391 392 int StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList){ 393 extern HANDLE hHeap; 392 bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList, bool *pIsMemoryAccessError){ 394 393 extern int cp; 395 394 int i,i2,i3,PareNum; … … 406 405 int sp,pnum; 407 406 407 if( pIsMemoryAccessError ) *pIsMemoryAccessError = false; 408 408 409 *pi64data=0; 409 if(Command[0]=='\0') return 0;410 if(Command[0]=='\0') return false; 410 411 411 412 for(i=0,i2=0,sp=0,pnum=0,PareNum=0;;i++,i2++){ … … 487 488 extern int cp; 488 489 if(enableerror) SetError(3,temp2,cp); 489 return 0;490 return false; 490 491 } 491 492 i64nums[pnum]=GetTypeSize(i3,lpIndex); … … 497 498 if(!GetConstCalcBuffer(temporary,temp2,Parms)){ 498 499 if(enableerror) SetError(3,temporary,cp); 499 return 0;500 return false; 500 501 } 501 502 502 type[pnum]=StaticCalculation(true, Parms,BaseType,&i64data,&before_index[pnum]); 503 if(IsRealNumberType(type[pnum])){ 504 //整数型 503 Type tempType; 504 StaticCalculation(true, Parms,BaseType,&i64data,tempType); 505 type[pnum] = tempType.GetBasicType(); 506 before_index[pnum] = tempType.GetIndex(); 507 if(tempType.IsReal()){ 508 //実数型 505 509 memcpy(&nums[pnum],&i64data,sizeof(double)); 506 510 } … … 548 552 549 553 RELATIVE_VAR RelativeVar; 550 LONG_PTR lpIndex;551 554 int ss[MAX_ARRAYDIM]; 552 555 void *offset; … … 557 560 extern HANDLE hDebugProcess; 558 561 559 i3=Debugging_GetVarOffset(Parms,&i2,&RelativeVar,&lpIndex,ss); 562 Type tempType; 563 i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType,ss); 560 564 if(i3==0){ 561 565 //式エラー 562 return 0;566 return false; 563 567 } 564 568 if(i3==-1){ 565 569 //メモリにアクセスできないとき 566 return -1; 570 if( pIsMemoryAccessError ) *pIsMemoryAccessError = true; 571 return false; 567 572 } 568 573 … … 571 576 offset=(void *)Debugging_GetVarPtr(&RelativeVar); 572 577 573 type[pnum]= i2;574 575 if( i2==DEF_DOUBLE){578 type[pnum]=tempType.GetBasicType(); 579 580 if(tempType.IsDouble()){ 576 581 i3=ReadProcessMemory(hDebugProcess,offset,&nums[pnum],sizeof(double),&stAccBytes); 577 582 } 578 else if( i2==DEF_SINGLE){583 else if(tempType.IsSingle()){ 579 584 if(i3=ReadProcessMemory(hDebugProcess,offset,&flt,sizeof(float),&stAccBytes)){ 580 585 nums[pnum]=(double)flt; 581 586 } 582 587 } 583 else if( IsPtrType(i2)){588 else if(tempType.IsPointer()){ 584 589 LONG_PTR lpData; 585 590 if(i3=ReadProcessMemory(hDebugProcess,offset,&lpData,sizeof(LONG_PTR),&stAccBytes)){ … … 587 592 } 588 593 } 589 else if( Is64Type(i2)){594 else if(tempType.Is64()){ 590 595 type[pnum]=DEF_INT64; 591 596 … … 593 598 } 594 599 595 else if( i2==DEF_LONG){600 else if(tempType.IsLong()){ 596 601 long lData; 597 602 if(i3=ReadProcessMemory(hDebugProcess,offset,&lData,sizeof(long),&stAccBytes)){ … … 599 604 } 600 605 } 601 else if( i2==DEF_DWORD){606 else if(tempType.IsDWord()){ 602 607 if(i3=ReadProcessMemory(hDebugProcess,offset,&dwData,sizeof(DWORD),&stAccBytes)){ 603 608 i64nums[pnum]=(_int64)dwData; 604 609 } 605 610 } 606 else if( i2==DEF_INTEGER || (isUnicode&&i2==DEF_CHAR)){611 else if(tempType.IsInteger()){ 607 612 short shortData; 608 613 if(i3=ReadProcessMemory(hDebugProcess,offset,&shortData,sizeof(short),&stAccBytes)){ … … 610 615 } 611 616 } 612 else if( i2==DEF_WORD){617 else if(tempType.IsWord()){ 613 618 WORD wData; 614 619 if(i3=ReadProcessMemory(hDebugProcess,offset,&wData,sizeof(WORD),&stAccBytes)){ … … 616 621 } 617 622 } 618 else if( i2==DEF_SBYTE || (isUnicode==false&&i2==DEF_CHAR)){623 else if(tempType.IsSByte()){ 619 624 char charData; 620 625 if(i3=ReadProcessMemory(hDebugProcess,offset,&charData,sizeof(char),&stAccBytes)){ … … 622 627 } 623 628 } 624 else if( i2==DEF_BYTE){629 else if(tempType.IsByte()){ 625 630 BYTE byteData; 626 631 if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){ … … 628 633 } 629 634 } 630 else if( i2==DEF_BOOLEAN){635 else if(tempType.IsBoolean()){ 631 636 BYTE byteData; 632 637 if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){ … … 634 639 } 635 640 } 636 else return 0;641 else return false; 637 642 638 643 if(!i3){ 639 644 //読み込みに失敗 640 return -1; 645 if( pIsMemoryAccessError ) *pIsMemoryAccessError = true; 646 return false; 641 647 } 642 648 goto JumpConst; … … 672 678 //エラー 673 679 if(enableerror) SetError(300,NULL,cp); 674 return -1;680 return 0; 675 681 } 676 682 goto JumpConst; … … 685 691 686 692 if(type[pnum]==-1){ 687 if(bDebuggingWatchList) return -1; 693 if(bDebuggingWatchList){ 694 if( pIsMemoryAccessError ) *pIsMemoryAccessError = true; 695 return false; 696 } 688 697 //エラー 689 698 if(enableerror) SetError(3,Parms,cp); 690 return 0;699 return false; 691 700 } 692 701 JumpConst:; … … 713 722 if(!(Command[i]=='+'||Command[i]=='-'||(Command[i]==1&&Command[i+1]==ESC_NOT))){ 714 723 if(enableerror) SetError(1,NULL,cp); 715 return 0;724 return false; 716 725 } 717 726 if(Command[i]=='+'){ … … 898 907 //文字列ポインタ 899 908 *pi64data=(_int64)stack[0]; 900 *plpIndex=index_stack[0];901 return t ype_stack[0];909 resultType.SetType( type_stack[0], index_stack[0] ); 910 return true; 902 911 } 903 912 … … 905 914 //実数 906 915 memcpy(pi64data,&dbl_stack[0],sizeof(double)); 907 return type_stack[0]; 916 resultType.SetType( type_stack[0], index_stack[0] ); 917 return true; 908 918 } 909 919 … … 911 921 *pi64data=i64stack[0]; 912 922 913 if(plpIndex){ 914 *plpIndex=index_stack[0]; 915 if(*plpIndex==-1){ 916 if(Is64Type(type_stack[0])==0&&IsRealNumberType(type_stack[0])==0){ 917 //整数(符号有り/無し) 918 i64data=*pi64data; 919 920 *plpIndex=GetLiteralIndex(i64data); 921 } 922 } 923 } 924 925 return type_stack[0]; 923 if(index_stack[0]==-1){ 924 if(Is64Type(type_stack[0])==0&&IsRealNumberType(type_stack[0])==0){ 925 //整数(符号有り/無し) 926 i64data=*pi64data; 927 928 resultType.SetIndex( GetLiteralIndex(i64data) ); 929 } 930 } 931 else{ 932 resultType.SetIndex( index_stack[0] ); 933 } 934 935 resultType.SetBasicType( type_stack[0] ); 936 return true; 926 937 } 927 938 … … 1187 1198 return -1; 1188 1199 } 1189 bool IsStringObjectType(const TYPEINFO &TypeInfo){1190 if(TypeInfo.type==DEF_OBJECT){1191 if(lstrcmp(TypeInfo.u.pobj_Class->name,"String")==0){1192 return 1;1193 }1194 }1195 return 0;1196 }1197 1200 int IsStrCalculation(char *Command){ 1198 int i,i2,i3,i4, type,PareNum;1201 int i,i2,i3,i4,PareNum; 1199 1202 char temporary[VN_SIZE],temp2[8192]; 1200 1203 … … 1245 1248 } 1246 1249 if(Command[i2+i3]=='('){ 1247 TYPEINFO TypeInfo;1248 1250 1249 1251 //DLL関数の場合 1250 D ECLAREINFO *pdi;1251 p di=GetDeclareHash(temporary);1252 if(p di){1253 TypeInfo.type=pdi->ReturnType;1254 TypeInfo.u.lpIndex=pdi->u.ReturnIndex;1255 if(IsStringObjectType( TypeInfo )) return 1;1252 DllProc *pDllProc; 1253 pDllProc=GetDeclareHash(temporary); 1254 if(pDllProc){ 1255 if( pDllProc->ReturnType().IsStringObject() ){ 1256 return 1; 1257 } 1256 1258 return 0; 1257 1259 } 1258 1260 1259 1261 //ユーザー定義関数 1260 SubInfo *psi;1261 p si=GetSubHash(temporary);1262 if(p si){1263 TypeInfo.type=psi->ReturnType;1264 TypeInfo.u.lpIndex=psi->u.ReturnIndex;1265 if(IsStringObjectType(TypeInfo)) return 1;1262 UserProc *pUserProc; 1263 pUserProc=GetSubHash(temporary); 1264 if(pUserProc){ 1265 if( pUserProc->ReturnType().IsStringObject() ){ 1266 return 1; 1267 } 1266 1268 return 0; 1267 1269 } … … 1297 1299 1298 1300 //変数 1299 CClass *pobj_Class; 1300 type = GetVarType(Command+i2,(LONG_PTR *)&pobj_Class,1); 1301 if(type==-1 || type ==0){ 1301 Type varType; 1302 if( !GetVarType(Command+i2,varType,1) ){ 1302 1303 //エラー 1303 1304 return -1; 1304 1305 } 1305 if(type==DEF_OBJECT){ 1306 if(lstrcmp(pobj_Class->name,"String")==0){ 1307 return 1; 1308 } 1309 return 0; 1306 if( varType.IsStringObject() ){ 1307 return 1; 1310 1308 } 1311 1309 }
Note:
See TracChangeset
for help on using the changeset viewer.