]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/ExpressionParser/Go/GoUserExpression.h
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / source / Plugins / ExpressionParser / Go / GoUserExpression.h
1 //===-- GoUserExpression.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_GoUserExpression_h_
11 #define liblldb_GoUserExpression_h_
12
13 // C Includes
14 // C++ Includes
15 #include <memory>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/lldb-forward.h"
20 #include "lldb/lldb-private.h"
21 #include "lldb/Expression/UserExpression.h"
22 #include "lldb/Expression/ExpressionVariable.h"
23 #include "lldb/Target/ExecutionContext.h"
24
25 namespace lldb_private
26 {
27 class GoParser;
28
29 class GoPersistentExpressionState : public PersistentExpressionState
30 {
31   public:
32     GoPersistentExpressionState();
33
34     ConstString GetNextPersistentVariableName() override;
35
36     void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
37
38     lldb::addr_t
39     LookupSymbol(const ConstString &name) override
40     {
41         return LLDB_INVALID_ADDRESS;
42     }
43
44     static bool
45     classof(const PersistentExpressionState *pv)
46     {
47         return pv->getKind() == PersistentExpressionState::eKindGo;
48     }
49
50   private:
51     uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName().
52 };
53
54 //----------------------------------------------------------------------
55 /// @class GoUserExpression GoUserExpression.h "lldb/Expression/GoUserExpression.h"
56 /// @brief Encapsulates a single expression for use with Go
57 ///
58 /// LLDB uses expressions for various purposes, notably to call functions
59 /// and as a backend for the expr command.  GoUserExpression encapsulates
60 /// the objects needed to parse and interpret an expression.
61 //----------------------------------------------------------------------
62 class GoUserExpression : public UserExpression
63 {
64   public:
65       GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
66                        lldb::LanguageType language, ResultType desired_type, const EvaluateExpressionOptions &options);
67
68       bool
69       Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
70             lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory,
71             bool generate_debug_info) override;
72
73       bool
74       CanInterpret() override
75       {
76           return true;
77       }
78       bool
79       FinalizeJITExecution(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
80                            lldb::ExpressionVariableSP &result,
81                            lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
82                            lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override
83       {
84           return true;
85     }
86
87   protected:
88       lldb::ExpressionResults
89       DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
90                 const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me,
91                 lldb::ExpressionVariableSP &result) override;
92
93   private:
94     class GoInterpreter;
95     std::unique_ptr<GoInterpreter> m_interpreter;
96 };
97
98 } // namespace lldb_private
99
100 #endif // liblldb_GoUserExpression_h_