| Eugene Zelenko | 26f34fb | 2015-11-07 00:28:50 +0000 | [diff] [blame] | 1 | //===-- GoUserExpression.h --------------------------------------*- C++ -*-===// |
| Ryan Brown | 998c8a1c1 | 2015-11-02 19:30:40 +0000 | [diff] [blame] | 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 |
| Eugene Zelenko | 26f34fb | 2015-11-07 00:28:50 +0000 | [diff] [blame] | 15 | #include <memory> |
| Ryan Brown | 998c8a1c1 | 2015-11-02 19:30:40 +0000 | [diff] [blame] | 16 | |
| 17 | // Other libraries and framework includes |
| 18 | // Project includes |
| Ryan Brown | 998c8a1c1 | 2015-11-02 19:30:40 +0000 | [diff] [blame] | 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, |
| Jim Ingham | 19a63fc | 2015-11-03 02:11:24 +0000 | [diff] [blame] | 66 | lldb::LanguageType language, ResultType desired_type, const EvaluateExpressionOptions &options); |
| Ryan Brown | 998c8a1c1 | 2015-11-02 19:30:40 +0000 | [diff] [blame] | 67 | |
| Eugene Zelenko | 26f34fb | 2015-11-07 00:28:50 +0000 | [diff] [blame] | 68 | bool |
| 69 | Parse(Stream &error_stream, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy, |
| 70 | bool keep_result_in_memory, bool generate_debug_info) override; |
| Ryan Brown | 998c8a1c1 | 2015-11-02 19:30:40 +0000 | [diff] [blame] | 71 | |
| Eugene Zelenko | 26f34fb | 2015-11-07 00:28:50 +0000 | [diff] [blame] | 72 | lldb::ExpressionResults |
| 73 | Execute(Stream &error_stream, ExecutionContext &exe_ctx, |
| 74 | const EvaluateExpressionOptions &options, |
| 75 | lldb::UserExpressionSP &shared_ptr_to_me, |
| 76 | lldb::ExpressionVariableSP &result) override; |
| Ryan Brown | 998c8a1c1 | 2015-11-02 19:30:40 +0000 | [diff] [blame] | 77 | |
| 78 | bool |
| 79 | CanInterpret() override |
| 80 | { |
| 81 | return true; |
| 82 | } |
| 83 | bool |
| 84 | FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result, |
| 85 | lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS, |
| 86 | lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override |
| 87 | { |
| 88 | return true; |
| 89 | } |
| 90 | |
| 91 | private: |
| 92 | class GoInterpreter; |
| 93 | std::unique_ptr<GoInterpreter> m_interpreter; |
| 94 | }; |
| 95 | |
| 96 | } // namespace lldb_private |
| 97 | |
| 98 | #endif // liblldb_GoUserExpression_h_ |