1 //===-- ExpressionParser.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ExpressionParser_h_
11 #define liblldb_ExpressionParser_h_
13 #include "lldb/lldb-public.h"
14 #include "lldb/Core/Error.h"
16 namespace lldb_private
19 class IRExecutionUnit;
21 //----------------------------------------------------------------------
22 /// @class ExpressionParser ExpressionParser.h "lldb/Expression/ExpressionParser.h"
23 /// @brief Encapsulates an instance of a compiler that can parse expressions.
25 /// ExpressionParser is the base class for llvm based Expression parsers.
26 //----------------------------------------------------------------------
27 class ExpressionParser
30 //------------------------------------------------------------------
33 /// Initializes class variables.
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.
41 /// The expression to be parsed.
42 //------------------------------------------------------------------
43 ExpressionParser (ExecutionContextScope *exe_scope,
45 bool generate_debug_info) :
47 m_generate_debug_info(generate_debug_info)
51 //------------------------------------------------------------------
53 //------------------------------------------------------------------
54 virtual ~ExpressionParser () {};
56 //------------------------------------------------------------------
57 /// Parse a single expression and convert it to IR using Clang. Don't
58 /// wrap the expression in anything at all.
61 /// The stream to print errors to.
64 /// The number of errors encountered during parsing. 0 means
66 //------------------------------------------------------------------
68 Parse (Stream &stream) = 0;
70 //------------------------------------------------------------------
71 /// Ready an already-parsed expression for execution, possibly
72 /// evaluating it statically.
74 /// @param[out] func_addr
75 /// The address to which the function has been written.
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.)
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.
86 /// @param[in] exe_ctx
87 /// The execution context to write the function into.
89 /// @param[out] can_interpret
90 /// Set to true if the expression could be interpreted statically;
91 /// untouched otherwise.
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.
99 /// An error code indicating the success or failure of the operation.
100 /// Test with Success().
101 //------------------------------------------------------------------
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,
108 lldb_private::ExecutionPolicy execution_policy) = 0;
111 GetGenerateDebugInfo () const
113 return m_generate_debug_info;
117 Expression & m_expr; ///< The expression to be parsed
118 bool m_generate_debug_info;
123 #endif // liblldb_ExpressionParser_h_