]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Expression/ExpressionSourceCode.h
Vendor import of lldb release_39 branch r276489:
[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
20 class ExecutionContext;
21
22 class ExpressionSourceCode
23 {
24 public:
25     static const char * g_expression_prefix;
26
27     static ExpressionSourceCode *CreateWrapped (const char *prefix,
28                                                 const char *body)
29     {
30         return new ExpressionSourceCode ("$__lldb_expr",
31                                          prefix,
32                                          body,
33                                          true);
34     }
35     
36     static ExpressionSourceCode *CreateUnwrapped (const char *name,
37                                                   const char *body)
38     {
39         return new ExpressionSourceCode (name,
40                                          "",
41                                          body,
42                                          false);
43     }
44     
45     bool NeedsWrapping () const
46     {
47         return m_wrap;
48     }
49     
50     const char *GetName () const
51     {
52         return m_name.c_str();
53     }
54     
55     bool GetText (std::string &text, 
56                   lldb::LanguageType wrapping_language, 
57                   bool static_method,
58                   ExecutionContext &exe_ctx) const;
59     
60     // Given a string returned by GetText, find the beginning and end of the body passed to CreateWrapped.
61     // Return true if the bounds could be found.  This will also work on text with FixItHints applied.
62     static bool
63     GetOriginalBodyBounds(std::string transformed_text,
64                           lldb::LanguageType wrapping_language,
65                           size_t &start_loc,
66                           size_t &end_loc);
67     
68 private:
69     ExpressionSourceCode (const char *name,
70                           const char *prefix,
71                           const char *body,
72                           bool wrap) :
73         m_name(name),
74         m_prefix(prefix),
75         m_body(body),
76         m_wrap(wrap)
77     {
78     }
79     
80     std::string m_name;
81     std::string m_prefix;
82     std::string m_body;
83     bool m_wrap;
84 };
85
86 } // namespace lldb_private
87
88 #endif