]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Expression/ExpressionParser.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 / ExpressionParser.h
1 //===-- ExpressionParser.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_ExpressionParser_h_
11 #define liblldb_ExpressionParser_h_
12
13 #include "lldb/lldb-public.h"
14 #include "lldb/Core/Error.h"
15
16 namespace lldb_private
17 {
18
19 class IRExecutionUnit;
20     
21 //----------------------------------------------------------------------
22 /// @class ExpressionParser ExpressionParser.h "lldb/Expression/ExpressionParser.h"
23 /// @brief Encapsulates an instance of a compiler that can parse expressions.
24 ///
25 /// ExpressionParser is the base class for llvm based Expression parsers.
26 //----------------------------------------------------------------------
27 class ExpressionParser
28 {
29 public:
30     //------------------------------------------------------------------
31     /// Constructor
32     ///
33     /// Initializes class variables.
34     ///
35     /// @param[in] exe_scope,
36     ///     If non-NULL, an execution context scope that can help to 
37     ///     correctly create an expression with a valid process for 
38     ///     optional tuning Objective-C runtime support. Can be NULL.
39     ///
40     /// @param[in] expr
41     ///     The expression to be parsed.
42     //------------------------------------------------------------------
43     ExpressionParser (ExecutionContextScope *exe_scope,
44                       Expression &expr,
45                       bool generate_debug_info) :
46         m_expr(expr),
47         m_generate_debug_info(generate_debug_info)
48     {
49     }
50     
51     //------------------------------------------------------------------
52     /// Destructor
53     //------------------------------------------------------------------
54     virtual ~ExpressionParser () {};
55     
56     //------------------------------------------------------------------
57     /// Parse a single expression and convert it to IR using Clang.  Don't
58     /// wrap the expression in anything at all.
59     ///
60     /// @param[in] stream
61     ///     The stream to print errors to.
62     ///
63     /// @return
64     ///     The number of errors encountered during parsing.  0 means
65     ///     success.
66     //------------------------------------------------------------------
67     virtual unsigned
68     Parse (Stream &stream) = 0;
69     
70     //------------------------------------------------------------------
71     /// Ready an already-parsed expression for execution, possibly
72     /// evaluating it statically.
73     ///
74     /// @param[out] func_addr
75     ///     The address to which the function has been written.
76     ///
77     /// @param[out] func_end
78     ///     The end of the function's allocated memory region.  (func_addr
79     ///     and func_end do not delimit an allocated region; the allocated
80     ///     region may begin before func_addr.)
81     ///
82     /// @param[in] execution_unit_sp
83     ///     After parsing, ownership of the execution unit for
84     ///     for the expression is handed to this shared pointer.
85     ///
86     /// @param[in] exe_ctx
87     ///     The execution context to write the function into.
88     ///
89     /// @param[out] can_interpret
90     ///     Set to true if the expression could be interpreted statically;
91     ///     untouched otherwise.
92     ///
93     /// @param[in] execution_policy
94     ///     Determines whether the expression must be JIT-compiled, must be
95     ///     evaluated statically, or whether this decision may be made
96     ///     opportunistically.
97     ///
98     /// @return
99     ///     An error code indicating the success or failure of the operation.
100     ///     Test with Success().
101     //------------------------------------------------------------------
102     virtual Error
103     PrepareForExecution (lldb::addr_t &func_addr,
104                          lldb::addr_t &func_end,
105                          std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
106                          ExecutionContext &exe_ctx,
107                          bool &can_interpret,
108                          lldb_private::ExecutionPolicy execution_policy) = 0;
109         
110     bool
111     GetGenerateDebugInfo () const
112     {
113         return m_generate_debug_info;
114     }
115     
116 protected:
117     Expression &                       m_expr;                       ///< The expression to be parsed
118     bool                               m_generate_debug_info;
119 };
120     
121 }
122
123 #endif  // liblldb_ExpressionParser_h_