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

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