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

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

sourceをObjectModuleに入れた

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 CodeGenerator codeGenerator;
51
52 // リンカ
53 Linker linker;
54
55 // 静的リンクするオブジェクトファイル
56 std::vector<std::string> staticLibraryFilePaths;
57
58 // 静的リンクするオブジェクトモジュール
59 ObjectModules staticLibraries;
60
61 // オブジェクトモジュール
62 ObjectModule &GetObjectModule()
63 {
64 return *pNowObjectModule;
65 }
66 void SelectObjectModule( ObjectModule &objectModule )
67 {
68 pNowObjectModule = &objectModule;
69 }
70
71
72 // ターゲット
73 enum TargetModuleType
74 {
75 Exe,
76 Dll,
77 StaticLibrary,
78 };
79
80 TargetModuleType targetModuleType;
81
82 bool IsExe() const
83 {
84 if( targetModuleType == Exe )
85 {
86 return true;
87 }
88 return false;
89 }
90 bool IsDll() const
91 {
92 if( targetModuleType == Dll )
93 {
94 return true;
95 }
96 return false;
97 }
98 bool IsStaticLibrary() const
99 {
100 if( targetModuleType == StaticLibrary )
101 {
102 return true;
103 }
104 return false;
105 }
106 void SetTargetModuleType( TargetModuleType targetModuleType )
107 {
108 this->targetModuleType = targetModuleType;
109 }
110
111
112 static bool StringToType( const std::string &typeName, Type &type );
113 static const std::string TypeToString( const Type &type );
114
115 // コンパイル中のクラス
116 const CClass *pCompilingClass;
117};
118
119extern Compiler compiler;
Note: See TracBrowser for help on using the repository browser.