Changeset 50 in dev for BasicCompiler_Common
- Timestamp:
- Feb 10, 2007, 5:44:58 PM (18 years ago)
- Location:
- BasicCompiler_Common
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r46 r50 142 142 cp=pobj_c->ppobj_StaticMember[i]->source_code_address; 143 143 144 CallConstr actor(temporary,144 CallConstructor(temporary, 145 145 pobj_c->ppobj_StaticMember[i]->SubScripts, 146 146 pobj_c->ppobj_StaticMember[i]->TypeInfo, … … 225 225 } 226 226 227 if(ppobj_StaticMethod){ 228 //静的メソッド 229 for(i=0;i<iStaticMethodNum;i++){ 230 delete ppobj_StaticMethod[i]; 231 } 232 HeapDefaultFree(ppobj_StaticMethod); 233 ppobj_StaticMethod=0; 227 foreach( CMethod *method, StaticMethods ){ 228 delete method; 234 229 } 235 230 } … … 306 301 } 307 302 void CClass::AddStaticMethod(SUBINFO *psi,DWORD dwAccess){ 308 ppobj_StaticMethod=(CMethod **)HeapReAlloc(hHeap,0,ppobj_StaticMethod,(iStaticMethodNum+1)*sizeof(CMethod *)); 309 ppobj_StaticMethod[iStaticMethodNum]=new CMethod(); 310 ppobj_StaticMethod[iStaticMethodNum]->psi=psi; 311 ppobj_StaticMethod[iStaticMethodNum]->dwAccess=dwAccess; 312 ppobj_StaticMethod[iStaticMethodNum]->bAbstract=0; 313 ppobj_StaticMethod[iStaticMethodNum]->bVirtual=0; 314 ppobj_StaticMethod[iStaticMethodNum]->pobj_InheritsClass=0; 315 316 iStaticMethodNum++; 303 CMethod *method = new CMethod(); 304 method->psi=psi; 305 method->dwAccess=dwAccess; 306 method->bAbstract=0; 307 method->bVirtual=0; 308 method->pobj_InheritsClass=0; 309 310 StaticMethods.push_back( method ); 317 311 } 318 312 BOOL CClass::DupliCheckAll(const char *name){ … … 355 349 } 356 350 CMethod *CClass::GetMethodInfo( SUBINFO *psi ){ 357 int i; 358 for( i=0; i<iMethodNum; i++ ){ 359 if( psi == ppobj_Method[i]->psi ) break; 360 } 361 if( i == iMethodNum ){ 362 return NULL; 363 } 364 return ppobj_Method[i]; 351 for( int i=iMethodNum-1; i>=0; i-- ){ 352 if( psi == ppobj_Method[i]->psi ) return ppobj_Method[i]; 353 } 354 return NULL; 365 355 } 366 356 CMethod *CClass::GetStaticMethodInfo( SUBINFO *psi ){ 367 int i; 368 for( i=0; i<iStaticMethodNum; i++ ){ 369 if( psi == ppobj_StaticMethod[i]->psi ) break; 370 } 371 if( i == iStaticMethodNum ){ 372 return NULL; 373 } 374 return ppobj_StaticMethod[i]; 357 for( int i=(int)StaticMethods.size()-1; i>=0; i-- ){ 358 if( psi == StaticMethods[i]->psi ) return StaticMethods[i]; 359 } 360 return NULL; 375 361 } 376 362 bool CClass::IsExistMethod( const char *name ){ … … 381 367 } 382 368 bool CClass::IsExistStaticMethod( const char *name ){ 383 for ( int i=0; i<iStaticMethodNum; i++){384 if( lstrcmp( ppobj_StaticMethod[i]->psi->name, name ) == 0 ) return true;369 foreach( CMethod *method, StaticMethods ){ 370 if( lstrcmp( method->psi->name, name ) == 0 ) return true; 385 371 } 386 372 return false; 373 } 374 375 void CClass::EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const 376 { 377 foreach( CMethod *method, StaticMethods ){ 378 if(lstrcmp(methodName,method->psi->name)==0){ 379 subs.push_back( method->psi ); 380 } 381 } 382 } 383 384 void CClass::EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const 385 { 386 //オブジェクトのメンバ関数の場合 387 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う 388 for(int i=iMethodNum-1;i>=0;i--){ 389 if(lstrcmp(name,ppobj_Method[i]->psi->name)==0){ 390 subs.push_back( ppobj_Method[i]->psi ); 391 } 392 } 393 } 394 395 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const 396 { 397 for(int i=0;i<iMethodNum;i++){ 398 char *temp; 399 temp=ppobj_Method[i]->psi->name; 400 if(temp[0]==1&&temp[1]==ESC_OPERATOR){ 401 if((BYTE)temp[2]==idOperatorCalc){ 402 subs.push_back( ppobj_Method[i]->psi ); 403 } 404 } 405 } 387 406 } 388 407 … … 465 484 466 485 return false; 467 }468 469 470 SUBINFO **CClass::GetOperatorSubInfo(BYTE idCalc,int &num){471 //格納のための構造体配列を用意472 SUBINFO **ppArray_si;473 ppArray_si=(SUBINFO **)HeapAlloc(hHeap,0,sizeof(SUBINFO *)*1024);474 num=0;475 476 int i;477 for(i=0;i<iMethodNum;i++){478 char *temp;479 temp=ppobj_Method[i]->psi->name;480 if(temp[0]==1&&temp[1]==ESC_OPERATOR){481 if((BYTE)temp[2]==idCalc){482 ppArray_si[num]=ppobj_Method[i]->psi;483 num++;484 }485 }486 }487 488 return ppArray_si;489 486 } 490 487 … … 895 892 pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1); 896 893 pobj_c->iMethodNum=0; 897 pobj_c->ppobj_StaticMethod=(CMethod **)HeapAlloc(hHeap,0,1);898 pobj_c->iStaticMethodNum=0;899 894 900 895 pobj_c->ConstructorMemberSubIndex=-1; … … 1057 1052 pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1); 1058 1053 pobj_c->iMethodNum=0; 1059 pobj_c->ppobj_StaticMethod=(CMethod **)HeapAlloc(hHeap,0,1);1060 pobj_c->iStaticMethodNum=0;1061 1054 1062 1055 pobj_c->ConstructorMemberSubIndex=-1; -
BasicCompiler_Common/Class.h
r46 r50 1 1 #include <vector> 2 2 3 3 class CClass; … … 61 61 }; 62 62 class CClass{ 63 //静的メソッド情報 64 std::vector<CMethod *> StaticMethods; 65 63 66 public: 64 67 //クラス名 … … 83 86 int iStaticMemberNum; 84 87 85 //静的メソッド情報86 CMethod **ppobj_StaticMethod;87 int iStaticMethodNum;88 89 88 //仮想関数の数 90 89 int vtbl_num; … … 117 116 bool IsExistStaticMethod( const char *name ); 118 117 118 //メソッドを列挙 119 void EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const; 120 void EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const; 121 void EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const; 122 119 123 120 124 //vtbl … … 126 130 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 127 131 bool IsAbstract(); 128 129 130 //オペレータ関数の取得131 SUBINFO **GetOperatorSubInfo(BYTE idCalc,int &num);132 132 133 133 -
BasicCompiler_Common/NumOpe_GetType.cpp
r49 r50 193 193 pobj_c=(CClass *)index_stack[sp-2]; 194 194 195 SUBINFO **ppsi; 196 int num; 197 ppsi=pobj_c->GetOperatorSubInfo(idCalc,num); 198 if(num==0){ 199 HeapDefaultFree(ppsi); 200 195 std::vector<SUBINFO *> subs; 196 pobj_c->EnumMethod( idCalc, subs ); 197 if( subs.size() == 0 ){ 201 198 return 0; 202 199 } … … 234 231 else GetCalcName(idCalc,temporary); 235 232 SUBINFO *psi; 236 psi=OverloadSolution(temporary, ppsi,num,ppi,iParmNum,pBaseTypeInfo);237 HeapDefaultFree(ppsi); 233 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 234 238 235 239 236 if(!psi){ -
BasicCompiler_Common/Object.cpp
r40 r50 113 113 114 114 115 void CallConstr actor(char *ObjectName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter){115 void CallConstructor(char *ObjectName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter){ 116 116 if(TypeInfo.type!=DEF_OBJECT) return; 117 117 -
BasicCompiler_Common/Overload.cpp
r46 r50 7 7 #endif 8 8 9 SUBINFO *OverloadSolutionWithStrParam(char *name,SUBINFO **ppsi,int num,char *Parameter,char *ObjectName,TYPEINFO *pReturnTypeInfo){ 10 // オーバーロードの解決 9 SUBINFO *OverloadSolutionWithStrParam( 10 const char *name, 11 std::vector<SUBINFO *> &subs, 12 const char *Parameter, 13 const char *ObjectName, 14 TYPEINFO *pReturnTypeInfo){ 11 15 12 //オーバーロードされていないとき 13 if(num==1) return ppsi[0]; 16 // オーバーロードの解決 17 18 //オーバーロードされていないとき 19 if( subs.size() == 1 ) return subs[0]; 14 20 15 21 16 ////////////////////////17 // パラメータをセット18 ////////////////////////22 //////////////////////// 23 // パラメータをセット 24 //////////////////////// 19 25 20 CParameter *pobj_parameter=0;26 CParameter *pobj_parameter=0; 21 27 22 char MethodName[VN_SIZE];23 if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name );28 char MethodName[VN_SIZE]; 29 if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name ); 24 30 25 //メソッドの場合は静的かどうかを調べる26 bool isStatic = false;27 CClass *pClass = ppsi[0]->pobj_ParentClass;28 if( pClass ){29 isStatic = pClass->IsExistStaticMethod( MethodName );30 }31 //メソッドの場合は静的かどうかを調べる 32 bool isStatic = false; 33 CClass *pClass = subs[0]->pobj_ParentClass; 34 if( pClass ){ 35 isStatic = pClass->IsExistStaticMethod( MethodName ); 36 } 31 37 32 //パラメータオブジェクトを生成33 pobj_parameter=new CParameter(Parameter);34 if(pReturnTypeInfo) pobj_parameter->SetReturnType(pReturnTypeInfo);38 //パラメータオブジェクトを生成 39 pobj_parameter=new CParameter(Parameter); 40 if(pReturnTypeInfo) pobj_parameter->SetReturnType(pReturnTypeInfo); 35 41 36 42 37 SUBINFO *psi;38 psi=pobj_parameter->OverloadSolution(name,ppsi,num);43 SUBINFO *psi; 44 psi=pobj_parameter->OverloadSolution(name,subs); 39 45 40 46 41 //パラメータオブジェクトを破棄42 delete pobj_parameter;43 pobj_parameter=0;47 //パラメータオブジェクトを破棄 48 delete pobj_parameter; 49 pobj_parameter=0; 44 50 45 return psi;51 return psi; 46 52 } 47 53 48 SUBINFO *OverloadSolution(const char *name,SUBINFO **ppsi,int num,PARAMETER_INFO *ppi,int ParmNum,TYPEINFO *pReturnTypeInfo){ 49 // オーバーロードの解決 54 SUBINFO *OverloadSolution( 55 const char *name, 56 std::vector<SUBINFO *> &subs, 57 const PARAMETER_INFO *ppi, 58 const int ParmNum, 59 TYPEINFO *pReturnTypeInfo){ 50 60 51 //オーバーロードされていないとき 52 if(num==1) return ppsi[0]; 61 // オーバーロードの解決 62 63 //オーバーロードされていないとき 64 if( subs.size() == 1 ) return subs[0]; 53 65 54 66 55 CParameter *pobj_Parameter=new CParameter(ppi,ParmNum);56 if(pReturnTypeInfo) pobj_Parameter->SetReturnType(pReturnTypeInfo);67 CParameter *pobj_Parameter=new CParameter(ppi,ParmNum); 68 if(pReturnTypeInfo) pobj_Parameter->SetReturnType(pReturnTypeInfo); 57 69 58 SUBINFO *psi;59 psi=pobj_Parameter->OverloadSolution(name,ppsi,num);70 SUBINFO *psi; 71 psi=pobj_Parameter->OverloadSolution(name,subs); 60 72 61 delete pobj_Parameter;73 delete pobj_Parameter; 62 74 63 return psi;75 return psi; 64 76 } -
BasicCompiler_Common/Subroutine.cpp
r46 r50 104 104 return true; 105 105 } 106 int GetReturnTypeOfProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){ 106 107 108 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){ 107 109 int ret_type; 108 110 … … 129 131 //////////////////////// 130 132 131 SUBINFO **ppsi; 132 int num; 133 ppsi=GetOverloadSubHash(name,&num); 134 if(num){ 133 std::vector<SUBINFO *> subs; 134 GetOverloadSubHash(name,subs); 135 if(subs.size()){ 135 136 //オーバーロードを解決 136 psi=OverloadSolutionWithStrParam(name,ppsi,num,Parameter,ObjectName,NULL); 137 HeapDefaultFree(ppsi); 137 psi=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL); 138 138 139 139 if(!psi) return 0; … … 141 141 142 142 143 ret_type=psi->ReturnType; 144 *plpRetIndex=psi->u.ReturnIndex; 143 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType); 144 if( plpRetIndex ){ 145 *plpRetIndex = psi->u.ReturnIndex; 146 } 147 return psi->ReturnType; 145 148 } 146 149 else if(idProc==PROC_DLL){ … … 151 154 pdi=(DECLAREINFO *)pInfo; 152 155 153 ret_type=pdi->ReturnType; 154 *plpRetIndex=pdi->u.ReturnIndex; 156 ret_type=Opcode_CallDllProc(Parameter,pdi,plpRetIndex); 155 157 } 156 158 else if(idProc==PROC_BUILTIN){ … … 161 163 FuncId=(int)(_int64)pInfo; 162 164 163 ret_type=GetFunctionType(FuncId); 164 *plpRetIndex=-1; 165 TYPEINFO ReturnTypeInfo = { DEF_LONG, NULL }; 166 Opcode_CallFunc( Parameter, FuncId, ReturnTypeInfo ); 167 if( plpRetIndex ){ 168 *plpRetIndex = ReturnTypeInfo.u.lpIndex; 169 } 170 return ReturnTypeInfo.type; 165 171 } 166 172 else if(idProc==PROC_PTR){ … … 173 179 174 180 extern PROCPTRINFO *pProcPtrInfo; 175 ret_type=pProcPtrInfo[lpIndex].ReturnType; 176 *plpRetIndex=pProcPtrInfo[lpIndex].u.ReturnIndex; 181 ret_type=Opcode_CallProcPtr(name,Parameter,&pProcPtrInfo[lpIndex],plpRetIndex); 177 182 } 178 183 179 184 return ret_type; 180 185 } 181 BOOL GetReturnTypeOfPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){186 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){ 182 187 //プロパティ用のメソッドを呼び出す 183 188 … … 192 197 193 198 //オーバーロード用の関数リストを作成 194 SUBINFO **ppsi; 195 int num; 196 ppsi=GetOverloadSubHash(VarName,&num); 197 if(num==0){ 199 std::vector<SUBINFO *> subs; 200 GetOverloadSubHash(VarName,subs); 201 if(subs.size()==0){ 198 202 return 0; 199 203 } … … 210 214 //オーバーロードを解決 211 215 SUBINFO *psi; 212 psi=OverloadSolutionWithStrParam(VarName,ppsi,num,Parameter,ObjectName,NULL); 213 HeapDefaultFree(ppsi); 216 psi=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 217 218 if(psi){ 219 //呼び出し 220 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType); 221 222 if( pRetTypeInfo ){ 223 pRetTypeInfo->type = psi->ReturnType; 224 pRetTypeInfo->u.lpIndex = psi->u.ReturnIndex; 225 } 226 } 227 228 HeapDefaultFree(Parameter); 229 230 return 1; 231 } 232 233 234 int GetReturnTypeOfProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){ 235 int ret_type; 236 237 if(idProc==PROC_DEFAULT){ 238 ///////////////////// 239 // ユーザー定義関数 240 ///////////////////// 241 242 SUBINFO *psi; 243 psi=(SUBINFO *)pInfo; 244 245 //GetSubHash内でエラー提示が行われた場合 246 if(psi==(SUBINFO *)-1) return -1; 247 248 249 //オブジェクト名を取得 250 char ObjectName[VN_SIZE]; 251 int RefType; 252 SplitObjectName(name,ObjectName,&RefType); 253 254 255 //////////////////////// 256 // オーバーロードを解決 257 //////////////////////// 258 259 std::vector<SUBINFO *> subs; 260 GetOverloadSubHash(name,subs); 261 if( subs.size() > 0 ){ 262 //オーバーロードを解決 263 psi=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL); 264 265 if(!psi) return 0; 266 } 267 268 269 ret_type=psi->ReturnType; 270 *plpRetIndex=psi->u.ReturnIndex; 271 } 272 else if(idProc==PROC_DLL){ 273 ///////////////////////// 274 // DLL関数 275 ///////////////////////// 276 DECLAREINFO *pdi; 277 pdi=(DECLAREINFO *)pInfo; 278 279 ret_type=pdi->ReturnType; 280 *plpRetIndex=pdi->u.ReturnIndex; 281 } 282 else if(idProc==PROC_BUILTIN){ 283 ///////////////////////// 284 // 組み込み関数 285 ///////////////////////// 286 int FuncId; 287 FuncId=(int)(_int64)pInfo; 288 289 ret_type=GetFunctionType(FuncId); 290 *plpRetIndex=-1; 291 } 292 else if(idProc==PROC_PTR){ 293 ///////////////// 294 // 関数ポインタ 295 ///////////////// 296 297 LONG_PTR lpIndex; 298 GetVarType(name,&lpIndex,0); 299 300 extern PROCPTRINFO *pProcPtrInfo; 301 ret_type=pProcPtrInfo[lpIndex].ReturnType; 302 *plpRetIndex=pProcPtrInfo[lpIndex].u.ReturnIndex; 303 } 304 305 return ret_type; 306 } 307 BOOL GetReturnTypeOfPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){ 308 //プロパティ用のメソッドを呼び出す 309 310 //配列要素を取得 311 char VarName[VN_SIZE],ArrayElements[VN_SIZE]; 312 GetArrayElement(variable,VarName,ArrayElements); 313 314 //オブジェクト名を取得 315 char ObjectName[VN_SIZE]; 316 int RefType; 317 SplitObjectName(VarName,ObjectName,&RefType); 318 319 //オーバーロード用の関数リストを作成 320 std::vector<SUBINFO *> subs; 321 GetOverloadSubHash(VarName,subs); 322 if(subs.size()==0){ 323 return 0; 324 } 325 326 //パラメータを整備 327 char *Parameter; 328 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(RightSide)+32); 329 lstrcpy(Parameter,ArrayElements); 330 if(RightSide){ 331 if(Parameter[0]&&RightSide[0]) lstrcat(Parameter,","); 332 lstrcat(Parameter,RightSide); 333 } 334 335 //オーバーロードを解決 336 SUBINFO *psi; 337 psi=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 214 338 215 339 if(psi){ … … 225 349 //インデクサ(getter)の戻り値を取得 226 350 bool GetReturnTypeOfIndexerGetterProc(CClass *pobj_Class,TYPEINFO &RetTypeInfo){ 227 SUBINFO **ppsi; 228 int num; 229 ppsi=pobj_Class->GetOperatorSubInfo(CALC_ARRAY_GET,num); 230 if(num==0){ 231 HeapDefaultFree(ppsi); 232 351 std::vector<SUBINFO *> subs; 352 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 353 if( subs.size() == 0 ){ 233 354 return false; 234 355 } 235 356 236 RetTypeInfo.type = ppsi[0]->ReturnType; 237 RetTypeInfo.u.lpIndex = ppsi[0]->u.ReturnIndex; 238 239 HeapDefaultFree(ppsi); 357 RetTypeInfo.type = subs[0]->ReturnType; 358 RetTypeInfo.u.lpIndex = subs[0]->u.ReturnIndex; 240 359 241 360 return true; -
BasicCompiler_Common/calculation.cpp
r49 r50 1199 1199 BOOL bRet=0; 1200 1200 1201 SUBINFO **ppsi; 1202 int num; 1203 ppsi=pobj_c->GetOperatorSubInfo(CALC_SUBSITUATION,num); 1204 if(num==0){ 1201 std::vector<SUBINFO *> subs; 1202 pobj_c->EnumMethod( CALC_SUBSITUATION, subs ); 1203 if( subs.size() == 0 ){ 1205 1204 bRet=0; 1206 1205 goto finish; 1207 1206 } 1208 1207 1209 int i; 1210 for(i=0;i<num;i++){ 1211 if(ppsi[i]->ParmNum==2){ 1212 TYPEINFO TypeInfo={ppsi[i]->pParmInfo[1].type,ppsi[i]->pParmInfo[1].u.index}; 1208 foreach( SUBINFO *psi, subs ){ 1209 if(psi->ParmNum==2){ 1210 TYPEINFO TypeInfo={psi->pParmInfo[1].type,psi->pParmInfo[1].u.index}; 1213 1211 if(IsStringObjectType(&TypeInfo)){ 1214 1212 bRet=1; … … 1219 1217 1220 1218 finish: 1221 HeapDefaultFree(ppsi);1222 1219 return bRet; 1223 1220 } -
BasicCompiler_Common/common.h
r49 r50 11 11 #include <shlobj.h> 12 12 #include <vector> 13 14 //boost libraries 15 #include <boost/foreach.hpp> 16 17 #define foreach BOOST_FOREACH 13 18 14 19 #ifdef _AMD64_ … … 417 422 SUBINFO *GetSubHash(const char *name,BOOL bError=0); 418 423 SUBINFO *GetMethodHash(char *ObjectName,char *MethodName,char *Parameter,BOOL bError=0); 419 SUBINFO **GetOverloadObjectSubHash(char *name,CClass *pobj_c, int *pNum); 420 SUBINFO **GetOverloadSubHash(const char *name,int *pNum); 424 void GetOverloadSubHash( const char *lpszName, std::vector<SUBINFO *> &subs ); 421 425 422 426 //Object.cpp … … 424 428 int GetSizeOfClass(CClass *pobj_c); 425 429 void AddClassName(char *Parameter,int NowLine); 426 void CallConstr actor(char *VarName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter);430 void CallConstructor(char *VarName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter); 427 431 428 432 //Overload.sbp 429 SUBINFO *OverloadSolutionWithStrParam(char *name,SUBINFO **ppsi,int num,char *Parameter,char *ObjectName,TYPEINFO *pReturnTypeInfo); 430 SUBINFO *OverloadSolution(const char *name,SUBINFO **ppsi,int num,PARAMETER_INFO *ppi,int ParmNum,TYPEINFO *pReturnTypeInfo); 433 SUBINFO *OverloadSolutionWithStrParam( 434 const char *name, 435 std::vector<SUBINFO *> &subs, 436 const char *Parameter, 437 const char *ObjectName, 438 TYPEINFO *pReturnTypeInfo); 439 SUBINFO *OverloadSolution( 440 const char *name, 441 std::vector<SUBINFO *> &subs, 442 const PARAMETER_INFO *ppi, 443 const int ParmNum, 444 TYPEINFO *pReturnTypeInfo); 431 445 432 446 //Debug.cpp … … 550 564 void SplitObjectName(const char *name,char *ObjectName,int *pRefType); 551 565 bool SplitMemberName( const char *desc, char *object, char *member ); 566 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex); 567 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo); 552 568 int GetReturnTypeOfProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex); 553 569 BOOL GetReturnTypeOfPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo); -
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.