diff options
author | Sean Callanan <scallanan@apple.com> | 2010-08-11 03:57:18 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2010-08-11 03:57:18 +0000 |
commit | 2235f32bbdddf52d1e3a1119c747a0861143616d (patch) | |
tree | f3977aa629f768c113feee2f5f2ae99d09e67d47 /lldb/source/Expression/ClangPersistentVariables.cpp | |
parent | 00012c869f519848cb2463c036c27d5a60e8275c (diff) | |
download | bcm5719-llvm-2235f32bbdddf52d1e3a1119c747a0861143616d.tar.gz bcm5719-llvm-2235f32bbdddf52d1e3a1119c747a0861143616d.zip |
Added support for persistent variables to the
expression parser. It is now possible to type:
(lldb) expr int $i = 5; $i + 1
(int) 6
(lldb) expr $i + 2
(int) 7
The skeleton for automatic result variables is
also implemented. The changes affect:
- the process, which now contains a
ClangPersistentVariables object that holds
persistent variables associated with it
- the expression parser, which now uses
the persistent variables during variable
lookup
- TaggedASTType, where I loaded some commonly
used tags into a header so that they are
interchangeable between different clients of
the class
llvm-svn: 110777
Diffstat (limited to 'lldb/source/Expression/ClangPersistentVariables.cpp')
-rw-r--r-- | lldb/source/Expression/ClangPersistentVariables.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lldb/source/Expression/ClangPersistentVariables.cpp b/lldb/source/Expression/ClangPersistentVariables.cpp new file mode 100644 index 00000000000..dbeac006250 --- /dev/null +++ b/lldb/source/Expression/ClangPersistentVariables.cpp @@ -0,0 +1,59 @@ +//===-- 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/Log.h" +#include "lldb/Core/StreamString.h" + +using namespace lldb_private; +using namespace clang; + +ClangPersistentVariables::ClangPersistentVariables () : + m_variables(), + m_result_counter(0) +{ +} + +ClangPersistentVariable * +ClangPersistentVariables::CreateVariable (ConstString name, + TypeFromUser user_type) +{ + ClangPersistentVariable new_var(user_type); + + if (m_variables.find(name) != m_variables.end()) + return NULL; + + m_variables[name] = new_var; + + return &m_variables[name]; +} + +ClangPersistentVariable * +ClangPersistentVariables::CreateResultVariable (TypeFromUser user_type) +{ + StreamString s; + s.Printf("$%llu", m_result_counter); + ConstString name(s.GetString().c_str()); + + ClangPersistentVariable *ret = CreateVariable (name, user_type); + + if (ret != NULL) + ++m_result_counter; + + return ret; +} + +ClangPersistentVariable * +ClangPersistentVariables::GetVariable (ConstString name) +{ + if (m_variables.find(name) == m_variables.end()) + return NULL; + + return &m_variables[name]; +} |