Ignore:
Timestamp:
May 6, 2008, 8:31:52 PM (16 years ago)
Author:
dai_9181
Message:

Variables::DuplicateCheck、Variables::BackSearchメソッドにnowScopeLevelパラメータを追加した。

Location:
trunk/ab5.0/abdev/BasicCompiler_Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/VariableOpe.cpp

    r564 r570  
    565565        /////////////////
    566566
    567         pVar = compiler.GetCompilingUserProc().GetLocalVars().BackSearch( LexicalAnalyzer::FullNameToSymbol( VarName ) );
     567        pVar = compiler.GetCompilingUserProc().GetLocalVars().BackSearch(
     568            LexicalAnalyzer::FullNameToSymbol( VarName ),
     569            compiler.codeGenerator.lexicalScopes.GetNowLevel()
     570        );
    568571        if( pVar ){
    569572            goto ok;
     
    669672    ////////////////////
    670673
    671     pVar = compiler.GetObjectModule().meta.GetGlobalVars().BackSearch( LexicalAnalyzer::FullNameToSymbol( VarName ) );
     674    pVar = compiler.GetObjectModule().meta.GetGlobalVars().BackSearch(
     675        LexicalAnalyzer::FullNameToSymbol( VarName ),
     676        compiler.codeGenerator.lexicalScopes.GetNowLevel()
     677    );
    672678    if( pVar ){
    673679        goto ok;
     
    943949    /////////////////////////
    944950
    945     if( compiler.GetObjectModule().meta.GetGlobalVars().DuplicateCheck( LexicalAnalyzer::FullNameToSymbol( name ) ) ){
     951    if( compiler.GetObjectModule().meta.GetGlobalVars().DuplicateCheck( LexicalAnalyzer::FullNameToSymbol( name ), compiler.codeGenerator.lexicalScopes.GetNowLevel() ) ){
    946952        //2重定義のエラー
    947953        compiler.errorMessenger.Output(15,name,cp);
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Variable.h

    r529 r570  
    222222    }
    223223
    224     bool DuplicateCheck( const Symbol &symbol ) const;
    225 
    226     const Variable *BackSearch( const Symbol &symbol ) const;
     224    bool DuplicateCheck( const Symbol &symbol, int nowScopeLevel ) const;
     225
     226    const Variable *BackSearch( const Symbol &symbol, int nowScopeLevel ) const;
    227227    const Variable *Find( const Symbol &symbol )const;
    228228};
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Variable.cpp

    r523 r570  
    4343
    4444
    45 bool Variables::DuplicateCheck( const Symbol &symbol ) const
     45bool Variables::DuplicateCheck( const Symbol &symbol, int nowScopeLevel ) const
    4646{
    4747    //レキシカルスコープを考慮して重複判定
    4848    for( int i=(int)this->size()-1; i>=0 ; i-- ){
    4949        const Variable *pVar = (*this)[i];
    50         if( pVar->isLiving                                          //現在のスコープで有効なもの
    51             && pVar->GetScopeLevel() == compiler.codeGenerator.lexicalScopes.GetNowLevel()  //現在のスコープと同一レベル
     50        if( pVar->isLiving                                  //現在のスコープで有効なもの
     51            && pVar->GetScopeLevel() == nowScopeLevel       //現在のスコープと同一レベル
    5252            )
    5353        {
     
    6060}
    6161
    62 const Variable *Variables::BackSearch( const Symbol &symbol ) const
     62const Variable *Variables::BackSearch( const Symbol &symbol, int nowScopeLevel ) const
    6363{
    6464    //レキシカルスコープを考慮してバックサーチ
    6565    for( int i=(int)this->size()-1; i>=0 ; i-- ){
    6666        const Variable *pVar = (*this)[i];
    67         if( pVar->isLiving                                          //現在のスコープで有効なもの
    68             && pVar->GetScopeLevel() <= compiler.codeGenerator.lexicalScopes.GetNowLevel()  //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮)
     67        if( pVar->isLiving                                  //現在のスコープで有効なもの
     68            && pVar->GetScopeLevel() <= nowScopeLevel       //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮)
    6969            ){
    7070                if( pVar->IsEqualSymbol( symbol ) ){
Note: See TracChangeset for help on using the changeset viewer.