Changeset 270 in dev for trunk/abdev/BasicCompiler_Common/src/Class.cpp
- Timestamp:
- Aug 9, 2007, 3:18:40 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r266 r270 758 758 } 759 759 760 761 int Classes::GetHashCode(const char *name) const762 {763 int key;764 765 for(key=0;*name!='\0';name++){766 key=((key<<8)+ *name )%MAX_CLASS_HASH;767 }768 769 return key;770 }771 772 760 CClass *Classes::Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name){ 773 761 return new CClass(namespaceScopes, importedNamespaces, name); … … 789 777 ///////////////////////////////// 790 778 791 int key; 792 key=GetHashCode( pClass->GetName().c_str() ); 793 794 if(pobj_ClassHash[key]){ 795 CClass *pobj_c2; 796 pobj_c2=pobj_ClassHash[key]; 797 while(1){ 798 if( ((const Prototype *)pobj_c2)->IsEqualSymbol( *(const Prototype *)pClass ) ){ 799 //名前空間及びクラス名が重複した場合 800 SmoothieException::Throw(15,pClass->GetName()); 801 return false; 802 } 803 804 if(pobj_c2->pobj_NextClass==0) break; 805 pobj_c2=pobj_c2->pobj_NextClass; 806 } 807 pobj_c2->pobj_NextClass=pClass; 808 } 809 else{ 810 pobj_ClassHash[key]=pClass; 779 if( !Put( pClass ) ) 780 { 781 SetError(15,pClass->GetName(), cp); 782 return false; 811 783 } 812 784 return true; … … 961 933 962 934 void Classes::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){ 963 int i; 964 for(i=0;i<MAX_CLASS_HASH;i++){ 965 if(pobj_ClassHash[i]){ 966 CClass *pobj_c; 967 pobj_c=pobj_ClassHash[i]; 968 while(1){ 969 pobj_c->ActionVtblSchedule(ImageBase,MemPos_CodeSection); 970 971 if(pobj_c->pobj_NextClass==0) break; 972 pobj_c=pobj_c->pobj_NextClass; 973 } 974 } 935 Iterator_Reset(); 936 while( Iterator_HasNext() ) 937 { 938 CClass *pClass = Iterator_GetNext(); 939 pClass->ActionVtblSchedule(ImageBase,MemPos_CodeSection); 975 940 } 976 941 } … … 981 946 982 947 //イテレータをリセット 983 this->Iterator_Reset();984 948 985 949 extern int cp; 986 950 int back_cp=cp; 987 951 952 this->Iterator_Reset(); 988 953 while(this->Iterator_HasNext()){ 989 954 CClass &objClass = *this->Iterator_GetNext(); … … 1634 1599 const CClass *Classes::Find( const NamespaceScopes &namespaceScopes, const string &name ) const 1635 1600 { 1636 int key;1637 key=GetHashCode(name.c_str());1638 1639 1601 if( namespaceScopes.size() == 0 && name == "Object" ){ 1640 1602 return GetObjectClassPtr(); … … 1644 1606 } 1645 1607 1646 if(pobj_ClassHash[key]){ 1647 CClass *pobj_c; 1648 pobj_c=pobj_ClassHash[key]; 1649 while(1){ 1650 if( pobj_c->IsEqualSymbol( namespaceScopes, name ) ){ 1651 //名前空間とクラス名が一致した 1652 return pobj_c; 1653 } 1654 1655 if(pobj_c->pobj_NextClass==0) break; 1656 pobj_c=pobj_c->pobj_NextClass; 1657 } 1608 const CClass *pClass = GetHashArrayElement( name.c_str() ); 1609 while( pClass ) 1610 { 1611 if( pClass->IsEqualSymbol( namespaceScopes, name ) ){ 1612 //名前空間とクラス名が一致した 1613 return pClass; 1614 } 1615 pClass = pClass->GetChainNext(); 1658 1616 } 1659 1617 … … 1711 1669 return pObjectClass; 1712 1670 } 1713 1714 1715 //////////////////////1716 // イテレータ1717 //////////////////////1718 1719 void Classes::Iterator_Init() const1720 {1721 if(ppobj_IteClass) free(ppobj_IteClass);1722 1723 iIteMaxNum=0;1724 iIteNextNum=0;1725 ppobj_IteClass=(CClass **)malloc(1);1726 1727 int i;1728 for(i=0;i<MAX_CLASS_HASH;i++){1729 if(pobj_ClassHash[i]){1730 CClass *pobj_c;1731 pobj_c=pobj_ClassHash[i];1732 while(1){1733 ppobj_IteClass=(CClass **)realloc(ppobj_IteClass,(iIteMaxNum+1)*sizeof(CClass *));1734 ppobj_IteClass[iIteMaxNum]=pobj_c;1735 iIteMaxNum++;1736 1737 if(pobj_c->pobj_NextClass==0) break;1738 pobj_c=pobj_c->pobj_NextClass;1739 }1740 }1741 }1742 }1743 void Classes::Iterator_Reset() const1744 {1745 iIteNextNum = 0;1746 }1747 BOOL Classes::Iterator_HasNext() const1748 {1749 if(iIteNextNum<iIteMaxNum) return 1;1750 return 0;1751 }1752 CClass *Classes::Iterator_GetNext() const1753 {1754 CClass *pobj_c = ppobj_IteClass[iIteNextNum];1755 iIteNextNum++;1756 return pobj_c;1757 }1758 int Classes::Iterator_GetMaxCount() const1759 {1760 return iIteMaxNum;1761 }
Note:
See TracChangeset
for help on using the changeset viewer.