ValueObjectDynamicValue.h revision 5ae1418055cbf87686d097b8addc58452e54c9c1
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/Type.h"
19
20namespace lldb_private {
21
22//----------------------------------------------------------------------
23// A ValueObject that represents memory at a given address, viewed as some
24// set lldb type.
25//----------------------------------------------------------------------
26class ValueObjectDynamicValue : public ValueObject
27{
28public:
29    virtual
30    ~ValueObjectDynamicValue();
31
32    virtual uint64_t
33    GetByteSize();
34
35    virtual ConstString
36    GetTypeName();
37
38    virtual ConstString
39    GetQualifiedTypeName();
40
41    virtual size_t
42    CalculateNumChildren();
43
44    virtual lldb::ValueType
45    GetValueType() const;
46
47    virtual bool
48    IsInScope ();
49
50    virtual bool
51    IsDynamic ()
52    {
53        return true;
54    }
55
56    virtual ValueObject *
57    GetParent()
58    {
59        if (m_parent)
60            return m_parent->GetParent();
61        else
62            return NULL;
63    }
64
65    virtual const ValueObject *
66    GetParent() const
67    {
68        if (m_parent)
69            return m_parent->GetParent();
70        else
71            return NULL;
72    }
73
74    virtual lldb::ValueObjectSP
75    GetStaticValue ()
76    {
77        return m_parent->GetSP();
78    }
79
80    void
81    SetOwningSP (lldb::ValueObjectSP &owning_sp)
82    {
83        if (m_owning_valobj_sp == owning_sp)
84            return;
85
86        assert (m_owning_valobj_sp.get() == NULL);
87        m_owning_valobj_sp = owning_sp;
88    }
89
90    virtual bool
91    SetValueFromCString (const char *value_str, Error& error);
92
93    virtual bool
94    SetData (DataExtractor &data, Error &error);
95
96protected:
97    virtual bool
98    UpdateValue ();
99
100    virtual lldb::DynamicValueType
101    GetDynamicValueTypeImpl ()
102    {
103        return m_use_dynamic;
104    }
105
106    virtual bool
107    HasDynamicValueTypeInfo ()
108    {
109        return true;
110    }
111
112    virtual clang::ASTContext *
113    GetClangASTImpl ();
114
115    virtual lldb::clang_type_t
116    GetClangTypeImpl ();
117
118    Address  m_address;  ///< The variable that this value object is based upon
119    TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name
120    lldb::ValueObjectSP m_owning_valobj_sp;
121    lldb::DynamicValueType m_use_dynamic;
122
123private:
124    friend class ValueObject;
125    friend class ValueObjectConstResult;
126    ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic);
127
128    //------------------------------------------------------------------
129    // For ValueObject only
130    //------------------------------------------------------------------
131    DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue);
132};
133
134} // namespace lldb_private
135
136#endif  // liblldb_ValueObjectDynamicValue_h_
137