Changeset 53 in dev for BasicCompiler_Common


Ignore:
Timestamp:
Feb 11, 2007, 12:30:12 AM (18 years ago)
Author:
dai_9181
Message:

ppobj_StaticMemberを廃止し、vectorに統一した(staticMember)。

Location:
BasicCompiler_Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler_Common/Class.cpp

    r51 r53  
    125125        pobj_c=pobj_DBClass->Iterator_GetNext();
    126126
    127         int i;
    128         char temporary[VN_SIZE];
    129         for(i=0;i<pobj_c->iStaticMemberNum;i++){
    130             sprintf(temporary,"%s.%s",pobj_c->name,pobj_c->ppobj_StaticMember[i]->name);
     127        foreach( CMember *member, pobj_c->staticMembers ){
     128            char temporary[VN_SIZE];
     129            sprintf(temporary,"%s.%s",pobj_c->name,member->name);
    131130            AddGlobalVariable(
    132131                temporary,
    133                 pobj_c->ppobj_StaticMember[i]->SubScripts,
    134                 &pobj_c->ppobj_StaticMember[i]->TypeInfo,
    135                 GetTypeSize(pobj_c->ppobj_StaticMember[i]->TypeInfo.type,pobj_c->ppobj_StaticMember[i]->TypeInfo.u.lpIndex),
    136                 pobj_c->ppobj_StaticMember[i]->InitBuf,
    137                 pobj_c->ppobj_StaticMember[i]->ConstractParameter,
     132                member->SubScripts,
     133                &member->TypeInfo,
     134                GetTypeSize(member->TypeInfo.type,member->TypeInfo.u.lpIndex),
     135                member->InitBuf,
     136                member->ConstractParameter,
    138137                0);
    139138
    140             if(pobj_c->ppobj_StaticMember[i]->TypeInfo.type==DEF_OBJECT){
     139            if(member->TypeInfo.type==DEF_OBJECT){
    141140                //エラー用
    142                 cp=pobj_c->ppobj_StaticMember[i]->source_code_address;
     141                cp=member->source_code_address;
    143142
    144143                CallConstructor(temporary,
    145                     pobj_c->ppobj_StaticMember[i]->SubScripts,
    146                     pobj_c->ppobj_StaticMember[i]->TypeInfo,
    147                     pobj_c->ppobj_StaticMember[i]->ConstractParameter);
     144                    member->SubScripts,
     145                    member->TypeInfo,
     146                    member->ConstractParameter);
    148147            }
    149148
     
    207206    }
    208207
    209     if(ppobj_StaticMember){
    210         //静的メンバ
    211         for(i=0;i<iStaticMemberNum;i++){
    212             delete ppobj_StaticMember[i];
    213         }
    214         HeapDefaultFree(ppobj_StaticMember);
    215         ppobj_StaticMember=0;
     208    //静的メンバ
     209    foreach( CMember *member, staticMembers ){
     210        delete member;
    216211    }
    217212
     
    277272}
    278273void CClass::AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine ){
    279     ppobj_StaticMember=(CMember **)HeapReAlloc(hHeap,0,ppobj_StaticMember,(iStaticMemberNum+1)*sizeof(CMember *));
    280     ppobj_StaticMember[iStaticMemberNum]=new CMember( this, dwAccess, isConst, isRef, buffer, NowLine );
    281     iStaticMemberNum++;
     274    CMember *member = new CMember( this, dwAccess, isConst, isRef, buffer, NowLine );
     275    staticMembers.push_back( member );
    282276}
    283277void CClass::AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){
     
    320314    //重複チェック
    321315
    322     int i;
    323 
    324316    //メンバ
    325     for(i=0;i<iMemberNum;i++){
     317    for( int i=0;i<iMemberNum;i++){
    326318        if(lstrcmp(name,ppobj_Member[i]->name)==0){
    327319            return 1;
     
    330322
    331323    //静的メンバ
    332     for(i=0;i<iStaticMemberNum;i++){
    333         if(lstrcmp(name,ppobj_StaticMember[i]->name)==0){
     324    foreach( CMember *member, staticMembers ){
     325        if( lstrcmp( name, member->name ) == 0 ){
    334326            return 1;
    335327        }
     
    911903            pobj_c->ppobj_Member=(CMember **)HeapAlloc(hHeap,0,1);
    912904            pobj_c->iMemberNum=0;
    913             pobj_c->ppobj_StaticMember=(CMember **)HeapAlloc(hHeap,0,1);
    914             pobj_c->iStaticMemberNum=0;
    915905
    916906            pobj_c->ConstructorMemberSubIndex=-1;
     
    10691059            pobj_c->ppobj_Member=(CMember **)HeapAlloc(hHeap,0,1);
    10701060            pobj_c->iMemberNum=0;
    1071             pobj_c->ppobj_StaticMember=(CMember **)HeapAlloc(hHeap,0,1);
    1072             pobj_c->iStaticMemberNum=0;
    10731061
    10741062            pobj_c->ConstructorMemberSubIndex=-1;
  • BasicCompiler_Common/Class.h

    r51 r53  
    6363class CDebugSection;
    6464class CClass{
     65    friend CMember;
    6566    friend CDBClass;
    6667    friend CDebugSection;
     68
     69    //静的メンバ情報
     70    std::vector<CMember *>staticMembers;
    6771
    6872    //メソッド情報
     
    8690    int iMemberNum;
    8791
    88     //静的メンバ情報
    89     CMember **ppobj_StaticMember;
    90     int iStaticMemberNum;
    91 
    9292    //仮想関数の数
    9393    int vtbl_num;
     
    104104    void Inherits( CClass *pInheritsClass );
    105105
     106    //メンバ、メソッドの追加
    106107    void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
    107108    void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine );
     
    109110    void AddStaticMethod(SUBINFO *psi,DWORD dwAccess);
    110111
     112    //重複チェック
    111113    BOOL DupliCheckAll(const char *name);
    112114    BOOL DupliCheckMember(const char *name);
  • BasicCompiler_Common/DebugMiddleFile.cpp

    r51 r53  
    382382
    383383        //静的メンバ
    384         *(long *)(buffer+i2)=pobj_c->iStaticMemberNum;
    385         i2+=sizeof(long);
    386         for(i4=0;i4<pobj_c->iStaticMemberNum;i4++){
    387             lstrcpy(buffer+i2,pobj_c->ppobj_StaticMember[i4]->name);
     384        *(long *)(buffer+i2)=(long)pobj_c->staticMembers.size();
     385        i2+=sizeof(long);
     386        foreach( CMember *member, pobj_c->staticMembers ){
     387            lstrcpy(buffer+i2,member->name);
    388388            i2+=lstrlen(buffer+i2)+1;
    389389
    390             memcpy(buffer+i2,pobj_c->ppobj_StaticMember[i4]->SubScripts,sizeof(int)*MAX_ARRAYDIM);
     390            memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM);
    391391            i2+=sizeof(int)*MAX_ARRAYDIM;
    392392
    393393            //型
    394             *(long *)(buffer+i2)=pobj_c->ppobj_StaticMember[i4]->TypeInfo.type;
     394            *(long *)(buffer+i2)=member->TypeInfo.type;
    395395            i2+=sizeof(long);
    396396
    397397            //型の拡張情報
    398             SetLpIndex_DebugFile(buffer,&i2,pobj_c->ppobj_StaticMember[i4]->TypeInfo.type,pobj_c->ppobj_StaticMember[i4]->TypeInfo.u.lpIndex);
    399 
    400             *(long *)(buffer+i2)=pobj_c->ppobj_StaticMember[i4]->dwAccess;
     398            SetLpIndex_DebugFile(buffer,&i2,member->TypeInfo.type,member->TypeInfo.u.lpIndex);
     399
     400            *(long *)(buffer+i2)=member->dwAccess;
    401401            i2+=sizeof(long);
    402402
     
    772772
    773773        //静的メンバ
    774         pobj_c->iStaticMemberNum=*(long *)(buffer+i2);
    775         i2+=sizeof(long);
    776         pobj_c->ppobj_StaticMember=
    777             (CMember **)HeapAlloc(hHeap,0,pobj_c->iStaticMemberNum*sizeof(CMember *));
    778         for(i4=0;i4<pobj_c->iStaticMemberNum;i4++){
    779             pobj_c->ppobj_StaticMember[i4]=new CMember();
    780 
    781             pobj_c->ppobj_StaticMember[i4]->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1);
    782             lstrcpy(pobj_c->ppobj_StaticMember[i4]->name,buffer+i2);
     774        int nStaticMember = *(long *)(buffer+i2);
     775        i2+=sizeof(long);
     776        for( i4=0; i4<nStaticMember; i4++ ){
     777            CMember *member=new CMember();
     778
     779            member->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1);
     780            lstrcpy(member->name,buffer+i2);
    783781            i2+=lstrlen(buffer+i2)+1;
    784782
    785             memcpy(pobj_c->ppobj_StaticMember[i4]->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
     783            memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
    786784            i2+=sizeof(int)*MAX_ARRAYDIM;
    787785
    788786            //型
    789             pobj_c->ppobj_StaticMember[i4]->TypeInfo.type=*(long *)(buffer+i2);
     787            member->TypeInfo.type=*(long *)(buffer+i2);
    790788            i2+=sizeof(long);
    791789
    792790            //型の拡張情報
    793             GetLpIndex_DebugFile(buffer,&i2,pobj_c->ppobj_StaticMember[i4]->TypeInfo.type,&pobj_c->ppobj_StaticMember[i4]->TypeInfo.u.lpIndex);
    794 
    795             pobj_c->ppobj_StaticMember[i4]->dwAccess=*(long *)(buffer+i2);
    796             i2+=sizeof(long);
     791            GetLpIndex_DebugFile(buffer,&i2,member->TypeInfo.type,&member->TypeInfo.u.lpIndex);
     792
     793            member->dwAccess=*(long *)(buffer+i2);
     794            i2+=sizeof(long);
     795
     796            pobj_c->staticMembers.push_back( member );
    797797        }
    798798    }
Note: See TracChangeset for help on using the changeset viewer.