Changeset 102 in dev for BasicCompiler_Common/Class.cpp
- Timestamp:
- Apr 29, 2007, 2:34:04 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r101 r102 194 194 } 195 195 196 bool CClass::IsEqualSymbol() const 197 { 198 return false; 196 bool CClass::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 197 { 198 if( GetName() != name ){ 199 return false; 200 } 201 202 return NamespaceScopes::IsSameArea( GetNamespaceScopes(), namespaceScopes ); 203 } 204 bool CClass::IsEqualSymbol( const CClass &objClass ) const 205 { 206 return IsEqualSymbol( objClass.GetNamespaceScopes(), objClass.GetName() ); 207 } 208 bool CClass::IsEqualSymbol( const string &fullName ) const 209 { 210 char AreaName[VN_SIZE] = ""; //オブジェクト変数 211 char NestName[VN_SIZE] = ""; //入れ子メンバ 212 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 213 214 return IsEqualSymbol( NamespaceScopes( AreaName ), NestName ); 199 215 } 200 216 … … 735 751 736 752 737 int CDBClass::hash(const char *name) {753 int CDBClass::hash(const char *name) const{ 738 754 int key; 739 755 … … 789 805 } 790 806 791 CClass *CDBClass::check(const char *name){ 807 CClass *CDBClass::Find( const string &fullName ) const 808 { 809 char AreaName[VN_SIZE] = ""; //オブジェクト変数 810 char NestName[VN_SIZE] = ""; //入れ子メンバ 811 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 812 792 813 int key; 793 key=hash( name);814 key=hash(NestName); 794 815 795 816 if(pobj_ClassHash[key]){ … … 797 818 pobj_c=pobj_ClassHash[key]; 798 819 while(1){ 799 if(lstrcmp(name,pobj_c->name)==0){ 800 //重複した場合 820 if( pobj_c->IsEqualSymbol( fullName ) ){ 821 //名前空間とクラス名が一致した 822 return pobj_c; 823 } 824 825 if(pobj_c->pobj_NextClass==0) break; 826 pobj_c=pobj_c->pobj_NextClass; 827 } 828 } 829 return NULL; 830 } 831 CClass *CDBClass::Find( const NamespaceScopes &namespaceScopes, const string &name ) const 832 { 833 int key; 834 key=hash(name.c_str()); 835 836 if(pobj_ClassHash[key]){ 837 CClass *pobj_c; 838 pobj_c=pobj_ClassHash[key]; 839 while(1){ 840 if( pobj_c->IsEqualSymbol( namespaceScopes, name ) ){ 841 //名前空間とクラス名が一致した 801 842 return pobj_c; 802 843 } … … 838 879 pobj_c2=pobj_ClassHash[key]; 839 880 while(1){ 840 if( lstrcmp(name,pobj_c2->name)==0){841 // 重複した場合881 if( pobj_c2->IsEqualSymbol( namespaceScopes, name ) ){ 882 //名前空間及びクラス名が重複した場合 842 883 SetError(15,name,nowLine); 843 884 return 0; … … 1100 1141 char temporary[8192]; 1101 1142 1143 // 名前空間管理 1144 NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes; 1145 namespaceScopes.clear(); 1146 1102 1147 for(i=0;;i++){ 1103 1148 if(basbuf[i]=='\0') break; 1104 1149 1105 CClass *pobj_c; 1150 1151 // 名前空間 1152 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){ 1153 for(i+=2,i2=0;;i2++,i++){ 1154 if( IsCommandDelimitation( basbuf[i] ) ){ 1155 temporary[i2]=0; 1156 break; 1157 } 1158 temporary[i2]=basbuf[i]; 1159 } 1160 namespaceScopes.push_back( temporary ); 1161 1162 continue; 1163 } 1164 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){ 1165 if( namespaceScopes.size() <= 0 ){ 1166 SetError(12, "End Namespace", i ); 1167 } 1168 else{ 1169 namespaceScopes.pop_back(); 1170 } 1171 1172 i += 2; 1173 continue; 1174 } 1175 1176 1106 1177 1107 1178 if(basbuf[i]==1&&basbuf[i+1]==ESC_INTERFACE){ … … 1117 1188 GetIdentifierToken( temporary, basbuf, i ); 1118 1189 1119 pobj_c=pobj_DBClass->check(temporary);1190 CClass *pobj_c=pobj_DBClass->Find(namespaceScopes, temporary); 1120 1191 if(!pobj_c) continue; 1121 1192 … … 1155 1226 1156 1227 //継承元クラスを取得 1157 CClass *pInheritsClass = check(temporary);1228 CClass *pInheritsClass = Find(temporary); 1158 1229 if( !pInheritsClass ){ 1159 1230 SetError(106,temporary,i); … … 1263 1334 GetIdentifierToken( temporary, basbuf, i ); 1264 1335 1265 pobj_c=pobj_DBClass->check(temporary);1336 CClass *pobj_c=pobj_DBClass->Find(namespaceScopes, temporary); 1266 1337 if(!pobj_c) continue; 1267 1338 … … 1320 1391 1321 1392 //継承元クラスを取得 1322 CClass *pInheritsClass = check(temporary);1393 CClass *pInheritsClass = Find(temporary); 1323 1394 if( !pInheritsClass ){ 1324 1395 SetError(106,temporary,i); … … 1328 1399 if( pInheritsClass->IsInterface() ){ 1329 1400 // クラスを継承していないとき 1330 CClass *pObjectClass = check("Object");1401 CClass *pObjectClass = Find("Object"); 1331 1402 if( !pObjectClass ){ 1332 1403 SetError(106,"Object",i);
Note:
See TracChangeset
for help on using the changeset viewer.