Changeset 103 in dev for BasicCompiler_Common/Variable.h


Ignore:
Timestamp:
May 2, 2007, 4:08:58 AM (17 years ago)
Author:
dai_9181
Message:

名前空間機能をグローバル変数、定数と列挙型に適用。
一部、クラスの静的メンバと名前空間の相性が悪いコードが潜んでいるため、要改修

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler_Common/Variable.h

    r100 r103  
    55class Variable : public Type
    66{
     7    const NamespaceScopes namespaceScopes;
    78    string name;
    89    bool isConst;
     
    1415
    1516public:
    16     Variable( const string &name, const Type &type, bool isConst = false, bool isRef = false ):
    17         Type( type ),
    18         name( name ),
    19         isConst( isConst ),
    20         isRef( isRef ),
    21         isArray( false ),
    22         isParameter( false)
     17    Variable( const string &name, const Type &type, bool isConst = false, bool isRef = false )
     18        : Type( type )
     19        , name( name )
     20        , isConst( isConst )
     21        , isRef( isRef )
     22        , isArray( false )
     23        , isParameter( false)
    2324    {
    2425        subScripts[0] = -1;
    2526    }
    26     Variable( const Variable &var ):
    27         Type( var ),
    28         name( var.name ),
    29         isConst( var.isConst ),
    30         isRef( var.isRef ),
    31         isArray( false ),
    32         isParameter( false )
     27    Variable( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, bool isConst = false, bool isRef = false )
     28        : namespaceScopes( namespaceScopes )
     29        , Type( type )
     30        , name( name )
     31        , isConst( isConst )
     32        , isRef( isRef )
     33        , isArray( false )
     34        , isParameter( false)
     35    {
     36        subScripts[0] = -1;
     37    }
     38    Variable( const Variable &var )
     39        : Type( var )
     40        , name( var.name )
     41        , isConst( var.isConst )
     42        , isRef( var.isRef )
     43        , isArray( false )
     44        , isParameter( false )
    3345    {
    3446        subScripts[0] = -1;
     
    4860        return name;
    4961    }
     62
     63    bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
     64    bool IsEqualSymbol( const string &name ) const;
    5065
    5166    void ConstOff(){
     
    150165                && var.ScopeLevel == obj_LexScopes.GetNowLevel()    //現在のスコープと同一レベル
    151166                ){
    152                     if( var.GetName() == varName ){
     167                    if( var.IsEqualSymbol( varName ) ){
    153168                        return true;
    154169                    }
     
    166181                && var.ScopeLevel <= obj_LexScopes.GetNowLevel()    //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮)
    167182                ){
    168                     if( var.GetName() == varName ){
     183                    if( var.IsEqualSymbol( varName ) ){
    169184                        return &var;
    170185                    }
     
    179194        for( int i=0; i<max; i++ ){
    180195            Variable *pVar = (*this)[i];
    181             if( pVar->GetName() == varName ){
     196            if( pVar->IsEqualSymbol( varName ) ){
    182197                return pVar;
    183198            }
Note: See TracChangeset for help on using the changeset viewer.