[184] | 1 | #pragma once
|
---|
| 2 |
|
---|
| 3 | #include <CodeGenerator.h>
|
---|
[199] | 4 | #include <NamespaceSupporter.h>
|
---|
[256] | 5 | #include <Meta.h>
|
---|
[224] | 6 | #include <DataTable.h>
|
---|
[225] | 7 | #include <CodeGenerator.h>
|
---|
[270] | 8 | #include <ObjectModule.h>
|
---|
[256] | 9 | #include <Linker.h>
|
---|
[322] | 10 | #include <Delegate.h>
|
---|
[357] | 11 | #include <Exception.h>
|
---|
[407] | 12 | #include <Enum.h>
|
---|
[193] | 13 |
|
---|
[184] | 14 | class Compiler
|
---|
| 15 | {
|
---|
[308] | 16 | // モジュール名
|
---|
| 17 | std::string moduleName;
|
---|
| 18 |
|
---|
[199] | 19 | // 名前空間サポート
|
---|
| 20 | NamespaceSupporter namespaceSupporter;
|
---|
| 21 |
|
---|
[265] | 22 | // オブジェクトモジュール
|
---|
| 23 | ObjectModule *pObjectModule;
|
---|
| 24 | ObjectModule *pNowObjectModule;
|
---|
| 25 |
|
---|
[184] | 26 | public:
|
---|
[193] | 27 |
|
---|
[265] | 28 | Compiler()
|
---|
| 29 | : pObjectModule( new ObjectModule )
|
---|
| 30 | , pNowObjectModule( pObjectModule )
|
---|
[266] | 31 | , targetModuleType( Exe )
|
---|
[294] | 32 | , isCore( false )
|
---|
[265] | 33 | {
|
---|
| 34 | }
|
---|
| 35 | ~Compiler()
|
---|
| 36 | {
|
---|
| 37 | delete pObjectModule;
|
---|
[270] | 38 | Clear();
|
---|
[265] | 39 | }
|
---|
[270] | 40 | void Clear()
|
---|
| 41 | {
|
---|
| 42 | BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
|
---|
| 43 | {
|
---|
| 44 | delete pStaticLibrary;
|
---|
| 45 | }
|
---|
| 46 | staticLibraries.clear();
|
---|
| 47 | }
|
---|
[265] | 48 |
|
---|
[270] | 49 | void StaticLink( ObjectModules &staticLibraries );
|
---|
| 50 |
|
---|
[308] | 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 | // 名前空間サポート
|
---|
[199] | 62 | NamespaceSupporter &GetNamespaceSupporter()
|
---|
| 63 | {
|
---|
| 64 | return namespaceSupporter;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[225] | 67 | // コード生成機構
|
---|
| 68 | CodeGenerator codeGenerator;
|
---|
| 69 |
|
---|
[256] | 70 | // リンカ
|
---|
| 71 | Linker linker;
|
---|
| 72 |
|
---|
[269] | 73 | // 静的リンクするオブジェクトファイル
|
---|
| 74 | std::vector<std::string> staticLibraryFilePaths;
|
---|
| 75 |
|
---|
[270] | 76 | // 静的リンクするオブジェクトモジュール
|
---|
| 77 | ObjectModules staticLibraries;
|
---|
| 78 |
|
---|
[266] | 79 | // オブジェクトモジュール
|
---|
[265] | 80 | ObjectModule &GetObjectModule()
|
---|
| 81 | {
|
---|
| 82 | return *pNowObjectModule;
|
---|
| 83 | }
|
---|
| 84 | void SelectObjectModule( ObjectModule &objectModule )
|
---|
| 85 | {
|
---|
| 86 | pNowObjectModule = &objectModule;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[266] | 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 |
|
---|
[294] | 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 |
|
---|
[308] | 141 | // グローバルエリアが置かれる関数名
|
---|
| 142 | std::string globalAreaProcName;
|
---|
[294] | 143 |
|
---|
[406] | 144 | // 列挙型
|
---|
| 145 | EnumInfoCollection enumInfoCollection;
|
---|
[308] | 146 |
|
---|
[406] | 147 |
|
---|
[299] | 148 | bool StringToType( const std::string &typeName, Type &type );
|
---|
| 149 | const std::string TypeToString( const Type &type );
|
---|
[206] | 150 |
|
---|
| 151 | // コンパイル中のクラス
|
---|
| 152 | const CClass *pCompilingClass;
|
---|
[184] | 153 | };
|
---|
[193] | 154 |
|
---|
[195] | 155 | extern Compiler compiler;
|
---|