Changeset 17 in dev


Ignore:
Timestamp:
Dec 20, 2006, 2:51:56 AM (17 years ago)
Author:
dai_9181
Message:

定数メンバ機能を有効にした。

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/Compile_ProcOp.cpp

    r11 r17  
    442442            // コンストラクタをコンパイルするとき
    443443            ////////////////////////////////////
     444
     445            //コンストラクタのコンパイル開始を通知
     446            pobj_CompilingClass->NotifyStartConstructorCompile();
    444447
    445448            //スーパークラスかどうかの識別
     
    577580    //////////////////////////////////////////
    578581
    579     if(pobj_CompilingClass){
     582    if( pobj_CompilingClass ){
     583
     584        if( pobj_CompilingClass->IsCompilingConstructor() ){
     585            // コンストラクタをコンパイルしていたとき
     586            // コンストラクタのコンパイルが完了したことを通知
     587
     588            pobj_CompilingClass->NotifyFinishConstructorCompile();
     589        }
     590
    580591        if(psi->name[0]=='~'){
    581592            ////////////////////////////////////
  • BasicCompiler32/Compile_Var.cpp

    r11 r17  
    157157    return 1;
    158158}
    159 BOOL GetMemberOffset(bool ErrorEnabled,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
     159BOOL GetMemberOffset(bool isErrorEnabled, bool isWriteAccess, CClass *pobj_c, char *member, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpNestIndex, BOOL bPrivateAccess){
    160160    int i,offset;
    161161
     
    175175    offset=GetSizeOfClassMember(pobj_c,VarName,&i);
    176176    if(i==pobj_c->iMemberNum){
    177         if(ErrorEnabled) SetError(103,VarName,cp);
     177        if(isErrorEnabled) SetError(103,VarName,cp);
    178178        return 0;
    179179    }
     
    183183        //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    184184        if(pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    185             if(ErrorEnabled) SetError(107,VarName,cp);
     185            if(isErrorEnabled) SetError(107,VarName,cp);
    186186            return 0;
    187187        }
     
    190190        if((bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||
    191191            pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    192             if(ErrorEnabled) SetError(107,VarName,cp);
     192            if(isErrorEnabled) SetError(107,VarName,cp);
    193193            return 0;
    194194        }
    195195        else if(bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED){
    196             if(ErrorEnabled) SetError(108,VarName,cp);
     196            if(isErrorEnabled) SetError(108,VarName,cp);
    197197            return 0;
    198198        }
     199    }
     200
     201    //Const定義の場合は書き込みアクセスを制限する
     202    //※コンストラクタをコンパイル中の場合は例外的に許可する
     203    if( pobj_c->ppobj_Member[i]->IsConst() &&       //定数メンバである
     204        isWriteAccess &&                            //書き込みアクセスを要求されている
     205        pobj_c->IsCompilingConstructor() == false   //コンストラクタ コンパイル中を除く
     206        ){
     207            //Const定義の変数に書き込みアクセスをしようとした場合
     208            SetError(61,VarName,cp);
    199209    }
    200210
     
    211221    else{
    212222        if(lpPtrOffset[0]){
    213             if(ErrorEnabled) SetError(16,member,cp);
     223            if(isErrorEnabled) SetError(16,member,cp);
    214224            return 0;
    215225        }
     
    227237        //配列オフセット
    228238        if(!GetArrayOffset(pobj_c->ppobj_Member[i]->SubScripts,array,*pType,pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex))
    229             if(ErrorEnabled) SetError(14,member,cp);
     239            if(isErrorEnabled) SetError(14,member,cp);
    230240    }
    231241    else if(pobj_c->ppobj_Member[i]->SubScripts[0]!=-1){
     
    238248        if(*pType==DEF_OBJECT){
    239249            if(RefType!=DEF_OBJECT){
    240                 if(ErrorEnabled) SetError(104,member,cp);
     250                if(isErrorEnabled) SetError(104,member,cp);
    241251                return 0;
    242252            }
     
    248258                //pObj[n].member
    249259                if(RefType!=DEF_OBJECT){
    250                     if(ErrorEnabled) SetError(104,member,cp);
     260                    if(isErrorEnabled) SetError(104,member,cp);
    251261                    return 0;
    252262                }
     
    261271                //pObj->member
    262272                if(RefType!=DEF_PTR_OBJECT){
    263                     if(ErrorEnabled) SetError(104,member,cp);
     273                    if(isErrorEnabled) SetError(104,member,cp);
    264274                    return 0;
    265275                }
     
    287297                //ppObj[n]->member
    288298                if(RefType!=DEF_PTR_OBJECT){
    289                     if(ErrorEnabled) SetError(104,member,cp);
     299                    if(isErrorEnabled) SetError(104,member,cp);
    290300                    return 0;
    291301                }
     
    302312            }
    303313            else{
    304                 if(ErrorEnabled) SetError(104,member,cp);
     314                if(isErrorEnabled) SetError(104,member,cp);
    305315                return 0;
    306316            }
    307317        }
    308318
    309         if(!GetMemberOffset(ErrorEnabled,pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,
     319        if(!GetMemberOffset(
     320            isErrorEnabled,
     321            isWriteAccess,
     322            pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,
    310323            NestMember,
    311324            pType,
     
    344357}
    345358
    346 BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
     359BOOL GetVarOffset(bool isErrorEnabled, bool isWriteAccess, char *NameBuffer, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpIndex, int *pss){
    347360    extern BOOL bCompilingGlobal;
    348361    int i,RefType;
     
    441454
    442455        pRelativeVar->dwKind=VAR_DIRECTMEM;
    443         if(!GetMemberOffset(ErrorEnabled,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
     456        if(!GetMemberOffset(
     457            isErrorEnabled,
     458            isWriteAccess,
     459            pobj_CompilingClass,
     460            variable,
     461            pType,
     462            pRelativeVar,
     463            &lpIndex,1)) return 0;
    444464        if(plpIndex) *plpIndex=lpIndex;
    445465        return 1;
     
    513533    }
    514534
    515     if(ErrorEnabled) SetError(3,variable,cp);
     535    if(isErrorEnabled) SetError(3,variable,cp);
    516536    pRelativeVar->dwKind=NON_VAR;
    517537    return 0;
     
    547567ok:
    548568
    549     if(bConst && WriteAccess){
     569    if(bConst && isWriteAccess){
    550570        //Const定義の変数に書き込みアクセスをしようとした場合
    551571        SetError(61,VarName,cp);
     
    581601                return 0;
    582602            }
    583 
    584             LONG_PTR lp2;
    585             if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    586             if(plpIndex) *plpIndex=lp2;
    587603        }
    588604        else if(*pType==DEF_PTR_OBJECT){
     
    597613                SetRelativeOffset(pType,lpIndex,pRelativeVar,lpPtrOffset);
    598614                pRelativeVar->dwKind=VAR_DIRECTMEM;
    599 
    600                 LONG_PTR lp2;
    601                 if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    602                 if(plpIndex) *plpIndex=lp2;
    603615            }
    604616            else{
     
    616628                OpBuffer[obp++]=(char)0x8B;
    617629                OpBuffer[obp++]=(char)0x08;
    618 
    619                 LONG_PTR lp2;
    620                 if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    621                 if(plpIndex) *plpIndex=lp2;
    622630            }
    623631        }
     
    641649                OpBuffer[obp++]=(char)0x8B;
    642650                OpBuffer[obp++]=(char)0x08;
    643 
    644                 LONG_PTR lp2;
    645                 if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    646                 if(plpIndex) *plpIndex=lp2;
    647651            }
    648652            else{
     
    657661            return 0;
    658662        }
     663
     664        LONG_PTR lp2;
     665        if(!GetMemberOffset(
     666            isErrorEnabled,
     667            isWriteAccess,
     668            (CClass *)lpIndex,
     669            member,pType,pRelativeVar,&lp2,0)) return 0;
     670        if(plpIndex) *plpIndex=lp2;
     671
    659672        return 1;
    660673    }
  • BasicCompiler32/Opcode.h

    r11 r17  
    172172void GetWithName(char *buffer);
    173173void SetThisPtrToReg(int reg);
    174 BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
     174BOOL GetVarOffset(bool isErrorEnabled,bool isWriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
    175175BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf);
    176176#define DIMFLAG_INITDEBUGVAR            1
  • BasicCompiler64/Compile_ProcOp.cpp

    r11 r17  
    497497            // コンストラクタをコンパイルするとき
    498498            ////////////////////////////////////
     499
     500            //コンストラクタのコンパイル開始を通知
     501            pobj_CompilingClass->NotifyStartConstructorCompile();
    499502
    500503            //スーパークラスかどうかの識別
     
    626629    //////////////////////////////////////////
    627630
    628     if(pobj_CompilingClass){
     631    if( pobj_CompilingClass ){
     632
     633        if( pobj_CompilingClass->IsCompilingConstructor() ){
     634            // コンストラクタをコンパイルしていたとき
     635            // コンストラクタのコンパイルが完了したことを通知
     636
     637            pobj_CompilingClass->NotifyFinishConstructorCompile();
     638        }
     639
    629640        if(psi->name[0]=='~'){
    630641            ////////////////////////////////////
  • BasicCompiler64/Compile_Var.cpp

    r11 r17  
    179179    return 1;
    180180}
    181 BOOL GetMemberOffset(bool ErrorEnabled,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
     181BOOL GetMemberOffset(bool isErrorEnabled, bool isWriteAccess, CClass *pobj_c, char *member, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpNestIndex, BOOL bPrivateAccess){
    182182    int i,offset;
    183183
     
    202202    offset=GetSizeOfClassMember(pobj_c,VarName,&i);
    203203    if(i==pobj_c->iMemberNum){
    204         if(ErrorEnabled) SetError(103,VarName,cp);
     204        if(isErrorEnabled) SetError(103,VarName,cp);
    205205        return 0;
    206206    }
     
    211211        //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    212212        if(pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    213             if(ErrorEnabled) SetError(107,VarName,cp);
     213            if(isErrorEnabled) SetError(107,VarName,cp);
    214214            return 0;
    215215        }
     
    218218        if((bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||
    219219            pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    220             if(ErrorEnabled) SetError(107,VarName,cp);
     220            if(isErrorEnabled) SetError(107,VarName,cp);
    221221            return 0;
    222222        }
    223223        else if(bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED){
    224             if(ErrorEnabled) SetError(108,VarName,cp);
     224            if(isErrorEnabled) SetError(108,VarName,cp);
    225225            return 0;
    226226        }
     227    }
     228
     229    //Const定義の場合は書き込みアクセスを制限する
     230    //※コンストラクタをコンパイル中の場合は例外的に許可する
     231    if( pobj_c->ppobj_Member[i]->IsConst() &&       //定数メンバである
     232        isWriteAccess &&                            //書き込みアクセスを要求されている
     233        pobj_c->IsCompilingConstructor() == false   //コンストラクタ コンパイル中を除く
     234        ){
     235            //Const定義の変数に書き込みアクセスをしようとした場合
     236            SetError(61,VarName,cp);
    227237    }
    228238
     
    239249    else{
    240250        if(lpPtrOffset[0]){
    241             if(ErrorEnabled) SetError(16,member,cp);
     251            if(isErrorEnabled) SetError(16,member,cp);
    242252            return 0;
    243253        }
     
    256266        //配列オフセット
    257267        if(!GetArrayOffset(pobj_c->ppobj_Member[i]->SubScripts,array,*pType,pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex)){
    258             if(ErrorEnabled) SetError(14,member,cp);
     268            if(isErrorEnabled) SetError(14,member,cp);
    259269        }
    260270    }
     
    268278        if(*pType==DEF_OBJECT){
    269279            if(RefType!=DEF_OBJECT){
    270                 if(ErrorEnabled) SetError(104,member,cp);
     280                if(isErrorEnabled) SetError(104,member,cp);
    271281                return 0;
    272282            }
     
    278288                //pObj[n].member
    279289                if(RefType!=DEF_OBJECT){
    280                     if(ErrorEnabled) SetError(104,member,cp);
     290                    if(isErrorEnabled) SetError(104,member,cp);
    281291                    return 0;
    282292                }
     
    291301                //pObj->member
    292302                if(RefType!=DEF_PTR_OBJECT){
    293                     if(ErrorEnabled) SetError(104,member,cp);
     303                    if(isErrorEnabled) SetError(104,member,cp);
    294304                    return 0;
    295305                }
     
    315325                //ppObj[n]->member
    316326                if(RefType!=DEF_PTR_OBJECT){
    317                     if(ErrorEnabled) SetError(104,member,cp);
     327                    if(isErrorEnabled) SetError(104,member,cp);
    318328                    return 0;
    319329                }
     
    329339            }
    330340            else{
    331                 if(ErrorEnabled) SetError(104,member,cp);
     341                if(isErrorEnabled) SetError(104,member,cp);
    332342                return 0;
    333343            }
    334344        }
    335345
    336         if(!GetMemberOffset(ErrorEnabled,
     346        if(!GetMemberOffset(
     347            isErrorEnabled,
     348            isWriteAccess,
    337349            pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,
    338350            NestMember,
     
    371383    SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg);
    372384}
    373 BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
     385BOOL GetVarOffset(bool isErrorEnabled,bool isWriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
    374386    extern BOOL bCompilingGlobal;
    375387    int i,RefType;
     
    465477
    466478        pRelativeVar->dwKind=VAR_DIRECTMEM;
    467         if(!GetMemberOffset(ErrorEnabled,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
     479        if(!GetMemberOffset(
     480            isErrorEnabled,
     481            isWriteAccess,
     482            pobj_CompilingClass,
     483            variable,
     484            pType,
     485            pRelativeVar,
     486            &lpIndex,1)) return 0;
    468487        if(plpIndex) *plpIndex=lpIndex;
    469488        return 1;
     
    536555    }
    537556
    538     if(ErrorEnabled) SetError(3,variable,cp);
     557    if(isErrorEnabled) SetError(3,variable,cp);
    539558    pRelativeVar->dwKind=NON_VAR;
    540559    return 0;
     
    571590ok:
    572591
    573     if(bConst && WriteAccess){
     592    if(bConst && isWriteAccess){
    574593        //Const定義の変数に書き込みアクセスをしようとした場合
    575594        SetError(61,VarName,cp);
     
    605624                return 0;
    606625            }
    607 
    608             LONG_PTR lp2;
    609             if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    610             if(plpIndex) *plpIndex=lp2;
    611626        }
    612627        else if(*pType==DEF_PTR_OBJECT){
     
    621636                SetRelativeOffset(pType,lpIndex,pRelativeVar,lpPtrOffset);
    622637                pRelativeVar->dwKind=VAR_DIRECTMEM;
    623 
    624                 LONG_PTR lp2;
    625                 if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    626                 if(plpIndex) *plpIndex=lp2;
    627638            }
    628639            else{
     
    639650                //mov r11,qword ptr[r12]
    640651                op_mov_RM(sizeof(_int64),REG_R11,REG_R12,0,MOD_BASE);
    641 
    642                 LONG_PTR lp2;
    643                 if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    644                 if(plpIndex) *plpIndex=lp2;
    645652            }
    646653        }
     
    663670                //mov r11,qword ptr[r12]
    664671                op_mov_RM(sizeof(_int64),REG_R11,REG_R12,0,MOD_BASE);
    665 
    666                 LONG_PTR lp2;
    667                 if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    668                 if(plpIndex) *plpIndex=lp2;
    669672            }
    670673            else{
     
    679682            return 0;
    680683        }
     684
     685        LONG_PTR lp2;
     686        if(!GetMemberOffset(
     687            isErrorEnabled,
     688            isWriteAccess,
     689            (CClass *)lpIndex,
     690            member,pType,pRelativeVar,&lp2,0)) return 0;
     691        if(plpIndex) *plpIndex=lp2;
     692
    681693        return 1;
    682694    }
  • BasicCompiler64/Opcode.h

    r15 r17  
    317317void GetWithName(char *buffer);
    318318void SetThisPtrToReg(int reg);
    319 BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
     319BOOL GetVarOffset(bool isErrorEnabled,bool isWriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
    320320BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf);
    321321#define DIMFLAG_INITDEBUGVAR            1
  • BasicCompiler_Common/Class.cpp

    r5 r17  
    1616
    1717
    18 CMember::CMember(CClass *pobj_c,DWORD access,char *buffer,int NowLine){
     18CMember::CMember( CClass *pobj_c, DWORD access, bool isConst, char *buffer, int NowLine ){
    1919    extern int cp;
    2020
     
    4646    dwAccess=access;
    4747
     48    //定数扱いかどうか
     49    this->isConst = isConst;
     50
    4851    //初期データ
    4952    InitBuf=(char *)HeapAlloc(hHeap,0,lstrlen(init_buf)+1);
     
    6467    name=(char *)HeapAlloc(hHeap,0,lstrlen(pobj->name)+1);
    6568    lstrcpy(name,pobj->name);
     69
     70    //定数扱いかどうか
     71    isConst = pobj->isConst;
    6672
    6773    //SubScripts
     
    8187    if(InitBuf) HeapDefaultFree(InitBuf);
    8288    if(ConstractParameter) HeapDefaultFree(ConstractParameter);
     89}
     90
     91bool CMember::IsConst(){
     92    return isConst;
    8393}
    8494
     
    159169    this->name=(char *)HeapAlloc(hHeap,0,lstrlen(name)+1);
    160170    lstrcpy(this->name,name);
     171
     172    isCompilingConstructor = 0;
    161173}
    162174CClass::~CClass(){
     
    202214    }
    203215}
    204 void CClass::AddMember(DWORD dwAccess,char *buffer){
    205     ppobj_Member=(CMember **)HeapReAlloc(hHeap,0,ppobj_Member,(iMemberNum+1)*sizeof(CMember *));
    206     ppobj_Member[iMemberNum]=new CMember(this,dwAccess,buffer);
     216void CClass::AddMember( DWORD dwAccess, bool isConst, char *buffer ){
     217    ppobj_Member = (CMember **)HeapReAlloc( hHeap, 0, ppobj_Member, ( iMemberNum + 1 ) * sizeof(CMember *) );
     218    ppobj_Member[iMemberNum] = new CMember( this, dwAccess, isConst, buffer );
    207219    iMemberNum++;
    208220}
    209 void CClass::AddStaticMember(DWORD dwAccess,char *buffer,int NowLine){
     221void CClass::AddStaticMember( DWORD dwAccess, bool isConst, char *buffer, int NowLine ){
    210222    ppobj_StaticMember=(CMember **)HeapReAlloc(hHeap,0,ppobj_StaticMember,(iStaticMemberNum+1)*sizeof(CMember *));
    211     ppobj_StaticMember[iStaticMemberNum]=new CMember(this,dwAccess,buffer,NowLine);
     223    ppobj_StaticMember[iStaticMemberNum]=new CMember( this, dwAccess, isConst, buffer, NowLine );
    212224    iStaticMemberNum++;
    213225}
     
    380392
    381393    return ppArray_si;
     394}
     395
     396// コンストラクタのコンパイルを開始
     397void CClass::NotifyStartConstructorCompile(){
     398    isCompilingConstructor = true;
     399}
     400
     401//コンストラクタのコンパイルを終了
     402void CClass::NotifyFinishConstructorCompile(){
     403    isCompilingConstructor = false;
     404}
     405
     406//コンストラクタをコンパイル中かどうかを判別
     407bool CClass::IsCompilingConstructor(){
     408    return isCompilingConstructor;
    382409}
    383410
     
    700727
    701728            //インターフェイス名を取得
    702             for(i2=0;;i++,i2++){
    703                 if(IsCommandDelimitation(basbuf[i])){
    704                     temporary[i2]=0;
    705                     break;
    706                 }
    707                 temporary[i2]=basbuf[i];
    708             }
     729            GetIdentifierToken( temporary, basbuf, i );
    709730
    710731            pobj_c=pobj_DBClass->check(temporary);
     
    897918
    898919            //クラス名を取得
    899             for(i2=0;;i++,i2++){
    900                 if(IsCommandDelimitation(basbuf[i])){
    901                     temporary[i2]=0;
    902                     break;
    903                 }
    904                 temporary[i2]=basbuf[i];
    905             }
     920            GetIdentifierToken( temporary, basbuf, i );
    906921
    907922            pobj_c=pobj_DBClass->check(temporary);
     
    10511066                else bStatic=0;
    10521067
     1068                //Const修飾子
     1069                bool isConst = false;
     1070                if( basbuf[i] == 1 && basbuf[i + 1] == ESC_CONST ){
     1071                    isConst = true;
     1072                    i += 2;
     1073                }
     1074
    10531075                if(basbuf[i]==1&&(
    10541076                    basbuf[i+1]==ESC_ABSTRACT||basbuf[i+1]==ESC_VIRTUAL||basbuf[i+1]==ESC_OVERRIDE||
     
    11281150                        //静的メンバを追加
    11291151                        cp=i;   //エラー用
    1130                         pobj_c->AddStaticMember(dwAccess,temporary,i);
     1152                        pobj_c->AddStaticMember( dwAccess, isConst, temporary, i);
    11311153                    }
    11321154                    else{
    11331155                        //メンバを追加
    11341156                        cp=i;   //エラー用
    1135                         pobj_c->AddMember(dwAccess,temporary);
     1157                        pobj_c->AddMember( dwAccess, isConst, temporary );
    11361158
    11371159
  • BasicCompiler_Common/Class.h

    r4 r17  
    1919
    2020class CMember{
     21    bool isConst;
    2122public:
    2223    char *name;
     
    3233
    3334
    34     CMember(CClass *pobj_c,DWORD access,char *buffer,int NowLine=-1);
    35     CMember(CMember *pobj);
     35    CMember( CClass *pobj_c, DWORD access, bool idConst, char *buffer, int NowLine=-1 );
     36    CMember( CMember *pobj );
    3637    CMember();
    3738    ~CMember();
     39
     40    bool IsConst();
    3841
    3942
     
    9194    ~CClass();
    9295
    93     void AddMember(DWORD dwAccess,char *buffer);
    94     void AddStaticMember(DWORD dwAccess,char *buffer,int NowLine);
     96    void AddMember( DWORD dwAccess, bool idConst, char *buffer );
     97    void AddStaticMember( DWORD dwAccess, bool isConst, char *buffer, int NowLine );
    9598    void AddMethod(SUBINFO *psi,DWORD dwAccess,BOOL bAbstract,BOOL bVirtual);
    9699    void AddStaticMethod(SUBINFO *psi,DWORD dwAccess);
     
    112115    //オペレータ関数の取得
    113116    SUBINFO **GetOperatorSubInfo(BYTE idCalc,int &num);
     117
     118
     119    //コンストラクタをコンパイルしているかどうかのチェックフラグ
     120private:
     121    bool isCompilingConstructor;
     122public:
     123    void NotifyStartConstructorCompile();
     124    void NotifyFinishConstructorCompile();
     125    bool IsCompilingConstructor();
    114126
    115127
  • BasicCompiler_Common/Compile.cpp

    r16 r17  
    4848//With情報
    4949WITHINFO WithInfo;
     50
     51
     52///////////////////////////////////////////////////
     53// トークンを取得
     54///////////////////////////////////////////////////
     55void GetIdentifierToken( char *token, const char *source, int &pos ){
     56    for( int i=0; ; i++, pos++ ){
     57        if( ! IsVariableChar( source[pos] ) ){
     58            token[i] = 0;
     59            break;
     60        }
     61        token[i] = source[pos];
     62    }
     63}
    5064
    5165
  • BasicCompiler_Common/common.h

    r16 r17  
    575575
    576576//Compile.cpp
     577void GetIdentifierToken( char *token, const char *source, int &pos );
    577578int JumpStatement(const char *source, int &pos);
    578579void DebugVariable(void);
  • BasicCompiler_Common/error.cpp

    r11 r17  
    142142    if(num==59) sprintf(msg,"マニフェスト ファイル \"%s\" の読み込みに失敗。",KeyWord);
    143143    if(num==60) lstrcpy(msg,"Staticステートメントはグローバル領域では使用できません。");
    144     if(num==61) sprintf(msg,"\"%s\" Const定義の変数には書き込めません。",KeyWord);
     144    if(num==61) sprintf(msg,"\"%s\" は定数です。書き込めません。",KeyWord);
    145145
    146146
Note: See TracChangeset for help on using the changeset viewer.