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

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