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

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