1 //===-- ExpressionSourceCode.h ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ExpressionSourceCode_h
11 #define liblldb_ExpressionSourceCode_h
13 #include "lldb/lldb-enumerations.h"
17 namespace lldb_private {
19 class ExecutionContext;
21 class ExpressionSourceCode {
23 static const char *g_expression_prefix;
25 static ExpressionSourceCode *CreateWrapped(const char *prefix,
27 return new ExpressionSourceCode("$__lldb_expr", prefix, body, true);
30 static ExpressionSourceCode *CreateUnwrapped(const char *name,
32 return new ExpressionSourceCode(name, "", body, false);
35 bool NeedsWrapping() const { return m_wrap; }
37 const char *GetName() const { return m_name.c_str(); }
39 bool GetText(std::string &text, lldb::LanguageType wrapping_language,
40 bool static_method, ExecutionContext &exe_ctx) const;
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);
51 ExpressionSourceCode(const char *name, const char *prefix, const char *body,
53 : m_name(name), m_prefix(prefix), m_body(body), m_wrap(wrap) {}
61 } // namespace lldb_private