| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | #include <CodeGenerator.h>
|
|---|
| 4 | #include <NamespaceSupporter.h>
|
|---|
| 5 | #include <Meta.h>
|
|---|
| 6 | #include <DataTable.h>
|
|---|
| 7 | #include <CodeGenerator.h>
|
|---|
| 8 | #include <ObjectModule.h>
|
|---|
| 9 | #include <Linker.h>
|
|---|
| 10 | #include <Delegate.h>
|
|---|
| 11 | #include <Exception.h>
|
|---|
| 12 | #include <Enum.h>
|
|---|
| 13 |
|
|---|
| 14 | class Compiler
|
|---|
| 15 | {
|
|---|
| 16 | // モジュール名
|
|---|
| 17 | std::string moduleName;
|
|---|
| 18 |
|
|---|
| 19 | // 名前空間サポート
|
|---|
| 20 | NamespaceSupporter namespaceSupporter;
|
|---|
| 21 |
|
|---|
| 22 | // オブジェクトモジュール
|
|---|
| 23 | ObjectModule *pObjectModule;
|
|---|
| 24 | ObjectModule *pNowObjectModule;
|
|---|
| 25 |
|
|---|
| 26 | public:
|
|---|
| 27 |
|
|---|
| 28 | Compiler()
|
|---|
| 29 | : pObjectModule( new ObjectModule )
|
|---|
| 30 | , pNowObjectModule( pObjectModule )
|
|---|
| 31 | , targetModuleType( Exe )
|
|---|
| 32 | , isCore( false )
|
|---|
| 33 | {
|
|---|
| 34 | }
|
|---|
| 35 | ~Compiler()
|
|---|
| 36 | {
|
|---|
| 37 | delete pObjectModule;
|
|---|
| 38 | Clear();
|
|---|
| 39 | }
|
|---|
| 40 | void Clear()
|
|---|
| 41 | {
|
|---|
| 42 | BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
|
|---|
| 43 | {
|
|---|
| 44 | delete pStaticLibrary;
|
|---|
| 45 | }
|
|---|
| 46 | staticLibraries.clear();
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | void StaticLink( ObjectModules &staticLibraries );
|
|---|
| 50 |
|
|---|
| 51 | // モジュール名
|
|---|
| 52 | void SetModuleName( const std::string &moduleName )
|
|---|
| 53 | {
|
|---|
| 54 | this->moduleName = moduleName;
|
|---|
| 55 | }
|
|---|
| 56 | const std::string &GetModuleName() const
|
|---|
| 57 | {
|
|---|
| 58 | return moduleName;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | // 名前空間サポート
|
|---|
| 62 | NamespaceSupporter &GetNamespaceSupporter()
|
|---|
| 63 | {
|
|---|
| 64 | return namespaceSupporter;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | // コード生成機構
|
|---|
| 68 | CodeGenerator codeGenerator;
|
|---|
| 69 |
|
|---|
| 70 | // リンカ
|
|---|
| 71 | Linker linker;
|
|---|
| 72 |
|
|---|
| 73 | // 静的リンクするオブジェクトファイル
|
|---|
| 74 | std::vector<std::string> staticLibraryFilePaths;
|
|---|
| 75 |
|
|---|
| 76 | // 静的リンクするオブジェクトモジュール
|
|---|
| 77 | ObjectModules staticLibraries;
|
|---|
| 78 |
|
|---|
| 79 | // オブジェクトモジュール
|
|---|
| 80 | ObjectModule &GetObjectModule()
|
|---|
| 81 | {
|
|---|
| 82 | return *pNowObjectModule;
|
|---|
| 83 | }
|
|---|
| 84 | void SelectObjectModule( ObjectModule &objectModule )
|
|---|
| 85 | {
|
|---|
| 86 | pNowObjectModule = &objectModule;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | // ターゲット
|
|---|
| 91 | enum TargetModuleType
|
|---|
| 92 | {
|
|---|
| 93 | Exe,
|
|---|
| 94 | Dll,
|
|---|
| 95 | StaticLibrary,
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | TargetModuleType targetModuleType;
|
|---|
| 99 |
|
|---|
| 100 | bool IsExe() const
|
|---|
| 101 | {
|
|---|
| 102 | if( targetModuleType == Exe )
|
|---|
| 103 | {
|
|---|
| 104 | return true;
|
|---|
| 105 | }
|
|---|
| 106 | return false;
|
|---|
| 107 | }
|
|---|
| 108 | bool IsDll() const
|
|---|
| 109 | {
|
|---|
| 110 | if( targetModuleType == Dll )
|
|---|
| 111 | {
|
|---|
| 112 | return true;
|
|---|
| 113 | }
|
|---|
| 114 | return false;
|
|---|
| 115 | }
|
|---|
| 116 | bool IsStaticLibrary() const
|
|---|
| 117 | {
|
|---|
| 118 | if( targetModuleType == StaticLibrary )
|
|---|
| 119 | {
|
|---|
| 120 | return true;
|
|---|
| 121 | }
|
|---|
| 122 | return false;
|
|---|
| 123 | }
|
|---|
| 124 | void SetTargetModuleType( TargetModuleType targetModuleType )
|
|---|
| 125 | {
|
|---|
| 126 | this->targetModuleType = targetModuleType;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | // コアモジュールかどうか
|
|---|
| 131 | bool isCore;
|
|---|
| 132 | void SetCoreMark( bool isCore )
|
|---|
| 133 | {
|
|---|
| 134 | this->isCore = isCore;
|
|---|
| 135 | }
|
|---|
| 136 | bool IsCore() const
|
|---|
| 137 | {
|
|---|
| 138 | return isCore;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | // グローバルエリアが置かれる関数名
|
|---|
| 142 | std::string globalAreaProcName;
|
|---|
| 143 |
|
|---|
| 144 | // 列挙型
|
|---|
| 145 | EnumInfoCollection enumInfoCollection;
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 | bool StringToType( const std::string &typeName, Type &type );
|
|---|
| 149 | const std::string TypeToString( const Type &type );
|
|---|
| 150 |
|
|---|
| 151 | // コンパイル中のクラス
|
|---|
| 152 | const CClass *pCompilingClass;
|
|---|
| 153 | };
|
|---|
| 154 |
|
|---|
| 155 | extern Compiler compiler;
|
|---|