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

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