[270] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[272] | 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 |
|
---|
[280] | 36 | void Meta::StaticLink( Meta &meta, long dataSectionBaseOffset, int sourceIndexBase )
|
---|
[270] | 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;
|
---|
[273] | 53 |
|
---|
| 54 | pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset );
|
---|
[280] | 55 | pUserProc->GetNativeCode().ResetSourceIndexes( sourceIndexBase );
|
---|
[273] | 56 |
|
---|
[270] | 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 | // クラス
|
---|
[271] | 72 | meta.GetClasses().Iterator_Reset();
|
---|
| 73 | while( meta.GetClasses().Iterator_HasNext() )
|
---|
| 74 | {
|
---|
| 75 | CClass *pClass = meta.GetClasses().Iterator_GetNext();
|
---|
| 76 | pClass->isTargetObjectModule = false;
|
---|
| 77 | this->GetClasses().Put( pClass );
|
---|
| 78 | }
|
---|
| 79 | meta.GetClasses().PullOutAll();
|
---|
[270] | 80 |
|
---|
| 81 | // グローバル変数
|
---|
[288] | 82 | long initAreaBaseOffset = this->globalVars.initAreaBuffer.GetSize();
|
---|
[271] | 83 | BOOST_FOREACH( Variable *pVar, meta.globalVars )
|
---|
| 84 | {
|
---|
[283] | 85 | // 基底スコープレベルのグローバル変数の生存値をオンにする
|
---|
| 86 | if( pVar->GetScopeLevel() == 0 )
|
---|
| 87 | {
|
---|
[392] | 88 | pVar->isLiving = true;
|
---|
[283] | 89 | }
|
---|
| 90 |
|
---|
[287] | 91 | bool isResetOffsetAddress = true;
|
---|
| 92 | if( pVar->HasInitData() )
|
---|
| 93 | {
|
---|
| 94 | // 初期バッファがあるときはデータテーブルオフセットを適用する
|
---|
[288] | 95 | pVar->SetOffsetAddress( pVar->GetOffsetAddress() + initAreaBaseOffset );
|
---|
[287] | 96 |
|
---|
| 97 | isResetOffsetAddress = false;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
[271] | 100 | pVar->isTargetObjectModule = false;
|
---|
[287] | 101 | this->globalVars.Add( pVar, isResetOffsetAddress );
|
---|
[271] | 102 | }
|
---|
| 103 | meta.globalVars.PullOutAll();
|
---|
[288] | 104 | this->globalVars.initAreaBuffer.Put(
|
---|
| 105 | meta.globalVars.initAreaBuffer.GetBuffer(),
|
---|
| 106 | meta.globalVars.initAreaBuffer.GetSize()
|
---|
| 107 | );
|
---|
[270] | 108 |
|
---|
| 109 | // グローバル定数
|
---|
[271] | 110 | meta.GetGlobalConsts().Iterator_Reset();
|
---|
| 111 | while( meta.GetGlobalConsts().Iterator_HasNext() )
|
---|
| 112 | {
|
---|
| 113 | CConst *pConst = meta.GetGlobalConsts().Iterator_GetNext();
|
---|
| 114 | pConst->isTargetObjectModule = false;
|
---|
| 115 | this->GetGlobalConsts().Put( pConst );
|
---|
| 116 | }
|
---|
| 117 | meta.GetGlobalConsts().PullOutAll();
|
---|
[270] | 118 |
|
---|
| 119 | // グローバル定数マクロ
|
---|
[271] | 120 | meta.GetGlobalConstMacros().Iterator_Reset();
|
---|
| 121 | while( meta.GetGlobalConstMacros().Iterator_HasNext() )
|
---|
| 122 | {
|
---|
| 123 | ConstMacro *pConstMacro = meta.GetGlobalConstMacros().Iterator_GetNext();
|
---|
| 124 | pConstMacro->isTargetObjectModule = false;
|
---|
| 125 | this->GetGlobalConstMacros().Put( pConstMacro );
|
---|
| 126 | }
|
---|
| 127 | meta.GetGlobalConstMacros().PullOutAll();
|
---|
[270] | 128 |
|
---|
| 129 | // blittable型
|
---|
[271] | 130 | BOOST_FOREACH( BlittableType &blittableType, meta.blittableTypes )
|
---|
| 131 | {
|
---|
| 132 | blittableType.isTargetObjectModule = false;
|
---|
| 133 | this->blittableTypes.push_back( blittableType );
|
---|
| 134 | }
|
---|
| 135 | meta.blittableTypes.clear();
|
---|
[270] | 136 |
|
---|
| 137 | // TypeDef
|
---|
[271] | 138 | BOOST_FOREACH( TypeDef &typeDef, meta.typeDefs )
|
---|
| 139 | {
|
---|
| 140 | typeDef.isTargetObjectModule = false;
|
---|
| 141 | this->typeDefs.push_back( typeDef );
|
---|
| 142 | }
|
---|
| 143 | meta.typeDefs.clear();
|
---|
[270] | 144 |
|
---|
| 145 | // 関数ポインタ
|
---|
[271] | 146 | BOOST_FOREACH( ProcPointer *pProcPointer, meta.procPointers )
|
---|
| 147 | {
|
---|
| 148 | pProcPointer->isTargetObjectModule = false;
|
---|
| 149 | this->procPointers.push_back( pProcPointer );
|
---|
| 150 | }
|
---|
| 151 | meta.procPointers.PullOutAll();
|
---|
[448] | 152 |
|
---|
| 153 | // デリゲート
|
---|
| 154 | meta.GetDelegates().Iterator_Reset();
|
---|
| 155 | while( meta.GetDelegates().Iterator_HasNext() )
|
---|
| 156 | {
|
---|
| 157 | Delegate *pDelegate = meta.GetDelegates().Iterator_GetNext();
|
---|
| 158 | pDelegate->isTargetObjectModule = false;
|
---|
| 159 | this->GetDelegates().Put( pDelegate );
|
---|
| 160 | }
|
---|
| 161 | meta.GetDelegates().PullOutAll();
|
---|
[270] | 162 | }
|
---|
[562] | 163 |
|
---|
| 164 | const ::Delegate &Meta::ToDelegate( const CClass &_class )
|
---|
| 165 | {
|
---|
| 166 | const ::Delegate *dg = this->GetDelegates().GetHashArrayElement( _class.GetName().c_str() );
|
---|
| 167 | while( dg )
|
---|
| 168 | {
|
---|
| 169 | if( dg->IsEqualSymbol( _class.GetNamespaceScopes(), _class.GetName() ) ){
|
---|
| 170 | //名前空間とクラス名が一致した
|
---|
| 171 | return *dg;
|
---|
| 172 | }
|
---|
| 173 | dg = dg->GetChainNext();
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | throw;
|
---|
| 177 | }
|
---|
[566] | 178 |
|
---|
[598] | 179 | const CClass *Meta::FindClassSupportedTypeDef( const Symbol &symbol )
|
---|
[566] | 180 | {
|
---|
[598] | 181 | const CClass *pClass = this->GetClasses().FindEx( symbol );
|
---|
[566] | 182 | if( pClass )
|
---|
| 183 | {
|
---|
| 184 | return pClass;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | // TypeDefも見る
|
---|
[598] | 188 | int index = this->GetTypeDefs().GetIndex( symbol );
|
---|
[566] | 189 | if( index != -1 ){
|
---|
| 190 | Type type = this->GetTypeDefs()[index].GetBaseType();
|
---|
| 191 | if( type.IsObject() ){
|
---|
| 192 | return &type.GetClass();
|
---|
| 193 | }
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | return NULL;
|
---|
| 197 | }
|
---|