source: dev/trunk/abdev/BasicCompiler_Common/src/NamespaceSupporter.cpp@ 318

Last change on this file since 318 was 265, checked in by dai_9181, 17 years ago
File size: 1.6 KB
Line 
1#include "stdafx.h"
2
3#include <jenga/include/smoothie/SmoothieException.h>
4#include <jenga/include/smoothie/LexicalAnalysis.h>
5
6#include <Compiler.h>
7
8bool NamespaceSupporter::ImportsNamespace( const std::string &namespaceStr )
9{
10 NamespaceScopes namespaceScopes( namespaceStr );
11 if( !compiler.GetObjectModule().meta.GetNamespaces().IsExist( namespaceScopes ) ){
12 return false;
13 }
14
15 this->importedNamespaces.push_back( namespaceScopes );
16
17 return true;
18}
19
20bool 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.