12c1f46dcSZachary Turner //===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
22c1f46dcSZachary Turner //
3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
62c1f46dcSZachary Turner //
72c1f46dcSZachary Turner //===----------------------------------------------------------------------===//
82c1f46dcSZachary Turner 
92c1f46dcSZachary Turner #include "ScriptInterpreterNone.h"
102c1f46dcSZachary Turner #include "lldb/Core/Debugger.h"
112c1f46dcSZachary Turner #include "lldb/Core/PluginManager.h"
122c1f46dcSZachary Turner #include "lldb/Core/StreamFile.h"
132c1f46dcSZachary Turner #include "lldb/Interpreter/CommandInterpreter.h"
14bf9a7730SZachary Turner #include "lldb/Utility/Stream.h"
15573ab909SZachary Turner #include "lldb/Utility/StringList.h"
162c1f46dcSZachary Turner 
17c5f28e2aSKamil Rytarowski #include "llvm/Support/Threading.h"
18c5f28e2aSKamil Rytarowski 
192c1f46dcSZachary Turner #include <mutex>
202c1f46dcSZachary Turner 
212c1f46dcSZachary Turner using namespace lldb;
222c1f46dcSZachary Turner using namespace lldb_private;
232c1f46dcSZachary Turner 
242c1f46dcSZachary Turner ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
25b9c1b51eSKate Stone     : ScriptInterpreter(interpreter, eScriptLanguageNone) {}
262c1f46dcSZachary Turner 
27b9c1b51eSKate Stone ScriptInterpreterNone::~ScriptInterpreterNone() {}
282c1f46dcSZachary Turner 
294d51a902SRaphael Isemann bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command,
30b9c1b51eSKate Stone                                            CommandReturnObject *,
31b9c1b51eSKate Stone                                            const ExecuteScriptOptions &) {
322c1f46dcSZachary Turner   m_interpreter.GetDebugger().GetErrorFile()->PutCString(
332c1f46dcSZachary Turner       "error: there is no embedded script interpreter in this mode.\n");
342c1f46dcSZachary Turner   return false;
352c1f46dcSZachary Turner }
362c1f46dcSZachary Turner 
37b9c1b51eSKate Stone void ScriptInterpreterNone::ExecuteInterpreterLoop() {
382c1f46dcSZachary Turner   m_interpreter.GetDebugger().GetErrorFile()->PutCString(
392c1f46dcSZachary Turner       "error: there is no embedded script interpreter in this mode.\n");
402c1f46dcSZachary Turner }
412c1f46dcSZachary Turner 
42b9c1b51eSKate Stone void ScriptInterpreterNone::Initialize() {
43c5f28e2aSKamil Rytarowski   static llvm::once_flag g_once_flag;
442c1f46dcSZachary Turner 
45c5f28e2aSKamil Rytarowski   llvm::call_once(g_once_flag, []() {
46b9c1b51eSKate Stone     PluginManager::RegisterPlugin(GetPluginNameStatic(),
47b9c1b51eSKate Stone                                   GetPluginDescriptionStatic(),
482c1f46dcSZachary Turner                                   lldb::eScriptLanguageNone, CreateInstance);
492c1f46dcSZachary Turner   });
502c1f46dcSZachary Turner }
512c1f46dcSZachary Turner 
52b9c1b51eSKate Stone void ScriptInterpreterNone::Terminate() {}
532c1f46dcSZachary Turner 
542c1f46dcSZachary Turner lldb::ScriptInterpreterSP
55b9c1b51eSKate Stone ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter) {
562c1f46dcSZachary Turner   return std::make_shared<ScriptInterpreterNone>(interpreter);
572c1f46dcSZachary Turner }
582c1f46dcSZachary Turner 
59b9c1b51eSKate Stone lldb_private::ConstString ScriptInterpreterNone::GetPluginNameStatic() {
602c1f46dcSZachary Turner   static ConstString g_name("script-none");
612c1f46dcSZachary Turner   return g_name;
622c1f46dcSZachary Turner }
632c1f46dcSZachary Turner 
64b9c1b51eSKate Stone const char *ScriptInterpreterNone::GetPluginDescriptionStatic() {
652c1f46dcSZachary Turner   return "Null script interpreter";
662c1f46dcSZachary Turner }
672c1f46dcSZachary Turner 
68b9c1b51eSKate Stone lldb_private::ConstString ScriptInterpreterNone::GetPluginName() {
692c1f46dcSZachary Turner   return GetPluginNameStatic();
702c1f46dcSZachary Turner }
712c1f46dcSZachary Turner 
72b9c1b51eSKate Stone uint32_t ScriptInterpreterNone::GetPluginVersion() { return 1; }
73