]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Expression/Expression.h
Upgrade our copies of clang, llvm, lldb and compiler-rt to 3.8.0
[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 <string>
16 #include <map>
17 #include <vector>
18
19 // Other libraries and framework includes
20 // Project includes
21
22 #include "lldb/lldb-forward.h"
23 #include "lldb/lldb-private.h"
24 #include "lldb/Expression/ExpressionTypeSystemHelper.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 {
42 public:
43     enum ResultType {
44         eResultTypeAny,
45         eResultTypeId
46     };
47     
48     Expression (Target &target);
49     
50     Expression (ExecutionContextScope &exe_scope);
51     
52     //------------------------------------------------------------------
53     /// Destructor
54     //------------------------------------------------------------------
55     virtual ~Expression ()
56     {
57     }
58     
59     //------------------------------------------------------------------
60     /// Return the string that the parser should parse.  Must be a full
61     /// translation unit.
62     //------------------------------------------------------------------
63     virtual const char *
64     Text () = 0;
65     
66     //------------------------------------------------------------------
67     /// Return the function name that should be used for executing the
68     /// expression.  Text() should contain the definition of this
69     /// function.
70     //------------------------------------------------------------------
71     virtual const char *
72     FunctionName () = 0;
73     
74     //------------------------------------------------------------------
75     /// Return the language that should be used when parsing.  To use
76     /// the default, return eLanguageTypeUnknown.
77     //------------------------------------------------------------------
78     virtual lldb::LanguageType
79     Language ()
80     {
81         return lldb::eLanguageTypeUnknown;
82     }
83     
84     //------------------------------------------------------------------
85     /// Return the desired result type of the function, or 
86     /// eResultTypeAny if indifferent.
87     //------------------------------------------------------------------
88     virtual ResultType
89     DesiredResultType ()
90     {
91         return eResultTypeAny;
92     }
93     
94     //------------------------------------------------------------------
95     /// Flags
96     //------------------------------------------------------------------
97     
98     //------------------------------------------------------------------
99     /// Return true if validation code should be inserted into the
100     /// expression.
101     //------------------------------------------------------------------
102     virtual bool
103     NeedsValidation () = 0;
104     
105     //------------------------------------------------------------------
106     /// Return true if external variables in the expression should be
107     /// resolved.
108     //------------------------------------------------------------------
109     virtual bool
110     NeedsVariableResolution () = 0;
111
112     virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
113
114     //------------------------------------------------------------------
115     /// Return the address of the function's JIT-compiled code, or
116     /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
117     //------------------------------------------------------------------
118     lldb::addr_t
119     StartAddress ()
120     {
121         return m_jit_start_addr;
122     }
123     
124     virtual ExpressionTypeSystemHelper *
125     GetTypeSystemHelper ()
126     {
127         return nullptr;
128     }
129
130 protected:
131
132     lldb::TargetWP  m_target_wp;            /// Expression's always have to have a target...
133     lldb::ProcessWP m_jit_process_wp;       /// An expression might have a process, but it doesn't need to (e.g. calculator mode.)
134     lldb::addr_t    m_jit_start_addr;       ///< The address of the JITted function within the JIT allocation.  LLDB_INVALID_ADDRESS if invalid.
135     lldb::addr_t    m_jit_end_addr;         ///< The address of the JITted function within the JIT allocation.  LLDB_INVALID_ADDRESS if invalid.
136
137 };
138
139 } // namespace lldb_private
140
141 #endif  // liblldb_Expression_h_