1 //===-- 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 
15 using namespace lldb;
16 using namespace lldb_private;
17 
18 //----------------------------------------------------------------------
19 // VariableList constructor
20 //----------------------------------------------------------------------
21 VariableList::VariableList() :
22     m_variables()
23 {
24 }
25 
26 //----------------------------------------------------------------------
27 // Destructor
28 //----------------------------------------------------------------------
29 VariableList::~VariableList()
30 {
31 }
32 
33 
34 void
35 VariableList::AddVariable(VariableSP &variable_sp)
36 {
37     m_variables.push_back(variable_sp);
38 }
39 
40 
41 void
42 VariableList::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 
50 void
51 VariableList::Clear()
52 {
53     m_variables.clear();
54 }
55 
56 
57 
58 VariableSP
59 VariableList::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 
69 VariableSP
70 VariableList::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 
86 size_t
87 VariableList::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 
96 size_t
97 VariableList::GetSize() const
98 {
99     return m_variables.size();
100 }
101 
102 
103 void
104 VariableList::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 
117