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