]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / include / lldb / Core / ValueObjectSyntheticFilter.h
1 //===-- ValueObjectSyntheticFilter.h -------------------------------*- 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 #ifndef liblldb_ValueObjectSyntheticFilter_h_
11 #define liblldb_ValueObjectSyntheticFilter_h_
12
13 // C Includes
14 // C++ Includes
15 #include <map>
16 #include <vector>
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Core/ValueObject.h"
20
21 namespace lldb_private {
22
23 //----------------------------------------------------------------------
24 // A ValueObject that obtains its children from some source other than
25 // real information
26 // This is currently used to implement Python-based children and filters
27 // but you can bind it to any source of synthetic information and have
28 // it behave accordingly
29 //----------------------------------------------------------------------
30 class ValueObjectSynthetic : public ValueObject
31 {
32 public:
33     virtual
34     ~ValueObjectSynthetic();
35
36     virtual uint64_t
37     GetByteSize();
38     
39     virtual ConstString
40     GetTypeName();
41     
42     virtual ConstString
43     GetQualifiedTypeName();
44
45     virtual bool
46     MightHaveChildren();
47
48     virtual size_t
49     CalculateNumChildren();
50
51     virtual lldb::ValueType
52     GetValueType() const;
53     
54     virtual lldb::ValueObjectSP
55     GetChildAtIndex (size_t idx, bool can_create);
56     
57     virtual lldb::ValueObjectSP
58     GetChildMemberWithName (const ConstString &name, bool can_create);
59     
60     virtual size_t
61     GetIndexOfChildWithName (const ConstString &name);
62
63     virtual lldb::ValueObjectSP
64     GetDynamicValue (lldb::DynamicValueType valueType);
65     
66     virtual bool
67     IsInScope ();
68     
69     virtual bool
70     HasSyntheticValue()
71     {
72         return false;
73     }
74     
75     virtual bool
76     IsSynthetic() { return true; }
77     
78     virtual void
79     CalculateSyntheticValue (bool use_synthetic)
80     {
81     }
82     
83     virtual bool
84     IsDynamic ()
85     {
86         if (m_parent)
87             return m_parent->IsDynamic();
88         else
89             return false;
90     }
91     
92     virtual lldb::ValueObjectSP
93     GetStaticValue ()
94     {
95         if (m_parent)
96             return m_parent->GetStaticValue();
97         else
98             return GetSP();
99     }
100     
101     virtual lldb::DynamicValueType
102     GetDynamicValueType ()
103     {
104         if (m_parent)
105             return m_parent->GetDynamicValueType();
106         else
107             return lldb::eNoDynamicValues;
108     }
109
110     virtual ValueObject *
111     GetParent()
112     {
113         if (m_parent)
114             return m_parent->GetParent();
115         else
116             return NULL;
117     }
118
119     virtual const ValueObject *
120     GetParent() const
121     {
122         if (m_parent)
123             return m_parent->GetParent();
124         else
125             return NULL;
126     }
127     
128     virtual lldb::ValueObjectSP
129     GetNonSyntheticValue ();
130     
131     virtual bool
132     ResolveValue (Scalar &scalar)
133     {
134         if (m_parent)
135             return m_parent->ResolveValue(scalar);
136         return false;
137     }
138     
139 protected:
140     virtual bool
141     UpdateValue ();
142     
143     virtual ClangASTType
144     GetClangTypeImpl ();
145     
146     virtual void
147     CreateSynthFilter ();
148
149     // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive
150     lldb::SyntheticChildrenSP m_synth_sp;
151     std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
152     
153     typedef std::map<uint32_t, ValueObject*> ByIndexMap;
154     typedef std::map<const char*, uint32_t> NameToIndexMap;
155     
156     typedef ByIndexMap::iterator ByIndexIterator;
157     typedef NameToIndexMap::iterator NameToIndexIterator;
158
159     ByIndexMap      m_children_byindex;
160     NameToIndexMap  m_name_toindex;
161     uint32_t        m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution
162     
163     ConstString     m_parent_type_name;
164
165     LazyBool        m_might_have_children;
166     
167 private:
168     friend class ValueObject;
169     ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
170     
171     void
172     CopyParentData ();
173     
174     //------------------------------------------------------------------
175     // For ValueObject only
176     //------------------------------------------------------------------
177     DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
178 };
179
180 } // namespace lldb_private
181
182 #endif  // liblldb_ValueObjectSyntheticFilter_h_