blob: 826a0021e7e2c835e84909054b6dcf1d4f139955 [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
Greg Claytone86cbb92011-03-22 01:14:58 +000072ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback,
Enrico Granataf7a9b142011-07-15 02:26:42 +000073 SWIGBreakpointCallbackFunction python_swig_breakpoint_callback,
Enrico Granata9ae7cef2011-07-24 00:14:56 +000074 SWIGPythonTypeScriptCallbackFunction python_swig_typescript_callback,
75 SWIGPythonCreateSyntheticProvider python_swig_synthetic_script,
76 SWIGPythonCalculateNumChildren python_swig_calc_children,
77 SWIGPythonGetChildAtIndex python_swig_get_child_index,
78 SWIGPythonGetIndexOfChildWithName python_swig_get_index_child,
Enrico Granata979e20d2011-07-29 19:53:35 +000079 SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue,
Enrico Granatac2a28252011-08-16 16:49:25 +000080 SWIGPythonUpdateSynthProviderInstance python_swig_update_provider,
Enrico Granata59df36f2011-10-17 21:45:27 +000081 SWIGPythonCallCommand python_swig_call_command,
82 SWIGPythonCallModuleInit python_swig_call_mod_init)
Caroline Tice0aa2e552011-01-14 00:29:16 +000083{
Greg Clayton3e4238d2011-11-04 03:34:56 +000084#ifndef LLDB_DISABLE_PYTHON
Greg Claytone86cbb92011-03-22 01:14:58 +000085 ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback,
Enrico Granataf7a9b142011-07-15 02:26:42 +000086 python_swig_breakpoint_callback,
Enrico Granata9ae7cef2011-07-24 00:14:56 +000087 python_swig_typescript_callback,
88 python_swig_synthetic_script,
89 python_swig_calc_children,
90 python_swig_get_child_index,
91 python_swig_get_index_child,
Enrico Granata979e20d2011-07-29 19:53:35 +000092 python_swig_cast_to_sbvalue,
Enrico Granatac2a28252011-08-16 16:49:25 +000093 python_swig_update_provider,
Enrico Granata59df36f2011-10-17 21:45:27 +000094 python_swig_call_command,
95 python_swig_call_mod_init);
Greg Clayton3e4238d2011-11-04 03:34:56 +000096#endif // #ifndef LLDB_DISABLE_PYTHON
Caroline Tice0aa2e552011-01-14 00:29:16 +000097}
98
99void
Greg Claytone86cbb92011-03-22 01:14:58 +0000100ScriptInterpreter::TerminateInterpreter ()
Caroline Tice0aa2e552011-01-14 00:29:16 +0000101{
Greg Clayton3e4238d2011-11-04 03:34:56 +0000102#ifndef LLDB_DISABLE_PYTHON
Greg Claytone86cbb92011-03-22 01:14:58 +0000103 ScriptInterpreterPython::TerminateInterpreter ();
Greg Clayton3e4238d2011-11-04 03:34:56 +0000104#endif // #ifndef LLDB_DISABLE_PYTHON
Caroline Tice0aa2e552011-01-14 00:29:16 +0000105}
106