|
|
|||
File indexing completed on 2026-05-10 08:42:47
0001 //===-- ExpressionParser.h --------------------------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLDB_EXPRESSION_EXPRESSIONPARSER_H 0010 #define LLDB_EXPRESSION_EXPRESSIONPARSER_H 0011 0012 #include "lldb/Utility/CompletionRequest.h" 0013 #include "lldb/Utility/Status.h" 0014 #include "lldb/lldb-private-enumerations.h" 0015 #include "lldb/lldb-public.h" 0016 0017 namespace lldb_private { 0018 0019 class IRExecutionUnit; 0020 0021 /// \class ExpressionParser ExpressionParser.h 0022 /// "lldb/Expression/ExpressionParser.h" Encapsulates an instance of a 0023 /// compiler that can parse expressions. 0024 /// 0025 /// ExpressionParser is the base class for llvm based Expression parsers. 0026 class ExpressionParser { 0027 public: 0028 /// Constructor 0029 /// 0030 /// Initializes class variables. 0031 /// 0032 /// \param[in] exe_scope 0033 /// If non-NULL, an execution context scope that can help to 0034 /// correctly create an expression with a valid process for 0035 /// optional tuning Objective-C runtime support. Can be NULL. 0036 /// 0037 /// \param[in] expr 0038 /// The expression to be parsed. 0039 ExpressionParser(ExecutionContextScope *exe_scope, Expression &expr, 0040 bool generate_debug_info) 0041 : m_expr(expr), m_generate_debug_info(generate_debug_info) {} 0042 0043 /// Destructor 0044 virtual ~ExpressionParser() = default; 0045 0046 /// Attempts to find possible command line completions for the given 0047 /// expression. 0048 /// 0049 /// \param[out] request 0050 /// The completion request to fill out. The completion should be a string 0051 /// that would complete the current token at the cursor position. 0052 /// Note that the string in the list replaces the current token 0053 /// in the command line. 0054 /// 0055 /// \param[in] line 0056 /// The line with the completion cursor inside the expression as a string. 0057 /// The first line in the expression has the number 0. 0058 /// 0059 /// \param[in] pos 0060 /// The character position in the line with the completion cursor. 0061 /// If the value is 0, then the cursor is on top of the first character 0062 /// in the line (i.e. the user has requested completion from the start of 0063 /// the expression). 0064 /// 0065 /// \param[in] typed_pos 0066 /// The cursor position in the line as typed by the user. If the user 0067 /// expression has not been transformed in some form (e.g. wrapping it 0068 /// in a function body for C languages), then this is equal to the 0069 /// 'pos' parameter. The semantics of this value are otherwise equal to 0070 /// 'pos' (e.g. a value of 0 means the cursor is at start of the 0071 /// expression). 0072 /// 0073 /// \return 0074 /// True if we added any completion results to the output; 0075 /// false otherwise. 0076 virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos, 0077 unsigned typed_pos) = 0; 0078 0079 /// Try to use the FixIts in the diagnostic_manager to rewrite the 0080 /// expression. If successful, the rewritten expression is stored in the 0081 /// diagnostic_manager, get it out with GetFixedExpression. 0082 /// 0083 /// \param[in] diagnostic_manager 0084 /// The diagnostic manager containing fixit's to apply. 0085 /// 0086 /// \return 0087 /// \b true if the rewrite was successful, \b false otherwise. 0088 virtual bool RewriteExpression(DiagnosticManager &diagnostic_manager) { 0089 return false; 0090 } 0091 0092 /// Ready an already-parsed expression for execution, possibly evaluating it 0093 /// statically. 0094 /// 0095 /// \param[out] func_addr 0096 /// The address to which the function has been written. 0097 /// 0098 /// \param[out] func_end 0099 /// The end of the function's allocated memory region. (func_addr 0100 /// and func_end do not delimit an allocated region; the allocated 0101 /// region may begin before func_addr.) 0102 /// 0103 /// \param[in] execution_unit_sp 0104 /// After parsing, ownership of the execution unit for 0105 /// for the expression is handed to this shared pointer. 0106 /// 0107 /// \param[in] exe_ctx 0108 /// The execution context to write the function into. 0109 /// 0110 /// \param[out] can_interpret 0111 /// Set to true if the expression could be interpreted statically; 0112 /// untouched otherwise. 0113 /// 0114 /// \param[in] execution_policy 0115 /// Determines whether the expression must be JIT-compiled, must be 0116 /// evaluated statically, or whether this decision may be made 0117 /// opportunistically. 0118 /// 0119 /// \return 0120 /// An error code indicating the success or failure of the operation. 0121 /// Test with Success(). 0122 Status 0123 PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end, 0124 std::shared_ptr<IRExecutionUnit> &execution_unit_sp, 0125 ExecutionContext &exe_ctx, bool &can_interpret, 0126 lldb_private::ExecutionPolicy execution_policy); 0127 0128 bool GetGenerateDebugInfo() const { return m_generate_debug_info; } 0129 0130 protected: 0131 virtual Status 0132 DoPrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end, 0133 std::shared_ptr<IRExecutionUnit> &execution_unit_sp, 0134 ExecutionContext &exe_ctx, bool &can_interpret, 0135 lldb_private::ExecutionPolicy execution_policy) = 0; 0136 0137 private: 0138 /// Run all static initializers for an execution unit. 0139 /// 0140 /// \param[in] execution_unit_sp 0141 /// The execution unit. 0142 /// 0143 /// \param[in] exe_ctx 0144 /// The execution context to use when running them. Thread can't be null. 0145 /// 0146 /// \return 0147 /// The error code indicating the 0148 Status RunStaticInitializers(lldb::IRExecutionUnitSP &execution_unit_sp, 0149 ExecutionContext &exe_ctx); 0150 0151 protected: 0152 Expression &m_expr; ///< The expression to be parsed 0153 bool m_generate_debug_info; 0154 }; 0155 } 0156 0157 #endif // LLDB_EXPRESSION_EXPRESSIONPARSER_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|