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