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
RevLine 
[184]1#pragma once
2
[465]3#include <Messenger.h>
[184]4#include <CodeGenerator.h>
[256]5#include <Meta.h>
[224]6#include <DataTable.h>
[225]7#include <CodeGenerator.h>
[270]8#include <ObjectModule.h>
[256]9#include <Linker.h>
[322]10#include <Delegate.h>
[357]11#include <Exception.h>
[407]12#include <Enum.h>
[193]13
[184]14class Compiler
15{
[459]16public:
17 // ターゲット
18 enum TargetModuleType
19 {
20 Exe,
21 Dll,
22 StaticLibrary,
23 };
24
25private:
[472]26 // ビルド成功のフラグ
27 bool isBuildSuccessful;
28
[308]29 // モジュール名
30 std::string moduleName;
31
[459]32 // モジュール タイプ
33 TargetModuleType targetModuleType;
34
35 // デバッグ ビルドかどうか
36 bool isDebug;
37
[461]38 // Unicode対応モジュールかどうか
39 bool isUnicode;
40
[199]41 // 名前空間サポート
42 NamespaceSupporter namespaceSupporter;
43
[265]44 // オブジェクトモジュール
45 ObjectModule *pObjectModule;
46 ObjectModule *pNowObjectModule;
47
[184]48public:
[193]49
[265]50 Compiler()
[472]51 : isBuildSuccessful( false )
52 , pObjectModule( new ObjectModule )
[265]53 , pNowObjectModule( pObjectModule )
[266]54 , targetModuleType( Exe )
[459]55 , isDebug( false )
[461]56 , isUnicode( false )
[294]57 , isCore( false )
[265]58 {
[504]59 Symbol::RegistNamespaceSupporter( &namespaceSupporter );
[265]60 }
61 ~Compiler()
62 {
63 delete pObjectModule;
[270]64 Clear();
[265]65 }
[270]66 void Clear()
67 {
68 BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
69 {
70 delete pStaticLibrary;
71 }
72 staticLibraries.clear();
73 }
[265]74
[270]75 void StaticLink( ObjectModules &staticLibraries );
76
[472]77 // ビルド成功のフラグ
78 bool IsBuildSuccessful() const
79 {
80 return isBuildSuccessful;
81 }
82 void BuildSuccessful()
83 {
84 isBuildSuccessful = true;
85 }
86
[308]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 // 名前空間サポート
[199]98 NamespaceSupporter &GetNamespaceSupporter()
99 {
100 return namespaceSupporter;
101 }
102
[465]103 // メッセンジャー
104 Messenger messenger;
105 ErrorMessenger errorMessenger;
106
[225]107 // コード生成機構
108 CodeGenerator codeGenerator;
109
[256]110 // リンカ
111 Linker linker;
112
[269]113 // 静的リンクするオブジェクトファイル
114 std::vector<std::string> staticLibraryFilePaths;
115
[270]116 // 静的リンクするオブジェクトモジュール
117 ObjectModules staticLibraries;
118
[266]119 // オブジェクトモジュール
[265]120 ObjectModule &GetObjectModule()
121 {
122 return *pNowObjectModule;
123 }
124 void SelectObjectModule( ObjectModule &objectModule )
125 {
126 pNowObjectModule = &objectModule;
[507]127
128 namespaceSupporter.RegistAllNamespaceScopesCollection( &GetObjectModule().meta.GetNamespaces() );
[265]129 }
130
[266]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
[459]160 void SetDebugMark( bool isDebug )
161 {
162 this->isDebug = isDebug;
163 }
164 bool IsDebug() const
165 {
166 return isDebug;
167 }
[266]168
[461]169 void SetUnicodeMark( bool isUnicode )
170 {
171 this->isUnicode = isUnicode;
172 }
173 bool IsUnicode()
174 {
175 return isUnicode;
176 }
[459]177
[461]178
[294]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
[308]190 // グローバルエリアが置かれる関数名
191 std::string globalAreaProcName;
[294]192
[406]193 // 列挙型
194 EnumInfoCollection enumInfoCollection;
[308]195
[406]196
[299]197 bool StringToType( const std::string &typeName, Type &type );
198 const std::string TypeToString( const Type &type );
[206]199
200 // コンパイル中のクラス
201 const CClass *pCompilingClass;
[184]202};
[193]203
[195]204extern Compiler compiler;
Note: See TracBrowser for help on using the repository browser.