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