blob: 7f864f287eade70acdbbc7b0ee4aa637f43f0f20 [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
35VariableList::AddVariable(VariableSP &variable_sp)
36{
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
85
86size_t
87VariableList::MemorySize() const
88{
89 size_t mem_size = sizeof(VariableList);
90 const_iterator pos, end = m_variables.end();
91 for (pos = m_variables.begin(); pos != end; ++pos)
92 mem_size += (*pos)->MemorySize();
93 return mem_size;
94}
95
96size_t
97VariableList::GetSize() const
98{
99 return m_variables.size();
100}
101
102
103void
104VariableList::Dump(Stream *s, bool show_context) const
105{
106// s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
107// s.Indent();
108// s << "VariableList\n";
109
110 const_iterator pos, end = m_variables.end();
111 for (pos = m_variables.begin(); pos != end; ++pos)
112 {
113 (*pos)->Dump(s, show_context);
114 }
115}
116