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