Changeset 114 in dev


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

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

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/Compile_Func.cpp

    r111 r114  
    176176        tempParm=temp2;
    177177
    178         extern CClass *pobj_StringClass;
     178        extern const CClass *pobj_StringClass;
    179179        type.SetType( DEF_OBJECT, pobj_StringClass );
    180180    }
     
    250250        ///////////////////////////////
    251251
    252         CClass *pobj_c;
     252        const CClass *pobj_c;
    253253
    254254        char ObjectName[VN_SIZE];
  • BasicCompiler32/NumOpe.cpp

    r106 r114  
    7777    SetStringQuotes( parameter );
    7878
    79     extern CClass *pobj_StringClass;
     79    extern const CClass *pobj_StringClass;
    8080    Operator_New( *pobj_StringClass, "", parameter, Type( DEF_OBJECT, *pobj_StringClass ) );
    8181
     
    719719                        NewStringObject(term);
    720720
    721                         extern CClass *pobj_StringClass;
     721                        extern const CClass *pobj_StringClass;
    722722                        type_stack[sp]=DEF_OBJECT;
    723723                        index_stack[sp]=(LONG_PTR)pobj_StringClass;
  • 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}
  • BasicCompiler_Common/Class.h

    r108 r114  
    4848    bool isStatic;
    4949
    50     CClass *pobj_InheritsClass;
     50    const CClass *pobj_InheritsClass;
    5151
    5252    CMethod(CMethod *pobj);
     
    8787    ClassType classType;
    8888
    89     bool isUsing;
     89    mutable bool isUsing;
    9090
    9191public:
     
    9494
    9595    //継承クラスへのポインタ
    96     CClass *pobj_InheritsClass;
     96    const CClass *pobj_InheritsClass;
    9797
    9898    //メンバ情報
     
    130130
    131131    bool IsUsing() const;
    132     void Using();
     132    void Using() const;
    133133
    134134    bool IsClass() const;
     
    139139
    140140    //継承させる
    141     bool Inherits( CClass &inheritsClass, int nowLine );
    142     bool InheritsInterface( CClass &inheritsClass, int nowLine );
     141    bool Inherits( const CClass &inheritsClass, int nowLine );
     142    bool InheritsInterface( const CClass &inheritsClass, int nowLine );
    143143
    144144    //メンバ、メソッドの追加
     
    192192    //vtbl
    193193private:
    194     long vtbl_offset;
     194    mutable long vtbl_offset;
    195195public:
    196196    int GetFuncNumInVtbl( const UserProc *pUserProc ) const;
    197     LONG_PTR GetVtblGlobalOffset(void);
     197    LONG_PTR GetVtblGlobalOffset(void) const;
    198198    void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
    199199    bool IsAbstract() const;
     
    202202    //コンストラクタをコンパイルしているかどうかのチェックフラグ
    203203private:
    204     bool isCompilingConstructor;
    205 public:
    206     void NotifyStartConstructorCompile();
    207     void NotifyFinishConstructorCompile();
     204    mutable bool isCompilingConstructor;
     205public:
     206    void NotifyStartConstructorCompile() const;
     207    void NotifyFinishConstructorCompile() const;
    208208    bool IsCompilingConstructor() const;
    209209
    210210    //デストラクタをコンパイルしているかどうかのチェックフラグ
    211211private:
    212     bool isCompilingDestructor;
    213 public:
    214     void NotifyStartDestructorCompile();
    215     void NotifyFinishDestructorCompile();
     212    mutable bool isCompilingDestructor;
     213public:
     214    void NotifyStartDestructorCompile() const;
     215    void NotifyFinishDestructorCompile() const;
    216216    bool IsCompilingDestructor() const;
    217217
     
    252252    ~CDBClass();
    253253
    254     CClass *Find( const string &fullName ) const;
    255     CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;
     254    const CClass *Find( const string &fullName ) const;
     255    const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;
    256256
    257257    CClass *AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
     
    283283    /////////////////////////////
    284284private:
    285     CClass *pCompilingClass;
     285    const CClass *pCompilingClass;
    286286    CMethod *pCompilingMethod;
    287287public:
     
    290290
    291291    //現在コンパイル中のメソッド情報を取得
    292     CClass *GetNowCompilingClass();
     292    const CClass *GetNowCompilingClass() const;
    293293    CMethod *GetNowCompilingMethodInfo();
    294294
     
    311311
    312312extern CDBClass *pobj_DBClass;
    313 extern CClass *pobj_CompilingClass;
     313extern const CClass *pobj_CompilingClass;
  • BasicCompiler_Common/DebugMiddleFile.cpp

    r113 r114  
    428428    char temp2[MAX_PATH],*temp5;
    429429
    430     extern CClass *pobj_CompilingClass;
    431     pobj_CompilingClass=0;
     430    pobj_CompilingClass = NULL;
    432431
    433432    i2=0;
     
    585584        i2+=lstrlen(buffer+i2)+1;
    586585
    587         CClass *pClass = NULL;
    588         if(szParentClassName[0])
     586        const CClass *pClass = NULL;
     587        if(szParentClassName[0]){
    589588            pClass=pobj_DBClass->Find(szParentClassName);
     589        }
    590590
    591591        //ID
     
    691691        i2+=lstrlen(buffer+i2)+1;
    692692
    693         pobj_c=pobj_DBClass->Find(szClassName);
     693        pobj_c =  const_cast<CClass *>( pobj_DBClass->Find(szClassName) );
    694694
    695695        //仮想関数の数
     
    741741            i2+=lstrlen(buffer+i2)+1;
    742742
    743             CClass *pobj_InheritsClass = NULL;
     743            const CClass *pobj_InheritsClass = NULL;
    744744            if(szInherits[0]){
    745745                pobj_InheritsClass=pobj_DBClass->Find(szInherits);
     
    749749            i2+=lstrlen(buffer+i2)+1;
    750750
    751             CClass *pobj_temp_c;
     751            const CClass *pobj_temp_c;
    752752            pobj_temp_c=pobj_InheritsClass;
    753753            if(pobj_temp_c==0) pobj_temp_c=pobj_c;
  • BasicCompiler_Common/NumOpe_GetType.cpp

    r103 r114  
    634634                    if( baseType.IsObject() || baseType.IsNull() ){
    635635                        //要求タイプがオブジェクト、または未定のとき
    636                         extern CClass *pobj_StringClass;
     636                        extern const CClass *pobj_StringClass;
    637637                        type_stack[sp]=DEF_OBJECT;
    638638                        index_stack[sp]=(LONG_PTR)pobj_StringClass;
     
    658658                    // 何らかの識別子
    659659
    660                         if( (string)term=="ParentArea2.xxxxxx"){
     660                        if( strstr(term,"T.B")){
    661661                            int test=0;
    662662                        }
  • BasicCompiler_Common/Procedure.h

    r113 r114  
    106106
    107107    // 親クラスと対応するメソッド
    108     CClass *pParentClass;
     108    const CClass *pParentClass;
    109109    CMethod *pMethod;
    110110
     
    158158    }
    159159
    160     void SetParentClass( CClass *pParentClass ){
     160    void SetParentClass( const CClass *pParentClass ){
    161161        this->pParentClass = pParentClass;
    162162    }
    163     CClass *GetParentClassPtr()
     163    const CClass *GetParentClassPtr()
    164164    {
    165165        return pParentClass;
  • BasicCompiler_Common/Type.cpp

    r102 r114  
    9696
    9797    //クラス
    98     CClass *pobj_c = pobj_DBClass->Find( typeName.c_str() );
     98    const CClass *pobj_c = pobj_DBClass->Find( typeName.c_str() );
    9999    if(pobj_c){
    100100        type.pClass = pobj_c;
     
    507507
    508508Type Type::String(){
    509     extern CClass *pobj_StringClass;
     509    extern const CClass *pobj_StringClass;
    510510    if( pobj_StringClass == NULL ){
    511511        SetError();
  • BasicCompiler_Common/Type.h

    r97 r114  
    77    union{
    88        LONG_PTR index;
    9         CClass *pClass;
     9        const CClass *pClass;
    1010    };
    1111
     
    5959        SetIndex( index );
    6060    }
    61     void SetType( int basicType, CClass *pClass ){
     61    void SetType( int basicType, const CClass *pClass ){
    6262        SetBasicType( basicType );
    6363        this->pClass = pClass;
  • BasicCompiler_Common/TypeDef.cpp

    r113 r114  
    5757    this->push_back( typeDef );
    5858}
    59 int TypeDefCollection::GetIndex( const string &typeName ) const{
     59int TypeDefCollection::GetIndex( const NamespaceScopes &namespaceScopes, const string &name ) const{
    6060    int max = (int)(*this).size();
    6161    for( int i=0; i<max; i++ ){
    62         if( (*this)[i].IsEqualSymbol( typeName ) ){
     62        if( (*this)[i].IsEqualSymbol( namespaceScopes, name ) ){
    6363            return i;
    6464        }
    6565    }
    6666    return -1;
     67}
     68int TypeDefCollection::GetIndex( const string &fullName ) const{
     69    char AreaName[VN_SIZE] = "";        //オブジェクト変数
     70    char NestName[VN_SIZE] = "";        //入れ子メンバ
     71    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
     72
     73    return GetIndex( NamespaceScopes( AreaName ), NestName );
    6774}
    6875
  • BasicCompiler_Common/TypeDef.h

    r113 r114  
    4646
    4747    void Add( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName );
    48     int GetIndex( const string &typeName ) const;
     48    int GetIndex( const NamespaceScopes &namespaceScopes, const string &name ) const;
     49    int GetIndex( const string &fullName ) const;
    4950
    5051private:
  • BasicCompiler_Common/VarList.cpp

    r100 r114  
    726726
    727727        if(pUserProc){
    728             pobj_CompilingClass=pUserProc->GetParentClassPtr();
     728            pobj_CompilingClass = pUserProc->GetParentClassPtr();
    729729            UserProc::CompileStartForUserProc( pUserProc );
    730730        }
  • BasicCompiler_Common/VariableOpe.cpp

    r106 r114  
    235235
    236236Type GetStringTypeInfo(){
    237     extern CClass *pobj_StringClass;
     237    extern const CClass *pobj_StringClass;
    238238    Type type( DEF_OBJECT, *pobj_StringClass );
    239239    return type;
     
    732732        }
    733733
     734        // TODO: TypeDefされたクラスの静的メンバに未対応
     735
    734736        char temp2[VN_SIZE];
    735737        sprintf(temp2,"%s.%s",VarName,temporary);
  • BasicCompiler_Common/common.h

    r112 r114  
    4747
    4848#ifdef _AMD64_
    49 #define VER_INFO        "(x64) β rev.234"
     49#define VER_INFO        "(x64) β rev.243"
    5050#else
    51 #define VER_INFO        "β rev.234"
     51#define VER_INFO        "β rev.243"
    5252#endif
    5353
  • BasicCompiler_Common/error.cpp

    r113 r114  
    465465            //双方がオブジェクトポインタ型の場合
    466466            if(lpVarIndex!=lpCalcIndex){
    467                 CClass *pobj_tempClass;
     467                const CClass *pobj_tempClass;
    468468                pobj_tempClass=(CClass *)lpCalcIndex;
    469469                while(pobj_tempClass&&(!IS_LITERAL((LONG_PTR)pobj_tempClass))){
  • BasicCompiler_Common/hash.cpp

    r113 r114  
    187187
    188188UserProc *GetClassMethod( const char *className, const char *methodName ){
    189     CClass *pClass = pobj_DBClass->Find( className );
     189    const CClass *pClass = pobj_DBClass->Find( className );
    190190    if( pClass ){
    191191        vector<UserProc *> userProcs;
Note: See TracChangeset for help on using the changeset viewer.