1 //===-- SBSymbolContext.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/SBSymbolContext.h"
11 #include "lldb/Symbol/SymbolContext.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 
17 
18 SBSymbolContext::SBSymbolContext () :
19     m_lldb_object_ap ()
20 {
21 }
22 
23 SBSymbolContext::SBSymbolContext (const SymbolContext *sc_ptr) :
24     m_lldb_object_ap ()
25 {
26     if (sc_ptr)
27         m_lldb_object_ap.reset (new SymbolContext (*sc_ptr));
28 }
29 
30 SBSymbolContext::SBSymbolContext (const SBSymbolContext& rhs) :
31     m_lldb_object_ap ()
32 {
33     if (rhs.IsValid())
34         *m_lldb_object_ap = *rhs.m_lldb_object_ap;
35 }
36 
37 SBSymbolContext::~SBSymbolContext ()
38 {
39 }
40 
41 const SBSymbolContext &
42 SBSymbolContext::operator = (const SBSymbolContext &rhs)
43 {
44     if (this != &rhs)
45     {
46         if (rhs.IsValid())
47             m_lldb_object_ap.reset (new lldb_private::SymbolContext(*rhs.m_lldb_object_ap.get()));
48     }
49     return *this;
50 }
51 
52 void
53 SBSymbolContext::SetSymbolContext (const SymbolContext *sc_ptr)
54 {
55     if (sc_ptr)
56     {
57         if (m_lldb_object_ap.get())
58             *m_lldb_object_ap = *sc_ptr;
59         else
60             m_lldb_object_ap.reset (new SymbolContext (*sc_ptr));
61     }
62     else
63     {
64         if (m_lldb_object_ap.get())
65             m_lldb_object_ap->Clear();
66     }
67 }
68 
69 bool
70 SBSymbolContext::IsValid () const
71 {
72     return m_lldb_object_ap.get() != NULL;
73 }
74 
75 
76 
77 SBModule
78 SBSymbolContext::GetModule ()
79 {
80     SBModule sb_module;
81     if (m_lldb_object_ap.get())
82         sb_module.SetModule(m_lldb_object_ap->module_sp);
83     return sb_module;
84 }
85 
86 SBCompileUnit
87 SBSymbolContext::GetCompileUnit ()
88 {
89     return SBCompileUnit (m_lldb_object_ap.get() ? m_lldb_object_ap->comp_unit : NULL);
90 }
91 
92 SBFunction
93 SBSymbolContext::GetFunction ()
94 {
95     return SBFunction (m_lldb_object_ap.get() ? m_lldb_object_ap->function : NULL);
96 }
97 
98 SBBlock
99 SBSymbolContext::GetBlock ()
100 {
101     return SBBlock (m_lldb_object_ap.get() ? m_lldb_object_ap->block : NULL);
102 }
103 
104 SBLineEntry
105 SBSymbolContext::GetLineEntry ()
106 {
107     SBLineEntry sb_line_entry;
108     if (m_lldb_object_ap.get())
109         sb_line_entry.SetLineEntry (m_lldb_object_ap->line_entry);
110 
111     return sb_line_entry;
112 }
113 
114 SBSymbol
115 SBSymbolContext::GetSymbol ()
116 {
117     return SBSymbol (m_lldb_object_ap.get() ? m_lldb_object_ap->symbol : NULL);
118 }
119 
120 lldb_private::SymbolContext*
121 SBSymbolContext::operator->() const
122 {
123     return m_lldb_object_ap.get();
124 }
125 
126 lldb_private::SymbolContext *
127 SBSymbolContext::GetLLDBObjectPtr() const
128 {
129     return m_lldb_object_ap.get();
130 }
131 
132 
133 
134