Changeset 803 in dev for branches/egtra/ab5.0
- Timestamp:
- Feb 11, 2011, 10:05:14 PM (14 years ago)
- Location:
- branches/egtra/ab5.0
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/egtra/ab5.0/abdev/BasicCompiler_Common/Debug.cpp
r798 r803 276 276 UserProc *GetSubFromObp(ULONG_PTR pos) 277 277 { 278 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 279 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 278 foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs()) 280 279 { 281 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();282 283 280 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pos && 284 281 pos < rva_to_real(pUserProc->GetEndOpAddress())) -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/Diagnose.cpp
r750 r803 34 34 int codeSizeOfGlobalProc = 0; 35 35 int codeSizeOfClassMethod = 0; 36 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 37 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 36 foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs()) 38 37 { 39 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();40 38 if( pUserProc->IsCompiled() ){ 41 39 if( pUserProc->HasParentClass() ){ … … 60 58 int codeSizeOfEnum = 0; 61 59 62 // イテレータをリセット 63 compiler.GetObjectModule().meta.GetClasses().Iterator_Reset(); 64 65 while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){ 60 foreach (auto pClass, compiler.GetObjectModule().meta.GetClasses()) 61 { 66 62 int codeSizeOfClass = 0; 67 63 68 CClass &objClass = * compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();64 CClass &objClass = *pClass; 69 65 70 66 if( !objClass.IsEnum() ){ … … 99 95 /////////////////////////////////////////////////////////////////// 100 96 101 // イテレータをリセット 102 compiler.GetObjectModule().meta.GetClasses().Iterator_Reset(); 103 104 while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){ 97 foreach (auto pClass, compiler.GetObjectModule().meta.GetClasses()) 98 { 105 99 int codeSizeOfClass = 0; 106 100 107 CClass &objClass = * compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();101 CClass &objClass = *pClass; 108 102 109 103 // 動的メソッド -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/Subroutine.cpp
r751 r803 319 319 320 320 bool IsNeedProcCompile(){ 321 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 322 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 323 { 324 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext(); 321 foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs()) 322 { 325 323 if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){ 326 324 return true; … … 385 383 386 384 repeat: 387 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 388 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 389 { 390 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext(); 385 foreach (auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs()) 386 { 391 387 CompileBufferInProcedure( *pUserProc ); 392 388 } … … 410 406 //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合 411 407 412 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 413 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 408 foreach(auto pUserProc, compiler.GetObjectModule().meta.GetUserProcs()) 414 409 { 415 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();416 410 CompileBufferInProcedure( *pUserProc ); 417 411 } -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/VarList.cpp
r763 r803 1 1 #include "stdafx.h" 2 2 3 #include <boost/range/algorithm.hpp> 3 4 #include <Compiler.h> 4 5 … … 411 412 if(pobj_dti->lplpSpBase[i2]==0) return; 412 413 413 UserProc *pUserProc = NULL; 414 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 415 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 414 auto const& t = compiler.GetObjectModule().meta.GetUserProcs(); 415 auto it = boost::find_if<boost::return_found>(t, [&](UserProc *pUserProc) -> bool { 416 return rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 417 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress()); 418 }); 419 if (it == boost::end(t)) 416 420 { 417 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext(); 418 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 419 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){ 420 break; 421 } 422 } 423 if(!pUserProc) return; 421 return; 422 } 423 UserProc *pUserProc = *it; 424 424 425 425 foreach( Variable *pVar, pUserProc->GetLocalVars() ){ … … 696 696 //プロシージャ コンボボックス 697 697 SendMessage(hProcCombo,CB_RESETCONTENT,0,0); 698 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){ 699 698 for(i2=pobj_dti->iProcLevel;i2>=0;i2--) 699 { 700 auto const& t = compiler.GetObjectModule().meta.GetUserProcs(); 701 auto it = boost::find_if<boost::return_found>(t, [&](UserProc* p) { 702 return rva_to_real(p->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 703 pobj_dti->lplpObp[i2] < rva_to_real(p->GetEndOpAddress()); 704 }); 700 705 UserProc *pUserProc = NULL; 701 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 702 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 706 if (it != boost::end(t)) 703 707 { 704 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext(); 705 706 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 707 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())) 708 { 709 lstrcpy(temporary,pUserProc->GetName().c_str()); 710 break; 711 } 708 pUserProc = *it; 709 lstrcpy(temporary, pUserProc->GetName().c_str()); 712 710 } 713 711 if(!pUserProc){ … … 811 809 i2=pobj_dti->iProcLevel-i2; 812 810 813 if(pobj_dti->lplpSpBase[i2]){ 814 815 UserProc *pUserProc = NULL; 816 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 817 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 811 if(pobj_dti->lplpSpBase[i2]) 812 { 813 auto const& t = compiler.GetObjectModule().meta.GetUserProcs(); 814 auto it = boost::find_if<boost::return_found>(t, [&](UserProc* p) { 815 return rva_to_real(p->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 816 pobj_dti->lplpObp[i2] < rva_to_real(p->GetEndOpAddress()); 817 }); 818 819 if (it != boost::end(t)) 818 820 { 819 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext(); 820 821 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 822 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){ 823 break; 824 } 825 } 826 827 if(pUserProc){ 828 compiler.StartProcedureCompile( pUserProc ); 821 compiler.StartProcedureCompile(*it); 829 822 } 830 823 } -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/hash.cpp
r598 r803 33 33 34 34 // ハッシュ値を取得 35 DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().GetHashArrayElement( simpleName );36 while(pDllProc){35 foreach (auto pDllProc, compiler.GetObjectModule().meta.GetDllProcs().GetHashArrayElement(simpleName)) 36 { 37 37 if( pDllProc->IsEqualSymbol( LexicalAnalyzer::FullNameToSymbol( fullName ) ) ){ 38 38 return pDllProc; 39 39 } 40 41 pDllProc=pDllProc->GetChainNext();42 40 } 43 41 -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp
r750 r803 1348 1348 delete pobj_LoopRefCheck; 1349 1349 pobj_LoopRefCheck=0; 1350 1351 // イテレータの準備1352 classes.Iterator_Init();1353 1350 } 1354 1351 … … 1412 1409 1413 1410 compiler.GetObjectModule().meta.GetUserProcs().Put( pUserProc ); 1414 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Init();1415 1411 1416 1412 LexicalAnalyzer::AddMethod( -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Const.cpp
r637 r803 206 206 } 207 207 } 208 209 // イテレータを初期化210 compiler.GetObjectModule().meta.GetGlobalConsts().Iterator_Init();211 compiler.GetObjectModule().meta.GetGlobalConstMacros().Iterator_Init();212 208 } 213 209 -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Delegate.cpp
r750 r803 127 127 Jenga::Common::SourceTemplate sourceTemplate( ActiveBasic::Common::Environment::GetAbdevSystemDirPath() + "\\templates\\delegate_class.tab" ); 128 128 129 delegates.Iterator_Reset(); 130 while( delegates.Iterator_HasNext() ) 131 { 132 const Delegate &dg = *delegates.Iterator_GetNext(); 129 foreach (auto pDelegate, delegates) 130 { 131 const Delegate &dg = *pDelegate; 133 132 134 133 if( dg.IsExternal() ) … … 263 262 void LexicalAnalyzer::RefleshDelegatesParameterAndReturnType( Delegates &delegates ) 264 263 { 265 delegates.Iterator_Reset(); 266 while( delegates.Iterator_HasNext() ) 267 { 268 Delegate &dg = *delegates.Iterator_GetNext(); 269 RefleshDelegateParameterAndReturnType( dg ); 270 } 271 } 264 foreach (auto *pDelegate, delegates) 265 { 266 RefleshDelegateParameterAndReturnType(*pDelegate); 267 } 268 } -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/src/Linker.cpp
r750 r803 257 257 nativeCode.PutEx( masterObjectModule.globalNativeCode ); 258 258 259 masterObjectModule.meta.GetUserProcs().Iterator_Reset(); 260 while( masterObjectModule.meta.GetUserProcs().Iterator_HasNext() ) 261 { 262 const UserProc *pUserProc = masterObjectModule.meta.GetUserProcs().Iterator_GetNext(); 263 259 foreach (auto pUserProc, masterObjectModule.meta.GetUserProcs()) 260 { 264 261 if( pUserProc->GetNativeCode().GetSize() > 0 ) 265 262 { -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/src/ProcedureGenerator.cpp
r750 r803 18 18 int back_cp=cp; 19 19 20 classes.Iterator_Reset();21 while(classes.Iterator_HasNext()){22 CClass &objClass = * classes.Iterator_GetNext();20 foreach(auto pClass, classes) 21 { 22 CClass &objClass = *pClass; 23 23 if( objClass.IsExternal() ) 24 24 { … … 83 83 //////////////////////////////////////////////////////////////////// 84 84 85 // イテレータをリセット 86 classes.Iterator_Reset(); 87 88 while( classes.Iterator_HasNext() ){ 89 const CClass &objClass = *classes.Iterator_GetNext(); 85 foreach (auto pClass, classes) 86 { 87 const CClass &objClass = *pClass; 90 88 91 89 if( !objClass.IsUsing() ){ … … 152 150 ChangeOpcode( temporary ); 153 151 154 // イテレータをリセット 155 classes.Iterator_Reset(); 156 157 while( classes.Iterator_HasNext() ){ 158 const CClass &objClass = *classes.Iterator_GetNext(); 152 foreach (auto pClass, classes) 153 { 154 const CClass &objClass = *pClass; 159 155 160 156 if( !objClass.IsUsing() ){ -
branches/egtra/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp
r750 r803 93 93 void VtblGenerator::GenerateVTablesForAllClasses( Classes &classes ) 94 94 { 95 classes.Iterator_Reset(); 96 while( classes.Iterator_HasNext() ) 95 foreach (auto pClass, classes) 97 96 { 98 CClass *pClass = classes.Iterator_GetNext();99 97 GenerateFullVTables( *pClass ); 100 98 … … 177 175 void VtblGenerator::ActionVtblScheduleForAllClasses( Classes &classes, LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ) 178 176 { 179 classes.Iterator_Reset(); 180 while( classes.Iterator_HasNext() ) 177 foreach(auto pClass, classes) 181 178 { 182 CClass *pClass = classes.Iterator_GetNext();183 179 ActionVtblSchedule( *pClass, ImageBase, MemPos_CodeSection, MemPos_DataSection ); 184 180 -
branches/egtra/ab5.0/abdev/ab-common-32.props
r798 r803 10 10 </ClCompile> 11 11 <Link> 12 <AdditionalLibraryDirectories> ..\..\jenga\lib\x86;..\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>12 <AdditionalLibraryDirectories>$(SolutionDir)..\jenga\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> 13 13 </Link> 14 14 </ItemDefinitionGroup> -
branches/egtra/ab5.0/abdev/ab-common-64.props
r798 r803 9 9 </ClCompile> 10 10 <Link> 11 <AdditionalLibraryDirectories>..\..\jenga\lib\x64; ..\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>11 <AdditionalLibraryDirectories>..\..\jenga\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> 12 12 </Link> 13 13 </ItemDefinitionGroup> -
branches/egtra/ab5.0/abdev/ab-common.props
r798 r803 7 7 </PropertyGroup> 8 8 <PropertyGroup> 9 <IntDir>$(SolutionDir)int\$( ProjectName)\$(Configuration)-$(Platform)\</IntDir>9 <IntDir>$(SolutionDir)int\$(Configuration)-$(Platform)\$(ProjectName)\</IntDir> 10 10 </PropertyGroup> 11 11 <ItemDefinitionGroup> … … 21 21 <ExceptionHandling>Async</ExceptionHandling> 22 22 <PreprocessorDefinitions>WIN32;_SECURE_ATL=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> 23 <AdditionalOptions>/Zm150 %(AdditionalOptions)</AdditionalOptions> 23 24 </ClCompile> 24 25 <Link> 25 26 <GenerateDebugInformation>true</GenerateDebugInformation> 27 <AdditionalLibraryDirectories>$(SolutionDir)lib\$(PlatformShortName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> 26 28 </Link> 27 29 </ItemDefinitionGroup> -
branches/egtra/ab5.0/abdev/ab_common/src/Lexical/Class.cpp
r750 r803 777 777 778 778 std::vector<const CClass *> classes; 779 const CClass *pClass = GetHashArrayElement( symbol.GetName().c_str() );780 while( pClass )781 {782 if( pClass->IsEqualSymbol( symbol.GetNamespaceScopes(), symbol.GetName() ) ){779 foreach (auto pClass, GetHashArrayElement(symbol.GetName())) 780 { 781 if ( pClass->IsEqualSymbol(symbol.GetNamespaceScopes(), symbol.GetName())) 782 { 783 783 //名前空間とクラス名が一致した 784 784 classes.push_back( pClass ); 785 785 } 786 pClass = pClass->GetChainNext();787 786 } 788 787 if( classes.size() > 0 ) 789 788 { 790 789 // 複数の名前空間の中に同一のクラス名が存在する場合があるので、アクセス可能で尚且つ階層が一番深いものをチョイスする 791 pClass = classes.front();790 auto pClass = classes.front(); 792 791 793 792 foreach( const CClass *pTempClass, classes ) -
branches/egtra/ab5.0/abdev/ab_common/src/Lexical/Const.cpp
r700 r803 29 29 CConst *Consts::GetObjectPtr( const Symbol &symbol ) 30 30 { 31 CConst *pConst = GetHashArrayElement( symbol.GetName().c_str() ); 32 while( pConst ) 33 { 34 if( pConst->IsEqualSymbol( symbol ) ) 35 { 36 break; 37 } 38 pConst = pConst->GetChainNext(); 39 } 40 41 return pConst; 31 auto c = GetHashArrayElement(symbol.GetName()); 32 auto it = std::find_if(c.begin(), c.end(), 33 [&](CConst* t) {return t->IsEqualSymbol(symbol);}); 34 return it != c.end() 35 ? *it 36 : nullptr; 42 37 } 43 38 … … 131 126 ConstMacro *ConstMacros::Find( const Symbol &symbol ) 132 127 { 133 ConstMacro *pConstMacro = GetHashArrayElement( symbol.GetName().c_str() ); 134 while( pConstMacro ) 135 { 136 if( pConstMacro->IsEqualSymbol( symbol ) ) 137 { 138 break; 139 } 140 pConstMacro = pConstMacro->GetChainNext(); 141 } 142 143 return pConstMacro; 128 auto c = GetHashArrayElement(symbol.GetName()); 129 auto it = std::find_if(c.begin(), c.end(), 130 [&](ConstMacro* t) {return t->IsEqualSymbol(symbol);}); 131 return it != c.end() 132 ? *it 133 : nullptr; 144 134 } -
branches/egtra/ab5.0/abdev/ab_common/src/Lexical/Meta.cpp
r750 r803 46 46 47 47 // 関数・メソッド 48 meta.GetUserProcs().Iterator_Reset(); 49 while( meta.GetUserProcs().Iterator_HasNext() ) 50 { 51 UserProc *pUserProc = meta.GetUserProcs().Iterator_GetNext(); 48 foreach (auto pUserProc, meta.GetUserProcs()) 49 { 52 50 if( pUserProc->IsExternal() ) 53 51 { … … 65 63 66 64 // DLL関数 67 meta.GetDllProcs().Iterator_Reset(); 68 while( meta.GetDllProcs().Iterator_HasNext() ) 69 { 70 DllProc *pDllProc = meta.GetDllProcs().Iterator_GetNext(); 65 foreach (auto pDllProc, meta.GetDllProcs()) 66 { 71 67 if( pDllProc->IsExternal() ) 72 68 { … … 81 77 82 78 // クラス 83 meta.GetClasses().Iterator_Reset(); 84 while( meta.GetClasses().Iterator_HasNext() ) 85 { 86 CClass *pClass = meta.GetClasses().Iterator_GetNext(); 79 foreach (auto pClass, meta.GetClasses()) 80 { 87 81 if( pClass->IsExternal() ) 88 82 { … … 132 126 133 127 // グローバル定数 134 meta.GetGlobalConsts().Iterator_Reset(); 135 while( meta.GetGlobalConsts().Iterator_HasNext() ) 136 { 137 CConst *pConst = meta.GetGlobalConsts().Iterator_GetNext(); 128 foreach (auto pConst, meta.GetGlobalConsts()) 129 { 138 130 if( pConst->IsExternal() ) 139 131 { … … 148 140 149 141 // グローバル定数マクロ 150 meta.GetGlobalConstMacros().Iterator_Reset(); 151 while( meta.GetGlobalConstMacros().Iterator_HasNext() ) 152 { 153 ConstMacro *pConstMacro = meta.GetGlobalConstMacros().Iterator_GetNext(); 142 foreach (auto pConstMacro, meta.GetGlobalConstMacros()) 143 { 154 144 if( pConstMacro->IsExternal() ) 155 145 { … … 200 190 201 191 // デリゲート 202 meta.GetDelegates().Iterator_Reset(); 203 while( meta.GetDelegates().Iterator_HasNext() ) 204 { 205 Delegate *pDelegate = meta.GetDelegates().Iterator_GetNext(); 192 foreach (auto pDelegate, meta.GetDelegates()) 193 { 206 194 if( pDelegate->IsExternal() ) 207 195 { … … 218 206 const ::Delegate &Meta::ToDelegate( const CClass &_class ) 219 207 { 220 const ::Delegate *dg = this->GetDelegates().GetHashArrayElement( _class.GetName().c_str());221 while( dg)222 { 223 if( dg->IsEqualSymbol( _class.GetNamespaceScopes(), _class.GetName() ) ){208 auto dg = this->GetDelegates().GetHashArrayElement(_class.GetName()); 209 foreach (auto t, dg) 210 { 211 if( t->IsEqualSymbol( _class.GetNamespaceScopes(), _class.GetName() ) ){ 224 212 //名前空間とクラス名が一致した 225 return *dg; 226 } 227 dg = dg->GetChainNext(); 228 } 229 230 throw; 213 return *t; 214 } 215 } 216 217 throw std::runtime_error("Meta::ToDelegate"); 231 218 } 232 219 … … 256 243 { 257 244 // 関数・メソッド 258 this->GetUserProcs().Iterator_Init(); 259 this->GetUserProcs().Iterator_Reset(); 260 while( this->GetUserProcs().Iterator_HasNext() ) 261 { 262 UserProc *pUserProc = this->GetUserProcs().Iterator_GetNext(); 245 foreach (auto pUserProc, this->GetUserProcs()) 246 { 263 247 pUserProc->Resolve( resolver, resolveErrors ); 264 248 } 265 249 266 250 // DLL関数 267 this->GetDllProcs().Iterator_Init(); 268 this->GetDllProcs().Iterator_Reset(); 269 while( this->GetDllProcs().Iterator_HasNext() ) 270 { 271 DllProc *pDllProc = this->GetDllProcs().Iterator_GetNext(); 251 foreach (auto pDllProc, this->GetDllProcs()) 252 { 272 253 pDllProc->Resolve( resolver, resolveErrors ); 273 254 } 274 255 275 256 // クラス 276 this->GetClasses().Iterator_Init(); 277 this->GetClasses().Iterator_Reset(); 278 while( this->GetClasses().Iterator_HasNext() ) 279 { 280 CClass *pClass = this->GetClasses().Iterator_GetNext(); 257 foreach (auto pClass, this->GetClasses()) 258 { 281 259 pClass->Resolve( resolver, resolveErrors ); 282 260 } … … 289 267 290 268 // グローバル定数 291 this->GetGlobalConsts().Iterator_Init(); 292 this->GetGlobalConsts().Iterator_Reset(); 293 while( this->GetGlobalConsts().Iterator_HasNext() ) 294 { 295 CConst *pConst = this->GetGlobalConsts().Iterator_GetNext(); 269 foreach (auto pConst, this->GetGlobalConsts()) 270 { 296 271 pConst->Resolve( resolver, resolveErrors ); 297 272 } 298 273 299 274 // グローバル定数マクロ 300 this->GetGlobalConstMacros().Iterator_Init(); 301 this->GetGlobalConstMacros().Iterator_Reset(); 302 while( this->GetGlobalConstMacros().Iterator_HasNext() ) 303 { 304 ConstMacro *pConstMacro = this->GetGlobalConstMacros().Iterator_GetNext(); 275 foreach (auto pConstMacro, this->GetGlobalConstMacros()) 276 { 305 277 pConstMacro->Resolve( resolver, resolveErrors ); 306 278 } … … 325 297 326 298 // デリゲート 327 this->GetDelegates().Iterator_Init(); 328 this->GetDelegates().Iterator_Reset(); 329 while( this->GetDelegates().Iterator_HasNext() ) 330 { 331 Delegate *pDelegate = this->GetDelegates().Iterator_GetNext(); 299 foreach (auto pDelegate, this->GetDelegates()) 300 { 332 301 pDelegate->Resolve( resolver, resolveErrors ); 333 302 } -
branches/egtra/ab5.0/abdev/ab_common/src/Lexical/Procedure.cpp
r750 r803 243 243 244 244 // ハッシュ値を取得 245 UserProc *pUserProc = GetHashArrayElement( simpleName );246 while(pUserProc){245 foreach (auto pUserProc, GetHashArrayElement( simpleName )) 246 { 247 247 if( pUserProc->IsGlobalProcedure() ){ 248 248 if( pUserProc->IsEqualSymbol( localSymbol ) ){ … … 250 250 } 251 251 } 252 253 pUserProc=pUserProc->GetChainNext();254 252 } 255 253 } -
branches/egtra/ab5.0/abdev/abdev/abdev.vcxproj
r801 r803 114 114 <DelayLoadDLLs>PSAPI.DLL;DWMAPI.DLL;%(DelayLoadDLLs)</DelayLoadDLLs> 115 115 <SubSystem>Windows</SubSystem> 116 <TargetMachine>MachineX86</TargetMachine>117 116 <EntryPointSymbol>Startup_OldWindowsHelper</EntryPointSymbol> 118 117 </Link> … … 152 151 <AdditionalDependencies>comctl32.lib;imm32.lib;htmlhelp.lib;rpcrt4.lib;imagehlp.lib;tinyxmld_STL.lib;%(AdditionalDependencies)</AdditionalDependencies> 153 152 <SubSystem>Windows</SubSystem> 154 <TargetMachine>MachineX64</TargetMachine>155 153 <EntryPointSymbol> 156 154 </EntryPointSymbol> … … 194 192 <OptimizeReferences>true</OptimizeReferences> 195 193 <EnableCOMDATFolding>true</EnableCOMDATFolding> 196 <TargetMachine>MachineX86</TargetMachine>197 194 <EntryPointSymbol>Startup_OldWindowsHelper</EntryPointSymbol> 198 195 </Link> … … 235 232 <OptimizeReferences>true</OptimizeReferences> 236 233 <EnableCOMDATFolding>true</EnableCOMDATFolding> 237 <TargetMachine>MachineX64</TargetMachine>238 234 <EntryPointSymbol> 239 235 </EntryPointSymbol> -
branches/egtra/ab5.0/abdev/compiler.vcxproj
r802 r803 117 117 <SubSystem>Console</SubSystem> 118 118 <StackReserveSize>4194304</StackReserveSize> 119 <EntryPointSymbol> mainStartup_OldWindowsHelper</EntryPointSymbol>119 <EntryPointSymbol>Startup_OldWindowsHelper</EntryPointSymbol> 120 120 <DelayLoadDLLs>PSAPI.DLL</DelayLoadDLLs> 121 121 </Link> -
branches/egtra/ab5.0/abdev/compiler_x64/MakePeHdr.cpp
r769 r803 166 166 compiler.GetObjectModule().meta.GetDelegates() 167 167 ); 168 compiler.GetObjectModule().meta.GetDelegates().Iterator_Init();169 168 170 169 // デリゲートからクラスコードを生成 … … 219 218 ); 220 219 221 // サブルーチン(ユーザー定義、DLL関数)のイテレータの準備222 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Init();223 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Init();224 225 220 226 221 /////////////////////////// … … 527 522 } 528 523 } 529 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 530 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 531 { 532 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext(); 533 524 foreach (auto const* pDllProc, compiler.GetObjectModule().meta.GetDllProcs() ) 525 { 534 526 if( !pDllProc->IsUsing() ){ 535 527 continue; … … 601 593 //辞書順にサーチ 602 594 temporary[0]=0; 603 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 604 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 595 foreach (auto pTempUserProc, compiler.GetObjectModule().meta.GetUserProcs()) 605 596 { 606 UserProc *pTempUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();607 597 if(pTempUserProc->IsExport()){ 608 598 if(temporary[0]=='\0'){ … … 707 697 int ImportDllNum=0; 708 698 709 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 710 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 711 { 712 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext(); 713 699 foreach (auto const* pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 700 { 714 701 if( !pDllProc->IsUsing() ){ 715 702 continue; … … 745 732 pImportDescriptor[i].Name=i*0x10; //※すぐ下で再計算 746 733 747 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 748 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 734 foreach (auto const* pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 749 735 { 750 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext();751 752 736 if( !pDllProc->IsUsing() ){ 753 737 continue; … … 782 766 pHintTable=(char *)HeapAlloc(hHeap,0,HintAllocSize); 783 767 for(i=0,i5=0;i<ImportDllNum;i++){ 784 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 785 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 768 foreach (auto pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 786 769 { 787 DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext();788 789 770 if( !pDllProc->IsUsing() ){ 790 771 continue; … … 1071 1052 LookupSize; //ルックアップテーブル 1072 1053 1073 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 1074 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 1054 foreach (auto const* pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 1075 1055 { 1076 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext();1077 1078 1056 if( !pDllProc->IsUsing() ){ 1079 1057 continue; -
branches/egtra/ab5.0/abdev/compiler_x86/MakePeHdr.cpp
r750 r803 176 176 compiler.GetObjectModule().meta.GetDelegates() 177 177 ); 178 compiler.GetObjectModule().meta.GetDelegates().Iterator_Init();179 178 180 179 // デリゲートからクラスコードを生成 … … 229 228 ); 230 229 231 // サブルーチン(ユーザー定義、DLL関数)のイテレータの準備232 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Init();233 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Init();234 235 236 230 237 231 /////////////////////////// … … 558 552 } 559 553 } 560 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 561 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 562 { 563 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext(); 564 554 foreach(auto pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 555 { 565 556 if( !pDllProc->IsUsing() ){ 566 557 continue; … … 631 622 //辞書順にサーチ 632 623 temporary[0]=0; 633 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset(); 634 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() ) 624 foreach(auto pTempUserProc, compiler.GetObjectModule().meta.GetUserProcs()) 635 625 { 636 UserProc *pTempUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();637 626 if(pTempUserProc->IsExport()){ 638 627 if(temporary[0]=='\0'){ … … 723 712 int ImportDllNum=0; 724 713 725 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 726 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 727 { 728 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext(); 729 714 foreach (auto const* pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 715 { 730 716 if( !pDllProc->IsUsing() ){ 731 717 continue; … … 762 748 pImportTable[i].Name=i3+i*0x10; 763 749 764 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 765 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 750 foreach (auto const *pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 766 751 { 767 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext(); 768 769 if( !pDllProc->IsUsing() ){ 752 if (!pDllProc->IsUsing()) 753 { 770 754 continue; 771 755 } 772 773 if( pDllProc->GetDllFileName() == ppDllNames[i] ){756 if (pDllProc->GetDllFileName() == ppDllNames[i]) 757 { 774 758 //ルックアップデータのサイズを追加 775 LookupSize +=sizeof(DWORD);759 LookupSize += sizeof (DWORD); 776 760 } 777 761 } … … 790 774 i3+=ImportDllNum*0x10; 791 775 for(i=0,i5=0;i<ImportDllNum;i++){ 792 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 793 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 776 foreach (auto pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 794 777 { 795 DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext();796 797 778 if( !pDllProc->IsUsing() ){ 798 779 continue; … … 1075 1056 HintSize; //ヒント名(関数名)テーブル 1076 1057 1077 compiler.GetObjectModule().meta.GetDllProcs().Iterator_Reset(); 1078 while( compiler.GetObjectModule().meta.GetDllProcs().Iterator_HasNext() ) 1058 foreach (auto const* pDllProc, compiler.GetObjectModule().meta.GetDllProcs()) 1079 1059 { 1080 const DllProc *pDllProc = compiler.GetObjectModule().meta.GetDllProcs().Iterator_GetNext();1081 1082 1060 if( !pDllProc->IsUsing() ){ 1083 1061 continue; -
branches/egtra/ab5.0/jenga/include/common/Hashmap.h
r639 r803 1 1 #pragma once 2 2 #include <unordered_set> 3 #include <boost/range/algorithm.hpp> 4 #include <boost/checked_delete.hpp> 5 #include <boost/iterator/transform_iterator.hpp> 6 #include <boost/cast.hpp> 3 7 4 8 namespace Jenga{ 5 9 namespace Common{ 6 10 11 template<class T> 12 class ObjectInHashmap; 13 template<class T> 14 struct ObjectInHashmapHash; 15 template<class T> 16 struct ObjectInHashmapEqualTo; 7 17 8 18 #define MAX_HASHMAP 65535 9 template<class T> class Hashmap 10 { 11 T* hashArray[MAX_HASHMAP]; 19 template<class T> class Hashmap : boost::noncopyable 20 { 21 typedef std::unordered_set<ObjectInHashmap<T>*, ObjectInHashmapHash<T>, ObjectInHashmapEqualTo<T>> MapType; 22 MapType map; 23 24 struct downcast 25 { 26 typedef T* result_type; 27 T* operator ()(ObjectInHashmap<T>* p) const 28 { 29 return boost::polymorphic_cast<T*>(p); 30 } 31 }; 32 struct const_downcast 33 { 34 typedef T const* result_type; 35 T const* operator ()(ObjectInHashmap<T> const* p) const 36 { 37 return boost::polymorphic_cast<T const*>(p); 38 } 39 }; 12 40 13 41 public: 14 virtual int GetHash( const char *keyName ) const15 {16 int key;17 for(key=0;*keyName!='\0';keyName++){18 key=((key<<8)+ *keyName )%MAX_HASHMAP;19 }20 return key;21 }22 42 23 43 Hashmap() 24 : isIteratorReady( false ) 25 { 26 memset( hashArray, 0, MAX_HASHMAP*sizeof(T*) ); 44 { 27 45 } 28 46 ~Hashmap() … … 32 50 void Clear() 33 51 { 34 for( int i=0; i<MAX_HASHMAP; i++ ) 35 { 36 T* temp = hashArray[i]; 37 if( temp ) 38 { 39 delete temp; 40 } 41 } 42 memset( hashArray, 0, MAX_HASHMAP*sizeof(T*) ); 52 boost::for_each(*this, boost::checked_deleter<T const>()); 53 map.clear(); 43 54 } 44 55 … … 46 57 void PullOutAll() 47 58 { 48 memset( hashArray, 0, MAX_HASHMAP*sizeof(T*) ); 49 } 50 51 bool Put( T* value ) 52 { 53 int key = GetHash( value->GetKeyName().c_str() ); 54 55 if(hashArray[key]){ 56 T *temp = hashArray[key]; 57 while( true ){ 58 if( temp->IsDuplication( value ) ) 59 { 60 // 重複している 61 return false; 62 } 63 64 if( temp->GetChainNext() == NULL ) 65 { 66 break; 67 } 68 temp = temp->GetChainNext(); 69 } 70 temp->SetChainNext( value ); 71 } 72 else{ 73 hashArray[key] = value; 74 } 75 76 return true; 77 } 78 79 T* GetHashArrayElement( const char *keyName ) 80 { 81 return hashArray[GetHash(keyName)]; 82 } 83 const T* GetHashArrayElement( const char *keyName ) const 84 { 85 return hashArray[GetHash(keyName)]; 86 } 87 88 bool IsExistDuplicationKeyName( const std::string &keyName ) const 89 { 90 int key = GetHash( keyName.c_str() ); 91 92 if(hashArray[key]){ 93 const T *temp = hashArray[key]; 94 while( true ){ 95 if( temp->IsDuplication( keyName ) ) 96 { 97 // 重複している 98 return true; 99 } 100 101 if( temp->GetChainNext() == NULL ) 102 { 103 break; 104 } 105 temp = temp->GetChainNext(); 106 } 107 } 108 109 return false; 59 map.clear(); 60 } 61 62 bool Put(T* value) 63 { 64 if (value == nullptr) 65 { 66 throw std::invalid_argument("Hashmap::Put"); 67 } 68 return map.insert(value).second; 69 } 70 71 typedef boost::transform_iterator<downcast, typename MapType::local_iterator> local_iterator; 72 typedef boost::transform_iterator<const_downcast, typename MapType::const_local_iterator> const_local_iterator; 73 74 boost::iterator_range<local_iterator> GetHashArrayElement(std::string const& keyName) 75 { 76 ObjectInHashmapDummy<T> t(keyName); 77 return boost::iterator_range<local_iterator>( 78 local_iterator(map.begin(map.bucket(&t)), downcast()), 79 local_iterator(map.end(map.bucket(&t)), downcast())); 80 } 81 82 boost::iterator_range<const_local_iterator> GetHashArrayElement(std::string const& keyName) const 83 { 84 ObjectInHashmapDummy<T> t(keyName); 85 return boost::iterator_range<const_local_iterator>( 86 const_local_iterator(map.begin(map.bucket(&t)), const_downcast()), 87 const_local_iterator(map.end(map.bucket(&t)), const_downcast())); 88 } 89 90 bool IsExistDuplicationKeyName(const std::string &keyName) const 91 { 92 ObjectInHashmapDummy<T> t(keyName); 93 return map.find(&t) != map.end(); 110 94 } 111 95 112 96 bool IsExist( const T* value ) const 113 97 { 114 int key = GetHash( value->GetKeyName().c_str() ); 115 116 if(hashArray[key]){ 117 const T *temp = hashArray[key]; 118 while( true ){ 119 if( temp->IsDuplication( value ) ) 120 { 121 // 重複している 122 return true; 123 } 124 125 if( temp->GetChainNext() == NULL ) 126 { 127 break; 128 } 129 temp = temp->GetChainNext(); 130 } 131 } 132 133 return false; 134 } 135 136 const T *FindLike( const T* value ) const 137 { 138 int key = GetHash( value->GetKeyName().c_str() ); 139 140 if(hashArray[key]){ 141 const T *temp = hashArray[key]; 142 while( true ){ 143 if( temp->IsDuplication( value ) ) 144 { 145 // 重複している 146 return temp; 147 } 148 149 if( temp->GetChainNext() == NULL ) 150 { 151 break; 152 } 153 temp = temp->GetChainNext(); 154 } 155 } 156 157 return NULL; 98 return map.find(const_cast<T*>(value)) != map.end(); 99 } 100 101 const T *FindLike( const ObjectInHashmap<T>* value ) const 102 { 103 auto it = map.find(const_cast<ObjectInHashmap<T>*>(value)); 104 return it != map.end() 105 ? boost::polymorphic_downcast<T const*>(*it) 106 : nullptr; 158 107 } 159 108 … … 162 111 // イテレータ 163 112 ///////////////////////////////////////////////////////////////// 164 private: 165 mutable std::vector<T*> iterator_Objects; 166 mutable int iterator_CurrentNext; 167 mutable bool isIteratorReady; 168 public: 169 void Iterator_Init() const 170 { 171 iterator_Objects.clear(); 172 iterator_CurrentNext = 0; 173 174 for( int i=0; i<MAX_HASHMAP; i++ ){ 175 if( hashArray[i] ){ 176 T* temp = hashArray[i]; 177 while( temp ) 178 { 179 iterator_Objects.push_back( temp ); 180 181 temp = (T*)temp->GetChainNext(); 182 } 183 } 184 } 185 186 isIteratorReady = true; 187 } 188 void Iterator_Reset() const 189 { 190 if( !isIteratorReady ) 191 { 192 Jenga::Throw( "イテレータの準備ができていない" ); 193 } 194 iterator_CurrentNext = 0; 195 } 196 bool Iterator_HasNext() const 197 { 198 return ( iterator_CurrentNext < (int)iterator_Objects.size() ); 199 } 200 T *Iterator_GetNext() const 201 { 202 return iterator_Objects[iterator_CurrentNext++]; 203 } 204 int Iterator_GetMaxCount() const 205 { 206 return (int)iterator_Objects.size(); 207 } 208 113 //typedef boost::transform_iterator<downcast, typename MapType::iterator> iterator; 114 typedef boost::transform_iterator<downcast, typename MapType::const_iterator> const_iterator; 115 typedef const_iterator iterator; 116 typedef typename MapType::size_type size_type; 117 typedef typename MapType::difference_type difference_type; 118 //iterator begin() 119 //{ 120 // return iterator(map.begin(), downcast()); 121 //} 122 //iterator end() 123 //{ 124 // return iterator(map.end(), downcast()); 125 //} 126 const_iterator begin() const 127 { 128 return const_iterator(map.begin(), downcast()); 129 } 130 const_iterator end() const 131 { 132 return const_iterator(map.end(), downcast()); 133 } 209 134 210 135 // XMLシリアライズ用 … … 215 140 { 216 141 std::vector<T *> objects; 217 ar & BOOST_SERIALIZATION_NVP( objects ); 218 219 // 読み込み後の処理 142 ar & BOOST_SERIALIZATION_NVP(objects); 220 143 Clear(); 221 BOOST_FOREACH( T *object, objects ) 222 { 223 Put( object ); 224 } 225 Iterator_Init(); 144 map = boost::copy_range<MapType>(objects); 226 145 } 227 146 template<class Archive> void save(Archive& ar, const unsigned int version) const 228 147 { 229 // 保存準備 230 std::vector<T *> objects; 231 objects.clear(); 232 Iterator_Reset(); 233 while( Iterator_HasNext() ) 234 { 235 objects.push_back( Iterator_GetNext() ); 236 } 237 238 ar & BOOST_SERIALIZATION_NVP( objects ); 239 } 240 }; 241 242 template<class T> class ObjectInHashmap 243 { 244 T *pNextObject; 148 std::vector<T *> objects(begin(), end()); 149 ar & BOOST_SERIALIZATION_NVP(objects); 150 } 151 }; 152 153 template<class T> 154 class ObjectInHashmap 155 { 245 156 public: 246 157 247 158 ObjectInHashmap() 248 : pNextObject( NULL )249 159 { 250 160 } 251 161 ~ObjectInHashmap() 252 162 { 253 if( pNextObject )254 {255 delete pNextObject;256 }257 163 } 258 164 … … 266 172 return ( GetKeyName() == keyName ); 267 173 } 268 269 T *GetChainNext() 270 { 271 return pNextObject; 272 } 273 const T *GetChainNext() const 274 { 275 return pNextObject; 276 } 277 void SetChainNext( T *pNextObject ) 278 { 279 this->pNextObject = pNextObject; 174 }; 175 176 template<class T> 177 struct ObjectInHashmapHash 178 { 179 typedef std::size_t result_type; 180 std::size_t operator ()(ObjectInHashmap<T> const* x) const 181 { 182 return std::hash<std::string>()(x->GetKeyName()); 183 } 184 }; 185 186 // GetHashArrayElementなどで文字列から検索するために用いる。 187 template<class T> 188 class ObjectInHashmapDummy : public ObjectInHashmap<T>, boost::noncopyable 189 { 190 public: 191 explicit ObjectInHashmapDummy(std::string const& s) : str(s) {} 192 193 virtual std::string const& GetKeyName() const override 194 { 195 return str; 196 } 197 198 virtual bool IsDuplication(T const* value) const override 199 { 200 return value != nullptr 201 && value->ObjectInHashmap<T>::IsDuplication(str); 202 } 203 204 private: 205 std::string const& str; 206 }; 207 208 template<class T> 209 struct ObjectInHashmapEqualTo 210 { 211 typedef bool result_type; 212 bool operator ()(ObjectInHashmap<T> const* lhs, ObjectInHashmap<T> const* rhs) const 213 { 214 assert(lhs != nullptr); 215 assert(rhs != nullptr); 216 if (auto pl = dynamic_cast<T const*>(rhs)) 217 { 218 return lhs->IsDuplication(pl); 219 } 220 else 221 { 222 return rhs->IsDuplication(dynamic_cast<T const*>(lhs)); 223 } 280 224 } 281 225 };
Note:
See TracChangeset
for help on using the changeset viewer.