| 1 | #include "stdafx.h"
 | 
|---|
| 2 | 
 | 
|---|
| 3 | #include <Compiler.h>
 | 
|---|
| 4 | 
 | 
|---|
| 5 | void Meta::Clear()
 | 
|---|
| 6 | {
 | 
|---|
| 7 |     // 名前空間
 | 
|---|
| 8 |     namespaceScopesCollection.clear();
 | 
|---|
| 9 | 
 | 
|---|
| 10 |     // 関数・メソッド
 | 
|---|
| 11 |     userProcs.Clear();
 | 
|---|
| 12 | 
 | 
|---|
| 13 |     // DLL関数
 | 
|---|
| 14 |     dllProcs.Clear();
 | 
|---|
| 15 | 
 | 
|---|
| 16 |     // クラス
 | 
|---|
| 17 |     classesImpl.Clear();
 | 
|---|
| 18 | 
 | 
|---|
| 19 |     // グローバル変数
 | 
|---|
| 20 |     globalVars.Clear();
 | 
|---|
| 21 | 
 | 
|---|
| 22 |     // グローバル定数
 | 
|---|
| 23 |     globalConsts.Clear();
 | 
|---|
| 24 | 
 | 
|---|
| 25 |     // グローバル定数マクロ
 | 
|---|
| 26 |     globalConstMacros.Clear();
 | 
|---|
| 27 | 
 | 
|---|
| 28 |     // blittable型
 | 
|---|
| 29 |     blittableTypes.clear();
 | 
|---|
| 30 | 
 | 
|---|
| 31 |     // TypeDef
 | 
|---|
| 32 |     typeDefs.clear();
 | 
|---|
| 33 | 
 | 
|---|
| 34 |     // 関数ポインタ
 | 
|---|
| 35 |     procPointers.Clear();
 | 
|---|
| 36 | }
 | 
|---|
| 37 | 
 | 
|---|
| 38 | void Meta::StaticLink( Meta &meta, long dataSectionBaseOffset, int sourceIndexBase )
 | 
|---|
| 39 | {
 | 
|---|
| 40 |     // 名前空間
 | 
|---|
| 41 |     BOOST_FOREACH( NamespaceScopes &namespaceScopes, meta.namespaceScopesCollection )
 | 
|---|
| 42 |     {
 | 
|---|
| 43 |         if( !this->namespaceScopesCollection.IsExist( namespaceScopes ) )
 | 
|---|
| 44 |         {
 | 
|---|
| 45 |             this->namespaceScopesCollection.push_back( namespaceScopes );
 | 
|---|
| 46 |         }
 | 
|---|
| 47 |     }
 | 
|---|
| 48 | 
 | 
|---|
| 49 |     // 関数・メソッド
 | 
|---|
| 50 |     meta.GetUserProcs().Iterator_Reset();
 | 
|---|
| 51 |     while( meta.GetUserProcs().Iterator_HasNext() )
 | 
|---|
| 52 |     {
 | 
|---|
| 53 |         UserProc *pUserProc = meta.GetUserProcs().Iterator_GetNext();
 | 
|---|
| 54 |         pUserProc->isTargetObjectModule = false;
 | 
|---|
| 55 | 
 | 
|---|
| 56 |         pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset );
 | 
|---|
| 57 |         pUserProc->GetNativeCode().ResetSourceIndexes( sourceIndexBase );
 | 
|---|
| 58 | 
 | 
|---|
| 59 |         this->userProcs.Put( pUserProc );
 | 
|---|
| 60 |     }
 | 
|---|
| 61 |     meta.GetUserProcs().PullOutAll();
 | 
|---|
| 62 | 
 | 
|---|
| 63 |     // DLL関数
 | 
|---|
| 64 |     meta.GetDllProcs().Iterator_Reset();
 | 
|---|
| 65 |     while( meta.GetDllProcs().Iterator_HasNext() )
 | 
|---|
| 66 |     {
 | 
|---|
| 67 |         DllProc *pDllProc = meta.GetDllProcs().Iterator_GetNext();
 | 
|---|
| 68 |         pDllProc->isTargetObjectModule = false;
 | 
|---|
| 69 |         this->dllProcs.Put( pDllProc );
 | 
|---|
| 70 |     }
 | 
|---|
| 71 |     meta.GetDllProcs().PullOutAll();
 | 
|---|
| 72 | 
 | 
|---|
| 73 |     // クラス
 | 
|---|
| 74 |     meta.GetClasses().Iterator_Reset();
 | 
|---|
| 75 |     while( meta.GetClasses().Iterator_HasNext() )
 | 
|---|
| 76 |     {
 | 
|---|
| 77 |         CClass *pClass = meta.GetClasses().Iterator_GetNext();
 | 
|---|
| 78 |         pClass->isTargetObjectModule = false;
 | 
|---|
| 79 |         this->GetClasses().Put( pClass );
 | 
|---|
| 80 |     }
 | 
|---|
| 81 |     meta.GetClasses().PullOutAll();
 | 
|---|
| 82 | 
 | 
