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