1 //==- NativeEnumTypes.cpp - Native Type Enumerator impl ----------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
12 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
13 #include "llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h"
14 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
21 NativeEnumTypes::NativeEnumTypes(NativeSession &PDBSession,
22 codeview::LazyRandomTypeCollection &Types,
23 codeview::TypeLeafKind Kind)
24 : Matches(), Index(0), Session(PDBSession), Kind(Kind) {
25 for (auto Index = Types.getFirst(); Index;
26 Index = Types.getNext(Index.getValue())) {
27 if (Types.getType(Index.getValue()).kind() == Kind)
28 Matches.push_back(Index.getValue());
32 NativeEnumTypes::NativeEnumTypes(
33 NativeSession &PDBSession, const std::vector<codeview::TypeIndex> &Matches,
34 codeview::TypeLeafKind Kind)
35 : Matches(Matches), Index(0), Session(PDBSession), Kind(Kind) {}
37 uint32_t NativeEnumTypes::getChildCount() const {
38 return static_cast<uint32_t>(Matches.size());
41 std::unique_ptr<PDBSymbol>
42 NativeEnumTypes::getChildAtIndex(uint32_t Index) const {
43 if (Index < Matches.size())
44 return Session.createEnumSymbol(Matches[Index]);
48 std::unique_ptr<PDBSymbol> NativeEnumTypes::getNext() {
49 return getChildAtIndex(Index++);
52 void NativeEnumTypes::reset() { Index = 0; }
54 NativeEnumTypes *NativeEnumTypes::clone() const {
55 return new NativeEnumTypes(Session, Matches, Kind);