]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Expression/ExpressionSourceCode.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / include / lldb / Expression / ExpressionSourceCode.h
1 //===-- ExpressionSourceCode.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_ExpressionSourceCode_h
11 #define liblldb_ExpressionSourceCode_h
12
13 #include "lldb/lldb-enumerations.h"
14
15 #include <string>
16
17 namespace lldb_private {
18
19 class ExecutionContext;
20
21 class ExpressionSourceCode {
22 public:
23   static const char *g_expression_prefix;
24
25   static ExpressionSourceCode *CreateWrapped(const char *prefix,
26                                              const char *body) {
27     return new ExpressionSourceCode("$__lldb_expr", prefix, body, true);
28   }
29
30   static ExpressionSourceCode *CreateUnwrapped(const char *name,
31                                                const char *body) {
32     return new ExpressionSourceCode(name, "", body, false);
33   }
34
35   bool NeedsWrapping() const { return m_wrap; }
36
37   const char *GetName() const { return m_name.c_str(); }
38
39   bool GetText(std::string &text, lldb::LanguageType wrapping_language,
40                bool static_method, ExecutionContext &exe_ctx) const;
41
42   // Given a string returned by GetText, find the beginning and end of the body
43   // passed to CreateWrapped.
44   // Return true if the bounds could be found.  This will also work on text with
45   // FixItHints applied.
46   static bool GetOriginalBodyBounds(std::string transformed_text,
47                                     lldb::LanguageType wrapping_language,
48                                     size_t &start_loc, size_t &end_loc);
49
50 private:
51   ExpressionSourceCode(const char *name, const char *prefix, const char *body,
52                        bool wrap)
53       : m_name(name), m_prefix(prefix), m_body(body), m_wrap(wrap) {}
54
55   std::string m_name;
56   std::string m_prefix;
57   std::string m_body;
58   bool m_wrap;
59 };
60
61 } // namespace lldb_private
62
63 #endif