blob: 5c6f8eb296338be51fc1b90dddbb7699d1e9d8de [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- ScriptInterpreter.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 "lldb/Interpreter/ScriptInterpreter.h"
11
12#include <string>
13#include <stdlib.h>
14#include <stdio.h>
15
16#include "lldb/Core/Error.h"
17#include "lldb/Core/Stream.h"
18#include "lldb/Core/StringList.h"
19#include "lldb/Interpreter/CommandReturnObject.h"
Caroline Tice0aa2e552011-01-14 00:29:16 +000020#include "lldb/Interpreter/ScriptInterpreterPython.h"
Jason Molendadea5ea72010-06-09 21:28:42 +000021#include "lldb/Utility/PseudoTerminal.h"
Chris Lattner24943d22010-06-08 16:52:24 +000022
23using namespace lldb;
24using namespace lldb_private;
25
Caroline Tice0aa2e552011-01-14 00:29:16 +000026ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang) :
Greg Clayton238c0a12010-09-18 01:14:36 +000027 m_interpreter (interpreter),
Greg Clayton177bc682012-01-27 00:13:27 +000028 m_script_lang (script_lang)
Chris Lattner24943d22010-06-08 16:52:24 +000029{
Chris Lattner24943d22010-06-08 16:52:24 +000030}
31
32ScriptInterpreter::~ScriptInterpreter ()
33{
Chris Lattner24943d22010-06-08 16:52:24 +000034}
35
Caroline Tice0aa2e552011-01-14 00:29:16 +000036CommandInterpreter &
37ScriptInterpreter::GetCommandInterpreter ()
38{
39 return m_interpreter;
40}
41
Chris Lattner24943d22010-06-08 16:52:24 +000042void
43ScriptInterpreter::CollectDataForBreakpointCommandCallback
44(
Chris Lattner24943d22010-06-08 16:52:24 +000045 BreakpointOptions *bp_options,
46 CommandReturnObject &result
47)
48{
49 result.SetStatus (eReturnStatusFailed);
50 result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
51}
52
Johnny Chenf3ec4612012-08-09 23:09:42 +000053void
54ScriptInterpreter::CollectDataForWatchpointCommandCallback
55(
56 WatchpointOptions *bp_options,
57 CommandReturnObject &result
58)
59{
60 result.SetStatus (eReturnStatusFailed);
61 result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
62}
63
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000064std::string
65ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language)
66{
67 std::string return_value;
Chris Lattner24943d22010-06-08 16:52:24 +000068
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000069 switch (language)
70 {
71 case eScriptLanguageNone:
72 return_value = "None";
73 break;
74 case eScriptLanguagePython:
75 return_value = "Python";
76 break;
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000077 }
78
79 return return_value;
80}
Caroline Tice0aa2e552011-01-14 00:29:16 +000081
82void
Enrico Granata1328b142012-02-29 03:28:49 +000083ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback)
Caroline Tice0aa2e552011-01-14 00:29:16 +000084{
Greg Clayton3e4238d2011-11-04 03:34:56 +000085#ifndef LLDB_DISABLE_PYTHON
Enrico Granata1328b142012-02-29 03:28:49 +000086 ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback);
Greg Clayton3e4238d2011-11-04 03:34:56 +000087#endif // #ifndef LLDB_DISABLE_PYTHON
Caroline Tice0aa2e552011-01-14 00:29:16 +000088}
89
90void
Greg Claytone86cbb92011-03-22 01:14:58 +000091ScriptInterpreter::TerminateInterpreter ()
Caroline Tice0aa2e552011-01-14 00:29:16 +000092{
Greg Clayton3e4238d2011-11-04 03:34:56 +000093#ifndef LLDB_DISABLE_PYTHON
Greg Claytone86cbb92011-03-22 01:14:58 +000094 ScriptInterpreterPython::TerminateInterpreter ();
Greg Clayton3e4238d2011-11-04 03:34:56 +000095#endif // #ifndef LLDB_DISABLE_PYTHON
Caroline Tice0aa2e552011-01-14 00:29:16 +000096}
97