1 //===-- 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"
20 #include "lldb/Interpreter/ScriptInterpreterPython.h"
21 #include "lldb/Utility/PseudoTerminal.h"
22 
23 using namespace lldb;
24 using namespace lldb_private;
25 
26 ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang) :
27     m_interpreter (interpreter),
28     m_script_lang (script_lang)
29 {
30 }
31 
32 ScriptInterpreter::~ScriptInterpreter ()
33 {
34 }
35 
36 CommandInterpreter &
37 ScriptInterpreter::GetCommandInterpreter ()
38 {
39     return m_interpreter;
40 }
41 
42 void
43 ScriptInterpreter::CollectDataForBreakpointCommandCallback
44 (
45     BreakpointOptions *bp_options,
46     CommandReturnObject &result
47 )
48 {
49     result.SetStatus (eReturnStatusFailed);
50     result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
51 }
52 
53 std::string
54 ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language)
55 {
56     std::string return_value;
57 
58     switch (language)
59     {
60         case eScriptLanguageNone:
61             return_value = "None";
62             break;
63         case eScriptLanguagePython:
64             return_value = "Python";
65             break;
66     }
67 
68     return return_value;
69 }
70 
71 void
72 ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback,
73                                           SWIGBreakpointCallbackFunction python_swig_breakpoint_callback,
74                                           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,
79                                           SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue,
80                                           SWIGPythonUpdateSynthProviderInstance python_swig_update_provider,
81                                           SWIGPythonCallCommand python_swig_call_command,
82                                           SWIGPythonCallModuleInit python_swig_call_mod_init)
83 {
84 #ifndef LLDB_DISABLE_PYTHON
85     ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback,
86                                                     python_swig_breakpoint_callback,
87                                                     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,
92                                                     python_swig_cast_to_sbvalue,
93                                                     python_swig_update_provider,
94                                                     python_swig_call_command,
95                                                     python_swig_call_mod_init);
96 #endif // #ifndef LLDB_DISABLE_PYTHON
97 }
98 
99 void
100 ScriptInterpreter::TerminateInterpreter ()
101 {
102 #ifndef LLDB_DISABLE_PYTHON
103     ScriptInterpreterPython::TerminateInterpreter ();
104 #endif // #ifndef LLDB_DISABLE_PYTHON
105 }
106 
107