#pragma once #include #include #include #include #include #include #include #include #include #include #include class Compiler { public: // ターゲット enum TargetModuleType { Exe, Dll, StaticLibrary, }; private: // ビルド成功のフラグ bool isBuildSuccessful; // モジュール名 std::string moduleName; // モジュール タイプ TargetModuleType targetModuleType; // デバッグ ビルドかどうか bool isDebug; // Unicode対応モジュールかどうか bool isUnicode; // 名前空間サポート NamespaceSupporter namespaceSupporter; // オブジェクトモジュール ObjectModule *pObjectModule; ObjectModule *pNowObjectModule; public: Compiler() : isBuildSuccessful( false ) , pObjectModule( new ObjectModule ) , pNowObjectModule( pObjectModule ) , targetModuleType( Exe ) , isDebug( false ) , isUnicode( false ) , isCore( false ) { } ~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; // 静的リンクするオブジェクトファイル std::vector staticLibraryFilePaths; // 静的リンクするオブジェクトモジュール ObjectModules staticLibraries; // オブジェクトモジュール ObjectModule &GetObjectModule() { return *pNowObjectModule; } void SelectObjectModule( ObjectModule &objectModule ) { pNowObjectModule = &objectModule; } bool IsExe() const { if( targetModuleType == Exe ) { return true; } return false; } bool IsDll() const { if( targetModuleType == Dll ) { return true; } return false; } bool IsStaticLibrary() const { if( targetModuleType == StaticLibrary ) { return true; } return false; } void SetTargetModuleType( TargetModuleType 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; bool StringToType( const std::string &typeName, Type &type ); const std::string TypeToString( const Type &type ); // コンパイル中のクラス const CClass *pCompilingClass; }; extern Compiler compiler;