source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/Procedure.cpp@ 637

Last change on this file since 637 was 637, checked in by dai_9181, 16 years ago

リンカの依存関係解決モジュールを製作中

File size: 4.9 KB
Line 
1#include "stdafx.h"
2
3
4void Procedure::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
5{
6 RelationalObjectModuleItem::ResetRelationalObjectModuleIndex( relationTable );
7
8 if( !this->sourceCodePosition.IsNothing() )
9 {
10 this->sourceCodePosition.SetRelationalObjectModuleIndex( relationTable[this->sourceCodePosition.GetRelationalObjectModuleIndex()] );
11 }
12}
13
14void UserProc::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
15{
16 Procedure::ResetRelationalObjectModuleIndex( relationTable );
17
18 this->GetNativeCode().ResetRelationalObjectModuleIndex( relationTable );
19}
20
21int id_base = 0;
22
23UserProc::UserProc( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces, Kind kind, bool isMacro, bool isCdecl, bool isExport )
24 : Procedure( symbol, kind, isCdecl )
25 , importedNamespaces( importedNamespaces )
26 , pParentClass( NULL )
27 , pInterface( NULL )
28 , pMethod( NULL )
29 , isMacro( isMacro )
30 , secondParmNum( 0 )
31 , realSecondParmNum( 1 )
32 , isExport( isExport )
33 , isSystem( false )
34 , isAutoGeneration( false )
35 , isCompiled( false )
36 , beginOpAddress( 0 )
37 , endOpAddress( 0 )
38 , id( id_base ++ )
39{
40}
41
42UserProc::UserProc( const UserProc &userProc, const CClass *pParentClass )
43 : Procedure( userProc )
44 , _paramStr( userProc._paramStr )
45 , importedNamespaces( userProc.importedNamespaces )
46 , pParentClass( pParentClass )
47 , pInterface( NULL )
48 , pMethod( NULL )
49 , isMacro( userProc.isMacro )
50 , secondParmNum( userProc.secondParmNum )
51 , realParams( userProc.realParams )
52 , realSecondParmNum( userProc.realSecondParmNum )
53 , isExport( userProc.isExport )
54 , isSystem( userProc.isSystem )
55 , isAutoGeneration( userProc.isAutoGeneration )
56 , isCompiled( false )
57 , beginOpAddress( 0 )
58 , endOpAddress( 0 )
59 , localVars( Variables() )
60 , id( id_base ++ )
61 , nativeCode( NativeCode() )
62{
63}
64
65UserProc::UserProc()
66{
67}
68
69UserProc::~UserProc()
70{
71 BOOST_FOREACH( Parameter *pParam, realParams ){
72 delete pParam;
73 }
74}
75
76bool UserProc::IsEqualForOverride( const Types &actualTypeParametersForThisProc, const UserProc *pUserProc ) const
77{
78 if( this->GetName() == pUserProc->GetName() // 名前空間及び名前が等しい
79 && this->Params().Equals( actualTypeParametersForThisProc, pUserProc->Params() ) ) // パラメータが等しい
80 {
81 if( this->returnType.Equals( pUserProc->returnType ) )
82 {
83 // 戻り値が等しい
84 return true;
85 }
86 else if( this->returnType.IsCovariant( pUserProc->returnType ) )
87 {
88 // 戻り値が共変
89 return true;
90 }
91 else if( this->returnType.IsTypeParameter() )
92 {
93 // 型パラメータだったとき
94
95 if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].Equals( pUserProc->returnType ) )
96 {
97 // 戻り値が等しい
98 return true;
99 }
100 else if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].IsCovariant( pUserProc->returnType ) )
101 {
102 // 戻り値が共変
103 return true;
104 }
105 }
106 }
107 return false;
108}
109
110
111std::string UserProc::GetFullName() const
112{
113 if( HasParentClass() ){
114 return GetParentClass().GetName() + "." + GetName();
115 }
116
117 return GetName();
118}
119bool UserProc::IsCastOperator() const
120{
121 if( GetName()[0] == 1 && GetName()[1] == ESC_OPERATOR && GetName()[2] == CALC_AS )
122 {
123 return true;
124 }
125 return false;
126}
127const NamespaceScopes &UserProc::GetNamespaceScopes() const
128{
129 if( HasParentClass() )
130 {
131 return GetParentClassPtr()->GetNamespaceScopes();
132 }
133 return Symbol::GetNamespaceScopes();
134}
135const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
136{
137 if( pParentClass )
138 {
139 return pParentClass->GetImportedNamespaces();
140 }
141 return importedNamespaces;
142}
143bool UserProc::IsVirtual() const
144{
145 if( pMethod == NULL ){
146 return false;
147 }
148 return ( pMethod->IsVirtual() != 0 );
149}
150const CMethod &UserProc::GetMethod() const
151{
152 if( !HasParentClass() )
153 {
154 Jenga::Throw( "グローバル関数に対してUserProc::GetMethodメソッドが呼ばれた" );
155 }
156 return *pMethod;
157}
158
159bool UserProc::Resolve()
160{
161 // TODO: Resolve
162 return true;
163}
164
165const UserProc *UserProc::pGlobalProc = NULL;
166
167
168void UserProcs::EnumGlobalProcs( const char *simpleName, const Symbol &localSymbol, std::vector<const UserProc *> &subs )
169{
170 ///////////////////////////
171 // グローバル関数を検索
172 ///////////////////////////
173
174 // ハッシュ値を取得
175 UserProc *pUserProc = GetHashArrayElement( simpleName );
176 while(pUserProc){
177 if( pUserProc->IsGlobalProcedure() ){
178 if( pUserProc->IsEqualSymbol( localSymbol ) ){
179 subs.push_back( pUserProc );
180 }
181 }
182
183 pUserProc=pUserProc->GetChainNext();
184 }
185}
186
187bool DllProc::Resolve()
188{
189 // TODO: Resolve
190 return true;
191}
192
193bool ProcPointer::Resolve()
194{
195 // TODO: Resolve
196 return true;
197}
198
199void ProcPointers::Clear()
200{
201 ProcPointers &procPointers = *this;
202 BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){
203 delete pProcPointer;
204 }
205 this->clear();
206}
Note: See TracBrowser for help on using the repository browser.