[828] | 1 | #include "Messenger.h"
|
---|
| 2 | #include "CodeGenerator.h"
|
---|
| 3 | #include "Linker.h"
|
---|
| 4 | #include "Enum.h"
|
---|
| 5 | #include "ErrorCode.h"
|
---|
| 6 |
|
---|
[184] | 7 | #pragma once
|
---|
| 8 |
|
---|
| 9 | class Compiler
|
---|
| 10 | {
|
---|
[472] | 11 | // ビルド成功のフラグ
|
---|
| 12 | bool isBuildSuccessful;
|
---|
| 13 |
|
---|
[308] | 14 | // モジュール名
|
---|
| 15 | std::string moduleName;
|
---|
| 16 |
|
---|
[459] | 17 | // モジュール タイプ
|
---|
[608] | 18 | ActiveBasic::Common::TargetModuleType::EnumType targetModuleType;
|
---|
[459] | 19 |
|
---|
| 20 | // デバッグ ビルドかどうか
|
---|
| 21 | bool isDebug;
|
---|
| 22 |
|
---|
[461] | 23 | // Unicode対応モジュールかどうか
|
---|
| 24 | bool isUnicode;
|
---|
| 25 |
|
---|
[199] | 26 | // 名前空間サポート
|
---|
| 27 | NamespaceSupporter namespaceSupporter;
|
---|
| 28 |
|
---|
[536] | 29 | // コンパイル中のUserProc/CClass
|
---|
| 30 | const UserProc *pCompilingUserProc;
|
---|
| 31 | const CClass *pCompilingClass;
|
---|
| 32 |
|
---|
[636] | 33 | // 現在参照したいソースコードのオブジェクト モジュール インデックス
|
---|
| 34 | int currentRelationalObjectModuleIndexForSource;
|
---|
[265] | 35 |
|
---|
[636] | 36 |
|
---|
| 37 |
|
---|
[184] | 38 | public:
|
---|
[193] | 39 |
|
---|
[636] | 40 | Compiler();
|
---|
| 41 | ~Compiler();
|
---|
[265] | 42 |
|
---|
[636] | 43 | // 静的リンクの準備を行う(オブジェクトモジュール同士の名前リストの結合など、前処理を行う)
|
---|
| 44 | void PreStaticLink( const ObjectModules &staticLibraries );
|
---|
| 45 |
|
---|
| 46 | // 静的リンクを行う
|
---|
[270] | 47 | void StaticLink( ObjectModules &staticLibraries );
|
---|
| 48 |
|
---|
[472] | 49 | // ビルド成功のフラグ
|
---|
| 50 | bool IsBuildSuccessful() const
|
---|
| 51 | {
|
---|
| 52 | return isBuildSuccessful;
|
---|
| 53 | }
|
---|
| 54 | void BuildSuccessful()
|
---|
| 55 | {
|
---|
| 56 | isBuildSuccessful = true;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
[308] | 59 | // モジュール名
|
---|
| 60 | void SetModuleName( const std::string &moduleName )
|
---|
| 61 | {
|
---|
| 62 | this->moduleName = moduleName;
|
---|
| 63 | }
|
---|
| 64 | const std::string &GetModuleName() const
|
---|
| 65 | {
|
---|
| 66 | return moduleName;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | // 名前空間サポート
|
---|
[199] | 70 | NamespaceSupporter &GetNamespaceSupporter()
|
---|
| 71 | {
|
---|
| 72 | return namespaceSupporter;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[465] | 75 | // メッセンジャー
|
---|
| 76 | Messenger messenger;
|
---|
| 77 | ErrorMessenger errorMessenger;
|
---|
| 78 |
|
---|
[225] | 79 | // コード生成機構
|
---|
| 80 | CodeGenerator codeGenerator;
|
---|
| 81 |
|
---|
[256] | 82 | // リンカ
|
---|
| 83 | Linker linker;
|
---|
| 84 |
|
---|
[622] | 85 | // リソースマネージャ
|
---|
| 86 | ActiveBasic::Common::ResourceManager resourceManager;
|
---|
| 87 |
|
---|
[269] | 88 | // 静的リンクするオブジェクトファイル
|
---|
| 89 | std::vector<std::string> staticLibraryFilePaths;
|
---|
| 90 |
|
---|
[270] | 91 | // 静的リンクするオブジェクトモジュール
|
---|
| 92 | ObjectModules staticLibraries;
|
---|
| 93 |
|
---|
[636] | 94 | ObjectModule *pSelectedObjectModule;
|
---|
| 95 |
|
---|
[266] | 96 | // オブジェクトモジュール
|
---|
[265] | 97 | ObjectModule &GetObjectModule()
|
---|
| 98 | {
|
---|
[636] | 99 | return *pSelectedObjectModule;
|
---|
[265] | 100 | }
|
---|
[636] | 101 |
|
---|
| 102 | void SelectObjectModule( ObjectModule *pObjectModule )
|
---|
[265] | 103 | {
|
---|
[636] | 104 | this->pSelectedObjectModule = pObjectModule;
|
---|
| 105 | }
|
---|
[507] | 106 |
|
---|
[636] | 107 | // 現在参照すべきソースコード
|
---|
| 108 | const BasicSource &GetCurrentSource()
|
---|
| 109 | {
|
---|
| 110 | return staticLibraries[currentRelationalObjectModuleIndexForSource]->GetSource();
|
---|
[265] | 111 | }
|
---|
| 112 |
|
---|
[636] | 113 | // 現在参照すべきソースコードを格納するオブジェクトモジュールのインデックス
|
---|
| 114 | int GetCurrentRelationalObjectModuleIndexForSource() const
|
---|
| 115 | {
|
---|
| 116 | return currentRelationalObjectModuleIndexForSource;
|
---|
| 117 | }
|
---|
| 118 | void SetCurrentRelationalObjectModuleIndexForSource( int currentRelationalObjectModuleIndexForSource )
|
---|
| 119 | {
|
---|
| 120 | this->currentRelationalObjectModuleIndexForSource = currentRelationalObjectModuleIndexForSource;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[266] | 123 | bool IsExe() const
|
---|
| 124 | {
|
---|
[608] | 125 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Exe )
|
---|
[266] | 126 | {
|
---|
| 127 | return true;
|
---|
| 128 | }
|
---|
| 129 | return false;
|
---|
| 130 | }
|
---|
| 131 | bool IsDll() const
|
---|
| 132 | {
|
---|
[608] | 133 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Dll )
|
---|
[266] | 134 | {
|
---|
| 135 | return true;
|
---|
| 136 | }
|
---|
| 137 | return false;
|
---|
| 138 | }
|
---|
[608] | 139 |
|
---|
| 140 | // スタティック リンク ライブラリをビルドする?
|
---|
| 141 | bool IsSll() const
|
---|
[266] | 142 | {
|
---|
[608] | 143 | if( targetModuleType == ActiveBasic::Common::TargetModuleType::Sll )
|
---|
[266] | 144 | {
|
---|
| 145 | return true;
|
---|
| 146 | }
|
---|
| 147 | return false;
|
---|
| 148 | }
|
---|
[608] | 149 |
|
---|
| 150 | void SetTargetModuleType( ActiveBasic::Common::TargetModuleType::EnumType targetModuleType )
|
---|
[266] | 151 | {
|
---|
| 152 | this->targetModuleType = targetModuleType;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
[459] | 155 | void SetDebugMark( bool isDebug )
|
---|
| 156 | {
|
---|
| 157 | this->isDebug = isDebug;
|
---|
| 158 | }
|
---|
| 159 | bool IsDebug() const
|
---|
| 160 | {
|
---|
| 161 | return isDebug;
|
---|
| 162 | }
|
---|
[266] | 163 |
|
---|
[461] | 164 | void SetUnicodeMark( bool isUnicode )
|
---|
| 165 | {
|
---|
| 166 | this->isUnicode = isUnicode;
|
---|
| 167 | }
|
---|
| 168 | bool IsUnicode()
|
---|
| 169 | {
|
---|
| 170 | return isUnicode;
|
---|
| 171 | }
|
---|
[459] | 172 |
|
---|
[745] | 173 | int AddStringToDataTable( const std::string &text );
|
---|
[461] | 174 |
|
---|
[745] | 175 |
|
---|
[294] | 176 | // コアモジュールかどうか
|
---|
| 177 | bool isCore;
|
---|
| 178 | void SetCoreMark( bool isCore )
|
---|
| 179 | {
|
---|
| 180 | this->isCore = isCore;
|
---|
| 181 | }
|
---|
| 182 | bool IsCore() const
|
---|
| 183 | {
|
---|
| 184 | return isCore;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
[308] | 187 | // グローバルエリアが置かれる関数名
|
---|
[710] | 188 | const std::string &GetGlobalAreaProcName() const;
|
---|
[294] | 189 |
|
---|
[406] | 190 | // 列挙型
|
---|
| 191 | EnumInfoCollection enumInfoCollection;
|
---|
[308] | 192 |
|
---|
[406] | 193 |
|
---|
[632] | 194 | private:
|
---|
| 195 | ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToGenericTypeEx( const std::string &typeName, Type &type );
|
---|
| 196 | public:
|
---|
[628] | 197 | ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToTypeEx( const std::string &typeName, Type &type, bool isResolveGenerics = false );
|
---|
[299] | 198 | bool StringToType( const std::string &typeName, Type &type );
|
---|
| 199 | const std::string TypeToString( const Type &type );
|
---|
[206] | 200 |
|
---|
[672] | 201 | // ジェネリック型の型パラメータ解決をサポートした上でSizeOf関数の戻り値を取得する
|
---|
| 202 | int SizeOf( const Type &type );
|
---|
| 203 |
|
---|
[536] | 204 | void ClearCompilingUserProcAndClass();
|
---|
[537] | 205 | void StartGlobalAreaCompile();
|
---|
| 206 | void FinishGlobalAreaCompile();
|
---|
[536] | 207 | void SetCompilingClass( const CClass *pClass );
|
---|
[537] | 208 | void SetCompilingUserProc( const UserProc *pUserProc );
|
---|
[533] | 209 | void StartProcedureCompile( const UserProc *pUserProc );
|
---|
| 210 | void FinishProcedureCompile();
|
---|
[536] | 211 |
|
---|
| 212 | bool IsGlobalAreaCompiling();
|
---|
[537] | 213 | bool IsLocalAreaCompiling();
|
---|
[536] | 214 | const UserProc &GetCompilingUserProc();
|
---|
| 215 | bool IsCompilingClass();
|
---|
| 216 | const CClass &GetCompilingClass();
|
---|
[828] | 217 |
|
---|
| 218 | private:
|
---|
| 219 | Compiler(Compiler const&);
|
---|
| 220 | Compiler& operator =(Compiler const&);
|
---|
[184] | 221 | };
|
---|
[193] | 222 |
|
---|
[195] | 223 | extern Compiler compiler;
|
---|