Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 1 | //===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/API/SBSymbolContextList.h" |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 11 | #include "lldb/API/SBStream.h" |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 12 | #include "lldb/Symbol/SymbolContext.h" |
| 13 | |
| 14 | using namespace lldb; |
| 15 | using namespace lldb_private; |
| 16 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 17 | SBSymbolContextList::SBSymbolContextList() |
| 18 | : m_opaque_ap(new SymbolContextList()) {} |
| 19 | |
| 20 | SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs) |
| 21 | : m_opaque_ap(new SymbolContextList(*rhs.m_opaque_ap)) {} |
| 22 | |
| 23 | SBSymbolContextList::~SBSymbolContextList() {} |
| 24 | |
| 25 | const SBSymbolContextList &SBSymbolContextList:: |
| 26 | operator=(const SBSymbolContextList &rhs) { |
| 27 | if (this != &rhs) { |
| 28 | *m_opaque_ap = *rhs.m_opaque_ap; |
| 29 | } |
| 30 | return *this; |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 31 | } |
| 32 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 33 | uint32_t SBSymbolContextList::GetSize() const { |
| 34 | if (m_opaque_ap.get()) |
| 35 | return m_opaque_ap->GetSize(); |
| 36 | return 0; |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 39 | SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { |
| 40 | SBSymbolContext sb_sc; |
| 41 | if (m_opaque_ap.get()) { |
| 42 | SymbolContext sc; |
| 43 | if (m_opaque_ap->GetContextAtIndex(idx, sc)) { |
| 44 | sb_sc.SetSymbolContext(&sc); |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 45 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 46 | } |
| 47 | return sb_sc; |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 50 | void SBSymbolContextList::Clear() { |
| 51 | if (m_opaque_ap.get()) |
| 52 | m_opaque_ap->Clear(); |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 55 | void SBSymbolContextList::Append(SBSymbolContext &sc) { |
| 56 | if (sc.IsValid() && m_opaque_ap.get()) |
| 57 | m_opaque_ap->Append(*sc); |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 60 | void SBSymbolContextList::Append(SBSymbolContextList &sc_list) { |
| 61 | if (sc_list.IsValid() && m_opaque_ap.get()) |
| 62 | m_opaque_ap->Append(*sc_list); |
Greg Clayton | fe356d3 | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 65 | bool SBSymbolContextList::IsValid() const { return m_opaque_ap.get() != NULL; } |
| 66 | |
| 67 | lldb_private::SymbolContextList *SBSymbolContextList::operator->() const { |
| 68 | return m_opaque_ap.get(); |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 71 | lldb_private::SymbolContextList &SBSymbolContextList::operator*() const { |
| 72 | assert(m_opaque_ap.get()); |
| 73 | return *m_opaque_ap.get(); |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | bool SBSymbolContextList::GetDescription(lldb::SBStream &description) { |
| 77 | Stream &strm = description.ref(); |
| 78 | if (m_opaque_ap.get()) |
| 79 | m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); |
| 80 | return true; |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 81 | } |