Changeset 50 in dev for BasicCompiler_Common/hash.cpp
- Timestamp:
- Feb 10, 2007, 5:44:58 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/hash.cpp
r47 r50 53 53 } 54 54 55 SUBINFO **GetOverloadObjectSubHash(char *name,CClass *pobj_c, int *pNum){ 56 int i; 57 58 59 //格納のための構造体配列を用意 60 extern HANDLE hHeap; 61 SUBINFO **ppArray_si; 62 int num=0; 63 ppArray_si=(SUBINFO **)HeapAlloc(hHeap,0,sizeof(SUBINFO *)*1024); 64 65 66 //オブジェクトのメンバ関数の場合 67 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う 68 for(i=pobj_c->iMethodNum-1;i>=0;i--){ 69 if(lstrcmp(name,pobj_c->ppobj_Method[i]->psi->name)==0){ 70 ppArray_si[num]=pobj_c->ppobj_Method[i]->psi; 71 num++; 72 } 73 } 74 75 *pNum=num; 76 return ppArray_si; 77 } 78 79 SUBINFO **GetOverloadSubHash( const char *lpszName, int *pNum ){ 55 void GetOverloadSubHash( const char *lpszName, std::vector<SUBINFO *> &subs ){ 80 56 extern SUBINFO *pSubInfo; 81 57 extern int SubInfoNum; … … 90 66 } 91 67 else lstrcpy(name,lpszName); 92 93 94 //格納のための構造体配列を用意95 extern HANDLE hHeap;96 SUBINFO **ppArray_si;97 int num=0;98 ppArray_si=(SUBINFO **)HeapAlloc(hHeap,0,sizeof(SUBINFO *)*1024);99 68 100 69 … … 122 91 } 123 92 else{ 124 goto finish;93 return; 125 94 } 126 95 } … … 129 98 if( isStatic ){ 130 99 // 静的メソッドから取得 131 for(i=0;i<pobj_c->iStaticMethodNum;i++){ 132 if(lstrcmp(NestMember,pobj_c->ppobj_StaticMethod[i]->psi->name)==0){ 133 ppArray_si[num]=pobj_c->ppobj_StaticMethod[i]->psi; 134 num++; 135 } 136 } 100 pobj_c->EnumStaticMethod( NestMember, subs ); 137 101 } 138 102 else{ … … 142 106 for(i=pobj_c->iMethodNum-1;i>=0;i--){ 143 107 if(lstrcmp(NestMember,pobj_c->ppobj_Method[i]->psi->name)==0){ 144 ppArray_si[num]=pobj_c->ppobj_Method[i]->psi; 145 num++; 108 subs.push_back( pobj_c->ppobj_Method[i]->psi ); 146 109 } 147 110 } … … 161 124 CClass *pobj_c = pobj_CompilingClass; 162 125 163 for(i=0;i<pobj_c->iStaticMethodNum;i++){ 164 if(lstrcmp(name,pobj_c->ppobj_StaticMethod[i]->psi->name)==0){ 165 ppArray_si[num]=pobj_c->ppobj_StaticMethod[i]->psi; 166 num++; 167 } 168 } 126 pobj_c->EnumStaticMethod( NestMember, subs ); 169 127 170 128 … … 178 136 for(;i<pobj_CompilingClass->iMethodNum;i++){ 179 137 if(lstrcmp(name,pobj_CompilingClass->ppobj_Method[i]->psi->name)==0){ 180 ppArray_si[num]=pobj_CompilingClass->ppobj_Method[i]->psi; 181 num++; 138 subs.push_back( pobj_CompilingClass->ppobj_Method[i]->psi ); 182 139 } 183 140 } … … 188 145 if(pobj_CompilingClass->ppobj_Method[i]->pobj_InheritsClass){ 189 146 if(lstrcmp(name,pobj_CompilingClass->ppobj_Method[i]->psi->name)==0){ 190 ppArray_si[num]=pobj_CompilingClass->ppobj_Method[i]->psi; 191 num++; 147 subs.push_back( pobj_CompilingClass->ppobj_Method[i]->psi ); 192 148 } 193 149 } … … 211 167 if(!psi->pobj_ParentClass){ 212 168 if(lstrcmp(psi->name,name)==0){ 213 ppArray_si[num]=psi; 214 num++; 169 subs.push_back( psi ); 215 170 } 216 171 } … … 220 175 221 176 } 222 finish:223 224 *pNum=num;225 return ppArray_si;226 177 } 227 178 228 179 //オーバーロードされていない関数を取得(昔のコンパイラソースコードとの互換性保持) 229 180 SUBINFO *GetSubHash(const char *lpszName,BOOL bError){ 230 int num; 231 SUBINFO **ppsi,*psi; 232 ppsi = GetOverloadSubHash(lpszName,&num); 181 std::vector<SUBINFO *> subs; 182 GetOverloadSubHash(lpszName,subs); 233 183 234 184 //関数が存在しないとき 235 if(num == 0){ 236 HeapDefaultFree(ppsi); 185 if(subs.size() == 0){ 237 186 return 0; 238 187 } 239 188 240 189 //一つ以上の関数が存在するときは内部エラー(デバッグ用) 241 if( num> 1){190 if(subs.size() > 1){ 242 191 if(bError) SetError(300,NULL,cp); 243 192 } 244 193 245 psi = ppsi[0]; 246 247 HeapDefaultFree(ppsi); 194 SUBINFO *psi; 195 psi = subs[0]; 248 196 249 197 return psi; … … 253 201 sprintf(temporary,"%s.%s",ObjectName,MethodName); 254 202 255 int num;256 SUBINFO * *ppsi,*psi;257 ppsi = GetOverloadSubHash(temporary,&num);203 std::vector<SUBINFO *> subs; 204 SUBINFO *psi; 205 GetOverloadSubHash(temporary,subs); 258 206 259 207 //関数が存在しないとき 260 if(num == 0){ 261 HeapDefaultFree(ppsi); 208 if(subs.size() == 0){ 262 209 return 0; 263 210 } 264 211 265 212 //オーバーロードを解決 266 psi=OverloadSolutionWithStrParam(temporary,ppsi,num,Parameter,ObjectName,NULL); 267 HeapDefaultFree(ppsi); 213 psi=OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName,NULL); 268 214 269 215 return psi;
Note:
See TracChangeset
for help on using the changeset viewer.