1 //===-- CommandObjectExpression.h -------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_CommandObjectExpression_h_
10 #define liblldb_CommandObjectExpression_h_
11 
12 #include "lldb/Core/IOHandler.h"
13 #include "lldb/Interpreter/CommandObject.h"
14 #include "lldb/Interpreter/OptionGroupBoolean.h"
15 #include "lldb/Interpreter/OptionGroupFormat.h"
16 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
17 #include "lldb/Target/ExecutionContext.h"
18 #include "lldb/lldb-private-enumerations.h"
19 namespace lldb_private {
20 
21 class CommandObjectExpression : public CommandObjectRaw,
22                                 public IOHandlerDelegate {
23 public:
24   class CommandOptions : public OptionGroup {
25   public:
26     CommandOptions();
27 
28     ~CommandOptions() override;
29 
30     llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
31 
32     Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
33                           ExecutionContext *execution_context) override;
34 
35     void OptionParsingStarting(ExecutionContext *execution_context) override;
36 
37     bool top_level;
38     bool unwind_on_error;
39     bool ignore_breakpoints;
40     bool allow_jit;
41     bool show_types;
42     bool show_summary;
43     bool debug;
44     uint32_t timeout;
45     bool try_all_threads;
46     lldb::LanguageType language;
47     LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
48     LazyBool auto_apply_fixits;
49   };
50 
51   CommandObjectExpression(CommandInterpreter &interpreter);
52 
53   ~CommandObjectExpression() override;
54 
55   Options *GetOptions() override;
56 
57   int HandleCompletion(CompletionRequest &request) override;
58 
59 protected:
60   //------------------------------------------------------------------
61   // IOHandler::Delegate functions
62   //------------------------------------------------------------------
63   void IOHandlerInputComplete(IOHandler &io_handler,
64                               std::string &line) override;
65 
66   bool IOHandlerIsInputComplete(IOHandler &io_handler,
67                                 StringList &lines) override;
68 
69   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
70 
71   bool EvaluateExpression(llvm::StringRef expr, Stream *output_stream,
72                           Stream *error_stream,
73                           CommandReturnObject *result = NULL);
74 
75   void GetMultilineExpression();
76 
77   OptionGroupOptions m_option_group;
78   OptionGroupFormat m_format_options;
79   OptionGroupValueObjectDisplay m_varobj_options;
80   OptionGroupBoolean m_repl_option;
81   CommandOptions m_command_options;
82   uint32_t m_expr_line_count;
83   std::string m_expr_lines;       // Multi-line expression support
84   std::string m_fixed_expression; // Holds the current expression's fixed text.
85 };
86 
87 } // namespace lldb_private
88 
89 #endif // liblldb_CommandObjectExpression_h_
90