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