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

Last change on this file since 829 was 829, checked in by イグトランス (egtra), 12 years ago

svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain; charset=Shift_JIS
File size: 6.3 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, const std::vector<int> &relationTable )
37{
38 // 名前空間
39 foreach (NamespaceScopes const &namespaceScopes, meta.namespaceScopesCollection)
40 {
41 if( !this->namespaceScopesCollection.IsExist( namespaceScopes ) )
42 {
43 this->namespaceScopesCollection.push_back( namespaceScopes );
44 }
45 }
46
47 // 関数・メソッド
48 foreach (auto pUserProc, meta.GetUserProcs())
49 {
50 if( pUserProc->IsExternal() )
51 {
52 // 外部参照の場合は取り込まない
53 continue;
54 }
55
56 pUserProc->ResetRelationalObjectModuleIndex( relationTable );
57
58 pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset );
59
60 this->userProcs.Put( pUserProc );
61 }
62 meta.GetUserProcs().PullOutAll();
63
64 // DLL関数
65 foreach (auto pDllProc, meta.GetDllProcs())
66 {
67 if( pDllProc->IsExternal() )
68 {
69 // 外部参照の場合は取り込まない
70 continue;
71 }
72
73 pDllProc->ResetRelationalObjectModuleIndex( relationTable );
74 this->dllProcs.Put( pDllProc );
75 }
76 meta.GetDllProcs().PullOutAll();
77
78 // クラス
79 foreach (auto pClass, meta.GetClasses())
80 {
81 if( pClass->IsExternal() )
82 {
83 // 外部参照の場合は取り込まない
84 continue;
85 }
86
87 pClass->ResetRelationalObjectModuleIndex( relationTable );
88 pClass->Readed();
89 this->GetClasses().Put( pClass );
90 }
91 meta.GetClasses().PullOutAll();
92
93 // グローバル変数
94 long initAreaBaseOffset = this->globalVars.initAreaBuffer.GetSize();
95 foreach( Variable *pVar, meta.globalVars )
96 {
97 if( pVar->IsExternal() )
98 {
99 // 外部参照の場合は取り込まない
100 continue;
101 }
102
103 // 基底スコープレベルのグローバル変数の生存値をオンにする
104 if( pVar->GetScopeLevel() == 0 )
105 {
106 pVar->isLiving = true;
107 }
108
109 bool isResetOffsetAddress = true;
110 if( pVar->HasInitData() )
111 {
112 // 初期バッファがあるときはデータテーブルオフセットを適用する
113 pVar->SetOffsetAddress( pVar->GetOffsetAddress() + initAreaBaseOffset );
114
115 isResetOffsetAddress = false;
116 }
117
118 pVar->ResetRelationalObjectModuleIndex( relationTable );
119 this->globalVars.Add( pVar, isResetOffsetAddress );
120 }
121 meta.globalVars.PullOutAll();
122 this->globalVars.initAreaBuffer.Put(
123 meta.globalVars.initAreaBuffer.GetBuffer(),
124 meta.globalVars.initAreaBuffer.GetSize()
125 );
126
127 // グローバル定数
128 foreach (auto pConst, meta.GetGlobalConsts())
129 {
130 if( pConst->IsExternal() )
131 {
132 // 外部参照の場合は取り込まない
133 continue;
134 }
135
136 pConst->ResetRelationalObjectModuleIndex( relationTable );
137 this->GetGlobalConsts().Put( pConst );
138 }
139 meta.GetGlobalConsts().PullOutAll();
140
141 // グローバル定数マクロ
142 foreach (auto pConstMacro, meta.GetGlobalConstMacros())
143 {
144 if( pConstMacro->IsExternal() )
145 {
146 // 外部参照の場合は取り込まない
147 continue;
148 }
149
150 pConstMacro->ResetRelationalObjectModuleIndex( relationTable );
151 this->GetGlobalConstMacros().Put( pConstMacro );
152 }
153 meta.GetGlobalConstMacros().PullOutAll();
154
155 // blittable型
156 BOOST_FOREACH( BlittableType &blittableType, meta.blittableTypes )
157 {
158 // TODO: coreモジュール以外でもBlittable型用のクラスモジュールを定義できるようにすべき
159 this->blittableTypes.push_back( blittableType );
160 }
161 meta.blittableTypes.clear();
162
163 // TypeDef
164 BOOST_FOREACH( TypeDef &typeDef, meta.typeDefs )
165 {
166 if( typeDef.IsExternal() )
167 {
168 // 外部参照の場合は取り込まない
169 continue;
170 }
171
172 typeDef.ResetRelationalObjectModuleIndex( relationTable );
173 this->typeDefs.push_back( typeDef );
174 }
175 meta.typeDefs.clear();
176
177 // 関数ポインタ
178 foreach( ProcPointer *pProcPointer, meta.procPointers )
179 {
180 if( pProcPointer->IsExternal() )
181 {
182 // 外部参照の場合は取り込まない
183 continue;
184 }
185
186 pProcPointer->ResetRelationalObjectModuleIndex( relationTable );
187 this->procPointers.push_back( pProcPointer );
188 }
189 meta.procPointers.PullOutAll();
190
191 // デリゲート
192 foreach (auto pDelegate, meta.GetDelegates())
193 {
194 if( pDelegate->IsExternal() )
195 {
196 // 外部参照の場合は取り込まない
197 continue;
198 }
199
200 pDelegate->ResetRelationalObjectModuleIndex( relationTable );
201 this->GetDelegates().Put( pDelegate );
202 }
203 meta.GetDelegates().PullOutAll();
204}
205
206const ::Delegate &Meta::ToDelegate( const CClass &_class )
207{
208 auto dg = this->GetDelegates().GetHashArrayElement(_class.GetName());
209 foreach (auto t, dg)
210 {
211 if( t->IsEqualSymbol( _class.GetNamespaceScopes(), _class.GetName() ) ){
212 //名前空間とクラス名が一致した
213 return *t;
214 }
215 }
216
217 throw std::runtime_error("Meta::ToDelegate");
218}
219
220const CClass *Meta::FindClassSupportedTypeDef( const Symbol &symbol )
221{
222 const CClass *pClass = this->GetClasses().FindEx( symbol );
223 if( pClass )
224 {
225 return pClass;
226 }
227
228 // TypeDefも見る
229 const TypeDef *pTypeDef = this->GetTypeDefs().Find( symbol );
230 if( pTypeDef )
231 {
232 Type type = pTypeDef->GetBaseType();
233 if( type.IsObject() )
234 {
235 return &type.GetClass();
236 }
237 }
238
239 return NULL;
240}
241
242void Meta::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
243{
244 // 関数・メソッド
245 foreach (auto pUserProc, this->GetUserProcs())
246 {
247 pUserProc->Resolve( resolver, resolveErrors );
248 }
249
250 // DLL関数
251 foreach (auto pDllProc, this->GetDllProcs())
252 {
253 pDllProc->Resolve( resolver, resolveErrors );
254 }
255
256 // クラス
257 foreach (auto pClass, this->GetClasses())
258 {
259 pClass->Resolve( resolver, resolveErrors );
260 }
261
262 // グローバル変数
263 foreach( Variable *pVar, globalVars )
264 {
265 pVar->Resolve( resolver, resolveErrors );
266 }
267
268 // グローバル定数
269 foreach (auto pConst, this->GetGlobalConsts())
270 {
271 pConst->Resolve( resolver, resolveErrors );
272 }
273
274 // グローバル定数マクロ
275 foreach (auto pConstMacro, this->GetGlobalConstMacros())
276 {
277 pConstMacro->Resolve( resolver, resolveErrors );
278 }
279
280 // blittable型
281 BOOST_FOREACH( BlittableType &blittableType, blittableTypes )
282 {
283 blittableType.Resolve( resolver, resolveErrors );
284 }
285
286 // TypeDef
287 BOOST_FOREACH( TypeDef &typeDef, typeDefs )
288 {
289 typeDef.Resolve( resolver, resolveErrors );
290 }
291
292 // 関数ポインタ
293 foreach( ProcPointer *pProcPointer, procPointers )
294 {
295 pProcPointer->Resolve( resolver, resolveErrors );
296 }
297
298 // デリゲート
299 foreach (auto pDelegate, this->GetDelegates())
300 {
301 pDelegate->Resolve( resolver, resolveErrors );
302 }
303}
Note: See TracBrowser for help on using the repository browser.