ClangExpressionSourceCode.h revision 351290
138465Smsmith//===-- ClangExpressionSourceCode.h -----------------------------*- C++ -*-===// 238465Smsmith// 338465Smsmith// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 438465Smsmith// See https://llvm.org/LICENSE.txt for license information. 538465Smsmith// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 638465Smsmith// 738465Smsmith//===----------------------------------------------------------------------===// 838465Smsmith 938465Smsmith#ifndef liblldb_ClangExpressionSourceCode_h 1038465Smsmith#define liblldb_ClangExpressionSourceCode_h 1138465Smsmith 1238465Smsmith#include "lldb/Expression/Expression.h" 1338465Smsmith#include "lldb/Expression/ExpressionSourceCode.h" 1438465Smsmith#include "lldb/lldb-enumerations.h" 1538465Smsmith#include "llvm/ADT/ArrayRef.h" 1638465Smsmith#include "llvm/ADT/StringRef.h" 1738465Smsmith 1838465Smsmith#include <string> 1938465Smsmith 2038465Smsmithnamespace lldb_private { 2138465Smsmith 2238465Smsmithclass ExecutionContext; 2338465Smsmith 2438465Smsmithclass ClangExpressionSourceCode : public ExpressionSourceCode { 2538465Smsmithpublic: 2638465Smsmith static const char *g_expression_prefix; 27119482Sobrien 28119482Sobrien static ClangExpressionSourceCode *CreateWrapped(const char *prefix, 29119482Sobrien const char *body) { 3039902Smsmith return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, true); 3139902Smsmith } 3238465Smsmith 3340146Speter uint32_t GetNumBodyLines(); 3439902Smsmith 35183667Sjhb /// Generates the source code that will evaluate the expression. 36183667Sjhb /// 37183667Sjhb /// \param text output parameter containing the source code string. 3838465Smsmith /// \param wrapping_language If the expression is supossed to be wrapped, 3939902Smsmith /// then this is the language that should be used for that. 4039902Smsmith /// \param static_method True iff the expression is valuated inside a static 4138465Smsmith /// Objective-C method. 4238465Smsmith /// \param exe_ctx The execution context in which the expression will be 4338465Smsmith /// evaluated. 4438465Smsmith /// \param add_locals True iff local variables should be injected into the 4538465Smsmith /// expression source code. 4638465Smsmith /// \param force_add_all_locals True iff all local variables should be 4772640Sasmodai /// injected even if they are not used in the expression. 4838465Smsmith /// \param modules A list of (C++) modules that the expression should import. 4938465Smsmith /// 5038465Smsmith /// \return true iff the source code was successfully generated. 5138465Smsmith bool GetText(std::string &text, lldb::LanguageType wrapping_language, 5238465Smsmith bool static_method, ExecutionContext &exe_ctx, bool add_locals, 5344572Sdcs bool force_add_all_locals, 5438465Smsmith llvm::ArrayRef<std::string> modules) const; 5538465Smsmith 5638465Smsmith // Given a string returned by GetText, find the beginning and end of the body 5738465Smsmith // passed to CreateWrapped. Return true if the bounds could be found. This 58114379Speter // will also work on text with FixItHints applied. 5940107Smsmith static bool GetOriginalBodyBounds(std::string transformed_text, 60114379Speter lldb::LanguageType wrapping_language, 61114379Speter size_t &start_loc, size_t &end_loc); 6240107Smsmith 6338465Smsmithprotected: 6438465Smsmith ClangExpressionSourceCode(const char *name, const char *prefix, const char *body, 65114379Speter bool wrap) : 66114379Speter ExpressionSourceCode(name, prefix, body, wrap) {} 67114379Speter}; 68114379Speter 69114379Speter} // namespace lldb_private 70114379Speter 7140107Smsmith#endif 7240107Smsmith