17a7e6055SDimitry Andric //==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- C++ -*-==//
27a7e6055SDimitry Andric //
37a7e6055SDimitry Andric //                     The LLVM Compiler Infrastructure
47a7e6055SDimitry Andric //
57a7e6055SDimitry Andric // This file is distributed under the University of Illinois Open Source
67a7e6055SDimitry Andric // License. See LICENSE.TXT for details.
77a7e6055SDimitry Andric //
87a7e6055SDimitry Andric //===----------------------------------------------------------------------===//
97a7e6055SDimitry Andric 
107a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
117a7e6055SDimitry Andric 
127a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
137a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
14*b5893f02SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
157a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
167a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbol.h"
177a7e6055SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
18*b5893f02SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
197a7e6055SDimitry Andric 
207a7e6055SDimitry Andric namespace llvm {
217a7e6055SDimitry Andric namespace pdb {
227a7e6055SDimitry Andric 
NativeEnumModules(NativeSession & PDBSession,uint32_t Index)23*b5893f02SDimitry Andric NativeEnumModules::NativeEnumModules(NativeSession &PDBSession, uint32_t Index)
24*b5893f02SDimitry Andric     : Session(PDBSession), Index(Index) {}
257a7e6055SDimitry Andric 
getChildCount() const267a7e6055SDimitry Andric uint32_t NativeEnumModules::getChildCount() const {
27*b5893f02SDimitry Andric   return Session.getSymbolCache().getNumCompilands();
287a7e6055SDimitry Andric }
297a7e6055SDimitry Andric 
307a7e6055SDimitry Andric std::unique_ptr<PDBSymbol>
getChildAtIndex(uint32_t N) const31*b5893f02SDimitry Andric NativeEnumModules::getChildAtIndex(uint32_t N) const {
32*b5893f02SDimitry Andric   return Session.getSymbolCache().getOrCreateCompiland(N);
337a7e6055SDimitry Andric }
347a7e6055SDimitry Andric 
getNext()357a7e6055SDimitry Andric std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
36*b5893f02SDimitry Andric   if (Index >= getChildCount())
377a7e6055SDimitry Andric     return nullptr;
387a7e6055SDimitry Andric   return getChildAtIndex(Index++);
397a7e6055SDimitry Andric }
407a7e6055SDimitry Andric 
reset()417a7e6055SDimitry Andric void NativeEnumModules::reset() { Index = 0; }
427a7e6055SDimitry Andric 
437a7e6055SDimitry Andric }
447a7e6055SDimitry Andric }
45