Changeset 114 in dev for BasicCompiler_Common/Class.cpp


Ignore:
Timestamp:
May 10, 2007, 8:52:40 PM (17 years ago)
Author:
dai_9181
Message:

CClassクラスのインスタンスを全面的にconstにした。
TypeDefされたクラスの静的メソッドを呼び出せるようにした。(静的メンバへの対応はまだ)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler_Common/Class.cpp

    r108 r114  
    99CDBClass *pobj_DBClass;
    1010
    11 CClass *pobj_CompilingClass;
    12 CClass *pobj_StringClass;
     11const CClass *pobj_CompilingClass;
     12const CClass *pobj_StringClass;
    1313
    1414CMember *pCompilingMethod;
     
    224224    return isUsing;
    225225}
    226 void CClass::Using(){
     226void CClass::Using() const
     227{
    227228    isUsing = true;
    228229}
     
    249250}
    250251
    251 bool CClass::Inherits( CClass &inheritsClass, int nowLine ){
     252bool CClass::Inherits( const CClass &inheritsClass, int nowLine ){
    252253
    253254    //ループ継承でないかをチェック
     
    309310    return true;
    310311}
    311 bool CClass::InheritsInterface( CClass &inheritsInterface, int nowLine ){
     312bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){
    312313
    313314    //ループ継承でないかをチェック
     
    615616    return n;
    616617}
    617 LONG_PTR CClass::GetVtblGlobalOffset(void){
     618LONG_PTR CClass::GetVtblGlobalOffset(void) const
     619{
    618620
    619621    //既に存在する場合はそれを返す
     
    688690
    689691// コンストラクタのコンパイルを開始
    690 void CClass::NotifyStartConstructorCompile(){
     692void CClass::NotifyStartConstructorCompile() const
     693{
    691694    isCompilingConstructor = true;
    692695}
    693696
    694697//コンストラクタのコンパイルを終了
    695 void CClass::NotifyFinishConstructorCompile(){
     698void CClass::NotifyFinishConstructorCompile() const
     699{
    696700    isCompilingConstructor = false;
    697701}
     
    704708
    705709//デストラクタのコンパイルを開始
    706 void CClass::NotifyStartDestructorCompile(){
     710void CClass::NotifyStartDestructorCompile() const{
    707711    isCompilingDestructor = true;
    708712}
    709713
    710714//デストラクタのコンパイルを終了
    711 void CClass::NotifyFinishDestructorCompile(){
     715void CClass::NotifyFinishDestructorCompile() const{
    712716    isCompilingDestructor = false;
    713717}
     
    810814}
    811815
    812 CClass *CDBClass::Find( const string &fullName ) const
    813 {
    814     char AreaName[VN_SIZE] = "";        //オブジェクト変数
    815     char NestName[VN_SIZE] = "";        //入れ子メンバ
    816     bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
    817 
    818     int key;
    819     key=hash(NestName);
    820 
    821     if(pobj_ClassHash[key]){
    822         CClass *pobj_c;
    823         pobj_c=pobj_ClassHash[key];
    824         while(1){
    825             if( pobj_c->IsEqualSymbol( fullName ) ){
    826                 //名前空間とクラス名が一致した
    827                 return pobj_c;
    828             }
    829 
    830             if(pobj_c->pobj_NextClass==0) break;
    831             pobj_c=pobj_c->pobj_NextClass;
    832         }
    833     }
    834     return NULL;
    835 }
    836 CClass *CDBClass::Find( const NamespaceScopes &namespaceScopes, const string &name ) const
     816const CClass *CDBClass::Find( const NamespaceScopes &namespaceScopes, const string &name ) const
    837817{
    838818    int key;
     
    852832        }
    853833    }
     834
     835    // TypeDefも見る
     836    int index = Smoothie::Meta::typeDefs.GetIndex( namespaceScopes, name );
     837    if( index != -1 ){
     838        Type type = Smoothie::Meta::typeDefs[index].GetBaseType();
     839        if( type.IsObject() ){
     840            return &type.GetClass();
     841        }
     842    }
     843
    854844    return NULL;
     845}
     846const CClass *CDBClass::Find( const string &fullName ) const
     847{
     848    char AreaName[VN_SIZE] = "";        //オブジェクト変数
     849    char NestName[VN_SIZE] = "";        //入れ子メンバ
     850    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
     851
     852    return Find( NamespaceScopes( AreaName ), NestName );
    855853}
    856854
     
    12131211            GetIdentifierToken( temporary, basbuf, i );
    12141212
    1215             CClass *pobj_c=pobj_DBClass->Find(namespaceScopes, temporary);
     1213            CClass *pobj_c = const_cast<CClass *>( pobj_DBClass->Find(namespaceScopes, temporary) );
    12161214            if(!pobj_c) continue;
    12171215
     
    12511249
    12521250                //継承元クラスを取得
    1253                 CClass *pInheritsClass = Find(temporary);
     1251                const CClass *pInheritsClass = Find(temporary);
    12541252                if( !pInheritsClass ){
    12551253                    SetError(106,temporary,i);
     
    13591357            GetIdentifierToken( temporary, basbuf, i );
    13601358
    1361             CClass *pobj_c=pobj_DBClass->Find(namespaceScopes, temporary);
     1359            CClass *pobj_c =  const_cast<CClass *>( pobj_DBClass->Find(namespaceScopes, temporary) );
    13621360            if(!pobj_c) continue;
    13631361
     
    14161414
    14171415                //継承元クラスを取得
    1418                 CClass *pInheritsClass = Find(temporary);
     1416                const CClass *pInheritsClass = Find(temporary);
    14191417                if( !pInheritsClass ){
    14201418                    SetError(106,temporary,i);
     
    14241422                if( pInheritsClass->IsInterface() ){
    14251423                    // クラスを継承していないとき
    1426                     CClass *pObjectClass = Find("Object");
     1424                    const CClass *pObjectClass = Find("Object");
    14271425                    if( !pObjectClass ){
    14281426                        SetError(106,"Object",i);
     
    18061804    }
    18071805}
    1808 CClass *CDBClass::GetNowCompilingClass(){
     1806const CClass *CDBClass::GetNowCompilingClass() const
     1807{
    18091808    return pCompilingClass;
    18101809}
Note: See TracChangeset for help on using the changeset viewer.