diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2013-08-23 18:06:42 +0000 | 
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2013-08-23 18:06:42 +0000 | 
| commit | ac7ddfbf72ce0012cf2944eeb05192d9d281fde1 (patch) | |
| tree | 05d762b98a499804ce690e6ce04033f1ddf4dee6 /contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp | |
| parent | aa9a5cc05a9fad687997910ba3252e073231daf3 (diff) | |
| parent | f034231a6a1fd5d6395206c1651de8cd9402cca3 (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp')
| -rw-r--r-- | contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp | 142 | 
1 files changed, 142 insertions, 0 deletions
diff --git a/contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp b/contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp new file mode 100644 index 000000000000..aef3b9e301e5 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/Expression/ExpressionSourceCode.cpp @@ -0,0 +1,142 @@ +//===-- ExpressionSourceCode.cpp --------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Expression/ExpressionSourceCode.h" + +#include "lldb/Core/StreamString.h" + +using namespace lldb_private; + +const char * +ExpressionSourceCode::g_expression_prefix = R"( +#undef NULL +#undef Nil +#undef nil +#undef YES +#undef NO +#define NULL (__null) +#define Nil (__null) +#define nil (__null) +#define YES ((BOOL)1) +#define NO ((BOOL)0) +typedef signed char BOOL; +typedef signed __INT8_TYPE__ int8_t; +typedef unsigned __INT8_TYPE__ uint8_t; +typedef signed __INT16_TYPE__ int16_t; +typedef unsigned __INT16_TYPE__ uint16_t; +typedef signed __INT32_TYPE__ int32_t; +typedef unsigned __INT32_TYPE__ uint32_t; +typedef signed __INT64_TYPE__ int64_t; +typedef unsigned __INT64_TYPE__ uint64_t; +typedef signed __INTPTR_TYPE__ intptr_t; +typedef unsigned __INTPTR_TYPE__ uintptr_t; +typedef __SIZE_TYPE__ size_t; +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef unsigned short unichar; +)"; + + +bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrapping_language, bool const_object, bool static_method) const +{ +    if (m_wrap) +    { +        switch (wrapping_language)  +        { +        default: +            return false; +        case lldb::eLanguageTypeC: +        case lldb::eLanguageTypeC_plus_plus: +        case lldb::eLanguageTypeObjC: +            break; +        } +         +        StreamString wrap_stream; +         +        switch (wrapping_language)  +        { +        default: +            break; +        case lldb::eLanguageTypeC: +            wrap_stream.Printf("%s                             \n" +                               "%s                             \n" +                               "void                           \n" +                               "%s(void *$__lldb_arg)          \n" +                               "{                              \n" +                               "    %s;                        \n"  +                               "}                              \n", +                               g_expression_prefix, +                               m_prefix.c_str(), +                               m_name.c_str(), +                               m_body.c_str()); +            break; +        case lldb::eLanguageTypeC_plus_plus: +            wrap_stream.Printf("%s                                     \n" +                               "%s                                     \n" +                               "void                                   \n" +                               "$__lldb_class::%s(void *$__lldb_arg) %s\n" +                               "{                                      \n" +                               "    %s;                                \n"  +                               "}                                      \n", +                               g_expression_prefix, +                               m_prefix.c_str(), +                               m_name.c_str(), +                               (const_object ? "const" : ""), +                               m_body.c_str()); +            break; +        case lldb::eLanguageTypeObjC: +            if (static_method) +            { +                wrap_stream.Printf("%s                                                      \n" +                                   "%s                                                      \n" +                                   "@interface $__lldb_objc_class ($__lldb_category)        \n" +                                   "+(void)%s:(void *)$__lldb_arg;                          \n" +                                   "@end                                                    \n" +                                   "@implementation $__lldb_objc_class ($__lldb_category)   \n" +                                   "+(void)%s:(void *)$__lldb_arg                           \n" +                                   "{                                                       \n" +                                   "    %s;                                                 \n" +                                   "}                                                       \n" +                                   "@end                                                    \n", +                                   g_expression_prefix, +                                   m_prefix.c_str(), +                                   m_name.c_str(), +                                   m_name.c_str(), +                                   m_body.c_str()); +            } +            else +            { +                wrap_stream.Printf("%s                                                     \n" +                                   "%s                                                     \n" +                                   "@interface $__lldb_objc_class ($__lldb_category)       \n" +                                   "-(void)%s:(void *)$__lldb_arg;                         \n" +                                   "@end                                                   \n" +                                   "@implementation $__lldb_objc_class ($__lldb_category)  \n" +                                   "-(void)%s:(void *)$__lldb_arg                          \n" +                                   "{                                                      \n" +                                   "    %s;                                                \n" +                                   "}                                                      \n" +                                   "@end                                                   \n", +                                   g_expression_prefix, +                                   m_prefix.c_str(), +                                   m_name.c_str(), +                                   m_name.c_str(), +                                   m_body.c_str()); +            } +            break; +        } +         +        text = wrap_stream.GetString(); +    } +    else +    { +        text.append(m_body); +    } +     +    return true; +}  | 
