source: dev/trunk/jenga/src/smoothie/Variable.cpp@ 192

Last change on this file since 192 was 192, checked in by dai_9181, 17 years ago
File size: 1.2 KB
Line 
1#include <jenga/include/smoothie/Smoothie.h>
2#include <jenga/include/smoothie/Class.h>
3
4
5bool Variables::DuplicateCheck( const Symbol &symbol ) const
6{
7 //レキシカルスコープを考慮して重複判定
8 for( int i=(int)this->size()-1; i>=0 ; i-- ){
9 Variable &var = *(*this)[i];
10 if( var.bLiving //現在のスコープで有効なもの
11 && var.ScopeLevel == Smoothie::Temp::pLexicalScopes->GetNowLevel() //現在のスコープと同一レベル
12 ){
13 if( var.IsEqualSymbol( symbol ) ){
14 return true;
15 }
16 }
17 }
18 return false;
19}
20
21const Variable *Variables::BackSearch( const Symbol &symbol ) const
22{
23 //レキシカルスコープを考慮してバックサーチ
24 for( int i=(int)this->size()-1; i>=0 ; i-- ){
25 Variable &var = *(*this)[i];
26 if( var.bLiving //現在のスコープで有効なもの
27 && var.ScopeLevel <= Smoothie::Temp::pLexicalScopes->GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮)
28 ){
29 if( var.IsEqualSymbol( symbol ) ){
30 return &var;
31 }
32 }
33 }
34 return NULL;
35}
36
37const Variable *Variables::Find( const Symbol &symbol )const
38{
39 int max = (int)this->size();
40 for( int i=0; i<max; i++ ){
41 Variable *pVar = (*this)[i];
42 if( pVar->IsEqualSymbol( symbol ) ){
43 return pVar;
44 }
45 }
46 return NULL;
47}
Note: See TracBrowser for help on using the repository browser.