|---|
| 83 |     // グローバル変数
 | 
|---|
| 84 |     long initAreaBaseOffset = this->globalVars.initAreaBuffer.GetSize();
 | 
|---|
| 85 |     BOOST_FOREACH( Variable *pVar, meta.globalVars )
 | 
|---|
| 86 |     {
 | 
|---|
| 87 |         // 基底スコープレベルのグローバル変数の生存値をオンにする
 | 
|---|
| 88 |         if( pVar->GetScopeLevel() == 0 )
 | 
|---|
| 89 |         {
 | 
|---|
| 90 |             pVar->isLiving = true;
 | 
|---|
| 91 |         }
 | 
|---|
| 92 | 
 | 
|---|
| 93 |         bool isResetOffsetAddress = true;
 | 
|---|
| 94 |         if( pVar->HasInitData() )
 | 
|---|
| 95 |         {
 | 
|---|
| 96 |             // 初期バッファがあるときはデータテーブルオフセットを適用する
 | 
|---|
| 97 |             pVar->SetOffsetAddress( pVar->GetOffsetAddress() + initAreaBaseOffset );
 | 
|---|
| 98 | 
 | 
|---|
| 99 |             isResetOffsetAddress = false;
 | 
|---|
| 100 |         }
 | 
|---|
| 101 | 
 | 
|---|
| 102 |         pVar->isTargetObjectModule = false;
 | 
|---|
| 103 |         this->globalVars.Add( pVar, isResetOffsetAddress );
 | 
|---|
| 104 |     }
 | 
|---|
| 105 |     meta.globalVars.PullOutAll();
 | 
|---|
| 106 |     this->globalVars.initAreaBuffer.Put(
 | 
|---|
| 107 |         meta.globalVars.initAreaBuffer.GetBuffer(),
 | 
|---|
| 108 |         meta.globalVars.initAreaBuffer.GetSize()
 | 
|---|
| 109 |     );
 | 
|---|
| 110 | 
 | 
|---|
| 111 |     // グローバル定数
 | 
|---|
| 112 |     meta.GetGlobalConsts().Iterator_Reset();
 | 
|---|
| 113 |     while( meta.GetGlobalConsts().Iterator_HasNext() )
 | 
|---|
| 114 |     {
 | 
|---|
| 115 |         CConst *pConst = meta.GetGlobalConsts().Iterator_GetNext();
 | 
|---|
| 116 |         pConst->isTargetObjectModule = false;
 | 
|---|
| 117 |         this->GetGlobalConsts().Put( pConst );
 | 
|---|
| 118 |     }
 | 
|---|
| 119 |     meta.GetGlobalConsts().PullOutAll();
 | 
|---|
| 120 | 
 | 
|---|
| 121 |     // グローバル定数マクロ
 | 
|---|
| 122 |     meta.GetGlobalConstMacros().Iterator_Reset();
 | 
|---|
| 123 |     while( meta.GetGlobalConstMacros().Iterator_HasNext() )
 | 
|---|
| 124 |     {
 | 
|---|
| 125 |         ConstMacro *pConstMacro = meta.GetGlobalConstMacros().Iterator_GetNext();
 | 
|---|
| 126 |         pConstMacro->isTargetObjectModule = false;
 | 
|---|
| 127 |         this->GetGlobalConstMacros().Put( pConstMacro );
 | 
|---|
| 128 |     }
 | 
|---|
| 129 |     meta.GetGlobalConstMacros().PullOutAll();
 | 
|---|
| 130 | 
 | 
|---|
| 131 |     // blittable型
 | 
|---|
| 132 |     BOOST_FOREACH( BlittableType &blittableType, meta.blittableTypes )
 | 
|---|
| 133 |     {
 | 
|---|
| 134 |         blittableType.isTargetObjectModule = false;
 | 
|---|
| 135 |         this->blittableTypes.push_back( blittableType );
 | 
|---|
| 136 |     }
 | 
|---|
| 137 |     meta.blittableTypes.clear();
 | 
|---|
| 138 | 
 | 
|---|
| 139 |     // TypeDef
 | 
|---|
| 140 |     BOOST_FOREACH( TypeDef &typeDef, meta.typeDefs )
 | 
|---|
| 141 |     {
 | 
|---|
| 142 |         typeDef.isTargetObjectModule = false;
 | 
|---|
| 143 |         this->typeDefs.push_back( typeDef );
 | 
|---|
| 144 |     }
 | 
|---|
| 145 |     meta.typeDefs.clear();
 | 
|---|
| 146 | 
 | 
|---|
| 147 |     // 関数ポインタ
 | 
|---|
| 148 |     BOOST_FOREACH( ProcPointer *pProcPointer, meta.procPointers )
 | 
|---|
| 149 |     {
 | 
|---|
| 150 |         pProcPointer->isTargetObjectModule = false;
 | 
|---|
| 151 |         this->procPointers.push_back( pProcPointer );
 | 
|---|
| 152 |     }
 | 
|---|
| 153 |     meta.procPointers.PullOutAll();
 | 
|---|
| 154 | }
 | 
|---|