1 | #pragma once |
---|
2 | |
---|
3 | class Compiler |
---|
4 | { |
---|
5 | // ビルド成功のフラグ |
---|
6 | bool isBuildSuccessful; |
---|
7 | |
---|
8 | // モジュール名 |
---|
9 | std::string moduleName; |
---|
10 | |
---|
11 | // モジュール タイプ |
---|
12 | ActiveBasic::Common::TargetModuleType::EnumType targetModuleType; |
---|
13 | |
---|
14 | // デバッグ ビルドかどうか |
---|
15 | bool isDebug; |
---|
16 | |
---|
17 | // Unicode対応モジュールかどうか |
---|
18 | bool isUnicode; |
---|
19 | |
---|
20 | // 名前空間サポート |
---|
21 | NamespaceSupporter namespaceSupporter; |
---|
22 | |
---|
23 | // コンパイル中のUserProc/CClass |
---|
24 | const UserProc *pCompilingUserProc; |
---|
25 | const CClass *pCompilingClass; |
---|
26 | |
---|
27 | // 現在参照したいソースコードのオブジェクト モジュール インデックス |
---|
28 | int currentRelationalObjectModuleIndexForSource; |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | public: |
---|
33 | |
---|
34 | Compiler(); |
---|
35 | ~Compiler(); |
---|
36 | |
---|
37 | // 静的リンクの準備を行う(オブジェクトモジュール同士の名前リストの結合など、前処理を行う) |
---|
38 | void PreStaticLink( const ObjectModules &staticLibraries ); |
---|
39 | |
---|
40 | // 静的リンクを行う |
---|
41 | void StaticLink( ObjectModules &staticLibraries ); |
---|
42 | |
---|
43 | // ビルド成功のフラグ |
---|
44 | bool IsBuildSuccessful() const |
---|
45 | { |
---|
46 | return isBuildSuccessful; |
---|
47 | } |
---|
48 | void BuildSuccessful() |
---|
49 | { |
---|
50 | isBuildSuccessful = true; |
---|
51 | } |
---|
52 | |
---|
53 | // モジュール名 |
---|
54 | void SetModuleName( const std::string &moduleName ) |
---|
55 | { |
---|
56 | this->moduleName = moduleName; |
---|
57 | } |
---|
58 | const std::string &GetModuleName() const |
---|
59 | { |
---|
60 | return moduleName; |
---|
61 | } |
---|
62 | |
---|
63 | // 名前空間サポート |
---|
64 | NamespaceSupporter &GetNamespaceSupporter() |
---|
65 | { |
---|
66 | return namespaceSupporter; |
---|
67 | } |
---|
68 | |
---|
69 | // メッセンジャー |
---|
70 | Messenger messenger; |
---|
71 | ErrorMessenger errorMessenger; |
---|
72 | |
---|
73 | // コード生成機構 |
---|
74 | CodeGenerator codeGenerator; |
---|
75 | |
---|
76 | // リンカ |
---|
77 | Linker linker; |
---|
78 | |
---|
79 | // リソースマネージャ |
---|
80 | ActiveBasic::Common::ResourceManager resourceManager; |
---|
81 | |
---|
82 | // 静的リンクするオブジェクトファイル |
---|
83 | std::vector<std::string> staticLibraryFilePaths; |
---|
84 | |
---|
85 | // 静的リンクするオブジェクトモジュール |
---|
86 | ObjectModules staticLibraries; |
---|
87 | |
---|
88 | ObjectModule *pSelectedObjectModule; |
---|
89 | |
---|
90 | // オブジェクトモジュール |
---|
91 | ObjectModule &GetObjectModule() |
---|
92 | { |
---|
93 | return *pSelectedObjectModule; |
---|
94 | } |
---|
95 | |
---|
96 | void SelectObjectModule( ObjectModule *pObjectModule ) |
---|
97 | { |
---|
98 | this->pSelectedObjectModule = pObjectModule; |
---|
99 | } |
---|
100 | |
---|
101 | // 現在参照すべきソースコード |
---|
102 | const BasicSource &GetCurrentSource() |
---|
103 | { |
---|
104 | return staticLibraries[currentRelationalObjectModuleIndexForSource]->GetSource(); |
---|
105 | } |
---|
106 | |
---|
107 | // 現在参照すべきソースコードを格納するオブジェクトモジュールのインデックス |
---|
108 | int GetCurrentRelationalObjectModuleIndexForSource() const |
---|
109 | { |
---|
110 | return currentRelationalObjectModuleIndexForSource; |
---|
111 | } |
---|
112 | void SetCurrentRelationalObjectModuleIndexForSource( int currentRelationalObjectModuleIndexForSource ) |
---|
113 | { |
---|
114 | this->currentRelationalObjectModuleIndexForSource = currentRelationalObjectModuleIndexForSource; |
---|
115 | } |
---|
116 | |
---|
117 | bool IsExe() const |
---|
118 | { |
---|
119 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Exe ) |
---|
120 | { |
---|
121 | return true; |
---|
122 | } |
---|
123 | return false; |
---|
124 | } |
---|
125 | bool IsDll() const |
---|
126 | { |
---|
127 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Dll ) |
---|
128 | { |
---|
129 | return true; |
---|
130 | } |
---|
131 | return false; |
---|
132 | } |
---|
133 | |
---|
134 | // スタティック リンク ライブラリをビルドする? |
---|
135 | bool IsSll() const |
---|
136 | { |
---|
137 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Sll ) |
---|
138 | { |
---|
139 | return true; |
---|
140 | } |
---|
141 | return false; |
---|
142 | } |
---|
143 | |
---|
144 | void SetTargetModuleType( ActiveBasic::Common::TargetModuleType::EnumType 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 | int AddStringToDataTable( const std::string &text ); |
---|
168 | |
---|
169 | |
---|
170 | // コアモジュールかどうか |
---|
171 | bool isCore; |
---|
172 | void SetCoreMark( bool isCore ) |
---|
173 | { |
---|
174 | this->isCore = isCore; |
---|
175 | } |
---|
176 | bool IsCore() const |
---|
177 | { |
---|
178 | return isCore; |
---|
179 | } |
---|
180 | |
---|
181 | // グローバルエリアが置かれる関数名 |
---|
182 | const std::string &GetGlobalAreaProcName() const; |
---|
183 | |
---|
184 | // 列挙型 |
---|
185 | EnumInfoCollection enumInfoCollection; |
---|
186 | |
---|
187 | |
---|
188 | private: |
---|
189 | ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToGenericTypeEx( const std::string &typeName, Type &type ); |
---|
190 | public: |
---|
191 | ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToTypeEx( const std::string &typeName, Type &type, bool isResolveGenerics = false ); |
---|
192 | bool StringToType( const std::string &typeName, Type &type ); |
---|
193 | const std::string TypeToString( const Type &type ); |
---|
194 | |
---|
195 | // ジェネリック型の型パラメータ解決をサポートした上でSizeOf関数の戻り値を取得する |
---|
196 | int SizeOf( const Type &type ); |
---|
197 | |
---|
198 | void ClearCompilingUserProcAndClass(); |
---|
199 | void StartGlobalAreaCompile(); |
---|
200 | void FinishGlobalAreaCompile(); |
---|
201 | void SetCompilingClass( const CClass *pClass ); |
---|
202 | void SetCompilingUserProc( const UserProc *pUserProc ); |
---|
203 | void StartProcedureCompile( const UserProc *pUserProc ); |
---|
204 | void FinishProcedureCompile(); |
---|
205 | |
---|
206 | bool IsGlobalAreaCompiling(); |
---|
207 | bool IsLocalAreaCompiling(); |
---|
208 | const UserProc &GetCompilingUserProc(); |
---|
209 | bool IsCompilingClass(); |
---|
210 | const CClass &GetCompilingClass(); |
---|
211 | }; |
---|
212 | |
---|
213 | extern Compiler compiler; |
---|