aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Expression/ExpressionSourceCode.h
blob: be1014ae3047992c0deda68cca6216db75744c94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//===-- ExpressionSourceCode.h ----------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_ExpressionSourceCode_h
#define liblldb_ExpressionSourceCode_h

#include "lldb/lldb-enumerations.h"

#include <string>

namespace lldb_private
{

class ExpressionSourceCode
{
public:
    static const char * g_expression_prefix;

    static ExpressionSourceCode *CreateWrapped (const char *prefix,
                                                const char *body)
    {
        return new ExpressionSourceCode ("$__lldb_expr",
                                         prefix,
                                         body,
                                         true);
    }
    
    static ExpressionSourceCode *CreateUnwrapped (const char *name,
                                                  const char *body)
    {
        return new ExpressionSourceCode (name,
                                         "",
                                         body,
                                         false);
    }
    
    bool NeedsWrapping () const
    {
        return m_wrap;
    }
    
    const char *GetName () const
    {
        return m_name.c_str();
    }
    
    bool GetText (std::string &text, 
                  lldb::LanguageType wrapping_language, 
                  bool const_object,
                  bool static_method) const;
    
private:
    ExpressionSourceCode (const char *name,
                          const char *prefix,
                          const char *body,
                          bool wrap) :
        m_name(name),
        m_prefix(prefix),
        m_body(body),
        m_wrap(wrap)
    {
    }
    
    std::string m_name;
    std::string m_prefix;
    std::string m_body;
    bool m_wrap;
};

} // namespace lldb_private

#endif