| Line | |
|---|
| 1 | #include "stdafx.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <jenga/include/smoothie/SmoothieException.h>
|
|---|
| 4 |
|
|---|
| 5 | #include <Compiler.h>
|
|---|
| 6 |
|
|---|
| 7 | bool NamespaceSupporter::ImportsNamespace( const std::string &namespaceStr )
|
|---|
| 8 | {
|
|---|
| 9 | NamespaceScopes namespaceScopes( namespaceStr );
|
|---|
| 10 | if( !compiler.GetObjectModule().meta.GetNamespaces().IsExist( namespaceScopes ) ){
|
|---|
| 11 | return false;
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | this->importedNamespaces.push_back( namespaceScopes );
|
|---|
| 15 |
|
|---|
| 16 | return true;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | bool NamespaceSupporter::CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection )
|
|---|
| 20 | {
|
|---|
| 21 | int i, i2;
|
|---|
| 22 | char temporary[1024];
|
|---|
| 23 |
|
|---|
| 24 | bool isSuccessful = true;
|
|---|
| 25 |
|
|---|
| 26 | // 名前空間管理
|
|---|
| 27 | NamespaceScopes namespaceScopes;
|
|---|
| 28 |
|
|---|
| 29 | for(i=0;;i++){
|
|---|
| 30 | if(source[i]=='\0') break;
|
|---|
| 31 |
|
|---|
| 32 | if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
|
|---|
| 33 | for(i+=2,i2=0;;i2++,i++){
|
|---|
| 34 | if( IsCommandDelimitation( source[i] ) ){
|
|---|
| 35 | temporary[i2]=0;
|
|---|
| 36 | break;
|
|---|
| 37 | }
|
|---|
| 38 | temporary[i2]=source[i];
|
|---|
| 39 | }
|
|---|
| 40 | namespaceScopes.push_back( temporary );
|
|---|
| 41 |
|
|---|
| 42 | if( !namespaceScopesCollection.IsExist( namespaceScopes ) ){
|
|---|
| 43 | namespaceScopesCollection.push_back( namespaceScopes );
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | continue;
|
|---|
| 47 | }
|
|---|
| 48 | else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
|
|---|
| 49 | if( namespaceScopes.size() <= 0 ){
|
|---|
| 50 | SmoothieException::Throw( 12, "End Namespace", i );
|
|---|
| 51 | isSuccessful = false;
|
|---|
| 52 | }
|
|---|
| 53 | else{
|
|---|
| 54 | namespaceScopes.pop_back();
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | i += 2;
|
|---|
| 58 | continue;
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | if( namespaceScopes.size() > 0 ){
|
|---|
| 63 | SmoothieException::Throw( 63 );
|
|---|
| 64 | isSuccessful = false;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | return isSuccessful;
|
|---|
| 68 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.