Ignore:
Timestamp:
Mar 20, 2007, 4:36:16 AM (17 years ago)
Author:
dai_9181
Message:

TYPEINFO→Typeへのリファクタリングを実施。64bitはほぼ完了。32bitが全般的に未完成。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler_Common/calculation.cpp

    r73 r75  
    390390}
    391391
    392 int StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,LONG_PTR *plpIndex,BOOL bDebuggingWatchList){
    393     extern HANDLE hHeap;
     392bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList, bool *pIsMemoryAccessError){
    394393    extern int cp;
    395394    int i,i2,i3,PareNum;
     
    406405    int sp,pnum;
    407406
     407    if( pIsMemoryAccessError ) *pIsMemoryAccessError = false;
     408
    408409    *pi64data=0;
    409     if(Command[0]=='\0') return 0;
     410    if(Command[0]=='\0') return false;
    410411
    411412    for(i=0,i2=0,sp=0,pnum=0,PareNum=0;;i++,i2++){
     
    487488                            extern int cp;
    488489                            if(enableerror) SetError(3,temp2,cp);
    489                             return 0;
     490                            return false;
    490491                        }
    491492                        i64nums[pnum]=GetTypeSize(i3,lpIndex);
     
    497498                        if(!GetConstCalcBuffer(temporary,temp2,Parms)){
    498499                            if(enableerror) SetError(3,temporary,cp);
    499                             return 0;
     500                            return false;
    500501                        }
    501502
    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                            //実数型
    505509                            memcpy(&nums[pnum],&i64data,sizeof(double));
    506510                        }
     
    548552
    549553                            RELATIVE_VAR RelativeVar;
    550                             LONG_PTR lpIndex;
    551554                            int ss[MAX_ARRAYDIM];
    552555                            void *offset;
     
    557560                            extern HANDLE hDebugProcess;
    558561
    559                             i3=Debugging_GetVarOffset(Parms,&i2,&RelativeVar,&lpIndex,ss);
     562                            Type tempType;
     563                            i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType,ss);
    560564                            if(i3==0){
    561565                                //式エラー
    562                                 return 0;
     566                                return false;
    563567                            }
    564568                            if(i3==-1){
    565569                                //メモリにアクセスできないとき
    566                                 return -1;
     570                                if( pIsMemoryAccessError ) *pIsMemoryAccessError = true;
     571                                return false;
    567572                            }
    568573
     
    571576                                offset=(void *)Debugging_GetVarPtr(&RelativeVar);
    572577
    573                                 type[pnum]=i2;
    574 
    575                                 if(i2==DEF_DOUBLE){
     578                                type[pnum]=tempType.GetBasicType();
     579
     580                                if(tempType.IsDouble()){
    576581                                    i3=ReadProcessMemory(hDebugProcess,offset,&nums[pnum],sizeof(double),&stAccBytes);
    577582                                }
    578                                 else if(i2==DEF_SINGLE){
     583                                else if(tempType.IsSingle()){
    579584                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&flt,sizeof(float),&stAccBytes)){
    580585                                        nums[pnum]=(double)flt;
    581586                                    }
    582587                                }
    583                                 else if(IsPtrType(i2)){
     588                                else if(tempType.IsPointer()){
    584589                                    LONG_PTR lpData;
    585590                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&lpData,sizeof(LONG_PTR),&stAccBytes)){
     
    587592                                    }
    588593                                }
    589                                 else if(Is64Type(i2)){
     594                                else if(tempType.Is64()){
    590595                                    type[pnum]=DEF_INT64;
    591596
     
    593598                                }
    594599
    595                                 else if(i2==DEF_LONG){
     600                                else if(tempType.IsLong()){
    596601                                    long lData;
    597602                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&lData,sizeof(long),&stAccBytes)){
     
    599604                                    }
    600605                                }
    601                                 else if(i2==DEF_DWORD){
     606                                else if(tempType.IsDWord()){
    602607                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&dwData,sizeof(DWORD),&stAccBytes)){
    603608                                        i64nums[pnum]=(_int64)dwData;
    604609                                    }
    605610                                }
    606                                 else if(i2==DEF_INTEGER || (isUnicode&&i2==DEF_CHAR)){
     611                                else if(tempType.IsInteger()){
    607612                                    short shortData;
    608613                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&shortData,sizeof(short),&stAccBytes)){
     
    610615                                    }
    611616                                }
    612                                 else if(i2==DEF_WORD){
     617                                else if(tempType.IsWord()){
    613618                                    WORD wData;
    614619                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&wData,sizeof(WORD),&stAccBytes)){
     
    616621                                    }
    617622                                }
    618                                 else if(i2==DEF_SBYTE || (isUnicode==false&&i2==DEF_CHAR)){
     623                                else if(tempType.IsSByte()){
    619624                                    char charData;
    620625                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&charData,sizeof(char),&stAccBytes)){
     
    622627                                    }
    623628                                }
    624                                 else if(i2==DEF_BYTE){
     629                                else if(tempType.IsByte()){
    625630                                    BYTE byteData;
    626631                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){
     
    628633                                    }
    629634                                }
    630                                 else if(i2==DEF_BOOLEAN){
     635                                else if(tempType.IsBoolean()){
    631636                                    BYTE byteData;
    632637                                    if(i3=ReadProcessMemory(hDebugProcess,offset,&byteData,sizeof(BYTE),&stAccBytes)){
     
    634639                                    }
    635640                                }
    636                                 else return 0;
     641                                else return false;
    637642
    638643                                if(!i3){
    639644                                    //読み込みに失敗
    640                                     return -1;
     645                                    if( pIsMemoryAccessError ) *pIsMemoryAccessError = true;
     646                                    return false;
    641647                                }
    642648                                goto JumpConst;
     
    672678                                //エラー
    673679                                if(enableerror) SetError(300,NULL,cp);
    674                                 return -1;
     680                                return 0;
    675681                            }
    676682                            goto JumpConst;
     
    685691
    686692                        if(type[pnum]==-1){
    687                             if(bDebuggingWatchList) return -1;
     693                            if(bDebuggingWatchList){
     694                                if( pIsMemoryAccessError ) *pIsMemoryAccessError = true;
     695                                return false;
     696                            }
    688697                            //エラー
    689698                            if(enableerror) SetError(3,Parms,cp);
    690                             return 0;
     699                            return false;
    691700                        }
    692701JumpConst:;
     
    713722                if(!(Command[i]=='+'||Command[i]=='-'||(Command[i]==1&&Command[i+1]==ESC_NOT))){
    714723                    if(enableerror) SetError(1,NULL,cp);
    715                     return 0;
     724                    return false;
    716725                }
    717726                if(Command[i]=='+'){
     
    898907        //文字列ポインタ
    899908        *pi64data=(_int64)stack[0];
    900         *plpIndex=index_stack[0];
    901         return type_stack[0];
     909        resultType.SetType( type_stack[0], index_stack[0] );
     910        return true;
    902911    }
    903912
     
    905914        //実数
    906915        memcpy(pi64data,&dbl_stack[0],sizeof(double));
    907         return type_stack[0];
     916        resultType.SetType( type_stack[0], index_stack[0] );
     917        return true;
    908918    }
    909919
     
    911921    *pi64data=i64stack[0];
    912922
    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;
    926937}
    927938
     
    11871198    return -1;
    11881199}
    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 }
    11971200int IsStrCalculation(char *Command){
    1198     int i,i2,i3,i4,type,PareNum;
     1201    int i,i2,i3,i4,PareNum;
    11991202    char temporary[VN_SIZE],temp2[8192];
    12001203
     
    12451248                }
    12461249                if(Command[i2+i3]=='('){
    1247                     TYPEINFO TypeInfo;
    12481250
    12491251                    //DLL関数の場合
    1250                     DECLAREINFO *pdi;
    1251                     pdi=GetDeclareHash(temporary);
    1252                     if(pdi){
    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                        }
    12561258                        return 0;
    12571259                    }
    12581260
    12591261                    //ユーザー定義関数
    1260                     SubInfo *psi;
    1261                     psi=GetSubHash(temporary);
    1262                     if(psi){
    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                        }
    12661268                        return 0;
    12671269                    }
     
    12971299
    12981300                //変数
    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) ){
    13021303                    //エラー
    13031304                    return -1;
    13041305                }
    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;
    13101308                }
    13111309            }
Note: See TracChangeset for help on using the changeset viewer.