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

Last change on this file since 537 was 537, checked in by dai_9181, 15 years ago

UserProcクラスによるコンパイル中関数管理用メソッドを除去(すべてCompilerクラス内で処理するようにした)。

File size: 3.9 KB
Line 
1#pragma once
2
3class Compiler
4{
5public:
6    // ターゲット
7    enum TargetModuleType
8    {
9        Exe,
10        Dll,
11        StaticLibrary,
12    };
13
14private:
15    // ビルド成功のフラグ
16    bool isBuildSuccessful;
17
18    // モジュール名
19    std::string moduleName;
20
21    // モジュール タイプ
22    TargetModuleType targetModuleType;
23
24    // デバッグ ビルドかどうか
25    bool isDebug;
26
27    // Unicode対応モジュールかどうか
28    bool isUnicode;
29
30    // 名前空間サポート
31    NamespaceSupporter namespaceSupporter;
32
33    // コンパイル中のUserProc/CClass
34    const UserProc *pCompilingUserProc;
35    const CClass *pCompilingClass;
36
37    // オブジェクトモジュール
38    ObjectModule *pObjectModule;
39    ObjectModule *pNowObjectModule;
40
41public:
42
43    Compiler()
44        : isBuildSuccessful( false )
45        , pObjectModule( new ObjectModule )
46        , targetModuleType( Exe )
47        , isDebug( false )
48        , isUnicode( false )
49        , isCore( false )
50    {
51        SelectObjectModule( *pObjectModule );
52        Symbol::RegistNamespaceSupporter( &namespaceSupporter );
53    }
54    ~Compiler()
55    {
56        delete pObjectModule;
57        Clear();
58    }
59    void Clear()
60    {
61        BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
62        {
63            delete pStaticLibrary;
64        }
65        staticLibraries.clear();
66    }
67
68    void StaticLink( ObjectModules &staticLibraries );
69
70    // ビルド成功のフラグ
71    bool IsBuildSuccessful() const
72    {
73        return isBuildSuccessful;
74    }
75    void BuildSuccessful()
76    {
77        isBuildSuccessful = true;
78    }
79
80    // モジュール名
81    void SetModuleName( const std::string &moduleName )
82    {
83        this->moduleName = moduleName;
84    }
85    const std::string &GetModuleName() const
86    {
87        return moduleName;
88    }
89
90    // 名前空間サポート
91    NamespaceSupporter &GetNamespaceSupporter()
92    {
93        return namespaceSupporter;
94    }
95
96    // メッセンジャー
97    Messenger messenger;
98    ErrorMessenger errorMessenger;
99
100    // コード生成機構
101    CodeGenerator codeGenerator;
102
103    // リンカ
104    Linker linker;
105
106    // 静的リンクするオブジェクトファイル
107    std::vector<std::string> staticLibraryFilePaths;
108
109    // 静的リンクするオブジェクトモジュール
110    ObjectModules staticLibraries;
111
112    // オブジェクトモジュール
113    ObjectModule &GetObjectModule()
114    {
115        return *pNowObjectModule;
116    }
117    void SelectObjectModule( ObjectModule &objectModule )
118    {
119        pNowObjectModule = &objectModule;
120
121        namespaceSupporter.RegistAllNamespaceScopesCollection( &GetObjectModule().meta.GetNamespaces() );
122    }
123
124    bool IsExe() const
125    {
126        if( targetModuleType == Exe )
127        {
128            return true;
129        }
130        return false;
131    }
132    bool IsDll() const
133    {
134        if( targetModuleType == Dll )
135        {
136            return true;
137        }
138        return false;
139    }
140    bool IsStaticLibrary() const
141    {
142        if( targetModuleType == StaticLibrary )
143        {
144            return true;
145        }
146        return false;
147    }
148    void SetTargetModuleType( TargetModuleType targetModuleType )
149    {
150        this->targetModuleType = targetModuleType;
151    }
152
153    void SetDebugMark( bool isDebug )
154    {
155        this->isDebug = isDebug;
156    }
157    bool IsDebug() const
158    {
159        return isDebug;
160    }
161
162    void SetUnicodeMark( bool isUnicode )
163    {
164        this->isUnicode = isUnicode;
165    }
166    bool IsUnicode()
167    {
168        return isUnicode;
169    }
170
171
172    // コアモジュールかどうか
173    bool isCore;
174    void SetCoreMark( bool isCore )
175    {
176        this->isCore = isCore;
177    }
178    bool IsCore() const
179    {
180        return isCore;
181    }
182
183    // グローバルエリアが置かれる関数名
184    std::string globalAreaProcName;
185
186    // 列挙型
187    EnumInfoCollection enumInfoCollection;
188
189
190    bool StringToType( const std::string &typeName, Type &type );
191    const std::string TypeToString( const Type &type );
192
193    void ClearCompilingUserProcAndClass();
194    void StartGlobalAreaCompile();
195    void FinishGlobalAreaCompile();
196    void SetCompilingClass( const CClass *pClass );
197    void SetCompilingUserProc( const UserProc *pUserProc );
198    void StartProcedureCompile( const UserProc *pUserProc );
199    void FinishProcedureCompile();
200
201    bool IsGlobalAreaCompiling();
202    bool IsLocalAreaCompiling();
203    const UserProc &GetCompilingUserProc();
204    bool IsCompilingClass();
205    const CClass &GetCompilingClass();
206};
207
208extern Compiler compiler;
Note: See TracBrowser for help on using the repository browser.