[184] | 1 | #pragma once
|
---|
| 2 |
|
---|
| 3 | class Compiler
|
---|
| 4 | {
|
---|
[472] | 5 | // ビルド成功のフラグ
|
---|
| 6 | bool isBuildSuccessful;
|
---|
| 7 |
|
---|
[308] | 8 | // モジュール名
|
---|
| 9 | std::string moduleName;
|
---|
| 10 |
|
---|
[459] | 11 | // モジュール タイプ
|
---|
[608] | 12 | ActiveBasic::Common::TargetModuleType::EnumType targetModuleType;
|
---|
[459] | 13 |
|
---|
| 14 | // デバッグ ビルドかどうか
|
---|
| 15 | bool isDebug;
|
---|
| 16 |
|
---|
[461] | 17 | // Unicode対応モジュールかどうか
|
---|
| 18 | bool isUnicode;
|
---|
| 19 |
|
---|
[199] | 20 | // 名前空間サポート
|
---|
| 21 | NamespaceSupporter namespaceSupporter;
|
---|
| 22 |
|
---|
[536] | 23 | // コンパイル中のUserProc/CClass
|
---|
| 24 | const UserProc *pCompilingUserProc;
|
---|
| 25 | const CClass *pCompilingClass;
|
---|
| 26 |
|
---|
[265] | 27 | // オブジェクトモジュール
|
---|
| 28 | ObjectModule *pObjectModule;
|
---|
| 29 | ObjectModule *pNowObjectModule;
|
---|
| 30 |
|
---|
[184] | 31 | public:
|
---|
[193] | 32 |
|
---|
[265] | 33 | Compiler()
|
---|
[472] | 34 | : isBuildSuccessful( false )
|
---|
| 35 | , pObjectModule( new ObjectModule )
|
---|
[608] | 36 | , targetModuleType( ActiveBasic::Common::TargetModuleType::Exe )
|
---|
[459] | 37 | , isDebug( false )
|
---|
[461] | 38 | , isUnicode( false )
|
---|
[294] | 39 | , isCore( false )
|
---|
[265] | 40 | {
|
---|
[508] | 41 | SelectObjectModule( *pObjectModule );
|
---|
[504] | 42 | Symbol::RegistNamespaceSupporter( &namespaceSupporter );
|
---|
[265] | 43 | }
|
---|
| 44 | ~Compiler()
|
---|
| 45 | {
|
---|
| 46 | delete pObjectModule;
|
---|
[270] | 47 | Clear();
|
---|
[265] | 48 | }
|
---|
[270] | 49 | void Clear()
|
---|
| 50 | {
|
---|
| 51 | BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
|
---|
| 52 | {
|
---|
| 53 | delete pStaticLibrary;
|
---|
| 54 | }
|
---|
| 55 | staticLibraries.clear();
|
---|
| 56 | }
|
---|
[265] | 57 |
|
---|
[270] | 58 | void StaticLink( ObjectModules &staticLibraries );
|
---|
| 59 |
|
---|
[472] | 60 | // ビルド成功のフラグ
|
---|
| 61 | bool IsBuildSuccessful() const
|
---|
| 62 | {
|
---|
| 63 | return isBuildSuccessful;
|
---|
| 64 | }
|
---|
| 65 | void BuildSuccessful()
|
---|
| 66 | {
|
---|
| 67 | isBuildSuccessful = true;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[308] | 70 | // モジュール名
|
---|
| 71 | void SetModuleName( const std::string &moduleName )
|
---|
| 72 | {
|
---|
| 73 | this->moduleName = moduleName;
|
---|
| 74 | }
|
---|
| 75 | const std::string &GetModuleName() const
|
---|
| 76 | {
|
---|
| 77 | return moduleName;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | // 名前空間サポート
|
---|
[199] | 81 | NamespaceSupporter &GetNamespaceSupporter()
|
---|
| 82 | {
|
---|
| 83 | return namespaceSupporter;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
[465] | 86 | // メッセンジャー
|
---|
| 87 | Messenger messenger;
|
---|
| 88 | ErrorMessenger errorMessenger;
|
---|
| 89 |
|
---|
[225] | 90 | // コード生成機構
|
---|
| 91 | CodeGenerator codeGenerator;
|
---|
| 92 |
|
---|
[256] | 93 | // リンカ
|
---|
| 94 | Linker linker;
|
---|
| 95 |
|
---|
[622] | 96 | // リソースマネージャ
|
---|
| 97 | ActiveBasic::Common::ResourceManager resourceManager;
|
---|
| 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;
|
---|
[507] | 113 |
|
---|
| 114 | namespaceSupporter.RegistAllNamespaceScopesCollection( &GetObjectModule().meta.GetNamespaces() );
|
---|
[265] | 115 | }
|
---|
| 116 |
|
---|
[266] | 117 | bool IsExe() const
|
---|
| 118 | {
|
---|
[608] | 119 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Exe )
|
---|
[266] | 120 | {
|
---|
| 121 | return true;
|
---|
| 122 | }
|
---|
| 123 | return false;
|
---|
| 124 | }
|
---|
| 125 | bool IsDll() const
|
---|
| 126 | {
|
---|
[608] | 127 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Dll )
|
---|
[266] | 128 | {
|
---|
| 129 | return true;
|
---|
| 130 | }
|
---|
| 131 | return false;
|
---|
| 132 | }
|
---|
[608] | 133 |
|
---|
| 134 | // スタティック リンク ライブラリをビルドする?
|
---|
| 135 | bool IsSll() const
|
---|
[266] | 136 | {
|
---|
[608] | 137 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Sll )
|
---|
[266] | 138 | {
|
---|
| 139 | return true;
|
---|
| 140 | }
|
---|
| 141 | return false;
|
---|
| 142 | }
|
---|
[608] | 143 |
|
---|
| 144 | void SetTargetModuleType( ActiveBasic::Common::TargetModuleType::EnumType targetModuleType )
|
---|
[266] | 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 |
|
---|
[632] | 186 | private:
|
---|
| 187 | ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToGenericTypeEx( const std::string &typeName, Type &type );
|
---|
| 188 | public:
|
---|
[628] | 189 | ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToTypeEx( const std::string &typeName, Type &type, bool isResolveGenerics = false );
|
---|
[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;
|
---|