Changeset 100 in dev for BasicCompiler_Common/Procedure.cpp
- Timestamp:
- Apr 24, 2007, 3:17:29 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Procedure.cpp
r79 r100 1 1 #include "common.h" 2 2 3 string UserProc::GetFullName() const 4 { 5 if( HasParentClass() ){ 6 return (string)GetParentClass().name + "." + GetName(); 7 } 8 9 return GetName(); 10 } 3 11 bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){ 4 12 int i = 0; … … 355 363 return true; 356 364 } 365 bool UserProc::IsVirtual() const 366 { 367 if( pMethod == NULL ){ 368 return false; 369 } 370 return ( pMethod->bVirtual != 0 ); 371 } 372 bool UserProc::EqualName( const string &name ) const 373 { 374 SetError(); 375 return true; 376 } 377 378 GlobalProc *GlobalProc::Create( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ){ 379 int i2; 380 char temporary[8192]; 381 382 int i=1; 383 384 Procedure::Kind kind = Procedure::Sub; 385 bool isMacro = false; 386 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function; 387 if(buffer[i]==ESC_MACRO){ 388 isMacro = true; 389 } 390 391 i++; 392 393 bool isCdecl = false; 394 bool isExport = false; 395 while(1){ 396 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){ 397 isCdecl = true; 398 399 i+=2; 400 } 401 else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){ 402 isExport = true; 403 404 i+=2; 405 } 406 else break; 407 } 408 409 i2=0; 410 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){ 411 SetError(126,NULL,nowLine); 412 return 0; 413 } 414 else{ 415 for(;;i++,i2++){ 416 if(!IsVariableChar(buffer[i])){ 417 temporary[i2]=0; 418 break; 419 } 420 temporary[i2]=buffer[i]; 421 } 422 } 423 424 if( isMacro ){ 425 //大文字に変換 426 CharUpper(temporary); 427 428 //マクロ関数の場合は名前リストに追加 429 extern char **ppMacroNames; 430 extern int MacroNum; 431 ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *)); 432 ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 433 lstrcpy(ppMacroNames[MacroNum],temporary); 434 MacroNum++; 435 } 436 437 //重複チェック 438 if(GetDeclareHash(temporary)){ 439 SetError(15,temporary,nowLine); 440 return 0; 441 } 442 443 extern int SubNum; 444 SubNum++; 445 446 GlobalProc *pGlobalProc = new GlobalProc( namespaceScopes, temporary, kind, isMacro, isCdecl, isExport ); 447 448 //ID 449 static int id_base=0; 450 pGlobalProc->id = (id_base++); 451 452 if(isExport){ 453 pGlobalProc->Using(); 454 } 455 456 // パラメータを解析 457 // ※第1パラメータにに指定するデータの例:"( s As String ) As String" 458 pGlobalProc->SetParamsAndReturnType( buffer + i, nowLine, true ); 459 460 #ifdef _DEBUG 461 pGlobalProc->_paramStr = buffer + i; 462 #endif 463 464 465 return pGlobalProc; 466 } 467 bool GlobalProc::AddGlobalProc( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ){ 468 GlobalProc *pGlobalProc = Create( namespaceScopes, buffer, nowLine ); 469 if( pGlobalProc == NULL ){ 470 return false; 471 } 472 473 474 ///////////////////////////////// 475 // ハッシュデータに追加 476 ///////////////////////////////// 477 478 int key; 479 key=hash_default(pGlobalProc->GetName().c_str()); 480 481 extern GlobalProc **ppSubHash; 482 if(ppSubHash[key]){ 483 GlobalProc *psi2; 484 psi2=ppSubHash[key]; 485 while(1){ 486 //重複エラーチェックを行う 487 if( pGlobalProc->GetName() == psi2->GetName() ){ 488 if( Parameter::Equals( psi2->Params(), pGlobalProc->Params() ) ){ 489 SetError(15,pGlobalProc->GetName().c_str(),nowLine); 490 return 0; 491 } 492 } 493 494 if(psi2->pNextData==0) break; 495 psi2=psi2->pNextData; 496 } 497 psi2->pNextData=pGlobalProc; 498 } 499 else{ 500 ppSubHash[key]=pGlobalProc; 501 } 502 503 return true; 504 } 505 bool GlobalProc::EqualName( const string &name ) const 506 { 507 char AreaName[VN_SIZE]; //オブジェクト変数 508 char NestName[VN_SIZE]; //入れ子メンバ 509 bool isNest = SplitMemberName( name.c_str(), AreaName, NestName ); 510 511 if( isNest ){ 512 if( GetNamespaceScopes().Equal( AreaName ) ){ 513 if( GetName() == NestName ){ 514 return true; 515 } 516 } 517 } 518 else{ 519 if( GetNamespaceScopes().size() ){ 520 // 名前空間の判断が必要なとき 521 if( !GetNamespaceScopes().IsUsing() ){ 522 // この名前空間は暗黙的に参照できないとき 523 return false; 524 } 525 } 526 if( GetName() == name ){ 527 return true; 528 } 529 } 530 531 return false; 532 } 357 533 358 534 bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
Note:
See TracChangeset
for help on using the changeset viewer.