| 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, int sourceIndexBase ) | 
|---|
| 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( sourceIndexBase ); | 
|---|
| 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 | this->GetClasses().Put( pClass ); | 
|---|
| 78 | } | 
|---|
| 79 | meta.GetClasses().PullOutAll(); | 
|---|
| 80 |  | 
|---|
| 81 | // グローバル変数 | 
|---|
| 82 | long initAreaBaseOffset = this->globalVars.initAreaBuffer.GetSize(); | 
|---|
| 83 | BOOST_FOREACH( Variable *pVar, meta.globalVars ) | 
|---|
| 84 | { | 
|---|
| 85 | // 基底スコープレベルのグローバル変数の生存値をオンにする | 
|---|
| 86 | if( pVar->GetScopeLevel() == 0 ) | 
|---|
| 87 | { | 
|---|
| 88 | pVar->isLiving = true; | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 | bool isResetOffsetAddress = true; | 
|---|
| 92 | if( pVar->HasInitData() ) | 
|---|
| 93 | { | 
|---|
| 94 | // 初期バッファがあるときはデータテーブルオフセットを適用する | 
|---|
| 95 | pVar->SetOffsetAddress( pVar->GetOffsetAddress() + initAreaBaseOffset ); | 
|---|
| 96 |  | 
|---|
| 97 | isResetOffsetAddress = false; | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|
| 100 | pVar->isTargetObjectModule = false; | 
|---|
| 101 | this->globalVars.Add( pVar, isResetOffsetAddress ); | 
|---|
| 102 | } | 
|---|
| 103 | meta.globalVars.PullOutAll(); | 
|---|
| 104 | this->globalVars.initAreaBuffer.Put( | 
|---|
| 105 | meta.globalVars.initAreaBuffer.GetBuffer(), | 
|---|
| 106 | meta.globalVars.initAreaBuffer.GetSize() | 
|---|
| 107 | ); | 
|---|
| 108 |  | 
|---|
| 109 | // グローバル定数 | 
|---|
| 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(); | 
|---|
| 118 |  | 
|---|
| 119 | // グローバル定数マクロ | 
|---|
| 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(); | 
|---|
| 128 |  | 
|---|
| 129 | // blittable型 | 
|---|
| 130 | BOOST_FOREACH( BlittableType &blittableType, meta.blittableTypes ) | 
|---|
| 131 | { | 
|---|
| 132 | blittableType.isTargetObjectModule = false; | 
|---|
| 133 | this->blittableTypes.push_back( blittableType ); | 
|---|
| 134 | } | 
|---|
| 135 | meta.blittableTypes.clear(); | 
|---|
| 136 |  | 
|---|
| 137 | // TypeDef | 
|---|
| 138 | BOOST_FOREACH( TypeDef &typeDef, meta.typeDefs ) | 
|---|
| 139 | { | 
|---|
| 140 | typeDef.isTargetObjectModule = false; | 
|---|
| 141 | this->typeDefs.push_back( typeDef ); | 
|---|
| 142 | } | 
|---|
| 143 | meta.typeDefs.clear(); | 
|---|
| 144 |  | 
|---|
| 145 | // 関数ポインタ | 
|---|
| 146 | BOOST_FOREACH( ProcPointer *pProcPointer, meta.procPointers ) | 
|---|
| 147 | { | 
|---|
| 148 | pProcPointer->isTargetObjectModule = false; | 
|---|
| 149 | this->procPointers.push_back( pProcPointer ); | 
|---|
| 150 | } | 
|---|
| 151 | meta.procPointers.PullOutAll(); | 
|---|
| 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(); | 
|---|
| 162 | } | 
|---|
| 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 | } | 
|---|
| 178 |  | 
|---|
| 179 | const CClass *Meta::FindClassSupportedTypeDef( const Symbol &symbol ) | 
|---|
| 180 | { | 
|---|
| 181 | const CClass *pClass = this->GetClasses().FindEx( symbol ); | 
|---|
| 182 | if( pClass ) | 
|---|
| 183 | { | 
|---|
| 184 | return pClass; | 
|---|
| 185 | } | 
|---|
| 186 |  | 
|---|
| 187 | // TypeDefも見る | 
|---|
| 188 | int index = this->GetTypeDefs().GetIndex( symbol ); | 
|---|
| 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 | } | 
|---|