blob: 483540050a32ec783f9f0f556f5e89917d345e6a [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- SBLineEntry.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/SBLineEntry.h"
11#include "lldb/Symbol/LineEntry.h"
12
13using namespace lldb;
14
15
16SBLineEntry::SBLineEntry () :
17 m_lldb_object_ap ()
18{
19}
20
21SBLineEntry::SBLineEntry (const SBLineEntry &rhs) :
22 m_lldb_object_ap ()
23{
24 if (rhs.IsValid())
25 {
26 m_lldb_object_ap.reset (new lldb_private::LineEntry (*rhs));
27 }
28}
29
30
31
32SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) :
33 m_lldb_object_ap ()
34{
35 if (lldb_object_ptr)
36 m_lldb_object_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr));
37}
38
39const SBLineEntry &
40SBLineEntry::operator = (const SBLineEntry &rhs)
41{
42 if (this != &rhs)
43 {
44 if (rhs.IsValid())
45 m_lldb_object_ap.reset (new lldb_private::LineEntry(*rhs));
46 }
47 return *this;
48}
49
50void
51SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref)
52{
53 if (m_lldb_object_ap.get())
54 (*m_lldb_object_ap.get()) = lldb_object_ref;
55 else
56 m_lldb_object_ap.reset (new lldb_private::LineEntry (lldb_object_ref));
57}
58
59
60SBLineEntry::~SBLineEntry ()
61{
62}
63
64
65SBAddress
66SBLineEntry::GetStartAddress () const
67{
68 SBAddress sb_address;
69 if (m_lldb_object_ap.get())
70 sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress());
71 return sb_address;
72}
73
74SBAddress
75SBLineEntry::GetEndAddress () const
76{
77 SBAddress sb_address;
78 if (m_lldb_object_ap.get())
79 {
80 sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress());
81 sb_address.OffsetAddress(m_lldb_object_ap->range.GetByteSize());
82 }
83 return sb_address;
84}
85
86bool
87SBLineEntry::IsValid () const
88{
89 return m_lldb_object_ap.get() != NULL;
90}
91
92
93SBFileSpec
94SBLineEntry::GetFileSpec () const
95{
96 SBFileSpec sb_file_spec;
97 if (m_lldb_object_ap.get() && m_lldb_object_ap->file)
98 sb_file_spec.SetFileSpec(m_lldb_object_ap->file);
99 return sb_file_spec;
100}
101
102uint32_t
103SBLineEntry::GetLine () const
104{
105 if (m_lldb_object_ap.get())
106 return m_lldb_object_ap->line;
107 return 0;
108}
109
110
111uint32_t
112SBLineEntry::GetColumn () const
113{
114 if (m_lldb_object_ap.get())
115 return m_lldb_object_ap->column;
116 return 0;
117}
118
119bool
120SBLineEntry::operator == (const SBLineEntry &rhs) const
121{
122 lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get();
123 lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get();
124
125 if (lhs_ptr && rhs_ptr)
126 return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0;
127
128 return lhs_ptr == rhs_ptr;
129}
130
131bool
132SBLineEntry::operator != (const SBLineEntry &rhs) const
133{
134 lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get();
135 lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get();
136
137 if (lhs_ptr && rhs_ptr)
138 return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0;
139
140 return lhs_ptr != rhs_ptr;
141}
142
143const lldb_private::LineEntry *
144SBLineEntry::operator->() const
145{
146 return m_lldb_object_ap.get();
147}
148
149const lldb_private::LineEntry &
150SBLineEntry::operator*() const
151{
152 return *m_lldb_object_ap;
153}
154
155
156
157
158