Changeset 735 in dev for trunk/ab5.0
- Timestamp:
- Aug 25, 2008, 5:26:44 PM (16 years ago)
- Location:
- trunk/ab5.0/abdev
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/Intermediate_Step1.cpp
r465 r735 7 7 void ChangeReturnCode(char *buffer) 8 8 { 9 int i;10 11 9 bool isMustChange = false; 12 for( i =0; ; i++ ){10 for( int i=0; ; i++ ){ 13 11 if( buffer[i] == '\0' ){ 14 12 break; … … 53 51 #endif 54 52 55 //改行コードのCRLFをLFに変換 56 for(int i=0,i2=0;;i++,i2++){ 57 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i++; 58 buffer[i2]=buffer[i]; 59 if(buffer[i]=='\0') break; 60 } 53 ChangeReturnCodeImpl(buffer); 61 54 } 62 55 void DeleteComment(char *buffer){ //注釈「'」の取り除き 63 56 int i,i2,i3,IsStr; 64 char *temporary; 65 temporary=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(buffer)+1); 57 char *temporary=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,lstrlen(buffer)+1); 66 58 for(i=0,i2=0,i3=0,IsStr=0;;i++,i2++){ 67 59 if(buffer[i]=='\"') IsStr^=1; 68 60 if(buffer[i]=='\n'||buffer[i]=='\0'){ 69 i2--; 70 while(temporary[i2]==' '||temporary[i2]=='\t') i2--; 71 i2++; 61 if(i2 > 0){ 62 i2--; 63 while(temporary[i2]==' '||temporary[i2]=='\t') i2--; 64 i2++; 65 } 72 66 73 67 if(i3){ … … 105 99 } 106 100 lstrcpy(buffer,temporary); 107 GlobalFree(temporary);101 HeapDefaultFree(temporary); 108 102 } 109 103 void CheckParenthesis(char *buffer){ … … 237 231 return 1; 238 232 } 233 234 inline int FindLineEnd(char const *basbuf, int i2){ 235 for(;;i2++){ 236 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 237 } 238 return i2; 239 } 240 239 241 void DirectiveCheck(void){ 240 242 extern char *basbuf; … … 273 275 compiler.staticLibraryFilePaths.push_back( temporary ); 274 276 275 for(;;i2++){ 276 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 277 } 277 i2 = FindLineEnd(basbuf, i2); 278 278 SlideString(basbuf+i2,i-i2); 279 279 } … … 284 284 compiler.SetCoreMark( true ); 285 285 286 for(;;i2++){ 287 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 288 } 286 i2 = FindLineEnd(basbuf, i2); 289 287 SlideString(basbuf+i2,i-i2); 290 288 } … … 292 290 //#noprompt 293 291 //旧機能なので、無視 294 for(;;i2++){ 295 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 296 } 292 i2 = FindLineEnd(basbuf, i2); 297 293 SlideString(basbuf+i2,i-i2); 298 294 } … … 300 296 //#strict 301 297 //旧機能なので、無視 302 for(;;i2++){ 303 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 304 } 298 i2 = FindLineEnd(basbuf, i2); 305 299 SlideString(basbuf+i2,i-i2); 306 300 } … … 308 302 //#struct code 309 303 //旧機能なので、無視 310 for(;;i2++){ 311 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 312 } 304 i2 = FindLineEnd(basbuf, i2); 313 305 SlideString(basbuf+i2,i-i2); 314 306 } … … 332 324 lstrcpy(ResourceFileName,temporary); 333 325 334 for(;;i2++){ 335 if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break; 336 } 326 i2 = FindLineEnd(basbuf, i2); 337 327 SlideString(basbuf+i2,i-i2); 338 328 } -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Compiler.cpp
r720 r735 346 346 tempType.PtrLevelDown(); 347 347 348 return (std::string)"*"+ TypeToString( tempType );348 return '*' + TypeToString( tempType ); 349 349 } 350 350 else if( type.IsObject() || type.IsStruct() ) … … 370 370 if( actualGenericTypesName.size() ) 371 371 { 372 actualGenericTypesName += ",";372 actualGenericTypesName += ','; 373 373 } 374 374 actualGenericTypesName += typeParameter.ToString(); 375 375 } 376 376 377 result += "<" + actualGenericTypesName + ">";377 result += '<' + actualGenericTypesName + '>'; 378 378 } 379 379 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Delegate.cpp
r708 r735 142 142 if( dg.GetNamespaceScopes().size() ) 143 143 { 144 std::string namespaceScopesCommandStr = "";145 std::string endNamespaceScopesCommandStr = "";144 std::string namespaceScopesCommandStr; 145 std::string endNamespaceScopesCommandStr; 146 146 BOOST_FOREACH( const std::string &namespaceStr, dg.GetNamespaceScopes() ) 147 147 { 148 148 if( namespaceScopesCommandStr.size() ) 149 149 { 150 namespaceScopesCommandStr += ":";151 endNamespaceScopesCommandStr += ":";150 namespaceScopesCommandStr += ':'; 151 endNamespaceScopesCommandStr += ':'; 152 152 } 153 153 namespaceScopesCommandStr += "Namespace " + namespaceStr; -
trunk/ab5.0/abdev/ab_common/include/Lexical/Source.h
r700 r735 1 1 #pragma once 2 3 int ChangeReturnCodeImpl(char *buffer); 2 4 3 5 class IncludedFilesRelation … … 96 98 bool ReadFile( const std::string &filePath ); 97 99 98 static void Text::SlideString(char *buffer, int slide){100 static void SlideString(char *buffer, int slide){ 99 101 memmove(buffer+slide, buffer, strlen(buffer)+1); 100 102 } -
trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp
r728 r735 1 1 #include "stdafx.h" 2 2 #include <algorithm> 3 #include <boost/checked_delete.hpp> 3 4 4 5 CClass::CClass( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces ) … … 74 75 CClass::~CClass() 75 76 { 77 using std::for_each; 78 using boost::checked_deleter; 76 79 // 動的メンバ 77 BOOST_FOREACH( Member *member, dynamicMembers ) 78 { 79 delete member; 80 } 81 80 for_each( dynamicMembers.begin(), dynamicMembers.end(), checked_deleter<Member>() ); 82 81 // 静的メンバ 83 BOOST_FOREACH( Member *member, staticMembers ) 84 { 85 delete member; 86 } 87 82 for_each( staticMembers.begin(), staticMembers.end(), checked_deleter<Member>() ); 88 83 // インターフェイス 89 BOOST_FOREACH( ::Interface *pInterface, interfaces ) 90 { 91 delete pInterface; 92 } 93 84 for_each( interfaces.begin(), interfaces.end(), checked_deleter<::Interface>() ); 94 85 // テンプレート展開済みのクラス 95 BOOST_FOREACH( ExpandedTemplateClass *pExpandedTemplateClass, expandedTemplateClasses ) 96 { 97 delete pExpandedTemplateClass; 98 } 86 for_each( expandedTemplateClasses.begin(), expandedTemplateClasses.end(), checked_deleter<ExpandedTemplateClass>() ); 99 87 } 100 88 … … 233 221 { 234 222 //メソッドをコピー 235 BOOST_FOREACH( const CMethod *pBaseMethod, inheritsClass.GetDynamicMethods() ){ 223 const Methods& inheritsClassMethods = inheritsClass.GetDynamicMethods(); 224 GetDynamicMethods().reserve( inheritsClassMethods.size() ); 225 BOOST_FOREACH( const CMethod *pBaseMethod, inheritsClassMethods ){ 236 226 CMethod *pMethod = new DynamicMethod( *pBaseMethod ); 237 227 … … 264 254 265 255 // インターフェイスを引き継ぐ 266 BOOST_FOREACH( ::Interface *pInterface, inheritsClass.GetInterfaces() ) 256 const Interfaces& inheritsClassInterfaces = inheritsClass.GetInterfaces(); 257 interfaces.reserve( inheritsClassInterfaces.size() ); 258 BOOST_FOREACH( const ::Interface *pInterface, inheritsClassInterfaces ) 267 259 { 268 260 interfaces.push_back( new ::Interface( *pInterface ) ); … … 307 299 //メソッド 308 300 BOOST_FOREACH( const CMethod *pMethod, GetDynamicMethods() ){ 309 if( lstrcmp( name, pMethod->GetUserProc().GetName().c_str() ) == 0){301 if( name == pMethod->GetUserProc().GetName() ){ 310 302 return 1; 311 303 } … … 328 320 329 321 // 動的メンバ 330 BOOST_FOREACH( Member *pMember, dynamicMembers )322 BOOST_FOREACH( const Member *pMember, dynamicMembers ) 331 323 { 332 324 if( GetName() == pMember->GetName() ) … … 438 430 if( this->HasSuperClass() ) 439 431 { 432 const CClass& super = this->GetSuperClass(); 440 433 // 基底クラスのサイズを追加 441 resultSize += this->GetSuperClass().GetSize();434 resultSize += super.GetSize(); 442 435 443 436 // 基底クラスのアラインメントを取得 444 alignment = this->GetSuperClass().GetAlignment();437 alignment = super.GetAlignment(); 445 438 } 446 439 else … … 455 448 BOOST_FOREACH( Member *pMember, dynamicMembers ) 456 449 { 450 const Type& memberType = pMember->GetType(); 457 451 // メンバサイズ 458 int tempMemberSize = pMember->GetType().GetSize();452 int tempMemberSize = memberType.GetSize(); 459 453 460 454 // 一時アラインメントを算出 461 455 int tempAlignment = tempMemberSize; 462 if( pMember->GetType().IsStruct() )456 if( memberType.IsStruct() ) 463 457 { 464 458 // メンバが構造体の場合は、メンバのアラインメントを取得 465 tempAlignment = pMember->GetType().GetClass().GetAlignment();459 tempAlignment = memberType.GetClass().GetAlignment(); 466 460 } 467 461 … … 484 478 if( tempMemberSize == 0 ) 485 479 { 486 if( ! pMember->GetType().IsStruct() )480 if( !memberType.IsStruct() ) 487 481 { 488 482 throw; … … 847 841 if( result.size() ) 848 842 { 849 result += ",";850 } 851 852 result += "\"" + pMember->GetName() + "\"";843 result += ','; 844 } 845 846 result += '\"' + pMember->GetName() + '\"'; 853 847 } 854 848 … … 863 857 if( result.size() ) 864 858 { 865 result += ",";859 result += ','; 866 860 } 867 861 … … 869 863 870 864 char temporary[255]; 871 itoa( offset, temporary, 16 );865 _itoa( offset, temporary, 16 ); 872 866 873 867 result += (std::string)"&H" + temporary; -
trunk/ab5.0/abdev/ab_common/src/Lexical/Source.cpp
r706 r735 6 6 7 7 class CDefine{ 8 std ::vector<std::string> names;8 stdext::hash_set<std::string> names; 9 9 public: 10 void Free();10 // void Free(); 11 11 void Init( bool isDebug, bool isDll, bool isUnicode, int majorVer ); 12 12 13 BOOLadd(char const *name);14 BOOLundef(char const *name);15 BOOLcheck(char const *name);13 bool add(char const *name); 14 bool undef(char const *name); 15 bool check(char const *name); 16 16 void preprocessor_ifdef(char *buffer,bool isNot); 17 17 void DirectiveIfdef(char *buffer); … … 84 84 add(temporary); 85 85 } 86 BOOLCDefine::add(char const *name)86 bool CDefine::add(char const *name) 87 87 { 88 //重複チェック 89 if(check(name)) return 0; 90 91 //追加 92 names.push_back( name ); 93 94 return 1; 95 } 96 BOOL CDefine::undef(char const *name){ 97 std::vector<std::string>::iterator i = names.begin(); 98 BOOST_FOREACH( const std::string &temp, names ){ 99 if( temp == name ){ 100 names.erase( i ); 101 return 1; 102 } 103 i++; 104 } 105 106 return 0; 107 } 108 BOOL CDefine::check(char const *name){ 109 110 //重複チェック 111 BOOST_FOREACH( const std::string &temp, names ){ 112 if( temp == name ){ 113 return 1; 114 } 115 } 116 return 0; 88 return names.insert(name).second; 89 } 90 bool CDefine::undef(char const *name){ 91 return names.erase(name) > 0; 92 } 93 bool CDefine::check(char const *name){ 94 return names.find(name) != names.end(); 117 95 } 118 96 … … 167 145 168 146 //#ifdefの行を消去 169 Text::SlideString(buffer+i,-i); 170 i=0; 147 memset(buffer,' ',static_cast<size_t>(i)); 171 148 172 149 BOOL bElse=0; … … 304 281 temporary[i3]=buffer[i2]; 305 282 } 306 307 283 add(temporary); 308 309 i2-=i;310 311 284 //ディレクティブを消去 312 Text::SlideString(buffer+i+i2,-i2); 285 memset(buffer+i,' ',static_cast<size_t>(i2-i)); 286 i=i2; 313 287 } 314 288 if(memicmp(buffer+i,"#undef",6)==0){ 315 i2=i+ 7;289 i2=i+6; 316 290 while(buffer[i2]==' '||buffer[i2]=='\t') i2++; 317 291 … … 323 297 temporary[i3]=buffer[i2]; 324 298 } 325 326 299 undef(temporary); 327 328 i2-=i;329 330 300 //ディレクティブを消去 331 Text::SlideString(buffer+i+i2,-i2); 301 memset(buffer+i,' ',static_cast<size_t>(i2-i)); 302 i=i2; 332 303 } 333 304 else if(memicmp(buffer+i,"#ifdef",6)==0){ … … 367 338 368 339 return true; 340 } 341 342 //改行コードのCRLFをLFに変換 343 int ChangeReturnCodeImpl(char *buffer) 344 { 345 int i; 346 for(i=0;buffer[i]!='\0';i++){ 347 if(buffer[i]=='\r'&&buffer[i+1]=='\n'){ 348 buffer[i]=' '; 349 } 350 } 351 return i; 369 352 } 370 353 … … 418 401 #endif 419 402 420 //改行コードのCRLFをLFに変換 421 for(i=0,i2=0;;i++,i2++){ 422 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i++; 423 buffer[i2]=buffer[i]; 424 if(buffer[i]=='\0') break; 425 } 403 ChangeReturnCodeImpl(buffer); 426 404 427 405 length = i; … … 471 449 if(buffer[i]=='\0') break; 472 450 } 473 st rcpy(buffer,temporary);451 std::swap(buffer,temporary); 474 452 free(temporary); 475 453 } … … 683 661 //カッコ'('直下の改行 684 662 while(buffer[0]=='\n'){ 685 Text::SlideString(buffer+1,-1);663 buffer[0]=' '; 686 664 (*pRnum)++; 687 665 }
Note:
See TracChangeset
for help on using the changeset viewer.