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

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