blob: 4bd4c6a029a0fdec414923a1258d05eb2b9167d7 [file] [log] [blame]
Zachary Turner2c1f46d2015-07-30 20:28:07 +00001//===-- 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"
Zachary Turner2c1f46d2015-07-30 20:28:07 +000013#include "lldb/Core/StreamFile.h"
Zachary Turner2c1f46d2015-07-30 20:28:07 +000014#include "lldb/Interpreter/CommandInterpreter.h"
Zachary Turnerbf9a7732017-02-02 21:39:50 +000015#include "lldb/Utility/Stream.h"
Zachary Turner573ab902017-03-21 18:25:04 +000016#include "lldb/Utility/StringList.h"
Zachary Turner2c1f46d2015-07-30 20:28:07 +000017
Kamil Rytarowskic5f28e22017-02-06 17:55:02 +000018#include "llvm/Support/Threading.h"
19
Zachary Turner2c1f46d2015-07-30 20:28:07 +000020#include <mutex>
21
22using namespace lldb;
23using namespace lldb_private;
24
25ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
Kate Stoneb9c1b512016-09-06 20:57:50 +000026 : ScriptInterpreter(interpreter, eScriptLanguageNone) {}
27
28ScriptInterpreterNone::~ScriptInterpreterNone() {}
29
Raphael Isemann4d51a902018-07-12 22:28:52 +000030bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command,
Kate Stoneb9c1b512016-09-06 20:57:50 +000031 CommandReturnObject *,
32 const ExecuteScriptOptions &) {
33 m_interpreter.GetDebugger().GetErrorFile()->PutCString(
34 "error: there is no embedded script interpreter in this mode.\n");
35 return false;
Zachary Turner2c1f46d2015-07-30 20:28:07 +000036}
37
Kate Stoneb9c1b512016-09-06 20:57:50 +000038void ScriptInterpreterNone::ExecuteInterpreterLoop() {
39 m_interpreter.GetDebugger().GetErrorFile()->PutCString(
40 "error: there is no embedded script interpreter in this mode.\n");
Zachary Turner2c1f46d2015-07-30 20:28:07 +000041}
42
Kate Stoneb9c1b512016-09-06 20:57:50 +000043void ScriptInterpreterNone::Initialize() {
Kamil Rytarowskic5f28e22017-02-06 17:55:02 +000044 static llvm::once_flag g_once_flag;
Kate Stoneb9c1b512016-09-06 20:57:50 +000045
Kamil Rytarowskic5f28e22017-02-06 17:55:02 +000046 llvm::call_once(g_once_flag, []() {
Kate Stoneb9c1b512016-09-06 20:57:50 +000047 PluginManager::RegisterPlugin(GetPluginNameStatic(),
48 GetPluginDescriptionStatic(),
49 lldb::eScriptLanguageNone, CreateInstance);
50 });
Zachary Turner2c1f46d2015-07-30 20:28:07 +000051}
52
Kate Stoneb9c1b512016-09-06 20:57:50 +000053void ScriptInterpreterNone::Terminate() {}
Zachary Turner2c1f46d2015-07-30 20:28:07 +000054
55lldb::ScriptInterpreterSP
Kate Stoneb9c1b512016-09-06 20:57:50 +000056ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter) {
57 return std::make_shared<ScriptInterpreterNone>(interpreter);
Zachary Turner2c1f46d2015-07-30 20:28:07 +000058}
59
Kate Stoneb9c1b512016-09-06 20:57:50 +000060lldb_private::ConstString ScriptInterpreterNone::GetPluginNameStatic() {
61 static ConstString g_name("script-none");
62 return g_name;
Zachary Turner2c1f46d2015-07-30 20:28:07 +000063}
64
Kate Stoneb9c1b512016-09-06 20:57:50 +000065const char *ScriptInterpreterNone::GetPluginDescriptionStatic() {
66 return "Null script interpreter";
Zachary Turner2c1f46d2015-07-30 20:28:07 +000067}
68
Kate Stoneb9c1b512016-09-06 20:57:50 +000069lldb_private::ConstString ScriptInterpreterNone::GetPluginName() {
70 return GetPluginNameStatic();
Zachary Turner2c1f46d2015-07-30 20:28:07 +000071}
72
Kate Stoneb9c1b512016-09-06 20:57:50 +000073uint32_t ScriptInterpreterNone::GetPluginVersion() { return 1; }