xref: /llvm-project/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp (revision 2c1f46dcc609a1bf61ab979eebdd72f81823ff74)
1 //===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "ScriptInterpreterNone.h"
11 #include "lldb/Core/Debugger.h"
12 #include "lldb/Core/PluginManager.h"
13 #include "lldb/Core/Stream.h"
14 #include "lldb/Core/StreamFile.h"
15 #include "lldb/Core/StringList.h"
16 #include "lldb/Interpreter/CommandInterpreter.h"
17 
18 #include <mutex>
19 
20 using namespace lldb;
21 using namespace lldb_private;
22 
23 ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
24     : ScriptInterpreter(interpreter, eScriptLanguageNone)
25 {
26 }
27 
28 ScriptInterpreterNone::~ScriptInterpreterNone()
29 {
30 }
31 
32 bool
33 ScriptInterpreterNone::ExecuteOneLine(const char *command, CommandReturnObject *, const ExecuteScriptOptions &)
34 {
35     m_interpreter.GetDebugger().GetErrorFile()->PutCString(
36         "error: there is no embedded script interpreter in this mode.\n");
37     return false;
38 }
39 
40 void
41 ScriptInterpreterNone::ExecuteInterpreterLoop()
42 {
43     m_interpreter.GetDebugger().GetErrorFile()->PutCString(
44         "error: there is no embedded script interpreter in this mode.\n");
45 }
46 
47 void
48 ScriptInterpreterNone::Initialize()
49 {
50     static std::once_flag g_once_flag;
51 
52     std::call_once(g_once_flag, []()
53                    {
54                        PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(),
55                                                      lldb::eScriptLanguageNone, CreateInstance);
56                    });
57 }
58 
59 void
60 ScriptInterpreterNone::Terminate()
61 {
62 }
63 
64 lldb::ScriptInterpreterSP
65 ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter)
66 {
67     return std::make_shared<ScriptInterpreterNone>(interpreter);
68 }
69 
70 lldb_private::ConstString
71 ScriptInterpreterNone::GetPluginNameStatic()
72 {
73     static ConstString g_name("script-none");
74     return g_name;
75 }
76 
77 const char *
78 ScriptInterpreterNone::GetPluginDescriptionStatic()
79 {
80     return "Null script interpreter";
81 }
82 
83 lldb_private::ConstString
84 ScriptInterpreterNone::GetPluginName()
85 {
86     return GetPluginNameStatic();
87 }
88 
89 uint32_t
90 ScriptInterpreterNone::GetPluginVersion()
91 {
92     return 1;
93 }
94