| 1 | #include "stdafx.h"
|
|---|
| 2 |
|
|---|
| 3 | void Meta::Clear()
|
|---|
| 4 | {
|
|---|
| 5 | // 名前空間
|
|---|
| 6 | namespaceScopesCollection.clear();
|
|---|
| 7 |
|
|---|
| 8 | // 関数・メソッド
|
|---|
| 9 | userProcs.Clear();
|
|---|
| 10 |
|
|---|
| 11 | // DLL関数
|
|---|
| 12 | dllProcs.Clear();
|
|---|
| 13 |
|
|---|
| 14 | // クラス
|
|---|
| 15 | classesImpl.Clear();
|
|---|
| 16 |
|
|---|
| 17 | // グローバル変数
|
|---|
| 18 | globalVars.Clear();
|
|---|
| 19 |
|
|---|
| 20 | // グローバル定数
|
|---|
| 21 | globalConsts.Clear();
|
|---|
| 22 |
|
|---|
| 23 | // グローバル定数マクロ
|
|---|
| 24 | globalConstMacros.Clear();
|
|---|
| 25 |
|
|---|
| 26 | // blittable型
|
|---|
| 27 | blittableTypes.clear();
|
|---|
| 28 |
|
|---|
| 29 | // TypeDef
|
|---|
| 30 | typeDefs.clear();
|
|---|
| 31 |
|
|---|
| 32 | // 関数ポインタ
|
|---|
| 33 | procPointers.Clear();
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | void Meta::StaticLink( Meta &meta, long dataSectionBaseOffset, const std::vector<int> &relationTable )
|
|---|
| 37 | {
|
|---|
| 38 | // 名前空間
|
|---|
| 39 | BOOST_FOREACH( NamespaceScopes &namespaceScopes, meta.namespaceScopesCollection )
|
|---|
| 40 | {
|
|---|
| 41 | if( !this->namespaceScopesCollection.IsExist( namespaceScopes ) )
|
|---|
| 42 | {
|
|---|
| 43 | this->namespaceScopesCollection.push_back( namespaceScopes );
|
|---|
| 44 | }
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | // 関数・メソッド
|
|---|
| 48 | meta.GetUserProcs().Iterator_Reset();
|
|---|
| 49 | while( meta.GetUserProcs().Iterator_HasNext() )
|
|---|
| 50 | {
|
|---|
| 51 | UserProc *pUserProc = meta.GetUserProcs().Iterator_GetNext();
|
|---|
| 52 | pUserProc->isTargetObjectModule = false;
|
|---|
| 53 |
|
|---|
| 54 | pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset );
|
|---|
| 55 | pUserProc->GetNativeCode().ResetSourceIndexes( relationTable );
|
|---|
| 56 |
|
|---|
| 57 | this->userProcs.Put( pUserProc );
|
|---|
| 58 | }
|
|---|
| 59 | meta.GetUserProcs().PullOutAll();
|
|---|
| 60 |
|
|---|
| 61 | // DLL関数
|
|---|
| 62 | meta.GetDllProcs().Iterator_Reset();
|
|---|
| 63 | while( meta.GetDllProcs().Iterator_HasNext() )
|
|---|
| 64 | {
|
|---|
| 65 | DllProc *pDllProc = meta.GetDllProcs().Iterator_GetNext();
|
|---|
| 66 | pDllProc->isTargetObjectModule = false;
|
|---|
| 67 | this->dllProcs.Put( pDllProc );
|
|---|
| 68 | }
|
|---|
| 69 | meta.GetDllProcs().PullOutAll();
|
|---|
| 70 |
|
|---|
| 71 | // クラス
|
|---|
| 72 | meta.GetClasses().Iterator_Reset();
|
|---|
| 73 | while( meta.GetClasses().Iterator_HasNext() )
|
|---|
| 74 | {
|
|---|
| 75 | CClass *pClass = meta.GetClasses().Iterator_GetNext();
|
|---|
| 76 | pClass->isTargetObjectModule = false;
|
|---|
| 77 | pClass->Readed();
|
|---|
| 78 | this->GetClasses().Put( pClass );
|
|---|
| 79 | }
|
|---|
| 80 | meta.GetClasses().PullOutAll();
|
|---|
| 81 |
|
|---|
| 82 | // グローバル変数
|
|---|
| 83 | long initAreaBaseOffset = this->globalVars.initAreaBuffer.GetSize();
|
|---|
| 84 | BOOST_FOREACH( Variable *pVar, meta.globalVars )
|
|---|
| 85 | {
|
|---|
| 86 | // 基底スコープレベルのグローバル変数の生存値をオンにする
|
|---|
| 87 | if( pVar->GetScopeLevel() == 0 )
|
|---|
| 88 | {
|
|---|
| 89 | pVar->isLiving = true;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | bool isResetOffsetAddress = true;
|
|---|
| 93 | if( pVar->HasInitData() )
|
|---|
| 94 | {
|
|---|
| 95 | // 初期バッファがあるときはデータテーブルオフセットを適用する
|
|---|
| 96 | pVar->SetOffsetAddress( pVar->GetOffsetAddress() + initAreaBaseOffset );
|
|---|
| 97 |
|
|---|
| 98 | isResetOffsetAddress = false;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | pVar->isTargetObjectModule = false;
|
|---|
| 102 | this->globalVars.Add( pVar, isResetOffsetAddress );
|
|---|
| 103 | }
|
|---|
| 104 | meta.globalVars.PullOutAll();
|
|---|
| 105 | this->globalVars.initAreaBuffer.Put(
|
|---|
| 106 | meta.globalVars.initAreaBuffer.GetBuffer(),
|
|---|
| 107 | meta.globalVars.initAreaBuffer.GetSize()
|
|---|
| 108 | );
|
|---|
| 109 |
|
|---|
| 110 | // グローバル定数
|
|---|
| 111 | meta.GetGlobalConsts().Iterator_Reset();
|
|---|
| 112 | while( meta.GetGlobalConsts().Iterator_HasNext() )
|
|---|
| 113 | {
|
|---|
| 114 | CConst *pConst = meta.GetGlobalConsts().Iterator_GetNext();
|
|---|
| 115 | pConst->isTargetObjectModule = false;
|
|---|
| 116 | this->GetGlobalConsts().Put( pConst );
|
|---|
| 117 | }
|
|---|
| 118 | meta.GetGlobalConsts().PullOutAll();
|
|---|
| 119 |
|
|---|
| 120 | // グローバル定数マクロ
|
|---|
| 121 | meta.GetGlobalConstMacros().Iterator_Reset();
|
|---|
| 122 | while( meta.GetGlobalConstMacros().Iterator_HasNext() )
|
|---|
| 123 | {
|
|---|
| 124 | ConstMacro *pConstMacro = meta.GetGlobalConstMacros().Iterator_GetNext();
|
|---|
| 125 | pConstMacro->isTargetObjectModule = false;
|
|---|
| 126 | this->GetGlobalConstMacros().Put( pConstMacro );
|
|---|
| 127 | }
|
|---|
| 128 | meta.GetGlobalConstMacros().PullOutAll();
|
|---|
| 129 |
|
|---|
| 130 | // blittable型
|
|---|
| 131 | BOOST_FOREACH( BlittableType &blittableType, meta.blittableTypes )
|
|---|
| 132 | {
|
|---|
| 133 | blittableType.isTargetObjectModule = false;
|
|---|
| 134 | this->blittableTypes.push_back( blittableType );
|
|---|
| 135 | }
|
|---|
| 136 | meta.blittableTypes.clear();
|
|---|
| 137 |
|
|---|
| 138 | // TypeDef
|
|---|
| 139 | BOOST_FOREACH( TypeDef &typeDef, meta.typeDefs )
|
|---|
| 140 | {
|
|---|
| 141 | typeDef.isTargetObjectModule = false;
|
|---|
| 142 | this->typeDefs.push_back( typeDef );
|
|---|
| 143 | }
|
|---|
| 144 | meta.typeDefs.clear();
|
|---|
| 145 |
|
|---|
| 146 | // 関数ポインタ
|
|---|
| 147 | BOOST_FOREACH( ProcPointer *pProcPointer, meta.procPointers )
|
|---|
| 148 | {
|
|---|
| 149 | pProcPointer->isTargetObjectModule = false;
|
|---|
| 150 | this->procPointers.push_back( pProcPointer );
|
|---|
| 151 | }
|
|---|
| 152 | meta.procPointers.PullOutAll();
|
|---|
| 153 |
|
|---|
| 154 | // デリゲート
|
|---|
| 155 | meta.GetDelegates().Iterator_Reset();
|
|---|
| 156 | while( meta.GetDelegates().Iterator_HasNext() )
|
|---|
| 157 | {
|
|---|
| 158 | Delegate *pDelegate = meta.GetDelegates().Iterator_GetNext();
|
|---|
| 159 | pDelegate->isTargetObjectModule = false;
|
|---|
| 160 | this->GetDelegates().Put( pDelegate );
|
|---|
| 161 | }
|
|---|
| 162 | meta.GetDelegates().PullOutAll();
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | const ::Delegate &Meta::ToDelegate( const CClass &_class )
|
|---|
| 166 | {
|
|---|
| 167 | const ::Delegate *dg = this->GetDelegates().GetHashArrayElement( _class.GetName().c_str() );
|
|---|
| 168 | while( dg )
|
|---|
| 169 | {
|
|---|
| 170 | if( dg->IsEqualSymbol( _class.GetNamespaceScopes(), _class.GetName() ) ){
|
|---|
| 171 | //名前空間とクラス名が一致した
|
|---|
| 172 | return *dg;
|
|---|
| 173 | }
|
|---|
| 174 | dg = dg->GetChainNext();
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | throw;
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | const CClass *Meta::FindClassSupportedTypeDef( const Symbol &symbol )
|
|---|
| 181 | {
|
|---|
| 182 | const CClass *pClass = this->GetClasses().FindEx( symbol );
|
|---|
| 183 | if( pClass )
|
|---|
| 184 | {
|
|---|
| 185 | return pClass;
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | // TypeDefも見る
|
|---|
| 189 | const TypeDef *pTypeDef = this->GetTypeDefs().Find( symbol );
|
|---|
| 190 | if( pTypeDef )
|
|---|
| 191 | {
|
|---|
| 192 | Type type = pTypeDef->GetBaseType();
|
|---|
| 193 | if( type.IsObject() )
|
|---|
| 194 | {
|
|---|
| 195 | return &type.GetClass();
|
|---|
| 196 | }
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | return NULL;
|
|---|
| 200 | }
|
|---|