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

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

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

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

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