summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2015-09-25 20:35:58 +0000
committerSean Callanan <scallanan@apple.com>2015-09-25 20:35:58 +0000
commit4dbb271fcc32cb7e1a336362308dccb08583cec3 (patch)
tree2a5bade5dfff082b22987b164e7768748c72e367 /lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
parent10aa8078566379592f36487fe9aa9e6b489d55cc (diff)
downloadbcm5719-llvm-4dbb271fcc32cb7e1a336362308dccb08583cec3.tar.gz
bcm5719-llvm-4dbb271fcc32cb7e1a336362308dccb08583cec3.zip
Moved more Clang-specific parts of the expression parser into the Clang plugin.
There are still a bunch of dependencies on the plug-in, but this helps to identify them. There are also a few more bits we need to move (and abstract, for example the ClangPersistentVariables). llvm-svn: 248612
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp')
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
new file mode 100644
index 00000000000..beaa1d69da3
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -0,0 +1,84 @@
+//===-- ClangPersistentVariables.cpp ----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ClangPersistentVariables.h"
+
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/Value.h"
+
+#include "llvm/ADT/StringMap.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+ClangPersistentVariables::ClangPersistentVariables () :
+ ExpressionVariableList(),
+ m_next_persistent_variable_id (0)
+{
+}
+
+ExpressionVariableSP
+ClangPersistentVariables::CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp)
+{
+ return ClangExpressionVariable::CreateVariableInList(*this, valobj_sp)->shared_from_this();
+}
+
+ClangExpressionVariable *
+ClangPersistentVariables::CreatePersistentVariable (ExecutionContextScope *exe_scope,
+ const ConstString &name,
+ const TypeFromUser& user_type,
+ lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size)
+{
+ return ClangExpressionVariable::CreateVariableInList(*this, exe_scope, name, user_type, byte_order, addr_byte_size);
+}
+
+void
+ClangPersistentVariables::RemovePersistentVariable (lldb::ExpressionVariableSP variable)
+{
+ RemoveVariable(variable);
+
+ const char *name = variable->GetName().AsCString();
+
+ if (*name != '$')
+ return;
+ name++;
+
+ if (strtoul(name, NULL, 0) == m_next_persistent_variable_id - 1)
+ m_next_persistent_variable_id--;
+}
+
+ConstString
+ClangPersistentVariables::GetNextPersistentVariableName ()
+{
+ char name_cstr[256];
+ ::snprintf (name_cstr, sizeof(name_cstr), "$%u", m_next_persistent_variable_id++);
+ ConstString name(name_cstr);
+ return name;
+}
+
+void
+ClangPersistentVariables::RegisterPersistentType (const ConstString &name,
+ clang::TypeDecl *type_decl)
+{
+ m_persistent_types.insert(std::pair<const char*, clang::TypeDecl*>(name.GetCString(), type_decl));
+}
+
+clang::TypeDecl *
+ClangPersistentVariables::GetPersistentType (const ConstString &name)
+{
+ PersistentTypeMap::const_iterator i = m_persistent_types.find(name.GetCString());
+
+ if (i == m_persistent_types.end())
+ return NULL;
+ else
+ return i->second;
+}
OpenPOWER on IntegriCloud