]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Expression/Expression.h
Upgrade Unbound to 1.6.1. More to follow.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Expression / Expression.h
1 //===-- Expression.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_Expression_h_
11 #define liblldb_Expression_h_
12
13 // C Includes
14 // C++ Includes
15 #include <map>
16 #include <string>
17 #include <vector>
18
19 // Other libraries and framework includes
20 // Project includes
21
22 #include "lldb/Expression/ExpressionTypeSystemHelper.h"
23 #include "lldb/lldb-forward.h"
24 #include "lldb/lldb-private.h"
25
26 namespace lldb_private {
27
28 class RecordingMemoryManager;
29
30 //----------------------------------------------------------------------
31 /// @class Expression Expression.h "lldb/Expression/Expression.h"
32 /// @brief Encapsulates a single expression for use in lldb
33 ///
34 /// LLDB uses expressions for various purposes, notably to call functions
35 /// and as a backend for the expr command.  Expression encapsulates
36 /// the objects needed to parse and interpret or JIT an expression.  It
37 /// uses the expression parser appropriate to the language of the expression
38 /// to produce LLVM IR from the expression.
39 //----------------------------------------------------------------------
40 class Expression {
41 public:
42   enum ResultType { eResultTypeAny, eResultTypeId };
43
44   Expression(Target &target);
45
46   Expression(ExecutionContextScope &exe_scope);
47
48   //------------------------------------------------------------------
49   /// Destructor
50   //------------------------------------------------------------------
51   virtual ~Expression() {}
52
53   //------------------------------------------------------------------
54   /// Return the string that the parser should parse.  Must be a full
55   /// translation unit.
56   //------------------------------------------------------------------
57   virtual const char *Text() = 0;
58
59   //------------------------------------------------------------------
60   /// Return the function name that should be used for executing the
61   /// expression.  Text() should contain the definition of this
62   /// function.
63   //------------------------------------------------------------------
64   virtual const char *FunctionName() = 0;
65
66   //------------------------------------------------------------------
67   /// Return the language that should be used when parsing.  To use
68   /// the default, return eLanguageTypeUnknown.
69   //------------------------------------------------------------------
70   virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
71
72   //------------------------------------------------------------------
73   /// Return the desired result type of the function, or
74   /// eResultTypeAny if indifferent.
75   //------------------------------------------------------------------
76   virtual ResultType DesiredResultType() { return eResultTypeAny; }
77
78   //------------------------------------------------------------------
79   /// Flags
80   //------------------------------------------------------------------
81
82   //------------------------------------------------------------------
83   /// Return true if validation code should be inserted into the
84   /// expression.
85   //------------------------------------------------------------------
86   virtual bool NeedsValidation() = 0;
87
88   //------------------------------------------------------------------
89   /// Return true if external variables in the expression should be
90   /// resolved.
91   //------------------------------------------------------------------
92   virtual bool NeedsVariableResolution() = 0;
93
94   virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
95
96   //------------------------------------------------------------------
97   /// Return the address of the function's JIT-compiled code, or
98   /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
99   //------------------------------------------------------------------
100   lldb::addr_t StartAddress() { return m_jit_start_addr; }
101
102   //------------------------------------------------------------------
103   /// Called to notify the expression that it is about to be executed.
104   //------------------------------------------------------------------
105   virtual void WillStartExecuting() {}
106
107   //------------------------------------------------------------------
108   /// Called to notify the expression that its execution has finished.
109   //------------------------------------------------------------------
110   virtual void DidFinishExecuting() {}
111
112   virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
113
114 protected:
115   lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
116   lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but
117                                     /// it doesn't need to (e.g. calculator
118                                     /// mode.)
119   lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within
120                                  ///the JIT allocation.  LLDB_INVALID_ADDRESS if
121                                  ///invalid.
122   lldb::addr_t m_jit_end_addr;   ///< The address of the JITted function within
123                                  ///the JIT allocation.  LLDB_INVALID_ADDRESS if
124                                  ///invalid.
125 };
126
127 } // namespace lldb_private
128
129 #endif // liblldb_Expression_h_