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