#pragma once class Compiler { // ビルド成功のフラグ bool isBuildSuccessful; // モジュール名 std::string moduleName; // モジュール タイプ ActiveBasic::Common::TargetModuleType::EnumType targetModuleType; // デバッグ ビルドかどうか bool isDebug; // Unicode対応モジュールかどうか bool isUnicode; // 名前空間サポート NamespaceSupporter namespaceSupporter; // コンパイル中のUserProc/CClass const UserProc *pCompilingUserProc; const CClass *pCompilingClass; // オブジェクトモジュール ObjectModule *pObjectModule; ObjectModule *pNowObjectModule; public: Compiler() : isBuildSuccessful( false ) , pObjectModule( new ObjectModule ) , targetModuleType( ActiveBasic::Common::TargetModuleType::Exe ) , isDebug( false ) , isUnicode( false ) , isCore( false ) { SelectObjectModule( *pObjectModule ); Symbol::RegistNamespaceSupporter( &namespaceSupporter ); } ~Compiler() { delete pObjectModule; Clear(); } void Clear() { BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries ) { delete pStaticLibrary; } staticLibraries.clear(); } void StaticLink( ObjectModules &staticLibraries ); // ビルド成功のフラグ bool IsBuildSuccessful() const { return isBuildSuccessful; } void BuildSuccessful() { isBuildSuccessful = true; } // モジュール名 void SetModuleName( const std::string &moduleName ) { this->moduleName = moduleName; } const std::string &GetModuleName() const { return moduleName; } // 名前空間サポート NamespaceSupporter &GetNamespaceSupporter() { return namespaceSupporter; } // メッセンジャー Messenger messenger; ErrorMessenger errorMessenger; // コード生成機構 CodeGenerator codeGenerator; // リンカ Linker linker; // リソースマネージャ ActiveBasic::Common::ResourceManager resourceManager; // 静的リンクするオブジェクトファイル std::vector staticLibraryFilePaths; // 静的リンクするオブジェクトモジュール ObjectModules staticLibraries; // オブジェクトモジュール ObjectModule &GetObjectModule() { return *pNowObjectModule; } void SelectObjectModule( ObjectModule &objectModule ) { pNowObjectModule = &objectModule; namespaceSupporter.RegistAllNamespaceScopesCollection( &GetObjectModule().meta.GetNamespaces() ); } bool IsExe() const { if( targetModuleType == ActiveBasic::Common::TargetModuleType::Exe ) { return true; } return false; } bool IsDll() const { if( targetModuleType == ActiveBasic::Common::TargetModuleType::Dll ) { return true; } return false; } // スタティック リンク ライブラリをビルドする? bool IsSll() const { if( targetModuleType == ActiveBasic::Common::TargetModuleType::Sll ) { return true; } return false; } void SetTargetModuleType( ActiveBasic::Common::TargetModuleType::EnumType targetModuleType ) { this->targetModuleType = targetModuleType; } void SetDebugMark( bool isDebug ) { this->isDebug = isDebug; } bool IsDebug() const { return isDebug; } void SetUnicodeMark( bool isUnicode ) { this->isUnicode = isUnicode; } bool IsUnicode() { return isUnicode; } // コアモジュールかどうか bool isCore; void SetCoreMark( bool isCore ) { this->isCore = isCore; } bool IsCore() const { return isCore; } // グローバルエリアが置かれる関数名 std::string globalAreaProcName; // 列挙型 EnumInfoCollection enumInfoCollection; ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToTypeEx( const std::string &typeName, Type &type, bool isResolveGenerics = false ); bool StringToType( const std::string &typeName, Type &type ); const std::string TypeToString( const Type &type ); void ClearCompilingUserProcAndClass(); void StartGlobalAreaCompile(); void FinishGlobalAreaCompile(); void SetCompilingClass( const CClass *pClass ); void SetCompilingUserProc( const UserProc *pUserProc ); void StartProcedureCompile( const UserProc *pUserProc ); void FinishProcedureCompile(); bool IsGlobalAreaCompiling(); bool IsLocalAreaCompiling(); const UserProc &GetCompilingUserProc(); bool IsCompilingClass(); const CClass &GetCompilingClass(); }; extern Compiler compiler;