| 1 | #include "stdafx.h"
|
|---|
| 2 | #include <jenga/include/jenga.h>
|
|---|
| 3 | #include <abdev/ab_common/include/ab_common.h>
|
|---|
| 4 |
|
|---|
| 5 | using namespace ActiveBasic::Common::Lexical;
|
|---|
| 6 |
|
|---|
| 7 | bool NamespaceSupporter::ImportsNamespace( const NamespaceScopes &namespaceScopes )
|
|---|
| 8 | {
|
|---|
| 9 | _ASSERT( allNamespaceScopesCollection );
|
|---|
| 10 | if( !allNamespaceScopesCollection->IsExist( namespaceScopes ) ){
|
|---|
| 11 | return false;
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | this->importedNamespaces.push_back( namespaceScopes );
|
|---|
| 15 |
|
|---|
| 16 | return true;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | bool NamespaceSupporter::ImportsNamespace( const std::string &namespaceStr )
|
|---|
| 20 | {
|
|---|
| 21 | NamespaceScopes namespaceScopes( namespaceStr );
|
|---|
| 22 |
|
|---|
| 23 | return ImportsNamespace( namespaceScopes );
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 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 | // 現在の名前空間とのマッチングを試みる
|
|---|
| 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 )
|
|---|
| 40 | {
|
|---|
| 41 | temp.assign( first, last );
|
|---|
| 42 | temp.append( entry );
|
|---|
| 43 | if( base.IsEqual( temp ) )
|
|---|
| 44 | {
|
|---|
| 45 | return true;
|
|---|
| 46 | }
|
|---|
| 47 | --last;
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | // Importsされている名前空間とのマッチングを試みる
|
|---|
| 51 | foreach( const NamespaceScopes &importedNamespaceScopes, GetImportedNamespaces() )
|
|---|
| 52 | {
|
|---|
| 53 | if( base.IsEqual( importedNamespaceScopes + entry ) )
|
|---|
| 54 | {
|
|---|
| 55 | return true;
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | return false;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 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 | }
|
|---|