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