blob: 5bdb70e1d1dab78140bb6d99e3cc7d3e61f1ad7a [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
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000053std::string
54ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language)
55{
56 std::string return_value;
Chris Lattner24943d22010-06-08 16:52:24 +000057
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000058 switch (language)
59 {
60 case eScriptLanguageNone:
61 return_value = "None";
62 break;
63 case eScriptLanguagePython:
64 return_value = "Python";
65 break;
Caroline Tice6e4c5ce2010-09-04 00:03:46 +000066 }
67
68 return return_value;
69}
Caroline Tice0aa2e552011-01-14 00:29:16 +000070
71void
Enrico Granata1328b142012-02-29 03:28:49 +000072ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback)
Caroline Tice0aa2e552011-01-14 00:29:16 +000073{
Greg Clayton3e4238d2011-11-04 03:34:56 +000074#ifndef LLDB_DISABLE_PYTHON
Enrico Granata1328b142012-02-29 03:28:49 +000075 ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback);
Greg Clayton3e4238d2011-11-04 03:34:56 +000076#endif // #ifndef LLDB_DISABLE_PYTHON
Caroline Tice0aa2e552011-01-14 00:29:16 +000077}
78
79void
Greg Claytone86cbb92011-03-22 01:14:58 +000080ScriptInterpreter::TerminateInterpreter ()
Caroline Tice0aa2e552011-01-14 00:29:16 +000081{
Greg Clayton3e4238d2011-11-04 03:34:56 +000082#ifndef LLDB_DISABLE_PYTHON
Greg Claytone86cbb92011-03-22 01:14:58 +000083 ScriptInterpreterPython::TerminateInterpreter ();
Greg Clayton3e4238d2011-11-04 03:34:56 +000084#endif // #ifndef LLDB_DISABLE_PYTHON
Caroline Tice0aa2e552011-01-14 00:29:16 +000085}
86