ClangExpressionVariable.h revision 4a7c6c62ac427ac3a390809a6ab1fe325cc69a0e
1//===-- ClangExpressionVariable.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_ClangExpressionVariable_h_ 11#define liblldb_ClangExpressionVariable_h_ 12 13// C Includes 14#include <signal.h> 15#include <stdint.h> 16 17// C++ Includes 18#include <vector> 19 20// Other libraries and framework includes 21// Project includes 22#include "lldb/Core/ClangForward.h" 23#include "lldb/Core/Value.h" 24 25namespace lldb_private { 26 27//---------------------------------------------------------------------- 28/// @class ClangExpressionVariableList ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h" 29/// @brief Manages local variables that the expression interpreter uses. 30/// 31/// The DWARF interpreter, when interpreting expressions, occasionally 32/// needs to interact with chunks of memory corresponding to local variable 33/// values. These locals are distinct from the externally-defined values 34/// handled by ClangExpressionDeclMap, and do not persist between expressions 35/// so they are not handled by ClangPersistentVariables. They are kept in a 36/// list, which is encapsulated in ClangEpxressionVariableList. 37//---------------------------------------------------------------------- 38class ClangExpressionVariableList 39{ 40public: 41 //---------------------------------------------------------------------- 42 /// Constructor 43 //---------------------------------------------------------------------- 44 ClangExpressionVariableList(); 45 46 //---------------------------------------------------------------------- 47 /// Destructor 48 //---------------------------------------------------------------------- 49 ~ClangExpressionVariableList(); 50 51 //---------------------------------------------------------------------- 52 /// Get or create the chunk of data corresponding to a given VarDecl. 53 /// 54 /// @param[in] var_decl 55 /// The Decl for which a chunk of memory is to be allocated. 56 /// 57 /// @param[out] idx 58 /// The index of the Decl in the list of variables. 59 /// 60 /// @param[in] can_create 61 /// True if the memory should be created if necessary. 62 /// 63 /// @return 64 /// A Value for the allocated memory. NULL if the Decl couldn't be 65 /// found and can_create was false, or if some error occurred during 66 /// allocation. 67 //---------------------------------------------------------------------- 68 Value * 69 GetVariableForVarDecl (const clang::VarDecl *var_decl, 70 uint32_t& idx, 71 bool can_create); 72 73 //---------------------------------------------------------------------- 74 /// Get the chunk of data corresponding to a given index into the list. 75 /// 76 /// @param[in] idx 77 /// The index of the Decl in the list of variables. 78 /// 79 /// @return 80 /// The value at the given index, or NULL if there is none. 81 //---------------------------------------------------------------------- 82 Value * 83 GetVariableAtIndex (uint32_t idx); 84private: 85 //---------------------------------------------------------------------- 86 /// @class ClangExpressionVariable ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h" 87 /// @brief Manages one local variable for the expression interpreter. 88 /// 89 /// The expression interpreter uses specially-created Values to hold its 90 /// temporary locals. These Values contain data buffers holding enough 91 /// space to contain a variable of the appropriate type. The VarDecls 92 /// are only used while creating the list and generating the DWARF code for 93 /// an expression; when interpreting the DWARF, the variables are identified 94 /// only by their index into the list of variables. 95 //---------------------------------------------------------------------- 96 struct ClangExpressionVariable 97 { 98 const clang::VarDecl *m_var_decl; ///< The VarDecl corresponding to the parsed local. 99 Value *m_value; ///< The LLDB Value containing the data for the local. 100 }; 101 102 typedef std::vector<ClangExpressionVariable> Variables; 103 Variables m_variables; ///< The list of variables used by the expression. 104}; 105 106} // namespace lldb_private 107 108#endif // liblldb_ClangExpressionVariable_h_ 109