source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Compiler.h@ 507

Last change on this file since 507 was 507, checked in by dai_9181, 16 years ago

NamespaceSupporterクラスをab_commonプロジェクトに移動した。

File size: 3.6 KB
Line 
1#pragma once
2
3#include <Messenger.h>
4#include <CodeGenerator.h>
5#include <Meta.h>
6#include <DataTable.h>
7#include <CodeGenerator.h>
8#include <ObjectModule.h>
9#include <Linker.h>
10#include <Delegate.h>
11#include <Exception.h>
12#include <Enum.h>
13
14class Compiler
15{
16public:
17 // ターゲット
18 enum TargetModuleType
19 {
20 Exe,
21 Dll,
22 StaticLibrary,
23 };
24
25private:
26 // ビルド成功のフラグ
27 bool isBuildSuccessful;
28
29 // モジュール名
30 std::string moduleName;
31
32 // モジュール タイプ
33 TargetModuleType targetModuleType;
34
35 // デバッグ ビルドかどうか
36 bool isDebug;
37
38 // Unicode対応モジュールかどうか
39 bool isUnicode;
40
41 // 名前空間サポート
42 NamespaceSupporter namespaceSupporter;
43
44 // オブジェクトモジュール
45 ObjectModule *pObjectModule;
46 ObjectModule *pNowObjectModule;
47
48public:
49
50 Compiler()
51 : isBuildSuccessful( false )
52 , pObjectModule( new ObjectModule )
53 , pNowObjectModule( pObjectModule )
54 , targetModuleType( Exe )
55 , isDebug( false )
56 , isUnicode( false )
57 , isCore( false )
58 {
59 Symbol::RegistNamespaceSupporter( &namespaceSupporter );
60 }
61 ~Compiler()
62 {
63 delete pObjectModule;
64 Clear();
65 }
66 void Clear()
67 {
68 BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
69 {
70 delete pStaticLibrary;
71 }
72 staticLibraries.clear();
73 }
74
75 void StaticLink( ObjectModules &staticLibraries );
76
77 // ビルド成功のフラグ
78 bool IsBuildSuccessful() const
79 {
80 return isBuildSuccessful;
81 }
82 void BuildSuccessful()
83 {
84 isBuildSuccessful = true;
85 }
86
87 // モジュール名
88 void SetModuleName( const std::string &moduleName )
89 {
90 this->moduleName = moduleName;
91 }
92 const std::string &GetModuleName() const
93 {
94 return moduleName;
95 }
96
97 // 名前空間サポート
98 NamespaceSupporter &GetNamespaceSupporter()
99 {
100 return namespaceSupporter;
101 }
102
103 // メッセンジャー
104 Messenger messenger;
105 ErrorMessenger errorMessenger;
106
107 // コード生成機構
108 CodeGenerator codeGenerator;
109
110 // リンカ
111 Linker linker;
112
113 // 静的リンクするオブジェクトファイル
114 std::vector<std::string> staticLibraryFilePaths;
115
116 // 静的リンクするオブジェクトモジュール
117 ObjectModules staticLibraries;
118
119 // オブジェクトモジュール
120 ObjectModule &GetObjectModule()
121 {
122 return *pNowObjectModule;
123 }
124 void SelectObjectModule( ObjectModule &objectModule )
125 {
126 pNowObjectModule = &objectModule;
127
128 namespaceSupporter.RegistAllNamespaceScopesCollection( &GetObjectModule().meta.GetNamespaces() );
129 }
130
131 bool IsExe() const
132 {
133 if( targetModuleType == Exe )
134 {
135 return true;
136 }
137 return false;
138 }
139 bool IsDll() const
140 {
141 if( targetModuleType == Dll )
142 {
143 return true;
144 }
145 return false;
146 }
147 bool IsStaticLibrary() const
148 {
149 if( targetModuleType == StaticLibrary )
150 {
151 return true;
152 }
153 return false;
154 }
155 void SetTargetModuleType( TargetModuleType targetModuleType )
156 {
157 this->targetModuleType = targetModuleType;
158 }
159
160 void SetDebugMark( bool isDebug )
161 {
162 this->isDebug = isDebug;
163 }
164 bool IsDebug() const
165 {
166 return isDebug;
167 }
168
169 void SetUnicodeMark( bool isUnicode )
170 {
171 this->isUnicode = isUnicode;
172 }
173 bool IsUnicode()
174 {
175 return isUnicode;
176 }
177
178
179 // コアモジュールかどうか
180 bool isCore;
181 void SetCoreMark( bool isCore )
182 {
183 this->isCore = isCore;
184 }
185 bool IsCore() const
186 {
187 return isCore;
188 }
189
190 // グローバルエリアが置かれる関数名
191 std::string globalAreaProcName;
192
193 // 列挙型
194 EnumInfoCollection enumInfoCollection;
195
196
197 bool StringToType( const std::string &typeName, Type &type );
198 const std::string TypeToString( const Type &type );
199
200 // コンパイル中のクラス
201 const CClass *pCompilingClass;
202};
203
204extern Compiler compiler;
Note: See TracBrowser for help on using the repository browser.