ValueObjectDynamicValue.h revision dc0a38c5a727cae5362b218a3180d0f4265a619d
1//===-- ValueObjectDynamicValue.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_ValueObjectDynamicValue_h_
11#define liblldb_ValueObjectDynamicValue_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Core/ValueObject.h"
18#include "lldb/Symbol/ClangASTType.h"
19
20namespace lldb_private {
21
22    class ValueObjectCast : public ValueObject
23    {
24    public:
25        static lldb::ValueObjectSP
26        Create (ValueObject &parent,
27                const ConstString &name,
28                const ClangASTType &cast_type);
29
30        virtual
31        ~ValueObjectCast();
32
33        virtual size_t
34        GetByteSize();
35
36        virtual uint32_t
37        CalculateNumChildren();
38
39        virtual lldb::ValueType
40        GetValueType() const;
41
42        virtual bool
43        IsInScope ();
44
45        virtual bool
46        IsDynamic ()
47        {
48            return true;
49        }
50
51        virtual ValueObject *
52        GetParent()
53        {
54            if (m_parent)
55                return m_parent->GetParent();
56            else
57                return NULL;
58        }
59
60        virtual const ValueObject *
61        GetParent() const
62        {
63            if (m_parent)
64                return m_parent->GetParent();
65            else
66                return NULL;
67        }
68
69        virtual lldb::ValueObjectSP
70        GetStaticValue ()
71        {
72            return m_parent->GetSP();
73        }
74
75    protected:
76        virtual bool
77        UpdateValue ();
78
79        virtual clang::ASTContext *
80        GetClangASTImpl ();
81
82        virtual lldb::clang_type_t
83        GetClangTypeImpl ();
84
85        ClangASTType m_cast_type;
86
87    private:
88        ValueObjectCast (ValueObject &parent,
89                         const ConstString &name,
90                         const ClangASTType &cast_type);
91
92        //------------------------------------------------------------------
93        // For ValueObject only
94        //------------------------------------------------------------------
95        DISALLOW_COPY_AND_ASSIGN (ValueObjectCast);
96    };
97
98//----------------------------------------------------------------------
99// A ValueObject that represents memory at a given address, viewed as some
100// set lldb type.
101//----------------------------------------------------------------------
102class ValueObjectDynamicValue : public ValueObject
103{
104public:
105    virtual
106    ~ValueObjectDynamicValue();
107
108    virtual size_t
109    GetByteSize();
110
111    virtual ConstString
112    GetTypeName();
113
114    virtual uint32_t
115    CalculateNumChildren();
116
117    virtual lldb::ValueType
118    GetValueType() const;
119
120    virtual bool
121    IsInScope ();
122
123    virtual bool
124    IsDynamic ()
125    {
126        return true;
127    }
128
129    virtual ValueObject *
130    GetParent()
131    {
132        if (m_parent)
133            return m_parent->GetParent();
134        else
135            return NULL;
136    }
137
138    virtual const ValueObject *
139    GetParent() const
140    {
141        if (m_parent)
142            return m_parent->GetParent();
143        else
144            return NULL;
145    }
146
147    virtual lldb::ValueObjectSP
148    GetStaticValue ()
149    {
150        return m_parent->GetSP();
151    }
152
153    void
154    SetOwningSP (lldb::ValueObjectSP &owning_sp)
155    {
156        if (m_owning_valobj_sp == owning_sp)
157            return;
158
159        assert (m_owning_valobj_sp.get() == NULL);
160        m_owning_valobj_sp = owning_sp;
161    }
162
163protected:
164    virtual bool
165    UpdateValue ();
166
167    virtual clang::ASTContext *
168    GetClangASTImpl ();
169
170    virtual lldb::clang_type_t
171    GetClangTypeImpl ();
172
173    Address  m_address;  ///< The variable that this value object is based upon
174    lldb::TypeSP m_type_sp;
175    lldb::ValueObjectSP m_owning_valobj_sp;
176    lldb::DynamicValueType m_use_dynamic;
177
178private:
179    friend class ValueObject;
180    ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic);
181
182    //------------------------------------------------------------------
183    // For ValueObject only
184    //------------------------------------------------------------------
185    DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue);
186};
187
188} // namespace lldb_private
189
190#endif  // liblldb_ValueObjectDynamicValue_h_
191