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/lldb-private-enumerations.h"
18 namespace lldb_private {
19 
20 class CommandObjectExpression : public CommandObjectRaw,
21                                 public IOHandlerDelegate {
22 public:
23   class CommandOptions : public OptionGroup {
24   public:
25     CommandOptions();
26 
27     ~CommandOptions() override;
28 
29     llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
30 
31     Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
32                           ExecutionContext *execution_context) override;
33 
34     void OptionParsingStarting(ExecutionContext *execution_context) override;
35 
36     bool top_level;
37     bool unwind_on_error;
38     bool ignore_breakpoints;
39     bool allow_jit;
40     bool show_types;
41     bool show_summary;
42     bool debug;
43     uint32_t timeout;
44     bool try_all_threads;
45     lldb::LanguageType language;
46     LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
47     LazyBool auto_apply_fixits;
48   };
49 
50   CommandObjectExpression(CommandInterpreter &interpreter);
51 
52   ~CommandObjectExpression() override;
53 
54   Options *GetOptions() override;
55 
56   void HandleCompletion(CompletionRequest &request) override;
57 
58 protected:
59   // IOHandler::Delegate functions
60   void IOHandlerInputComplete(IOHandler &io_handler,
61                               std::string &line) override;
62 
63   bool IOHandlerIsInputComplete(IOHandler &io_handler,
64                                 StringList &lines) override;
65 
66   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
67 
68   bool EvaluateExpression(llvm::StringRef expr, Stream *output_stream,
69                           Stream *error_stream,
70                           CommandReturnObject *result = nullptr);
71 
72   void GetMultilineExpression();
73 
74   OptionGroupOptions m_option_group;
75   OptionGroupFormat m_format_options;
76   OptionGroupValueObjectDisplay m_varobj_options;
77   OptionGroupBoolean m_repl_option;
78   CommandOptions m_command_options;
79   uint32_t m_expr_line_count;
80   std::string m_expr_lines;       // Multi-line expression support
81   std::string m_fixed_expression; // Holds the current expression's fixed text.
82 };
83 
84 } // namespace lldb_private
85 
86 #endif // liblldb_CommandObjectExpression_h_
87