[184] | 1 | #pragma once
|
---|
| 2 |
|
---|
| 3 | #include <CodeGenerator.h>
|
---|
[199] | 4 | #include <NamespaceSupporter.h>
|
---|
[256] | 5 | #include <Meta.h>
|
---|
[224] | 6 | #include <DataTable.h>
|
---|
[225] | 7 | #include <CodeGenerator.h>
|
---|
[270] | 8 | #include <ObjectModule.h>
|
---|
[256] | 9 | #include <Linker.h>
|
---|
[193] | 10 |
|
---|
[184] | 11 | class Compiler
|
---|
| 12 | {
|
---|
[199] | 13 | // 名前空間サポート
|
---|
| 14 | NamespaceSupporter namespaceSupporter;
|
---|
| 15 |
|
---|
[265] | 16 | // オブジェクトモジュール
|
---|
| 17 | ObjectModule *pObjectModule;
|
---|
| 18 | ObjectModule *pNowObjectModule;
|
---|
| 19 |
|
---|
[184] | 20 | public:
|
---|
[193] | 21 |
|
---|
[265] | 22 | Compiler()
|
---|
| 23 | : pObjectModule( new ObjectModule )
|
---|
| 24 | , pNowObjectModule( pObjectModule )
|
---|
[266] | 25 | , targetModuleType( Exe )
|
---|
[265] | 26 | {
|
---|
| 27 | }
|
---|
| 28 | ~Compiler()
|
---|
| 29 | {
|
---|
| 30 | delete pObjectModule;
|
---|
[270] | 31 | Clear();
|
---|
[265] | 32 | }
|
---|
[270] | 33 | void Clear()
|
---|
| 34 | {
|
---|
| 35 | BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
|
---|
| 36 | {
|
---|
| 37 | delete pStaticLibrary;
|
---|
| 38 | }
|
---|
| 39 | staticLibraries.clear();
|
---|
| 40 | }
|
---|
[265] | 41 |
|
---|
[270] | 42 | void StaticLink( ObjectModules &staticLibraries );
|
---|
| 43 |
|
---|
[199] | 44 | NamespaceSupporter &GetNamespaceSupporter()
|
---|
| 45 | {
|
---|
| 46 | return namespaceSupporter;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[225] | 49 | // コード生成機構
|
---|
| 50 | CodeGenerator codeGenerator;
|
---|
| 51 |
|
---|
[256] | 52 | // リンカ
|
---|
| 53 | Linker linker;
|
---|
| 54 |
|
---|
[269] | 55 | // 静的リンクするオブジェクトファイル
|
---|
| 56 | std::vector<std::string> staticLibraryFilePaths;
|
---|
| 57 |
|
---|
[270] | 58 | // 静的リンクするオブジェクトモジュール
|
---|
| 59 | ObjectModules staticLibraries;
|
---|
| 60 |
|
---|
[266] | 61 | // オブジェクトモジュール
|
---|
[265] | 62 | ObjectModule &GetObjectModule()
|
---|
| 63 | {
|
---|
| 64 | return *pNowObjectModule;
|
---|
| 65 | }
|
---|
| 66 | void SelectObjectModule( ObjectModule &objectModule )
|
---|
| 67 | {
|
---|
| 68 | pNowObjectModule = &objectModule;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[266] | 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 |
|
---|
[193] | 112 | static bool StringToType( const std::string &typeName, Type &type );
|
---|
| 113 | static const std::string TypeToString( const Type &type );
|
---|
[206] | 114 |
|
---|
| 115 | // コンパイル中のクラス
|
---|
| 116 | const CClass *pCompilingClass;
|
---|
[184] | 117 | };
|
---|
[193] | 118 |
|
---|
[195] | 119 | extern Compiler compiler;
|
---|