source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Compiler.h

Last change on this file was 829, checked in by イグトランス (egtra), 12 years ago

svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定

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