source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/Meta.cpp @ 632

Last change on this file since 632 was 632, checked in by dai_9181, 15 years ago

ジェネリッククラスの型パラメータに値型が指定されたときに限り、テンプレート展開を行うようにした。

TODO: libファイルを跨ってテンプレート展開ができていないため、ソースコード管理部分に手を加える必要あり。

File size: 4.9 KB
Line 
1#include "stdafx.h"
2
3void 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
36void 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
164const ::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
179const 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    const TypeDef *pTypeDef = this->GetTypeDefs().Find( symbol );
189    if( pTypeDef )
190    {
191        Type type = pTypeDef->GetBaseType();
192        if( type.IsObject() )
193        {
194            return &type.GetClass();
195        }
196    }
197
198    return NULL;
199}
Note: See TracBrowser for help on using the repository browser.