source: dev/trunk/abdev/BasicCompiler_Common/include/Compiler.h@ 322

Last change on this file since 322 was 322, checked in by dai_9181, 17 years ago

コンパイラ組み込みテンプレートエンジンを実装。
静的リンクライブラリ、デバッグ情報の内部形式をテキストからバイナリに変更した。

File size: 2.6 KB
Line 
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
12class Compiler
13{
14 // モジュール名
15 std::string moduleName;
16
17 // 名前空間サポート
18 NamespaceSupporter namespaceSupporter;
19
20 // オブジェクトモジュール
21 ObjectModule *pObjectModule;
22 ObjectModule *pNowObjectModule;
23
24public:
25
26 Compiler()
27 : pObjectModule( new ObjectModule )
28 , pNowObjectModule( pObjectModule )
29 , targetModuleType( Exe )
30 , isCore( false )
31 {
32 }
33 ~Compiler()
34 {
35 delete pObjectModule;
36 Clear();
37 }
38 void Clear()
39 {
40 BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
41 {
42 delete pStaticLibrary;
43 }
44 staticLibraries.clear();
45 }
46
47 void StaticLink( ObjectModules &staticLibraries );
48
49 // モジュール名
50 void SetModuleName( const std::string &moduleName )
51 {
52 this->moduleName = moduleName;
53 }
54 const std::string &GetModuleName() const
55 {
56 return moduleName;
57 }
58
59 // 名前空間サポート
60 NamespaceSupporter &GetNamespaceSupporter()
61 {
62 return namespaceSupporter;
63 }
64
65 // コード生成機構
66 CodeGenerator codeGenerator;
67
68 // リンカ
69 Linker linker;
70
71 // 静的リンクするオブジェクトファイル
72 std::vector<std::string> staticLibraryFilePaths;
73
74 // 静的リンクするオブジェクトモジュール
75 ObjectModules staticLibraries;
76
77 // オブジェクトモジュール
78 ObjectModule &GetObjectModule()
79 {
80 return *pNowObjectModule;
81 }
82 void SelectObjectModule( ObjectModule &objectModule )
83 {
84 pNowObjectModule = &objectModule;
85 }
86
87
88 // ターゲット
89 enum TargetModuleType
90 {
91 Exe,
92 Dll,
93 StaticLibrary,
94 };
95
96 TargetModuleType targetModuleType;
97
98 bool IsExe() const
99 {
100 if( targetModuleType == Exe )
101 {
102 return true;
103 }
104 return false;
105 }
106 bool IsDll() const
107 {
108 if( targetModuleType == Dll )
109 {
110 return true;
111 }
112 return false;
113 }
114 bool IsStaticLibrary() const
115 {
116 if( targetModuleType == StaticLibrary )
117 {
118 return true;
119 }
120 return false;
121 }
122 void SetTargetModuleType( TargetModuleType targetModuleType )
123 {
124 this->targetModuleType = targetModuleType;
125 }
126
127
128 // コアモジュールかどうか
129 bool isCore;
130 void SetCoreMark( bool isCore )
131 {
132 this->isCore = isCore;
133 }
134 bool IsCore() const
135 {
136 return isCore;
137 }
138
139 // グローバルエリアが置かれる関数名
140 std::string globalAreaProcName;
141
142
143 bool StringToType( const std::string &typeName, Type &type );
144 const std::string TypeToString( const Type &type );
145
146 // コンパイル中のクラス
147 const CClass *pCompilingClass;
148};
149
150extern Compiler compiler;
Note: See TracBrowser for help on using the repository browser.