Changeset 18 in dev for BasicCompiler64


Ignore:
Timestamp:
Dec 24, 2006, 4:46:12 AM (17 years ago)
Author:
dai_9181
Message:

オブジェクト定数に対応。

Location:
BasicCompiler64
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler64/Compile_CallProc.cpp

    r11 r18  
    233233
    234234    BOOL bStatic=0;
    235     CClass *pobj_c;
     235    CClass *pobj_c = NULL;
     236    CMethod *pMethod = NULL;
    236237    if(psi->pobj_ParentClass){
    237238        //クラスのメンバ関数を呼び出す場合はアクセスチェックを行う
     
    264265        }
    265266
    266         DWORD dwAccess;
    267         for(i=0;i<pobj_c->iMethodNum;i++){
    268             if(psi==pobj_c->ppobj_Method[i]->psi) break;
    269         }
    270         if(i==pobj_c->iMethodNum){
    271             for(i=0;i<pobj_c->iStaticMethodNum;i++){
    272                 if(psi==pobj_c->ppobj_StaticMethod[i]->psi) break;
    273             }
    274             dwAccess=pobj_c->ppobj_StaticMethod[i]->dwAccess;
    275 
    276             bStatic=1;
    277         }
    278         else dwAccess=pobj_c->ppobj_Method[i]->dwAccess;
     267
     268        /////////////////////////////////
     269        // メソッド情報を取得
     270        /////////////////////////////////
     271        pMethod = pobj_c->GetMethodInfo( psi );
     272        if( !pMethod ){
     273            //動的メソッドが取得できなかったときは静的メソッドを当たる
     274            pMethod = pobj_c->GetStaticMethodInfo( psi );
     275            if( !pMethod ){
     276                SetError(300,NULL,cp);
     277                return -1;
     278            }
     279        }
    279280
    280281
     
    282283        // アクセスエラーチェック
    283284        //////////////////////////////
     285        DWORD dwAccess = pMethod->dwAccess;
    284286
    285287        if(ObjectName[0]){
     
    408410            else{
    409411                RELATIVE_VAR RelativeVar;
    410                 if(!GetVarOffsetReadOnly(ObjectName,&i2,&RelativeVar,0)) return -1;
     412                if( pMethod->isConst ){
     413                    //Constアクセスが可能なメソッドの場合
     414                    if( !GetVarOffsetReadOnly( ObjectName, &i2, &RelativeVar, 0 ) ) return -1;
     415                }
     416                else{
     417                    //Constアクセスが不可能なメソッドの場合
     418                    if( !GetVarOffsetReadWrite( ObjectName, &i2, &RelativeVar, 0 ) ) return -1;
     419                }
     420
    411421                SetVarPtrToReg(REG_RCX,&RelativeVar);
    412422
  • BasicCompiler64/Compile_ProcOp.cpp

    r17 r18  
    374374    //コンパイル中の関数が属するクラス
    375375    pobj_CompilingClass=psi->pobj_ParentClass;
     376   
     377    //コンパイルスタートをクラス管理クラスに追加
     378    pobj_DBClass->StartCompile( psi );
    376379
    377380    //コンパイル中の関数
     
    614617            }
    615618        }
     619        if(psi->name[0]=='~'){
     620            //デストラクタをコンパイルしたとき
     621
     622            //デストラクタのコンパイル開始を通知
     623            pobj_CompilingClass->NotifyStartDestructorCompile();
     624        }
    616625    }
    617626
     
    633642        if( pobj_CompilingClass->IsCompilingConstructor() ){
    634643            // コンストラクタをコンパイルしていたとき
     644
    635645            // コンストラクタのコンパイルが完了したことを通知
    636 
    637646            pobj_CompilingClass->NotifyFinishConstructorCompile();
    638647        }
     
    642651            //デストラクタをコンパイルしたとき
    643652            ////////////////////////////////////
     653
     654            // デストラクタのコンパイルが完了したことを通知
     655            pobj_CompilingClass->NotifyFinishDestructorCompile();
    644656
    645657            if(pobj_CompilingClass->pobj_InheritsClass){
  • BasicCompiler64/Compile_Var.cpp

    r17 r18  
    471471            }
    472472            if(i==pobj_CompilingClass->iMemberNum) goto NonClassMember;
     473        }
     474
     475        //Const修飾子のメソッド内でメンバ書き込みアクセスが発生したとき
     476        //(コンストラクタ、デストラクタ内を除く)
     477        CMethod *pMethod = pobj_DBClass->GetNowCompilingMethodInfo();
     478        if( isWriteAccess &&
     479            pMethod->isConst &&
     480            pobj_CompilingClass->IsCompilingConstructor() == false &&
     481            pobj_CompilingClass->IsCompilingDestructor() == false
     482            ){
     483                SetError(131, NULL, cp );
    473484        }
    474485
     
    590601ok:
    591602
    592     if(bConst && isWriteAccess){
     603    if( bConst && isWriteAccess ){
    593604        //Const定義の変数に書き込みアクセスをしようとした場合
    594         SetError(61,VarName,cp);
     605        if( *pType == DEF_OBJECT ){
     606            //オブジェクト定数
     607            SetError(130, VarName, cp );
     608        }
     609        else{
     610            //一般のConst変数
     611            SetError(61,VarName,cp);
     612        }
    595613    }
    596614
Note: See TracChangeset for help on using the changeset viewer.