1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | using namespace ActiveBasic::Common::Lexical;
|
---|
4 |
|
---|
5 | bool 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 |
|
---|
17 | bool NamespaceSupporter::ImportsNamespace( const std::string &namespaceStr )
|
---|
18 | {
|
---|
19 | NamespaceScopes namespaceScopes( namespaceStr );
|
---|
20 |
|
---|
21 | return ImportsNamespace( namespaceScopes );
|
---|
22 | }
|
---|
23 |
|
---|
24 | bool NamespaceSupporter::IsCoverd( const NamespaceScopes &base, const NamespaceScopes &entry ) const
|
---|
25 | {
|
---|
26 | // まずはそのままでマッチングを試みる
|
---|
27 | if( base.IsEqual( entry ) )
|
---|
28 | {
|
---|
29 | return true;
|
---|
30 | }
|
---|
31 |
|
---|
32 | // 現在の名前空間とのマッチングを試みる
|
---|
33 | typedef NamespaceScopes::const_iterator cnsit_t;
|
---|
34 | cnsit_t first = livingNamespaceScopes.begin();
|
---|
35 | cnsit_t last = livingNamespaceScopes.end();
|
---|
36 | NamespaceScopes temp;
|
---|
37 | while( first != last )
|
---|
38 | {
|
---|
39 | temp.assign( first, last );
|
---|
40 | temp.append( entry );
|
---|
41 | if( base.IsEqual( temp ) )
|
---|
42 | {
|
---|
43 | return true;
|
---|
44 | }
|
---|
45 | --last;
|
---|
46 | }
|
---|
47 |
|
---|
48 | // Importsされている名前空間とのマッチングを試みる
|
---|
49 | foreach( const NamespaceScopes &importedNamespaceScopes, GetImportedNamespaces() )
|
---|
50 | {
|
---|
51 | if( base.IsEqual( importedNamespaceScopes + entry ) )
|
---|
52 | {
|
---|
53 | return true;
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | return false;
|
---|
58 | }
|
---|
59 |
|
---|
60 | bool NamespaceSupporter::IsSameAreaNamespace( const NamespaceScopes &baseNamespaceScopes, const NamespaceScopes &entryNamespaceScopes ) const
|
---|
61 | {
|
---|
62 | if( entryNamespaceScopes.size() )
|
---|
63 | {
|
---|
64 | if( IsCoverd( baseNamespaceScopes, entryNamespaceScopes ) )
|
---|
65 | {
|
---|
66 | // 包括しているときは同一と見なす
|
---|
67 | return true;
|
---|
68 | }
|
---|
69 | }
|
---|
70 | else{
|
---|
71 | if( baseNamespaceScopes.size() )
|
---|
72 | {
|
---|
73 | // 名前空間の判断が必要なとき
|
---|
74 | if( this->importedNamespaces.IsImported( baseNamespaceScopes )
|
---|
75 | || IsLiving( baseNamespaceScopes ) )
|
---|
76 | {
|
---|
77 | // Using指定があるとき
|
---|
78 | // または
|
---|
79 | // 指定された名前空間が現在の名前空間スコープと同一のとき
|
---|
80 | return true;
|
---|
81 | }
|
---|
82 | }
|
---|
83 | else{
|
---|
84 | return true;
|
---|
85 | }
|
---|
86 | }
|
---|
87 |
|
---|
88 | return false;
|
---|
89 | }
|
---|