blob: 28c00215ed72b050fb341397c48147aaf963a6dd [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
Kate Stoneb9c1b512016-09-06 20:57:50 +000019#include "lldb/Expression/ExpressionVariable.h"
20#include "lldb/Expression/UserExpression.h"
21#include "lldb/Target/ExecutionContext.h"
Ryan Brown998c8a1c12015-11-02 19:30:40 +000022#include "lldb/lldb-forward.h"
23#include "lldb/lldb-private.h"
Ryan Brown998c8a1c12015-11-02 19:30:40 +000024
Kate Stoneb9c1b512016-09-06 20:57:50 +000025namespace lldb_private {
Ryan Brown998c8a1c12015-11-02 19:30:40 +000026class GoParser;
27
Kate Stoneb9c1b512016-09-06 20:57:50 +000028class GoPersistentExpressionState : public PersistentExpressionState {
29public:
30 GoPersistentExpressionState();
Ryan Brown998c8a1c12015-11-02 19:30:40 +000031
Adrian Prantl5435f782018-04-30 23:59:15 +000032 ConstString GetNextPersistentVariableName(Target &target) override;
Ryan Brown998c8a1c12015-11-02 19:30:40 +000033
Kate Stoneb9c1b512016-09-06 20:57:50 +000034 void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
Ryan Brown998c8a1c12015-11-02 19:30:40 +000035
Kate Stoneb9c1b512016-09-06 20:57:50 +000036 lldb::addr_t LookupSymbol(const ConstString &name) override {
37 return LLDB_INVALID_ADDRESS;
38 }
Ryan Brown998c8a1c12015-11-02 19:30:40 +000039
Kate Stoneb9c1b512016-09-06 20:57:50 +000040 static bool classof(const PersistentExpressionState *pv) {
41 return pv->getKind() == PersistentExpressionState::eKindGo;
42 }
Ryan Brown998c8a1c12015-11-02 19:30:40 +000043
Kate Stoneb9c1b512016-09-06 20:57:50 +000044private:
45 uint32_t m_next_persistent_variable_id; ///< The counter used by
46 ///GetNextResultName().
Ryan Brown998c8a1c12015-11-02 19:30:40 +000047};
48
49//----------------------------------------------------------------------
Kate Stoneb9c1b512016-09-06 20:57:50 +000050/// @class GoUserExpression GoUserExpression.h
51/// "lldb/Expression/GoUserExpression.h"
Ryan Brown998c8a1c12015-11-02 19:30:40 +000052/// @brief Encapsulates a single expression for use with Go
53///
54/// LLDB uses expressions for various purposes, notably to call functions
55/// and as a backend for the expr command. GoUserExpression encapsulates
56/// the objects needed to parse and interpret an expression.
57//----------------------------------------------------------------------
Kate Stoneb9c1b512016-09-06 20:57:50 +000058class GoUserExpression : public UserExpression {
59public:
Zachary Turnerc5d7df92016-11-08 04:52:16 +000060 GoUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
61 llvm::StringRef prefix, lldb::LanguageType language,
Kate Stoneb9c1b512016-09-06 20:57:50 +000062 ResultType desired_type,
63 const EvaluateExpressionOptions &options);
Ryan Brown998c8a1c12015-11-02 19:30:40 +000064
Kate Stoneb9c1b512016-09-06 20:57:50 +000065 bool Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
66 lldb_private::ExecutionPolicy execution_policy,
67 bool keep_result_in_memory, bool generate_debug_info) override;
Ryan Brown998c8a1c12015-11-02 19:30:40 +000068
Kate Stoneb9c1b512016-09-06 20:57:50 +000069 bool CanInterpret() override { return true; }
70 bool FinalizeJITExecution(
71 DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
72 lldb::ExpressionVariableSP &result,
73 lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
74 lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override {
75 return true;
76 }
Ryan Brown998c8a1c12015-11-02 19:30:40 +000077
Kate Stoneb9c1b512016-09-06 20:57:50 +000078protected:
79 lldb::ExpressionResults
80 DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
81 const EvaluateExpressionOptions &options,
82 lldb::UserExpressionSP &shared_ptr_to_me,
83 lldb::ExpressionVariableSP &result) override;
Jim Inghamff7ac6a2016-04-12 17:17:35 +000084
Kate Stoneb9c1b512016-09-06 20:57:50 +000085private:
86 class GoInterpreter;
87 std::unique_ptr<GoInterpreter> m_interpreter;
Ryan Brown998c8a1c12015-11-02 19:30:40 +000088};
89
90} // namespace lldb_private
91
92#endif // liblldb_GoUserExpression_h_