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

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

Symbol::RegistNamespaceSupporterメソッドを追加。

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