1 //===-- ValueObjectDynamicValue.cpp ---------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "lldb/Core/ValueObjectCast.h"
15 // Other libraries and framework includes
17 #include "lldb/Core/Log.h"
18 #include "lldb/Core/Module.h"
19 #include "lldb/Core/ValueObjectList.h"
20 #include "lldb/Core/Value.h"
21 #include "lldb/Core/ValueObject.h"
23 #include "lldb/Symbol/ClangASTType.h"
24 #include "lldb/Symbol/ObjectFile.h"
25 #include "lldb/Symbol/SymbolContext.h"
26 #include "lldb/Symbol/Type.h"
27 #include "lldb/Symbol/Variable.h"
29 #include "lldb/Target/ExecutionContext.h"
30 #include "lldb/Target/LanguageRuntime.h"
31 #include "lldb/Target/Process.h"
32 #include "lldb/Target/RegisterContext.h"
33 #include "lldb/Target/Target.h"
34 #include "lldb/Target/Thread.h"
36 using namespace lldb_private;
39 ValueObjectCast::Create (ValueObject &parent,
40 const ConstString &name,
41 const ClangASTType &cast_type)
43 ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type);
44 return cast_valobj_ptr->GetSP();
47 ValueObjectCast::ValueObjectCast
50 const ConstString &name,
51 const ClangASTType &cast_type
54 m_cast_type (cast_type)
57 //m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType());
58 m_value.SetClangType (cast_type);
61 ValueObjectCast::~ValueObjectCast()
66 ValueObjectCast::GetClangTypeImpl ()
72 ValueObjectCast::CalculateNumChildren()
74 return GetClangType().GetNumChildren (true);
78 ValueObjectCast::GetByteSize()
80 return m_value.GetValueByteSize(NULL);
84 ValueObjectCast::GetValueType() const
86 // Let our parent answer global, local, argument, etc...
87 return m_parent->GetValueType();
91 ValueObjectCast::UpdateValue ()
93 SetValueIsValid (false);
96 if (m_parent->UpdateValueIfNeeded(false))
98 Value old_value(m_value);
99 m_update_point.SetUpdated();
100 m_value = m_parent->GetValue();
101 ClangASTType clang_type (GetClangType());
102 //m_value.SetContext (Value::eContextTypeClangType, clang_type);
103 m_value.SetClangType (clang_type);
104 SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren());
105 if (clang_type.IsAggregateType ())
107 // this value object represents an aggregate type whose
108 // children have values, but this object does not. So we
109 // say we are changed if our location has changed.
110 SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar());
112 ExecutionContext exe_ctx (GetExecutionContextRef());
113 m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
114 SetValueDidChange (m_parent->GetValueDidChange());
118 // The dynamic value failed to get an error, pass the error along
119 if (m_error.Success() && m_parent->GetError().Fail())
120 m_error = m_parent->GetError();
121 SetValueIsValid (false);
126 ValueObjectCast::IsInScope ()
128 return m_parent->IsInScope();