source: dev/trunk/abdev/BasicCompiler_Common/src/Variable.cpp@ 206

Last change on this file since 206 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

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