Changeset 511 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp
- Timestamp:
- Apr 30, 2008, 8:04:04 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp
r509 r511 502 502 return true; 503 503 } 504 UserProc *UserProcs::AddUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName ) 505 { 506 int i2,i3; 507 char temporary[8192]; 508 509 int i=1; 510 511 Procedure::Kind kind = Procedure::Sub; 512 bool isMacro = false; 513 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function; 514 if(buffer[i]==ESC_MACRO){ 515 isMacro = true; 516 } 517 518 i++; 519 520 bool isCdecl = false; 521 bool isExport = false; 522 while(1){ 523 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){ 524 isCdecl = true; 525 526 i+=2; 527 } 528 else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){ 529 isExport = true; 530 531 i+=2; 532 } 533 else break; 534 } 535 536 i2=0; 537 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){ 538 if(!pobj_c){ 539 compiler.errorMessenger.Output(126,NULL,nowLine); 540 return 0; 541 } 542 543 //オペレータの場合 544 temporary[i2++]=buffer[i++]; 545 temporary[i2++]=buffer[i++]; 546 547 int iCalcId; 548 if(buffer[i]=='='&&buffer[i+1]=='='){ 549 iCalcId=CALC_EQUAL; 550 i3=2; 551 } 552 else if(buffer[i]=='='){ 553 iCalcId=CALC_SUBSITUATION; 554 i3=1; 555 } 556 else if(buffer[i]=='('){ 557 iCalcId=CALC_AS; 558 i3=0; 559 } 560 else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){ 561 iCalcId=CALC_ARRAY_SET; 562 i3=3; 563 } 564 else if(buffer[i]=='['&&buffer[i+1]==']'){ 565 iCalcId=CALC_ARRAY_GET; 566 i3=2; 567 } 568 else{ 569 iCalcId=GetCalcId(buffer+i,&i3); 570 i3++; 571 } 572 if(!iCalcId){ 573 compiler.errorMessenger.Output(1,NULL,nowLine); 574 return 0; 575 } 576 temporary[i2++]=iCalcId; 577 temporary[i2]=0; 578 579 i+=i3; 580 } 581 else{ 582 if(pobj_c){ 583 //クラスメンバの場合、デストラクタには~が付くことを考慮 584 if(buffer[i]=='~'){ 585 temporary[i2]='~'; 586 i++; 587 i2++; 588 } 589 } 590 591 for(;;i++,i2++){ 592 if(!IsVariableChar(buffer[i])){ 593 temporary[i2]=0; 594 break; 595 } 596 temporary[i2]=buffer[i]; 597 } 598 599 char parentName[VN_SIZE], memberName[VN_SIZE]; 600 ReferenceKind refKind; 601 if( SplitMemberName( temporary, parentName, memberName, refKind ) ) 602 { 603 if( pobj_c ) 604 { 605 if( interfaceName ) 606 { 607 lstrcpy( interfaceName, parentName ); 608 } 609 else 610 { 611 compiler.errorMessenger.OutputFatalError(); 612 return NULL; 613 } 614 615 char dummyMemberName[VN_SIZE]; 616 if( SplitMemberName( memberName, parentName, dummyMemberName, refKind ) ) 617 { 618 compiler.errorMessenger.Output(69,temporary,nowLine); 619 return NULL; 620 } 621 } 622 else 623 { 624 compiler.errorMessenger.Output(68,temporary,nowLine); 625 return NULL; 626 } 627 628 lstrcpy( temporary, memberName ); 629 } 630 } 631 632 if( isMacro ){ 633 //大文字に変換 634 CharUpper(temporary); 635 636 //マクロ関数の場合は名前リストに追加 637 macroNames.push_back( temporary ); 638 } 639 640 if(!pobj_c){ 641 //クラスメンバ以外の場合のみ 642 //重複チェック 643 644 if(GetDeclareHash(temporary)){ 645 compiler.errorMessenger.Output(15,temporary,nowLine); 646 return 0; 647 } 648 } 649 650 // 識別ID 651 static int id_base=0; 652 653 UserProc *pUserProc = new UserProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport, (id_base++) ); 654 pUserProc->SetParentClass( pobj_c ); 655 656 // 親インターフェイスをセット 657 if( interfaceName && interfaceName[0] ) 658 { 659 ::Interface *pTargetInterface = NULL; 660 BOOST_FOREACH( ::Interface *pInterface, pobj_c->GetInterfaces() ) 661 { 662 if( pInterface->GetClass().GetName() == interfaceName ) 663 { 664 pTargetInterface = pInterface; 665 break; 666 } 667 } 668 pUserProc->SetInterface( pTargetInterface ); 669 } 670 671 if(isExport){ 672 pUserProc->Using(); 673 } 674 675 // パラメータを解析 676 // ※第1パラメータにに指定するデータの例:"( s As String ) As String" 677 pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic ); 678 679 pUserProc->_paramStr = buffer + i; 680 681 // ハッシュに追加 682 if( !Insert( pUserProc, nowLine ) ) 683 { 684 return NULL; 685 } 686 687 return pUserProc; 688 } 504 689 505 void UserProcs::EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs ) 690 506 {
Note:
See TracChangeset
for help on using the changeset viewer.