Changeset 18 in dev for BasicCompiler32


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

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

Location:
BasicCompiler32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/Compile_CallProc.cpp

    r11 r18  
    222222
    223223    BOOL bStatic=0;
    224     CClass *pobj_c;
     224    CClass *pobj_c = NULL;
     225    CMethod *pMethod = NULL;
    225226    if(psi->pobj_ParentClass){
    226227        //クラスのメンバ関数を呼び出す場合はアクセスチェックを行う
     
    254255
    255256
    256         DWORD dwAccess;
    257         for(i=0;i<pobj_c->iMethodNum;i++){
    258             if(psi==pobj_c->ppobj_Method[i]->psi) break;
    259         }
    260         if(i==pobj_c->iMethodNum){
    261             for(i=0;i<pobj_c->iStaticMethodNum;i++){
    262                 if(psi==pobj_c->ppobj_StaticMethod[i]->psi) break;
    263             }
    264             dwAccess=pobj_c->ppobj_StaticMethod[i]->dwAccess;
    265 
    266             bStatic=1;
    267         }
    268         else dwAccess=pobj_c->ppobj_Method[i]->dwAccess;
     257        /////////////////////////////////
     258        // メソッド情報を取得
     259        /////////////////////////////////
     260        pMethod = pobj_c->GetMethodInfo( psi );
     261        if( !pMethod ){
     262            //動的メソッドが取得できなかったときは静的メソッドを当たる
     263            pMethod = pobj_c->GetStaticMethodInfo( psi );
     264            if( !pMethod ){
     265                SetError(300,NULL,cp);
     266                return -1;
     267            }
     268        }
    269269
    270270
     
    272272        // アクセスエラーチェック
    273273        //////////////////////////////
     274        DWORD dwAccess = pMethod->dwAccess;
    274275
    275276        if(ObjectName[0]){
     
    380381        if(ObjectName[0]){
    381382            if(lstrcmpi(ObjectName,"Super")==0) goto InClassMember;
    382 
    383             RELATIVE_VAR RelativeVar;
    384             if(!GetVarOffsetReadOnly(ObjectName,&i2,&RelativeVar,0)) return -1;
    385             SetVarPtrToEax(&RelativeVar);
    386 
    387             //参照タイプが整合しているかをチェック
    388             if(i2!=RefType) SetError(104,ObjectName,cp);
    389 
    390             if(i2==DEF_PTR_OBJECT){
    391                 //mov eax,dword ptr[eax]
     383            else{
     384                RELATIVE_VAR RelativeVar;
     385                if( pMethod->isConst ){
     386                    //Constアクセスが可能なメソッドの場合
     387                    if( !GetVarOffsetReadOnly( ObjectName, &i2, &RelativeVar, 0 ) ) return -1;
     388                }
     389                else{
     390                    //Constアクセスが不可能なメソッドの場合
     391                    if( !GetVarOffsetReadWrite( ObjectName, &i2, &RelativeVar, 0 ) ) return -1;
     392                }
     393
     394                SetVarPtrToEax(&RelativeVar);
     395
     396                //参照タイプが整合しているかをチェック
     397                if(i2!=RefType) SetError(104,ObjectName,cp);
     398
     399                if(i2==DEF_PTR_OBJECT){
     400                    //mov eax,dword ptr[eax]
     401                    OpBuffer[obp++]=(char)0x8B;
     402                    OpBuffer[obp++]=(char)0x00;
     403                }
     404
     405                //mov ecx,eax
    392406                OpBuffer[obp++]=(char)0x8B;
    393                 OpBuffer[obp++]=(char)0x00;
    394             }
    395 
    396             //mov ecx,eax
    397             OpBuffer[obp++]=(char)0x8B;
    398             OpBuffer[obp++]=(char)0xC8;
     407                OpBuffer[obp++]=(char)0xC8;
     408            }
    399409        }
    400410        else{
  • BasicCompiler32/Compile_ProcOp.cpp

    r17 r18  
    335335    //コンパイル中の関数が属するクラス
    336336    pobj_CompilingClass=psi->pobj_ParentClass;
     337
     338    //コンパイルスタートをクラス管理クラスに追加
     339    pobj_DBClass->StartCompile( psi );
    337340
    338341    //コンパイル中の関数
     
    569572            }
    570573        }
     574        else if(psi->name[0]=='~'){
     575            //デストラクタをコンパイルしたとき
     576
     577            //デストラクタのコンパイル開始を通知
     578            pobj_CompilingClass->NotifyStartDestructorCompile();
     579        }
    571580    }
    572581
     
    584593        if( pobj_CompilingClass->IsCompilingConstructor() ){
    585594            // コンストラクタをコンパイルしていたとき
     595
    586596            // コンストラクタのコンパイルが完了したことを通知
    587 
    588597            pobj_CompilingClass->NotifyFinishConstructorCompile();
    589598        }
    590 
    591         if(psi->name[0]=='~'){
     599        else if(psi->name[0]=='~'){
    592600            ////////////////////////////////////
    593601            //デストラクタをコンパイルしたとき
    594602            ////////////////////////////////////
     603
     604            // デストラクタのコンパイルが完了したことを通知
     605            pobj_CompilingClass->NotifyFinishDestructorCompile();
    595606
    596607            if(pobj_CompilingClass->pobj_InheritsClass){
  • BasicCompiler32/Compile_Var.cpp

    r17 r18  
    445445            }
    446446            if(i==pobj_CompilingClass->iMemberNum) goto NonClassMember;
     447        }
     448
     449        //Const修飾子のメソッド内でメンバ書き込みアクセスが発生したとき
     450        //(コンストラクタ、デストラクタ内を除く)
     451        CMethod *pMethod = pobj_DBClass->GetNowCompilingMethodInfo();
     452        if( isWriteAccess &&
     453            pMethod->isConst &&
     454            pobj_CompilingClass->IsCompilingConstructor() == false &&
     455            pobj_CompilingClass->IsCompilingDestructor() == false
     456            ){
     457                SetError(131, NULL, cp );
    447458        }
    448459
     
    567578ok:
    568579
    569     if(bConst && isWriteAccess){
     580    if( bConst && isWriteAccess ){
    570581        //Const定義の変数に書き込みアクセスをしようとした場合
    571         SetError(61,VarName,cp);
     582        if( *pType == DEF_OBJECT ){
     583            //オブジェクト定数
     584            SetError(130, VarName, cp );
     585        }
     586        else{
     587            //一般のConst変数
     588            SetError(61,VarName,cp);
     589        }
    572590    }
    573591
Note: See TracChangeset for help on using the changeset viewer.