[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[507] | 3 | using namespace ActiveBasic::Common::Lexical;
|
---|
[195] | 4 |
|
---|
[507] | 5 | bool NamespaceSupporter::ImportsNamespace( const NamespaceScopes &namespaceScopes )
|
---|
[199] | 6 | {
|
---|
[508] | 7 | _ASSERT( allNamespaceScopesCollection );
|
---|
[507] | 8 | if( !allNamespaceScopesCollection->IsExist( namespaceScopes ) ){
|
---|
[199] | 9 | return false;
|
---|
| 10 | }
|
---|
[195] | 11 |
|
---|
[199] | 12 | this->importedNamespaces.push_back( namespaceScopes );
|
---|
| 13 |
|
---|
| 14 | return true;
|
---|
| 15 | }
|
---|
[507] | 16 |
|
---|
| 17 | bool NamespaceSupporter::ImportsNamespace( const std::string &namespaceStr )
|
---|
| 18 | {
|
---|
| 19 | NamespaceScopes namespaceScopes( namespaceStr );
|
---|
| 20 |
|
---|
| 21 | return ImportsNamespace( namespaceScopes );
|
---|
| 22 | }
|
---|
[669] | 23 |
|
---|
[670] | 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 | 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 |
|
---|
[669] | 56 | bool 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 | }
|
---|