1349cc55cSDimitry Andric //===-- ClangREPL.h ---------------------------------------------*- C++ -*-===// 2349cc55cSDimitry Andric // 3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6349cc55cSDimitry Andric // 7349cc55cSDimitry Andric //===----------------------------------------------------------------------===// 8349cc55cSDimitry Andric 9349cc55cSDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_REPL_CLANG_CLANGREPL_H 10349cc55cSDimitry Andric #define LLDB_SOURCE_PLUGINS_REPL_CLANG_CLANGREPL_H 11349cc55cSDimitry Andric 12349cc55cSDimitry Andric #include "lldb/Expression/REPL.h" 13349cc55cSDimitry Andric 14349cc55cSDimitry Andric namespace lldb_private { 15349cc55cSDimitry Andric /// Implements a Clang-based REPL for C languages on top of LLDB's REPL 16349cc55cSDimitry Andric /// framework. 17*06c3fb27SDimitry Andric class ClangREPL : public llvm::RTTIExtends<ClangREPL, REPL> { 18349cc55cSDimitry Andric public: 19*06c3fb27SDimitry Andric // LLVM RTTI support 20*06c3fb27SDimitry Andric static char ID; 21*06c3fb27SDimitry Andric 22349cc55cSDimitry Andric ClangREPL(lldb::LanguageType language, Target &target); 23349cc55cSDimitry Andric 24349cc55cSDimitry Andric ~ClangREPL() override; 25349cc55cSDimitry Andric 26349cc55cSDimitry Andric static void Initialize(); 27349cc55cSDimitry Andric 28349cc55cSDimitry Andric static void Terminate(); 29349cc55cSDimitry Andric 30349cc55cSDimitry Andric static lldb::REPLSP CreateInstance(Status &error, lldb::LanguageType language, 31349cc55cSDimitry Andric Debugger *debugger, Target *target, 32349cc55cSDimitry Andric const char *repl_options); 33349cc55cSDimitry Andric GetPluginNameStatic()34349cc55cSDimitry Andric static llvm::StringRef GetPluginNameStatic() { return "ClangREPL"; } 35349cc55cSDimitry Andric 36349cc55cSDimitry Andric protected: 37349cc55cSDimitry Andric Status DoInitialization() override; 38349cc55cSDimitry Andric 39*06c3fb27SDimitry Andric llvm::StringRef GetSourceFileBasename() override; 40349cc55cSDimitry Andric 41349cc55cSDimitry Andric const char *GetAutoIndentCharacters() override; 42349cc55cSDimitry Andric 43349cc55cSDimitry Andric bool SourceIsComplete(const std::string &source) override; 44349cc55cSDimitry Andric 45349cc55cSDimitry Andric lldb::offset_t GetDesiredIndentation(const StringList &lines, 46349cc55cSDimitry Andric int cursor_position, 47349cc55cSDimitry Andric int tab_size) override; 48349cc55cSDimitry Andric 49349cc55cSDimitry Andric lldb::LanguageType GetLanguage() override; 50349cc55cSDimitry Andric 51349cc55cSDimitry Andric bool PrintOneVariable(Debugger &debugger, lldb::StreamFileSP &output_sp, 52349cc55cSDimitry Andric lldb::ValueObjectSP &valobj_sp, 53349cc55cSDimitry Andric ExpressionVariable *var = nullptr) override; 54349cc55cSDimitry Andric 55349cc55cSDimitry Andric void CompleteCode(const std::string ¤t_code, 56349cc55cSDimitry Andric CompletionRequest &request) override; 57349cc55cSDimitry Andric 58349cc55cSDimitry Andric private: 59349cc55cSDimitry Andric /// The specific C language of this REPL. 60349cc55cSDimitry Andric lldb::LanguageType m_language; 61349cc55cSDimitry Andric /// A regex matching the implicitly created LLDB result variables. 62349cc55cSDimitry Andric lldb_private::RegularExpression m_implicit_expr_result_regex; 63349cc55cSDimitry Andric }; 64349cc55cSDimitry Andric } // namespace lldb_private 65349cc55cSDimitry Andric 66349cc55cSDimitry Andric #endif // LLDB_SOURCE_PLUGINS_REPL_CLANG_CLANGREPL_H 67