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