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