source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/NamespaceSupporter.cpp@ 670

Last change on this file since 670 was 670, checked in by dai_9181, 16 years ago

Importsが正常に解釈されない不具合を修正

File size: 1.9 KB
Line 
1#include "stdafx.h"
2
3using namespace ActiveBasic::Common::Lexical;
4
5bool NamespaceSupporter::ImportsNamespace( const NamespaceScopes &namespaceScopes )
6{
7 _ASSERT( allNamespaceScopesCollection );
8 if( !allNamespaceScopesCollection->IsExist( namespaceScopes ) ){
9 return false;
10 }
11
12 this->importedNamespaces.push_back( namespaceScopes );
13
14 return true;
15}
16
17bool NamespaceSupporter::ImportsNamespace( const std::string &namespaceStr )
18{
19 NamespaceScopes namespaceScopes( namespaceStr );
20
21 return ImportsNamespace( namespaceScopes );
22}
23
24bool NamespaceSupporter::IsCoverd( const NamespaceScopes &base, const NamespaceScopes &entry ) const
25{
26 // まずはそのままでマッチングを試みる
27 if( base.IsEqual( entry ) )
28 {
29 return true;
30 }
31
32 // 現在の名前空間とのマッチングを試みる
33 NamespaceScopes tempCurrent = this->livingNamespaceScopes;
34 while( !tempCurrent.empty() )
35 {
36 if( base.IsEqual( tempCurrent + entry ) )
37 {
38 return true;
39 }
40
41 tempCurrent.pop_back();
42 }
43
44 // Importsされている名前空間とのマッチングを試みる
45 BOOST_FOREACH( const NamespaceScopes &importedNamespaceScopes, GetImportedNamespaces() )
46 {
47 if( base.IsEqual( importedNamespaceScopes + entry ) )
48 {
49 return true;
50 }
51 }
52
53 return false;
54}
55
56bool NamespaceSupporter::IsSameAreaNamespace( const NamespaceScopes &baseNamespaceScopes, const NamespaceScopes &entryNamespaceScopes ) const
57{
58 if( entryNamespaceScopes.size() )
59 {
60 if( IsCoverd( baseNamespaceScopes, entryNamespaceScopes ) )
61 {
62 // 包括しているときは同一と見なす
63 return true;
64 }
65 }
66 else{
67 if( baseNamespaceScopes.size() )
68 {
69 // 名前空間の判断が必要なとき
70 if( this->importedNamespaces.IsImported( baseNamespaceScopes )
71 || IsLiving( baseNamespaceScopes ) )
72 {
73 // Using指定があるとき
74 // または
75 // 指定された名前空間が現在の名前空間スコープと同一のとき
76 return true;
77 }
78 }
79 else{
80 return true;
81 }
82 }
83
84 return false;
85}
Note: See TracBrowser for help on using the repository browser.