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

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

Compiler::StartProcedureCompile、Compiler::FinishProcedureCompileメソッドを追加(要実装)。

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