[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>
|
---|
[322] | 10 | #include <Delegate.h>
|
---|
[357] | 11 | #include <Exception.h>
|
---|
[407] | 12 | #include <Enum.h>
|
---|
[193] | 13 |
|
---|
[184] | 14 | class Compiler
|
---|
| 15 | {
|
---|
[459] | 16 | public:
|
---|
| 17 | // ターゲット
|
---|
| 18 | enum TargetModuleType
|
---|
| 19 | {
|
---|
| 20 | Exe,
|
---|
| 21 | Dll,
|
---|
| 22 | StaticLibrary,
|
---|
| 23 | };
|
---|
| 24 |
|
---|
| 25 | private:
|
---|
[308] | 26 | // モジュール名
|
---|
| 27 | std::string moduleName;
|
---|
| 28 |
|
---|
[459] | 29 | // モジュール タイプ
|
---|
| 30 | TargetModuleType targetModuleType;
|
---|
| 31 |
|
---|
| 32 | // デバッグ ビルドかどうか
|
---|
| 33 | bool isDebug;
|
---|
| 34 |
|
---|
[199] | 35 | // 名前空間サポート
|
---|
| 36 | NamespaceSupporter namespaceSupporter;
|
---|
| 37 |
|
---|
[265] | 38 | // オブジェクトモジュール
|
---|
| 39 | ObjectModule *pObjectModule;
|
---|
| 40 | ObjectModule *pNowObjectModule;
|
---|
| 41 |
|
---|
[184] | 42 | public:
|
---|
[193] | 43 |
|
---|
[265] | 44 | Compiler()
|
---|
| 45 | : pObjectModule( new ObjectModule )
|
---|
| 46 | , pNowObjectModule( pObjectModule )
|
---|
[266] | 47 | , targetModuleType( Exe )
|
---|
[459] | 48 | , isDebug( false )
|
---|
[294] | 49 | , isCore( false )
|
---|
[265] | 50 | {
|
---|
| 51 | }
|
---|
| 52 | ~Compiler()
|
---|
| 53 | {
|
---|
| 54 | delete pObjectModule;
|
---|
[270] | 55 | Clear();
|
---|
[265] | 56 | }
|
---|
[270] | 57 | void Clear()
|
---|
| 58 | {
|
---|
| 59 | BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
|
---|
| 60 | {
|
---|
| 61 | delete pStaticLibrary;
|
---|
| 62 | }
|
---|
| 63 | staticLibraries.clear();
|
---|
| 64 | }
|
---|
[265] | 65 |
|
---|
[270] | 66 | void StaticLink( ObjectModules &staticLibraries );
|
---|
| 67 |
|
---|
[308] | 68 | // モジュール名
|
---|
| 69 | void SetModuleName( const std::string &moduleName )
|
---|
| 70 | {
|
---|
| 71 | this->moduleName = moduleName;
|
---|
| 72 | }
|
---|
| 73 | const std::string &GetModuleName() const
|
---|
| 74 | {
|
---|
| 75 | return moduleName;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | // 名前空間サポート
|
---|
[199] | 79 | NamespaceSupporter &GetNamespaceSupporter()
|
---|
| 80 | {
|
---|
| 81 | return namespaceSupporter;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[225] | 84 | // コード生成機構
|
---|
| 85 | CodeGenerator codeGenerator;
|
---|
| 86 |
|
---|
[256] | 87 | // リンカ
|
---|
| 88 | Linker linker;
|
---|
| 89 |
|
---|
[269] | 90 | // 静的リンクするオブジェクトファイル
|
---|
| 91 | std::vector<std::string> staticLibraryFilePaths;
|
---|
| 92 |
|
---|
[270] | 93 | // 静的リンクするオブジェクトモジュール
|
---|
| 94 | ObjectModules staticLibraries;
|
---|
| 95 |
|
---|
[266] | 96 | // オブジェクトモジュール
|
---|
[265] | 97 | ObjectModule &GetObjectModule()
|
---|
| 98 | {
|
---|
| 99 | return *pNowObjectModule;
|
---|
| 100 | }
|
---|
| 101 | void SelectObjectModule( ObjectModule &objectModule )
|
---|
| 102 | {
|
---|
| 103 | pNowObjectModule = &objectModule;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[266] | 106 | bool IsExe() const
|
---|
| 107 | {
|
---|
| 108 | if( targetModuleType == Exe )
|
---|
| 109 | {
|
---|
| 110 | return true;
|
---|
| 111 | }
|
---|
| 112 | return false;
|
---|
| 113 | }
|
---|
| 114 | bool IsDll() const
|
---|
| 115 | {
|
---|
| 116 | if( targetModuleType == Dll )
|
---|
| 117 | {
|
---|
| 118 | return true;
|
---|
| 119 | }
|
---|
| 120 | return false;
|
---|
| 121 | }
|
---|
| 122 | bool IsStaticLibrary() const
|
---|
| 123 | {
|
---|
| 124 | if( targetModuleType == StaticLibrary )
|
---|
| 125 | {
|
---|
| 126 | return true;
|
---|
| 127 | }
|
---|
| 128 | return false;
|
---|
| 129 | }
|
---|
| 130 | void SetTargetModuleType( TargetModuleType targetModuleType )
|
---|
| 131 | {
|
---|
| 132 | this->targetModuleType = targetModuleType;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
[459] | 135 | void SetDebugMark( bool isDebug )
|
---|
| 136 | {
|
---|
| 137 | this->isDebug = isDebug;
|
---|
| 138 | }
|
---|
| 139 | bool IsDebug() const
|
---|
| 140 | {
|
---|
| 141 | return isDebug;
|
---|
| 142 | }
|
---|
[266] | 143 |
|
---|
[459] | 144 |
|
---|
[294] | 145 | // コアモジュールかどうか
|
---|
| 146 | bool isCore;
|
---|
| 147 | void SetCoreMark( bool isCore )
|
---|
| 148 | {
|
---|
| 149 | this->isCore = isCore;
|
---|
| 150 | }
|
---|
| 151 | bool IsCore() const
|
---|
| 152 | {
|
---|
| 153 | return isCore;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[308] | 156 | // グローバルエリアが置かれる関数名
|
---|
| 157 | std::string globalAreaProcName;
|
---|
[294] | 158 |
|
---|
[406] | 159 | // 列挙型
|
---|
| 160 | EnumInfoCollection enumInfoCollection;
|
---|
[308] | 161 |
|
---|
[406] | 162 |
|
---|
[299] | 163 | bool StringToType( const std::string &typeName, Type &type );
|
---|
| 164 | const std::string TypeToString( const Type &type );
|
---|
[206] | 165 |
|
---|
| 166 | // コンパイル中のクラス
|
---|
| 167 | const CClass *pCompilingClass;
|
---|
[184] | 168 | };
|
---|
[193] | 169 |
|
---|
[195] | 170 | extern Compiler compiler;
|
---|