blob: 5ee5299d62b34992606272a13107d1e7e5cfa49d [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- VariableList.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/Symbol/VariableList.h"
11#include "lldb/Symbol/Block.h"
12#include "lldb/Symbol/Function.h"
13#include "lldb/Symbol/CompileUnit.h"
14
15using namespace lldb;
16using namespace lldb_private;
17
18//----------------------------------------------------------------------
19// VariableList constructor
20//----------------------------------------------------------------------
21VariableList::VariableList() :
22 m_variables()
23{
24}
25
26//----------------------------------------------------------------------
27// Destructor
28//----------------------------------------------------------------------
29VariableList::~VariableList()
30{
31}
32
33
34void
Greg Clayton17dae082010-09-02 02:59:18 +000035VariableList::AddVariable(const VariableSP &variable_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000036{
37 m_variables.push_back(variable_sp);
38}
39
40
41void
42VariableList::AddVariables(VariableList *variable_list)
43{
44 std::copy( variable_list->m_variables.begin(), // source begin
45 variable_list->m_variables.end(), // source end
46 back_inserter(m_variables)); // destination
47}
48
49
50void
51VariableList::Clear()
52{
53 m_variables.clear();
54}
55
56
57
58VariableSP
59VariableList::GetVariableAtIndex(uint32_t idx)
60{
61 VariableSP variable_sp;
62 if (idx < m_variables.size())
63 variable_sp = m_variables[idx];
64 return variable_sp;
65}
66
67
68
69VariableSP
70VariableList::FindVariable(const ConstString& name)
71{
72 VariableSP var_sp;
73 iterator pos, end = m_variables.end();
74 for (pos = m_variables.begin(); pos != end; ++pos)
75 {
76 if ((*pos)->GetName() == name)
77 {
78 var_sp = (*pos);
79 break;
80 }
81 }
82 return var_sp;
83}
84
Greg Clayton17dae082010-09-02 02:59:18 +000085uint32_t
86VariableList::FindIndexForVariable (Variable* variable)
87{
88 VariableSP var_sp;
89 iterator pos;
90 const iterator begin = m_variables.begin();
91 const iterator end = m_variables.end();
92 for (pos = m_variables.begin(); pos != end; ++pos)
93 {
94 if ((*pos).get() == variable)
95 return std::distance (begin, pos);
96 }
97 return UINT32_MAX;
98}
Chris Lattner24943d22010-06-08 16:52:24 +000099
100size_t
101VariableList::MemorySize() const
102{
103 size_t mem_size = sizeof(VariableList);
104 const_iterator pos, end = m_variables.end();
105 for (pos = m_variables.begin(); pos != end; ++pos)
106 mem_size += (*pos)->MemorySize();
107 return mem_size;
108}
109
110size_t
111VariableList::GetSize() const
112{
113 return m_variables.size();
114}
115
116
117void
118VariableList::Dump(Stream *s, bool show_context) const
119{
120// s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
121// s.Indent();
122// s << "VariableList\n";
123
124 const_iterator pos, end = m_variables.end();
125 for (pos = m_variables.begin(); pos != end; ++pos)
126 {
127 (*pos)->Dump(s, show_context);
128 }
129}
130