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

Last change on this file since 672 was 672, checked in by dai_9181, 16 years ago

#171への対応。テンプレート展開後のクラスメソッドの実装で、SizeOf(T)が正常値を返さない不具合を修正(特にTが4バイト未満の型場合)。

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