#include "stdafx.h" void Meta::Clear() { // 名前空間 namespaceScopesCollection.clear(); // 関数・メソッド userProcs.Clear(); // DLL関数 dllProcs.Clear(); // クラス classesImpl.Clear(); // グローバル変数 globalVars.Clear(); // グローバル定数 globalConsts.Clear(); // グローバル定数マクロ globalConstMacros.Clear(); // blittable型 blittableTypes.clear(); // TypeDef typeDefs.clear(); // 関数ポインタ procPointers.Clear(); } void Meta::StaticLink( Meta &meta, long dataSectionBaseOffset, int sourceIndexBase ) { // 名前空間 BOOST_FOREACH( NamespaceScopes &namespaceScopes, meta.namespaceScopesCollection ) { if( !this->namespaceScopesCollection.IsExist( namespaceScopes ) ) { this->namespaceScopesCollection.push_back( namespaceScopes ); } } // 関数・メソッド meta.GetUserProcs().Iterator_Reset(); while( meta.GetUserProcs().Iterator_HasNext() ) { UserProc *pUserProc = meta.GetUserProcs().Iterator_GetNext(); pUserProc->isTargetObjectModule = false; pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset ); pUserProc->GetNativeCode().ResetSourceIndexes( sourceIndexBase ); this->userProcs.Put( pUserProc ); } meta.GetUserProcs().PullOutAll(); // DLL関数 meta.GetDllProcs().Iterator_Reset(); while( meta.GetDllProcs().Iterator_HasNext() ) { DllProc *pDllProc = meta.GetDllProcs().Iterator_GetNext(); pDllProc->isTargetObjectModule = false; this->dllProcs.Put( pDllProc ); } meta.GetDllProcs().PullOutAll(); // クラス meta.GetClasses().Iterator_Reset(); while( meta.GetClasses().Iterator_HasNext() ) { CClass *pClass = meta.GetClasses().Iterator_GetNext(); pClass->isTargetObjectModule = false; this->GetClasses().Put( pClass ); } meta.GetClasses().PullOutAll(); // グローバル変数 long initAreaBaseOffset = this->globalVars.initAreaBuffer.GetSize(); BOOST_FOREACH( Variable *pVar, meta.globalVars ) { // 基底スコープレベルのグローバル変数の生存値をオンにする if( pVar->GetScopeLevel() == 0 ) { pVar->isLiving = true; } bool isResetOffsetAddress = true; if( pVar->HasInitData() ) { // 初期バッファがあるときはデータテーブルオフセットを適用する pVar->SetOffsetAddress( pVar->GetOffsetAddress() + initAreaBaseOffset ); isResetOffsetAddress = false; } pVar->isTargetObjectModule = false; this->globalVars.Add( pVar, isResetOffsetAddress ); } meta.globalVars.PullOutAll(); this->globalVars.initAreaBuffer.Put( meta.globalVars.initAreaBuffer.GetBuffer(), meta.globalVars.initAreaBuffer.GetSize() ); // グローバル定数 meta.GetGlobalConsts().Iterator_Reset(); while( meta.GetGlobalConsts().Iterator_HasNext() ) { CConst *pConst = meta.GetGlobalConsts().Iterator_GetNext(); pConst->isTargetObjectModule = false; this->GetGlobalConsts().Put( pConst ); } meta.GetGlobalConsts().PullOutAll(); // グローバル定数マクロ meta.GetGlobalConstMacros().Iterator_Reset(); while( meta.GetGlobalConstMacros().Iterator_HasNext() ) { ConstMacro *pConstMacro = meta.GetGlobalConstMacros().Iterator_GetNext(); pConstMacro->isTargetObjectModule = false; this->GetGlobalConstMacros().Put( pConstMacro ); } meta.GetGlobalConstMacros().PullOutAll(); // blittable型 BOOST_FOREACH( BlittableType &blittableType, meta.blittableTypes ) { blittableType.isTargetObjectModule = false; this->blittableTypes.push_back( blittableType ); } meta.blittableTypes.clear(); // TypeDef BOOST_FOREACH( TypeDef &typeDef, meta.typeDefs ) { typeDef.isTargetObjectModule = false; this->typeDefs.push_back( typeDef ); } meta.typeDefs.clear(); // 関数ポインタ BOOST_FOREACH( ProcPointer *pProcPointer, meta.procPointers ) { pProcPointer->isTargetObjectModule = false; this->procPointers.push_back( pProcPointer ); } meta.procPointers.PullOutAll(); // デリゲート meta.GetDelegates().Iterator_Reset(); while( meta.GetDelegates().Iterator_HasNext() ) { Delegate *pDelegate = meta.GetDelegates().Iterator_GetNext(); pDelegate->isTargetObjectModule = false; this->GetDelegates().Put( pDelegate ); } meta.GetDelegates().PullOutAll(); } const ::Delegate &Meta::ToDelegate( const CClass &_class ) { const ::Delegate *dg = this->GetDelegates().GetHashArrayElement( _class.GetName().c_str() ); while( dg ) { if( dg->IsEqualSymbol( _class.GetNamespaceScopes(), _class.GetName() ) ){ //名前空間とクラス名が一致した return *dg; } dg = dg->GetChainNext(); } throw; } const CClass *Meta::FindClassSupportedTypeDef( const Symbol &symbol ) { const CClass *pClass = this->GetClasses().FindEx( symbol ); if( pClass ) { return pClass; } // TypeDefも見る const TypeDef *pTypeDef = this->GetTypeDefs().Find( symbol ); if( pTypeDef ) { Type type = pTypeDef->GetBaseType(); if( type.IsObject() ) { return &type.GetClass(); } } return NULL; }