blob: a35f94a8b54128b95e03b0c28b071f3506b1d5d1 [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 () :
Greg Clayton63094e02010-06-23 01:19:29 +000017 m_opaque_ap ()
Chris Lattner24943d22010-06-08 16:52:24 +000018{
19}
20
21SBLineEntry::SBLineEntry (const SBLineEntry &rhs) :
Greg Clayton63094e02010-06-23 01:19:29 +000022 m_opaque_ap ()
Chris Lattner24943d22010-06-08 16:52:24 +000023{
24 if (rhs.IsValid())
25 {
Greg Clayton63094e02010-06-23 01:19:29 +000026 m_opaque_ap.reset (new lldb_private::LineEntry (*rhs));
Chris Lattner24943d22010-06-08 16:52:24 +000027 }
28}
29
30
31
32SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) :
Greg Clayton63094e02010-06-23 01:19:29 +000033 m_opaque_ap ()
Chris Lattner24943d22010-06-08 16:52:24 +000034{
35 if (lldb_object_ptr)
Greg Clayton63094e02010-06-23 01:19:29 +000036 m_opaque_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr));
Chris Lattner24943d22010-06-08 16:52:24 +000037}
38
39const SBLineEntry &
40SBLineEntry::operator = (const SBLineEntry &rhs)
41{
42 if (this != &rhs)
43 {
44 if (rhs.IsValid())
Greg Clayton63094e02010-06-23 01:19:29 +000045 m_opaque_ap.reset (new lldb_private::LineEntry(*rhs));
Chris Lattner24943d22010-06-08 16:52:24 +000046 }
47 return *this;
48}
49
50void
51SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref)
52{
Greg Clayton63094e02010-06-23 01:19:29 +000053 if (m_opaque_ap.get())
54 (*m_opaque_ap.get()) = lldb_object_ref;
Chris Lattner24943d22010-06-08 16:52:24 +000055 else
Greg Clayton63094e02010-06-23 01:19:29 +000056 m_opaque_ap.reset (new lldb_private::LineEntry (lldb_object_ref));
Chris Lattner24943d22010-06-08 16:52:24 +000057}
58
59
60SBLineEntry::~SBLineEntry ()
61{
62}
63
64
65SBAddress
66SBLineEntry::GetStartAddress () const
67{
68 SBAddress sb_address;
Greg Clayton63094e02010-06-23 01:19:29 +000069 if (m_opaque_ap.get())
70 sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
Chris Lattner24943d22010-06-08 16:52:24 +000071 return sb_address;
72}
73
74SBAddress
75SBLineEntry::GetEndAddress () const
76{
77 SBAddress sb_address;
Greg Clayton63094e02010-06-23 01:19:29 +000078 if (m_opaque_ap.get())
Chris Lattner24943d22010-06-08 16:52:24 +000079 {
Greg Clayton63094e02010-06-23 01:19:29 +000080 sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
81 sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize());
Chris Lattner24943d22010-06-08 16:52:24 +000082 }
83 return sb_address;
84}
85
86bool
87SBLineEntry::IsValid () const
88{
Greg Clayton63094e02010-06-23 01:19:29 +000089 return m_opaque_ap.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000090}
91
92
93SBFileSpec
94SBLineEntry::GetFileSpec () const
95{
96 SBFileSpec sb_file_spec;
Greg Clayton63094e02010-06-23 01:19:29 +000097 if (m_opaque_ap.get() && m_opaque_ap->file)
98 sb_file_spec.SetFileSpec(m_opaque_ap->file);
Chris Lattner24943d22010-06-08 16:52:24 +000099 return sb_file_spec;
100}
101
102uint32_t
103SBLineEntry::GetLine () const
104{
Greg Clayton63094e02010-06-23 01:19:29 +0000105 if (m_opaque_ap.get())
106 return m_opaque_ap->line;
Chris Lattner24943d22010-06-08 16:52:24 +0000107 return 0;
108}
109
110
111uint32_t
112SBLineEntry::GetColumn () const
113{
Greg Clayton63094e02010-06-23 01:19:29 +0000114 if (m_opaque_ap.get())
115 return m_opaque_ap->column;
Chris Lattner24943d22010-06-08 16:52:24 +0000116 return 0;
117}
118
119bool
120SBLineEntry::operator == (const SBLineEntry &rhs) const
121{
Greg Clayton63094e02010-06-23 01:19:29 +0000122 lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
123 lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000124
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{
Greg Clayton63094e02010-06-23 01:19:29 +0000134 lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
135 lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000136
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{
Greg Clayton63094e02010-06-23 01:19:29 +0000146 return m_opaque_ap.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000147}
148
149const lldb_private::LineEntry &
150SBLineEntry::operator*() const
151{
Greg Clayton63094e02010-06-23 01:19:29 +0000152 return *m_opaque_ap;
Chris Lattner24943d22010-06-08 16:52:24 +0000153}
154
155
156
157
158