• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ClangPersistentVariables.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_ClangPersistentVariables_h_
11 #define liblldb_ClangPersistentVariables_h_
12 
13 #include "lldb/Expression/ClangExpressionVariable.h"
14 #include "llvm/ADT/DenseMap.h"
15 
16 namespace lldb_private
17 {
18 
19 //----------------------------------------------------------------------
20 /// @class ClangPersistentVariables ClangPersistentVariables.h "lldb/Expression/ClangPersistentVariables.h"
21 /// @brief Manages persistent values that need to be preserved between expression invocations.
22 ///
23 /// A list of variables that can be accessed and updated by any expression.  See
24 /// ClangPersistentVariable for more discussion.  Also provides an increasing,
25 /// 0-based counter for naming result variables.
26 //----------------------------------------------------------------------
27 class ClangPersistentVariables : public ClangExpressionVariableList
28 {
29 public:
30 
31     //----------------------------------------------------------------------
32     /// Constructor
33     //----------------------------------------------------------------------
34     ClangPersistentVariables ();
35 
36     lldb::ClangExpressionVariableSP
37     CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp);
38 
39     lldb::ClangExpressionVariableSP
40     CreatePersistentVariable (ExecutionContextScope *exe_scope,
41                               const ConstString &name,
42                               const TypeFromUser& user_type,
43                               lldb::ByteOrder byte_order,
44                               uint32_t addr_byte_size);
45 
46     //----------------------------------------------------------------------
47     /// Return the next entry in the sequence of strings "$0", "$1", ... for
48     /// use naming persistent expression convenience variables.
49     ///
50     /// @return
51     ///     A string that contains the next persistent variable name.
52     //----------------------------------------------------------------------
53     ConstString
54     GetNextPersistentVariableName ();
55 
56     void
57     RemovePersistentVariable (lldb::ClangExpressionVariableSP variable);
58 
59     void
60     RegisterPersistentType (const ConstString &name,
61                             clang::TypeDecl *tag_decl);
62 
63     clang::TypeDecl *
64     GetPersistentType (const ConstString &name);
65 
66 private:
67     uint32_t                                                m_next_persistent_variable_id;  ///< The counter used by GetNextResultName().
68 
69     typedef llvm::DenseMap<const char *, clang::TypeDecl *> PersistentTypeMap;
70     PersistentTypeMap                                       m_persistent_types;             ///< The persistent types declared by the user.
71 };
72 
73 }
74 
75 #endif
76