1 //===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "ScriptInterpreterNone.h"
10 #include "lldb/Core/Debugger.h"
11 #include "lldb/Core/PluginManager.h"
12 #include "lldb/Core/StreamFile.h"
13 #include "lldb/Interpreter/CommandInterpreter.h"
14 #include "lldb/Utility/Stream.h"
15 #include "lldb/Utility/StringList.h"
16 
17 #include "llvm/Support/Threading.h"
18 
19 #include <mutex>
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
24 ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
25     : ScriptInterpreter(interpreter, eScriptLanguageNone) {}
26 
27 ScriptInterpreterNone::~ScriptInterpreterNone() {}
28 
29 bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command,
30                                            CommandReturnObject *,
31                                            const ExecuteScriptOptions &) {
32   m_interpreter.GetDebugger().GetErrorFile()->PutCString(
33       "error: there is no embedded script interpreter in this mode.\n");
34   return false;
35 }
36 
37 void ScriptInterpreterNone::ExecuteInterpreterLoop() {
38   m_interpreter.GetDebugger().GetErrorFile()->PutCString(
39       "error: there is no embedded script interpreter in this mode.\n");
40 }
41 
42 void ScriptInterpreterNone::Initialize() {
43   static llvm::once_flag g_once_flag;
44 
45   llvm::call_once(g_once_flag, []() {
46     PluginManager::RegisterPlugin(GetPluginNameStatic(),
47                                   GetPluginDescriptionStatic(),
48                                   lldb::eScriptLanguageNone, CreateInstance);
49   });
50 }
51 
52 void ScriptInterpreterNone::Terminate() {}
53 
54 lldb::ScriptInterpreterSP
55 ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter) {
56   return std::make_shared<ScriptInterpreterNone>(interpreter);
57 }
58 
59 lldb_private::ConstString ScriptInterpreterNone::GetPluginNameStatic() {
60   static ConstString g_name("script-none");
61   return g_name;
62 }
63 
64 const char *ScriptInterpreterNone::GetPluginDescriptionStatic() {
65   return "Null script interpreter";
66 }
67 
68 lldb_private::ConstString ScriptInterpreterNone::GetPluginName() {
69   return GetPluginNameStatic();
70 }
71 
72 uint32_t ScriptInterpreterNone::GetPluginVersion() { return 1; }
73