[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 | // 現在の名前空間とのマッチングを試みる
|
---|
[736] | 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 )
|
---|
[670] | 38 | {
|
---|
[736] | 39 | temp.assign( first, last );
|
---|
| 40 | temp.append( entry );
|
---|
| 41 | if( base.IsEqual( temp ) )
|
---|
[670] | 42 | {
|
---|
| 43 | return true;
|
---|
| 44 | }
|
---|
[736] | 45 | --last;
|
---|
[670] | 46 | }
|
---|
| 47 |
|
---|
| 48 | // Importsされている名前空間とのマッチングを試みる
|
---|
[750] | 49 | foreach( const NamespaceScopes &importedNamespaceScopes, GetImportedNamespaces() )
|
---|
[670] | 50 | {
|
---|
| 51 | if( base.IsEqual( importedNamespaceScopes + entry ) )
|
---|
| 52 | {
|
---|
| 53 | return true;
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | return false;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[669] | 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 | }
|
---|