GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
interpreter.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2002-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_interpreter_h)
24 #define octave_interpreter_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 #include "quit.h"
31 #include "str-vec.h"
32 
33 #include "pt-eval.h"
34 
35 typedef void (*octave_exit_func) (int);
37 
38 extern OCTINTERP_API bool quit_allowed;
39 
41 
42 extern OCTINTERP_API void recover_from_exception (void);
43 
44 extern OCTINTERP_API void
46 
47 extern OCTINTERP_API bool
49 
50 // TRUE means we are ready to interpret commands, but not everything
51 // is ready for interactive use.
53 
54 // TRUE means we've processed all the init code and we are good to go.
56 
57 // Call a function with exceptions handled to avoid problems with
58 // errors while shutting down.
59 
60 #define OCTAVE_IGNORE_EXCEPTION(E) \
61  catch (E) \
62  { \
63  std::cerr << "error: ignoring " #E " while preparing to exit" << std::endl; \
64  recover_from_exception (); \
65  }
66 
67 #define OCTAVE_SAFE_CALL(F, ARGS) \
68  do \
69  { \
70  try \
71  { \
72  octave::unwind_protect frame; \
73  \
74  frame.protect_var (Vdebug_on_error); \
75  frame.protect_var (Vdebug_on_warning); \
76  \
77  Vdebug_on_error = false; \
78  Vdebug_on_warning = false; \
79  \
80  F ARGS; \
81  } \
82  OCTAVE_IGNORE_EXCEPTION (const octave::interrupt_exception&) \
83  OCTAVE_IGNORE_EXCEPTION (const octave::execution_exception&) \
84  OCTAVE_IGNORE_EXCEPTION (const std::bad_alloc&) \
85  } \
86  while (0)
87 
88 namespace octave
89 {
90  extern tree_evaluator *current_evaluator;
91 
92  // The application object contains a pointer to the current
93  // interpreter and the interpreter contains a pointer back to the
94  // application context so we need a forward declaration for one (or
95  // both) of them...
96 
97  class application;
98 
100  {
101  public:
102 
103  interpreter (application *app_context = 0, bool embedded = false);
104 
105  ~interpreter (void);
106 
107  int execute (void);
108 
109  int execute_eval_option_code (const std::string& code);
110 
111  void execute_command_line_file (const std::string& fname);
112 
113  bool interactive (void) const { return m_interactive; }
114  void interactive (bool arg) { m_interactive = arg; }
115 
116  private:
117 
118  // No copying, at least not yet...
119 
120  interpreter (const interpreter&);
121 
122  interpreter& operator = (const interpreter&);
123 
124  int main_loop (void);
125 
126  void clean_up_and_exit (int status, bool safe_to_return = false);
127 
129 
131 
133 
134  // TRUE means this is an interactive interpreter (forced or not).
136 
138  };
139 }
140 
141 #endif
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
void(* octave_exit_func)(int)
Definition: interpreter.h:35
OCTINTERP_API bool octave_interpreter_ready
Definition: interpreter.cc:79
fname
Definition: load-save.cc:754
bool interactive(void) const
Definition: interpreter.h:113
OCTINTERP_API bool octave_initialized
Definition: interpreter.cc:82
octave_value arg
Definition: pr-output.cc:3440
tree_evaluator * current_evaluator
tree_evaluator * m_evaluator
Definition: interpreter.h:130
#define OCTINTERP_API
Definition: mexproto.h:69
OCTINTERP_API bool octave_remove_atexit_function(const std::string &fname)
OCTAVE_API void clean_up_and_exit(int exit_status, bool safe_to_return)
Definition: quit.cc:52
OCTINTERP_API octave_exit_func octave_exit
Definition: interpreter.cc:72
OCTINTERP_API bool quitting_gracefully
OCTINTERP_API bool quit_allowed
Definition: interpreter.cc:75
do not permute tem code
Definition: balance.cc:90
application * m_app_context
Definition: interpreter.h:128
OCTINTERP_API void recover_from_exception(void)
Definition: interpreter.cc:200
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
void interactive(bool arg)
Definition: interpreter.h:114
OCTINTERP_API void octave_add_atexit_function(const std::string &fname)