blob: b429c68f023d5525241b57ca5f92c4dc40eb6a6f [file] [log] [blame]
Eugene Zelenko26f34fb2015-11-07 00:28:50 +00001//===-- GoUserExpression.h --------------------------------------*- C++ -*-===//
Ryan Brown998c8a1c12015-11-02 19:30:40 +00002//
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 Zelenko26f34fb2015-11-07 00:28:50 +000015#include <memory>
Ryan Brown998c8a1c12015-11-02 19:30:40 +000016
17// Other libraries and framework includes
18// Project includes
Ryan Brown998c8a1c12015-11-02 19:30:40 +000019#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
25namespace lldb_private
26{
27class GoParser;
28
29class 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//----------------------------------------------------------------------
62class GoUserExpression : public UserExpression
63{
64 public:
65 GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
Jim Ingham19a63fc2015-11-03 02:11:24 +000066 lldb::LanguageType language, ResultType desired_type, const EvaluateExpressionOptions &options);
Ryan Brown998c8a1c12015-11-02 19:30:40 +000067
Eugene Zelenko26f34fb2015-11-07 00:28:50 +000068 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 Brown998c8a1c12015-11-02 19:30:40 +000071
Eugene Zelenko26f34fb2015-11-07 00:28:50 +000072 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 Brown998c8a1c12015-11-02 19:30:40 +000077
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_