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