Mercurial > octave
annotate libinterp/corefcn/interpreter.cc @ 31039:ecb867dfc8eb stable
Don't shut down interpreter immediately on "execute" (bug #62308).
* libinterp/corefcn/interpreter.cc (interpreter::execute): Only shutdown
interpreter in cases where a main or server loop was started or in case an
exception was thrown.
(~interpreter): Shutdown the interpreter here if it wasn't shutdown in the
execute function.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 23 Apr 2022 15:20:18 +0200 |
parents | 076e19eac74a |
children | 0ee18536ec5c |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30310
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
30 #include <cstdio> |
30310
efaaf58c8d07
interpreter.cc: Include missing header <clocale>.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30309
diff
changeset
|
31 #include <clocale> |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
32 |
29619
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29618
diff
changeset
|
33 #include <iostream> |
27542
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
34 #include <set> |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include <string> |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
36 #include <thread> |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "cmd-edit.h" |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
39 #include "cmd-hist.h" |
27408
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
40 #include "file-ops.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "file-stat.h" |
27832
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
42 #include "file-ops.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "fpucw-wrappers.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22196
diff
changeset
|
44 #include "lo-blas-proto.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "lo-error.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "oct-env.h" |
29292
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
47 #include "quit.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 #include "str-vec.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "signal-wrappers.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "unistd-wrappers.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
52 #include "builtin-defun-decls.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 #include "defaults.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 #include "Cell.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 #include "defun.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 #include "display.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 #include "error.h" |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27262
diff
changeset
|
58 #include "event-manager.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 #include "file-io.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 #include "graphics.h" |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
61 #include "help.h" |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25404
diff
changeset
|
62 #include "input.h" |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
63 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 #include "interpreter.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 #include "load-path.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 #include "load-save.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 #include "octave.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 #include "oct-hist.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 #include "oct-map.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 #include "oct-mutex.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 #include "ovl.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 #include "ov.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 #include "ov-classdef.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 #include "parse.h" |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
75 #include "pt-classdef.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 #include "pt-eval.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 #include "pt-jump.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 #include "pt-stmt.h" |
25443
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
79 #include "settings.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 #include "sighandlers.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 #include "sysdep.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 #include "unwind-prot.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 #include "utils.h" |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 #include "variables.h" |
23466
5da300c55e89
use "" instead of <> for including defaults.h and version.h
John W. Eaton <jwe@octave.org>
parents:
23460
diff
changeset
|
85 #include "version.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 // TRUE means the quit() call is allowed. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 bool quit_allowed = true; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 // TRUE means we are ready to interpret commands, but not everything |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 // is ready for interactive use. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 bool octave_interpreter_ready = false; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 // TRUE means we've processed all the init code and we are good to go. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 bool octave_initialized = false; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29956
diff
changeset
|
97 OCTAVE_NAMESPACE_BEGIN |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29956
diff
changeset
|
98 |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 DEFUN (__version_info__, args, , |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 doc: /* -*- texinfo -*- |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 @deftypefn {} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date}) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 Undocumented internal function. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 @end deftypefn */) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 { |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 static octave_map vinfo; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 int nargin = args.length (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 if (nargin != 0 && nargin != 4) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 print_usage (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 octave_value retval; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 if (nargin == 0) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 retval = vinfo; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 else if (nargin == 4) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 { |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 if (vinfo.nfields () == 0) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 { |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 vinfo.assign ("Name", args(0)); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 vinfo.assign ("Version", args(1)); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 vinfo.assign ("Release", args(2)); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 vinfo.assign ("Date", args(3)); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 else |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 { |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 octave_idx_type n = vinfo.numel () + 1; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 vinfo.resize (dim_vector (n, 1)); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 octave_value idx (n); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 vinfo.assign (idx, "Name", Cell (octave_value (args(0)))); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 vinfo.assign (idx, "Version", Cell (octave_value (args(1)))); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 vinfo.assign (idx, "Release", Cell (octave_value (args(2)))); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 vinfo.assign (idx, "Date", Cell (octave_value (args(3)))); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 return retval; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 |
27261
dccdc3b001a2
eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents:
27214
diff
changeset
|
143 DEFMETHOD (quit, interp, args, , |
dccdc3b001a2
eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents:
27214
diff
changeset
|
144 doc: /* -*- texinfo -*- |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
145 @deftypefn {} {} quit |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
146 @deftypefnx {} {} quit cancel |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
147 @deftypefnx {} {} quit force |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
148 @deftypefnx {} {} quit ("cancel") |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
149 @deftypefnx {} {} quit ("force") |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 @deftypefnx {} {} quit (@var{status}) |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
151 @deftypefnx {} {} quit (@var{status}, "force") |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
152 Quit the current Octave session. |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
153 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
154 The @code{exit} function is an alias for @code{quit}. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 If the optional integer value @var{status} is supplied, pass that value to |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 the operating system as Octave's exit status. The default value is zero. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 When exiting, Octave will attempt to run the m-file @file{finish.m} if it |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 exists. User commands to save the workspace or clean up temporary files |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 may be placed in that file. Alternatively, another m-file may be scheduled |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
162 to run using @code{atexit}. If an error occurs while executing the |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
163 @file{finish.m} file, Octave does not exit and control is returned to |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
164 the command prompt. |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
165 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
166 If the optional argument @qcode{"cancel"} is provided, Octave does not |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
167 exit and control is returned to the command prompt. This feature allows |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
168 the @code{finish.m} file to cancel the quit process. |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
169 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
170 If the user preference to request confirmation before exiting, Octave |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
171 will display a dialog and give the user an option to cancel the exit |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
172 process. |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
173 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
174 If the optional argument @qcode{"force"} is provided, no confirmation is |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
175 requested, and the execution of the @file{finish.m} file is skipped. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 @seealso{atexit} |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 @end deftypefn */) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 { |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
179 int numel = args.length (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
181 if (numel > 2) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
182 print_usage (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 int exit_status = 0; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
186 bool force = false; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
187 bool cancel = false; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
188 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
189 if (numel == 2) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
190 { |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
191 exit_status = args(0).xnint_value ("quit: STATUS must be an integer"); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
192 std::string frc |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
193 = args(1).xstring_value ("quit: second argument must be a string"); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
194 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
195 if (frc == "force") |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
196 force = true; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
197 else |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
198 error (R"(quit: second argument must be string "force")"); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
199 } |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
200 else if (numel == 1) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
201 { |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
202 if (args(0).is_string ()) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
203 { |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
204 const char *msg |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
205 = R"(quit: option must be string "cancel" or "force")"; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
206 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
207 std::string opt = args(0).xstring_value (msg); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
209 if (opt == "cancel") |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
210 cancel = true; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
211 else if (opt == "force") |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
212 force = true; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
213 else |
27593
a2db1e36e9b2
Silence compiler warning about use of error() without format string.
Rik <rik@octave.org>
parents:
27592
diff
changeset
|
214 error ("%s", msg); |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
215 } |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
216 else |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
217 exit_status = args(0).xnint_value ("quit: STATUS must be an integer"); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
218 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
220 if (cancel) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
221 { |
27591
b54d6ac62fbf
make "quit cancel" a no-op outside of finish script
John W. Eaton <jwe@octave.org>
parents:
27588
diff
changeset
|
222 // No effect if "quit cancel" appears outside of finish script. |
b54d6ac62fbf
make "quit cancel" a no-op outside of finish script
John W. Eaton <jwe@octave.org>
parents:
27588
diff
changeset
|
223 |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
224 if (interp.executing_finish_script ()) |
27591
b54d6ac62fbf
make "quit cancel" a no-op outside of finish script
John W. Eaton <jwe@octave.org>
parents:
27588
diff
changeset
|
225 interp.cancel_quit (true); |
b54d6ac62fbf
make "quit cancel" a no-op outside of finish script
John W. Eaton <jwe@octave.org>
parents:
27588
diff
changeset
|
226 |
b54d6ac62fbf
make "quit cancel" a no-op outside of finish script
John W. Eaton <jwe@octave.org>
parents:
27588
diff
changeset
|
227 return ovl (); |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
228 } |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
229 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
230 interp.quit (exit_status, force); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 return ovl (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 DEFALIAS (exit, quit); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
237 DEFMETHOD (atexit, interp, args, nargout, |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
238 doc: /* -*- texinfo -*- |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 @deftypefn {} {} atexit (@var{fcn}) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 @deftypefnx {} {} atexit (@var{fcn}, @var{flag}) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 Register a function to be called when Octave exits. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 For example, |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 @example |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 @group |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 function last_words () |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 disp ("Bye bye"); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 endfunction |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 atexit ("last_words"); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 @end group |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 @end example |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 @noindent |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 will print the message @qcode{"Bye bye"} when Octave exits. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 The additional argument @var{flag} will register or unregister @var{fcn} |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 from the list of functions to be called when Octave exits. If @var{flag} is |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 true, the function is registered, and if @var{flag} is false, it is |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 unregistered. For example, after registering the function @code{last_words} |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 above, |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 @example |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 atexit ("last_words", false); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 @end example |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 @noindent |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 will remove the function from the list and Octave will not call |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 @code{last_words} when it exits. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 Note that @code{atexit} only removes the first occurrence of a function |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 from the list, so if a function was placed in the list multiple times with |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 @code{atexit}, it must also be removed from the list multiple times. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 @seealso{quit} |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 @end deftypefn */) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 { |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 int nargin = args.length (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 if (nargin < 1 || nargin > 2) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 print_usage (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string"); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 bool add_mode = (nargin == 2) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 ? args(1).xbool_value ("atexit: FLAG argument must be a logical value") |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 : true; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 octave_value_list retval; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 if (add_mode) |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
291 interp.add_atexit_fcn (arg); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 else |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 { |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
294 bool found = interp.remove_atexit_fcn (arg); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 if (nargout > 0) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 retval = ovl (found); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 return retval; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 |
28380
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
303 DEFMETHOD (__traditional__, interp, , , |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
304 doc: /* -*- texinfo -*- |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
305 @deftypefn {} {} __traditional__ () |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
306 Undocumented internal function. |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
307 @end deftypefn */) |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
308 { |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
309 return ovl (interp.traditional ()); |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
310 } |
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
311 |
27542
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
312 temporary_file_list::~temporary_file_list (void) |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
313 { |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
314 cleanup (); |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
315 } |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
316 |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
317 void temporary_file_list::insert (const std::string& file) |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
318 { |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
319 m_files.insert (file); |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
320 } |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
321 |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
322 void temporary_file_list::cleanup (void) |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
323 { |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
324 while (! m_files.empty ()) |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
325 { |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
326 auto it = m_files.begin (); |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
327 |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
328 octave_unlink_wrapper (it->c_str ()); |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
329 |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
330 m_files.erase (it); |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
331 } |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
332 } |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
333 |
27408
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
334 // The time we last time we changed directories. |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
335 sys::time Vlast_chdir_time = 0.0; |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
336 |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
337 // Execute commands from a file and catch potential exceptions in a consistent |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
338 // way. This function should be called anywhere we might parse and execute |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
339 // commands from a file before we have entered the main loop in |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
340 // toplev.cc. |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
341 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
342 static int safe_source_file (const std::string& file_name, |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
343 const std::string& context = "", |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
344 bool verbose = false, |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27506
diff
changeset
|
345 bool require_file = true) |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
346 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
347 interpreter& interp = __get_interpreter__ ("safe_source_file"); |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
348 |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
349 try |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
350 { |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27506
diff
changeset
|
351 source_file (file_name, context, verbose, require_file); |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
352 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
353 catch (const interrupt_exception&) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
354 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
355 interp.recover_from_exception (); |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
356 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
357 return 1; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
358 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
359 catch (const execution_exception& ee) |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
360 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
361 interp.handle_exception (ee); |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
362 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
363 return 1; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
364 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
365 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
366 return 0; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
367 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
368 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
369 static void initialize_version_info (void) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
370 { |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
371 octave_value_list args; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
372 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
373 args(3) = OCTAVE_RELEASE_DATE; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
374 args(2) = config::release (); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
375 args(1) = OCTAVE_VERSION; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
376 args(0) = "GNU Octave"; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
377 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
378 F__version_info__ (args, 0); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
379 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
380 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
381 static void xerbla_abort (void) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
382 { |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
383 error ("Fortran procedure terminated by call to XERBLA"); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
384 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
385 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
386 static void initialize_xerbla_error_handler (void) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
387 { |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
388 // The idea here is to force xerbla to be referenced so that we will |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
389 // link to our own version instead of the one provided by the BLAS |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
390 // library. But numeric_limits<double>::NaN () should never be -1, so |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
391 // we should never actually call xerbla. FIXME (again!): If this |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
392 // becomes a constant expression the test might be optimized away and |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
393 // then the reference to the function might also disappear. |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
394 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
395 if (numeric_limits<double>::NaN () == -1) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
396 F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6)); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
397 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
398 typedef void (*xerbla_handler_ptr) (void); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
399 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
400 typedef void (*octave_set_xerbla_handler_ptr) (xerbla_handler_ptr); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
401 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
402 dynamic_library libs (""); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
403 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
404 if (libs) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
405 { |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
406 octave_set_xerbla_handler_ptr octave_set_xerbla_handler |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
407 = reinterpret_cast<octave_set_xerbla_handler_ptr> |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
408 (libs.search ("octave_set_xerbla_handler")); |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
409 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
410 if (octave_set_xerbla_handler) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
411 octave_set_xerbla_handler (xerbla_abort); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
412 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
413 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
414 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
415 OCTAVE_NORETURN static void |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
416 lo_error_handler (const char *fmt, ...) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
417 { |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
418 va_list args; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
419 va_start (args, fmt); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
420 verror_with_cfn (fmt, args); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
421 va_end (args); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
422 |
27480
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
423 throw execution_exception (); |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
424 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
425 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
426 OCTAVE_NORETURN static void |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
427 lo_error_with_id_handler (const char *id, const char *fmt, ...) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
428 { |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
429 va_list args; |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
430 va_start (args, fmt); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
431 verror_with_id_cfn (id, fmt, args); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
432 va_end (args); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
433 |
27480
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
434 throw execution_exception (); |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
435 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
436 |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
437 static void initialize_error_handlers (void) |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
438 { |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
439 set_liboctave_error_handler (lo_error_handler); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
440 set_liboctave_error_with_id_handler (lo_error_with_id_handler); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
441 set_liboctave_warning_handler (warning); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
442 set_liboctave_warning_with_id_handler (warning_with_id); |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
443 } |
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
444 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
445 // Create an interpreter object and perform initialization up to the |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
446 // point of setting reading command history and setting the load |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
447 // path. |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22186
diff
changeset
|
448 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
449 interpreter::interpreter (application *app_context) |
23627
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
450 : m_app_context (app_context), |
27542
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
451 m_tmp_files (), |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
452 m_atexit_fcns (), |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
453 m_display_info (), |
23719
69a111259a2c
eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
23717
diff
changeset
|
454 m_environment (), |
25443
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
455 m_settings (), |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
456 m_error_system (*this), |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
457 m_help_system (*this), |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25404
diff
changeset
|
458 m_input_system (*this), |
25435
a52e6fb674b1
eliminate some singletons and static & global variables
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
459 m_output_system (*this), |
25994
f881d3e271d2
eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents:
25993
diff
changeset
|
460 m_history_system (*this), |
23627
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
461 m_dynamic_loader (*this), |
27394
489c74ac36da
store reference to interpreter in load_path object
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
462 m_load_path (*this), |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25488
diff
changeset
|
463 m_load_save_system (*this), |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24538
diff
changeset
|
464 m_type_info (), |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
465 m_symbol_table (*this), |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23627
diff
changeset
|
466 m_evaluator (*this), |
23738
8acd390d16c9
don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
467 m_stream_list (*this), |
24734
5d8c4cbc56d7
don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents:
24727
diff
changeset
|
468 m_child_list (), |
23742
1f0daaf81955
don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents:
23738
diff
changeset
|
469 m_url_handle_manager (), |
23651
5c6cceef132b
don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents:
23630
diff
changeset
|
470 m_cdef_manager (*this), |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
23753
diff
changeset
|
471 m_gtk_manager (), |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27301
diff
changeset
|
472 m_event_manager (*this), |
27321
eddce82a57cc
don't use singleton pattern for gh_manager object
John W. Eaton <jwe@octave.org>
parents:
27309
diff
changeset
|
473 m_gh_manager (nullptr), |
23627
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
474 m_interactive (false), |
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
475 m_read_site_files (true), |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23775
diff
changeset
|
476 m_read_init_files (m_app_context != nullptr), |
23627
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
477 m_verbose (false), |
28380
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
478 m_traditional (false), |
23627
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
479 m_inhibit_startup_message (false), |
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
480 m_load_path_initialized (false), |
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
481 m_history_initialized (false), |
29295
b73ddb964093
allow interrupts to be sent to all processes in process group or just octave
John W. Eaton <jwe@octave.org>
parents:
29293
diff
changeset
|
482 m_interrupt_all_in_process_group (true), |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
483 m_cancel_quit (false), |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
484 m_executing_finish_script (false), |
27690
c81139d8dcc3
prevent atexit functions from adding new atexit functions
John W. Eaton <jwe@octave.org>
parents:
27689
diff
changeset
|
485 m_executing_atexit (false), |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23552
diff
changeset
|
486 m_initialized (false) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 { |
24538
2b273df71aa0
allow experimenting with thread_local storage
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
488 // FIXME: When thread_local storage is used by default, this message |
2b273df71aa0
allow experimenting with thread_local storage
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
489 // should change to say something like |
2b273df71aa0
allow experimenting with thread_local storage
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
490 // |
2b273df71aa0
allow experimenting with thread_local storage
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
491 // only one Octave interpreter may be active in any given thread |
2b273df71aa0
allow experimenting with thread_local storage
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
492 |
30156
c8d5ec1f5618
maint: use "m_" prefix for member variable "instance" in class interpreter.
Rik <rik@octave.org>
parents:
29982
diff
changeset
|
493 if (m_instance) |
23511
232c8d69d934
manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
494 throw std::runtime_error |
24538
2b273df71aa0
allow experimenting with thread_local storage
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
495 ("only one Octave interpreter may be active"); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22186
diff
changeset
|
496 |
30156
c8d5ec1f5618
maint: use "m_" prefix for member variable "instance" in class interpreter.
Rik <rik@octave.org>
parents:
29982
diff
changeset
|
497 m_instance = this; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
498 |
30309
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
499 #if defined (OCTAVE_HAVE_WINDOWS_UTF8_LOCALE) |
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
500 // Force a UTF-8 locale on Windows if possible |
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
501 std::setlocale (LC_ALL, ".UTF8"); |
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
502 #else |
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
503 std::setlocale (LC_ALL, ""); |
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
504 #endif |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 // Matlab uses "C" locale for LC_NUMERIC class regardless of local setting |
30309
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
506 std::setlocale (LC_NUMERIC, "C"); |
bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
Markus Mützel <markus.muetzel@gmx.de>
parents:
30156
diff
changeset
|
507 std::setlocale (LC_TIME, "C"); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
508 sys::env::putenv ("LC_NUMERIC", "C"); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
509 sys::env::putenv ("LC_TIME", "C"); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 // Initialize the default floating point unit control state. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 octave_set_default_fpucw (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
514 thread::init (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
516 octave_ieee_init (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 |
25487
fbc270aeb55d
* interpreter.cc (intialize_xerbla_error_handler, xerbla_abort): New functions.
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
518 initialize_xerbla_error_handler (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 initialize_error_handlers (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
522 if (m_app_context) |
26826
20881d195d20
fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents:
26722
diff
changeset
|
523 { |
20881d195d20
fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents:
26722
diff
changeset
|
524 install_signal_handlers (); |
20881d195d20
fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents:
26722
diff
changeset
|
525 octave_unblock_signal_by_name ("SIGTSTP"); |
20881d195d20
fix handling of SIGTSTP (bug #51903)
John W. Eaton <jwe@octave.org>
parents:
26722
diff
changeset
|
526 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 else |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 quit_allowed = false; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
530 if (! m_app_context) |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
531 m_display_info.initialize (); |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
532 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
533 bool line_editing = false; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
535 if (m_app_context) |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
536 { |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
537 // Embedded interpreters don't execute command line options. |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
538 const cmdline_options& options = m_app_context->options (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
540 // Make all command-line arguments available to startup files, |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
541 // including PKG_ADD files. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
543 string_vector args = options.all_args (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
544 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
545 m_app_context->intern_argv (args); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
546 intern_nargin (args.numel () - 1); |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
547 |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
548 bool is_octave_program = m_app_context->is_octave_program (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
549 |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
550 std::list<std::string> command_line_path = options.command_line_path (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
552 for (const auto& pth : command_line_path) |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
553 m_load_path.set_command_line_path (pth); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
555 std::string exec_path = options.exec_path (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
556 if (! exec_path.empty ()) |
23719
69a111259a2c
eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
23717
diff
changeset
|
557 m_environment.exec_path (exec_path); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
559 std::string image_path = options.image_path (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
560 if (! image_path.empty ()) |
23719
69a111259a2c
eliminate some global variables
John W. Eaton <jwe@octave.org>
parents:
23717
diff
changeset
|
561 m_environment.image_path (image_path); |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
562 |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
563 if (! options.no_window_system ()) |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
564 m_display_info.initialize (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
566 // Is input coming from a terminal? If so, we are probably |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
567 // interactive. |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
568 |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
569 // If stdin is not a tty, then we are reading commands from a |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
570 // pipe or a redirected file. |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
571 bool stdin_is_tty = octave_isatty_wrapper (fileno (stdin)); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
572 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
573 m_interactive = (! is_octave_program && stdin_is_tty |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
574 && octave_isatty_wrapper (fileno (stdout))); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
575 |
29912
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
576 // Don't force interactive if we're already interactive (bug #60696). |
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
577 bool forced_interactive = options.forced_interactive (); |
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
578 if (m_interactive) |
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
579 { |
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
580 m_app_context->forced_interactive (false); |
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
581 forced_interactive = false; |
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
582 } |
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
583 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
584 // Check if the user forced an interactive session. |
29912
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
585 if (forced_interactive) |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
586 m_interactive = true; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
588 line_editing = options.line_editing (); |
29912
da5cc930ff10
Change startup so that '--interactive' does not always force '--no-line-editing' (bug #60696).
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
589 if ((! m_interactive || forced_interactive) |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
590 && ! options.forced_line_editing ()) |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
591 line_editing = false; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 |
28380
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
593 m_traditional = options.traditional (); |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
594 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
595 // FIXME: if possible, perform the following actions directly |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
596 // instead of using the interpreter-level functions. |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
597 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
598 if (options.echo_commands ()) |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
599 m_evaluator.echo |
25063
a211e39e59d9
restore '--echo-commands' option to same behavior as 'echo on all' (bug #53453)
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
600 (tree_evaluator::ECHO_SCRIPTS | tree_evaluator::ECHO_FUNCTIONS |
a211e39e59d9
restore '--echo-commands' option to same behavior as 'echo on all' (bug #53453)
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
601 | tree_evaluator::ECHO_ALL); |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
602 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
603 std::string docstrings_file = options.docstrings_file (); |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
604 if (! docstrings_file.empty ()) |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
605 Fbuilt_in_docstrings_file (*this, octave_value (docstrings_file)); |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
606 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
607 std::string doc_cache_file = options.doc_cache_file (); |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
608 if (! doc_cache_file.empty ()) |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
609 Fdoc_cache_file (*this, octave_value (doc_cache_file)); |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
610 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
611 std::string info_file = options.info_file (); |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
612 if (! info_file.empty ()) |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
613 Finfo_file (*this, octave_value (info_file)); |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
614 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
615 std::string info_program = options.info_program (); |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
616 if (! info_program.empty ()) |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
617 Finfo_program (*this, octave_value (info_program)); |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
618 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
619 std::string texi_macros_file = options.texi_macros_file (); |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
620 if (! texi_macros_file.empty ()) |
23721
b2d55b52ee51
new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents:
23719
diff
changeset
|
621 Ftexi_macros_file (*this, octave_value (texi_macros_file)); |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
622 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 |
27322
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
624 // FIXME: we defer creation of the gh_manager object because it |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
625 // creates a root_figure object that requires the display_info |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
626 // object, but that is currently only accessible through the global |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
627 // interpreter object and that is not available until after the |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
628 // interpreter::instance pointer is set (above). It would be better |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
629 // if m_gh_manager could be an object value instead of a pointer and |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
630 // created as part of the interpreter initialization. To do that, |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
631 // we should either make the display_info object independent of the |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
632 // interpreter object (does it really need to cache any |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
633 // information?) or defer creation of the root_figure object until |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
634 // it is actually needed. |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
635 m_gh_manager = new gh_manager (*this); |
cb92168e48f6
defer gh_manager creation until after display_info initialization
John W. Eaton <jwe@octave.org>
parents:
27321
diff
changeset
|
636 |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25404
diff
changeset
|
637 m_input_system.initialize (line_editing); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 // These can come after command line args since none of them set any |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 // defaults that might be changed by command line options. |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 initialize_version_info (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
643 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
644 // This should be done before initializing the load path because |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
645 // some PKG_ADD files might need --traditional behavior. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 |
28380
548556e78bdf
make --traditional option easily accessible to the interpreter
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
647 if (m_traditional) |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
648 maximum_braindamage (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
649 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
650 octave_interpreter_ready = true; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
651 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 |
30156
c8d5ec1f5618
maint: use "m_" prefix for member variable "instance" in class interpreter.
Rik <rik@octave.org>
parents:
29982
diff
changeset
|
653 OCTAVE_THREAD_LOCAL interpreter *interpreter::m_instance = nullptr; |
23511
232c8d69d934
manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents:
23466
diff
changeset
|
654 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22186
diff
changeset
|
655 interpreter::~interpreter (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22186
diff
changeset
|
656 { |
31039
ecb867dfc8eb
Don't shut down interpreter immediately on "execute" (bug #62308).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30749
diff
changeset
|
657 if (! m_app_context) |
ecb867dfc8eb
Don't shut down interpreter immediately on "execute" (bug #62308).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30749
diff
changeset
|
658 shutdown (); |
ecb867dfc8eb
Don't shut down interpreter immediately on "execute" (bug #62308).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30749
diff
changeset
|
659 |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27322
diff
changeset
|
660 delete m_gh_manager; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
661 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22186
diff
changeset
|
662 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
663 void interpreter::intern_nargin (octave_idx_type nargs) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
664 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
665 m_evaluator.set_auto_fcn_var (stack_frame::NARGIN, nargs); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22186
diff
changeset
|
666 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22186
diff
changeset
|
667 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
668 // Read the history file unless a command-line option inhibits that. |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
669 |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
670 void interpreter::initialize_history (bool read_history_file) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
671 { |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
672 if (! m_history_initialized) |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
673 { |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
674 // Allow command-line option to override. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
676 if (m_app_context) |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
677 { |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
678 const cmdline_options& options = m_app_context->options (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
680 read_history_file = options.read_history_file (); |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
681 |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
682 if (! read_history_file) |
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23703
diff
changeset
|
683 command_history::ignore_entries (); |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
684 } |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
685 |
25994
f881d3e271d2
eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents:
25993
diff
changeset
|
686 m_history_system.initialize (read_history_file); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
688 if (! m_app_context) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
689 command_history::ignore_entries (); |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
690 |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
691 m_history_initialized = true; |
23092
0fed4c678795
additional restructuring of startup and shutdown
John W. Eaton <jwe@octave.org>
parents:
23087
diff
changeset
|
692 } |
0fed4c678795
additional restructuring of startup and shutdown
John W. Eaton <jwe@octave.org>
parents:
23087
diff
changeset
|
693 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
695 // Set the initial path to the system default unless command-line |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
696 // option says to leave it empty. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
697 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
698 void interpreter::initialize_load_path (bool set_initial_path) |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
699 { |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
700 if (! m_load_path_initialized) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
701 { |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
702 // Allow command-line option to override. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
703 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
704 if (m_app_context) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 { |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
706 const cmdline_options& options = m_app_context->options (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
707 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
708 set_initial_path = options.set_initial_path (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
709 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
710 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
711 // Temporarily set the execute_pkg_add function to one that |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
712 // catches exceptions. This is better than wrapping |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
713 // load_path::initialize in a try-catch block because it will |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
714 // not stop executing PKG_ADD files at the first exception. |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
715 // It's also better than changing the default execute_pkg_add |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
716 // function to use safe_source file because that will normally |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
717 // be evaluated from the normal interpreter loop where exceptions |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
718 // are already handled. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
719 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
720 unwind_action restore_add_hook (&load_path::set_add_hook, &m_load_path, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
721 m_load_path.get_add_hook ()); |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
722 |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28623
diff
changeset
|
723 m_load_path.set_add_hook ([=] (const std::string& dir) |
25345
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
724 { this->execute_pkg_add (dir); }); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
726 m_load_path.initialize (set_initial_path); |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
727 |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
728 m_load_path_initialized = true; |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
729 } |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
730 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
732 // This may be called separately from execute |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
733 |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
734 void interpreter::initialize (void) |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
735 { |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
736 if (m_initialized) |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
737 return; |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
738 |
29543
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
739 if (m_app_context) |
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
740 { |
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
741 const cmdline_options& options = m_app_context->options (); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
742 |
29543
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
743 if (options.experimental_terminal_widget ()) |
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
744 { |
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
745 if (! options.gui ()) |
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
746 display_startup_message (); |
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
747 } |
97238418c028
avoid accessing invalid app context during interpreter initialization
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
748 else |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
749 display_startup_message (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
750 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
751 else |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
752 display_startup_message (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
753 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
754 // Wait to read the history file until the interpreter reads input |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
755 // files and begins evaluating commands. |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
756 |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
757 initialize_history (); |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
758 |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
759 // Initializing the load path may execute PKG_ADD files, so can't be |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
760 // done until the interpreter is ready to execute commands. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
762 // Deferring it to the execute step also allows the path to be |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
763 // initialized between creating and execute the interpreter, for |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
764 // example, to set a custom path for an embedded interpreter. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
765 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
766 initialize_load_path (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
767 |
27531
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
768 octave_save_signal_mask (); |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
769 |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
770 can_interrupt = true; |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
771 |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
772 octave_signal_hook = respond_to_pending_signals; |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
773 octave_interrupt_hook = nullptr; |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
774 |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
775 catch_interrupts (); |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
776 |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
777 // FIXME: could we eliminate this variable or make it not be global? |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
778 // Global used to communicate with signal handler. |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
779 octave_initialized = true; |
478150691336
consolidate initialization code
John W. Eaton <jwe@octave.org>
parents:
27530
diff
changeset
|
780 |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
781 m_initialized = true; |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
782 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
783 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
784 // Note: this function is currently only used with the new |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
785 // experimental terminal widget. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
786 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
787 void interpreter::get_line_and_eval (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
788 { |
29619
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29618
diff
changeset
|
789 m_evaluator.get_line_and_eval (); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
790 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
791 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
792 // Note: the following class is currently only used with the new |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
793 // experimental terminal widget. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
794 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
795 class cli_input_reader |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
796 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
797 public: |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
798 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
799 cli_input_reader (interpreter& interp) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
800 : m_interpreter (interp), m_thread () { } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
801 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
802 cli_input_reader (const cli_input_reader&) = delete; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
803 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
804 cli_input_reader& operator = (const cli_input_reader&) = delete; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
805 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
806 ~cli_input_reader (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
807 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
808 // FIXME: Would it be better to ensure that |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
809 // interpreter::get_line_and_eval exits and then call |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
810 // m_thread.join () here? |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
811 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
812 m_thread.detach (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
813 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
814 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
815 void start (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
816 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
817 m_thread = std::thread (&interpreter::get_line_and_eval, &m_interpreter); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
818 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
819 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
820 private: |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
821 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
822 interpreter& m_interpreter; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
823 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
824 std::thread m_thread; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
825 }; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
826 |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
827 void interpreter::parse_and_execute (const std::string& input, |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
828 bool& incomplete_parse) |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
829 { |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29254
diff
changeset
|
830 m_evaluator.parse_and_execute (input, incomplete_parse); |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
831 } |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
832 |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
833 // FIXME: this function is intended to be executed only once. Should |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
834 // we enforce that restriction? |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
835 |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
836 int interpreter::execute (void) |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
837 { |
27530
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
838 int exit_status = 0; |
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
839 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
840 try |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
841 { |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
842 initialize (); |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
843 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
844 execute_startup_files (); |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
845 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
846 if (m_app_context) |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
847 { |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
848 const cmdline_options& options = m_app_context->options (); |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
849 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
850 if (m_app_context->have_eval_option_code ()) |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
851 { |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
852 int status = execute_eval_option_code (); |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
853 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
854 if (status ) |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
855 exit_status = status; |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
856 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
857 if (! options.persist ()) |
30736
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
858 { |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
859 shutdown (); |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
860 |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
861 return exit_status; |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
862 } |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
863 } |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
864 |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
865 // If there is an extra argument, see if it names a file to |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
866 // read. Additional arguments are taken as command line options |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
867 // for the script. |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
868 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
869 if (m_app_context->have_script_file ()) |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
870 { |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
871 int status = execute_command_line_file (); |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
872 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
873 if (status) |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
874 exit_status = status; |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
875 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
876 if (! options.persist ()) |
30736
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
877 { |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
878 shutdown (); |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
879 |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
880 return exit_status; |
dadbfe6fddd6
don't perform interpreter shutdown actions in destructor (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
881 } |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
882 } |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
883 |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
884 if (options.forced_interactive ()) |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
885 command_editor::blink_matching_paren (false); |
27693
de4bfeda8d9f
do not call main_loop in embedded interpreter (bug #57229)
Mike Miller <mtmiller@octave.org>
parents:
27690
diff
changeset
|
886 |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
887 if (options.server ()) |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
888 exit_status = server_loop (); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
889 else if (options.experimental_terminal_widget ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
890 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
891 if (options.gui ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
892 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
893 m_event_manager.start_gui (true); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
894 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
895 exit_status = server_loop (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
896 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
897 else |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
898 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
899 // Use an object so that the thread started for the |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
900 // reader will be cleaned up no matter how we exit |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
901 // this function. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
902 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
903 cli_input_reader reader (*this); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
904 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
905 reader.start (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
906 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
907 exit_status = server_loop (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
908 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
909 } |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
910 else |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
911 exit_status = main_loop (); |
31039
ecb867dfc8eb
Don't shut down interpreter immediately on "execute" (bug #62308).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30749
diff
changeset
|
912 |
ecb867dfc8eb
Don't shut down interpreter immediately on "execute" (bug #62308).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30749
diff
changeset
|
913 shutdown (); |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
914 } |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
915 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
916 catch (const exit_exception& xe) |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
917 { |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
918 exit_status = xe.exit_status (); |
31039
ecb867dfc8eb
Don't shut down interpreter immediately on "execute" (bug #62308).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30749
diff
changeset
|
919 |
ecb867dfc8eb
Don't shut down interpreter immediately on "execute" (bug #62308).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30749
diff
changeset
|
920 shutdown (); |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
921 } |
27530
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
922 |
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
923 return exit_status; |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
924 } |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
925 |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
926 // Call a function with exceptions handled to avoid problems with |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
927 // errors while shutting down. |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
928 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
929 #define OCTAVE_IGNORE_EXCEPTION(E) \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
930 catch (E) \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
931 { \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
932 recover_from_exception (); \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
933 \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
934 std::cerr << "error: ignoring " #E " while preparing to exit" \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
935 << std::endl; \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
936 } |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
937 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
938 #define OCTAVE_SAFE_CALL(F, ARGS) \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
939 do \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
940 { \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
941 try \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
942 { \ |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
943 unwind_action restore_debug_on_error \ |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
944 (&error_system::set_debug_on_error, &m_error_system, \ |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
945 m_error_system.debug_on_error ()); \ |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
946 \ |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
947 unwind_action restore_debug_on_warning \ |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
948 (&error_system::set_debug_on_warning, &m_error_system, \ |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
949 m_error_system.debug_on_warning ()); \ |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
950 \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
951 m_error_system.debug_on_error (false); \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
952 m_error_system.debug_on_warning (false); \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
953 \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
954 F ARGS; \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
955 } \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
956 OCTAVE_IGNORE_EXCEPTION (const exit_exception&) \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
957 OCTAVE_IGNORE_EXCEPTION (const interrupt_exception&) \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
958 OCTAVE_IGNORE_EXCEPTION (const execution_exception&) \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
959 OCTAVE_IGNORE_EXCEPTION (const std::bad_alloc&) \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
960 } \ |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
961 while (0) |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
962 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
963 void interpreter::shutdown (void) |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
964 { |
29545
841ca9987302
perform shutdown actions in interpreter destructor (bug #60334)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
965 // Attempt to prevent more than one call to shutdown. |
841ca9987302
perform shutdown actions in interpreter destructor (bug #60334)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
966 |
841ca9987302
perform shutdown actions in interpreter destructor (bug #60334)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
967 if (! m_initialized) |
841ca9987302
perform shutdown actions in interpreter destructor (bug #60334)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
968 return; |
841ca9987302
perform shutdown actions in interpreter destructor (bug #60334)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
969 |
841ca9987302
perform shutdown actions in interpreter destructor (bug #60334)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
970 m_initialized = false; |
841ca9987302
perform shutdown actions in interpreter destructor (bug #60334)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
971 |
28616
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
972 OCTAVE_SAFE_CALL (feval, ("close", ovl ("all"), 0)); |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
973 |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
974 // Any atexit functions added after this function call won't be |
28616
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
975 // executed. Each atexit function is executed with |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
976 // OCTAVE_SAFE_CALL, so we don't need that here. |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
977 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
978 execute_atexit_fcns (); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
979 |
30738
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
980 // Clear all functions and variables while the event manager is |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
981 // still processing events and notify the event manager. This way, |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
982 // the workspace model will be cleared before the GUI exits. |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
983 |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
984 // FIXME: This approach seems a bit fragile since there could be |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
985 // other places in the GUI that have references to interpreter |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
986 // objects. How can we reliably ensure that they are all removed |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
987 // before the interpreter exits? Maybe the best solution is to |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
988 // always start the GUI from the interpreter and close it when the |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
989 // interpreter exits? However, the workspace model is owned by the |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
990 // base_qobject object not the workspace viewer or the main window, |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
991 // so simply closing the GUI window(s) is not sufficient. See also |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
992 // bug #61994. |
28616
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
993 |
28622
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
994 // Note that we don't force symbols to be cleared, so we will |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
995 // respect mlock at this point. Later, we'll force all variables |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
996 // and functions to be cleared. |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
997 |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
998 OCTAVE_SAFE_CALL (clear_all, ()); |
30747
311a8fb8b127
use clear_workspace instead of set_workspace with no arguments
John W. Eaton <jwe@octave.org>
parents:
30738
diff
changeset
|
999 OCTAVE_SAFE_CALL (m_event_manager.clear_workspace, ()); |
30738
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1000 |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1001 // If we are attached to a GUI, queue and event to close it (only |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1002 // works with the new terminal widget), process pending events and |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1003 // disable the link. |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1004 |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1005 OCTAVE_SAFE_CALL (m_event_manager.close_gui, ()); |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1006 OCTAVE_SAFE_CALL (m_event_manager.process_events, (true)); |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1007 OCTAVE_SAFE_CALL (m_event_manager.disable, ()); |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1008 |
3c4368f0a4ab
clear workspace model before exit (bug #61994)
John W. Eaton <jwe@octave.org>
parents:
30736
diff
changeset
|
1009 OCTAVE_SAFE_CALL (m_input_system.clear_input_event_hooks, ()); |
28616
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1010 |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1011 // We may still have some figures. Close them. |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1012 |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1013 OCTAVE_SAFE_CALL (feval, ("close", ovl ("all"), 0)); |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1014 |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1015 // What is supposed to happen if a figure has a closerequestfcn or |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1016 // deletefcn callback registered that creates other figures or |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1017 // variables? What if those variables are classdef objects with |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1018 // destructors that can create figures? The possibilities are |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1019 // endless. At some point, we have to give up and force execution |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1020 // to end. |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1021 |
28622
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1022 // Note that we again don't force symbols to be cleared, so we |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1023 // continue to respect mlock here. Later, we'll force all variables |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1024 // and functions to be cleared. |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1025 |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1026 OCTAVE_SAFE_CALL (clear_all, ()); |
28616
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1027 |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1028 // Do this explicitly so that destructors for mex file objects |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1029 // are called, so that functions registered with mexAtExit are |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1030 // called. |
28616
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1031 |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1032 OCTAVE_SAFE_CALL (m_symbol_table.clear_mex_functions, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1033 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1034 OCTAVE_SAFE_CALL (command_editor::restore_terminal_state, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1035 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1036 OCTAVE_SAFE_CALL (m_history_system.write_timestamp, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1037 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1038 if (! command_history::ignoring_entries ()) |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1039 OCTAVE_SAFE_CALL (command_history::clean_up_and_save, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1040 |
28622
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1041 OCTAVE_SAFE_CALL (m_gtk_manager.unload_all_toolkits, ()); |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1042 |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1043 // Now that the graphics toolkits have been unloaded, force all |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1044 // symbols to be cleared. |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1045 |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1046 OCTAVE_SAFE_CALL (clear_all, (true)); |
d075c2f26d1d
reorder shutdown steps (bug #57591)
John W. Eaton <jwe@octave.org>
parents:
28616
diff
changeset
|
1047 |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1048 // FIXME: May still need something like this to ensure that |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1049 // destructors for class objects will run properly. Should that be |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1050 // done earlier? Before or after atexit functions are executed? |
28616
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1051 // What will happen if the destructor for an obect attempts to |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1052 // display a figure? |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1053 |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1054 OCTAVE_SAFE_CALL (m_symbol_table.cleanup, ()); |
c315a866dbe9
attempt to avoid apparent graphics-related crash at shutdown (bug #58814)
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1055 |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1056 OCTAVE_SAFE_CALL (sysdep_cleanup, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1057 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1058 OCTAVE_SAFE_CALL (flush_stdout, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1059 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1060 // Don't call singleton_cleanup_list::cleanup until we have the |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1061 // problems with registering/unregistering types worked out. For |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1062 // example, uncomment the following line, then use the make_int |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1063 // function from the examples directory to create an integer |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1064 // object and then exit Octave. Octave should crash with a |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1065 // segfault when cleaning up the typinfo singleton. We need some |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1066 // way to force new octave_value_X types that are created in |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1067 // .oct files to be unregistered when the .oct file shared library |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1068 // is unloaded. |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1069 // |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1070 // OCTAVE_SAFE_CALL (singleton_cleanup_list::cleanup, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1071 } |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1072 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1073 void interpreter::execute_atexit_fcns (void) |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1074 { |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1075 // Prevent atexit functions from adding new functions to the list. |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1076 m_executing_atexit = true; |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1077 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1078 while (! m_atexit_fcns.empty ()) |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1079 { |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1080 std::string fcn = m_atexit_fcns.front (); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1081 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1082 m_atexit_fcns.pop_front (); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1083 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1084 OCTAVE_SAFE_CALL (feval, (fcn, octave_value_list (), 0)); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1085 |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1086 OCTAVE_SAFE_CALL (flush_stdout, ()); |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1087 } |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1088 } |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
1089 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1090 void interpreter::display_startup_message (void) const |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1091 { |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1092 bool inhibit_startup_message = false; |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1093 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1094 if (m_app_context) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1095 { |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1096 const cmdline_options& options = m_app_context->options (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1097 |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1098 inhibit_startup_message = options.inhibit_startup_message (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1099 } |
23396
945b53af4655
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1100 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1101 if (m_interactive && ! inhibit_startup_message) |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1102 std::cout << octave_startup_message () << "\n" << std::endl; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1103 } |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1104 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1105 // Initialize by reading startup files. Return non-zero if an exception |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1106 // occurs when reading any of them, but don't exit early because of an |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1107 // exception. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1108 |
26722
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1109 int interpreter::execute_startup_files (void) |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1110 { |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1111 bool read_site_files = m_read_site_files; |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1112 bool read_init_files = m_read_init_files; |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1113 bool verbose = m_verbose; |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1114 bool inhibit_startup_message = m_inhibit_startup_message; |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1115 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1116 if (m_app_context) |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1117 { |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1118 const cmdline_options& options = m_app_context->options (); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1119 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1120 read_site_files = options.read_site_files (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1121 read_init_files = options.read_init_files (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1122 verbose = options.verbose_flag (); |
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1123 inhibit_startup_message = options.inhibit_startup_message (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1124 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1125 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1126 verbose = (verbose && ! inhibit_startup_message); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1127 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1128 bool require_file = false; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1129 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1130 std::string context; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1131 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1132 int exit_status = 0; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1133 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1134 if (read_site_files) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1135 { |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1136 // Execute commands from the site-wide configuration file. |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1137 // First from the file $(prefix)/lib/octave/site/m/octaverc |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1138 // (if it exists), then from the file |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1139 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1140 |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23712
diff
changeset
|
1141 int status = safe_source_file (config::local_site_defaults_file (), |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23712
diff
changeset
|
1142 context, verbose, require_file); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1143 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1144 if (status) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1145 exit_status = status; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1146 |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23712
diff
changeset
|
1147 status = safe_source_file (config::site_defaults_file (), |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23712
diff
changeset
|
1148 context, verbose, require_file); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1149 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1150 if (status) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1151 exit_status = status; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1152 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1153 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1154 if (read_init_files) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1155 { |
26722
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1156 // Try to execute commands from the Matlab compatible startup.m file |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1157 // if it exists anywhere in the load path when starting Octave. |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1158 std::string ff_startup_m = file_in_path ("startup.m", ""); |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1159 |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1160 if (! ff_startup_m.empty ()) |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1161 { |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1162 int parse_status = 0; |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1163 |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1164 try |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1165 { |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1166 eval_string (std::string ("startup"), false, parse_status, 0); |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1167 } |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1168 catch (const interrupt_exception&) |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1169 { |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1170 recover_from_exception (); |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1171 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
1172 catch (const execution_exception& ee) |
26722
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1173 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
1174 handle_exception (ee); |
26722
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1175 } |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1176 } |
f51e8a7c33f4
run Matlab user files from interpreter, not startup scripts (bug #55681)
Mike Miller <mtmiller@octave.org>
parents:
26661
diff
changeset
|
1177 |
27832
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1178 // Try to execute commands from $CONFIG/octave/octaverc, where |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1179 // $CONFIG is the platform-dependent location for user local |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1180 // configuration files. |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1181 |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1182 std::string user_config_dir = sys::env::get_user_config_directory (); |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1183 |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1184 std::string cfg_dir = user_config_dir + sys::file_ops::dir_sep_str () |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1185 + "octave"; |
27832
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1186 |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1187 std::string cfg_rc = sys::env::make_absolute ("octaverc", cfg_dir); |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1188 |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1189 if (! cfg_rc.empty ()) |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1190 { |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1191 int status = safe_source_file (cfg_rc, context, verbose, |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1192 require_file); |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1193 |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1194 if (status) |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1195 exit_status = status; |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1196 } |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
27693
diff
changeset
|
1197 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1198 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1199 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1200 // .octaverc is assumed. |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1201 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1202 bool home_rc_already_executed = false; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1203 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1204 std::string initfile = sys::env::getenv ("OCTAVE_INITFILE"); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1205 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1206 if (initfile.empty ()) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1207 initfile = ".octaverc"; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1208 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1209 std::string home_dir = sys::env::get_home_directory (); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1210 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1211 std::string home_rc = sys::env::make_absolute (initfile, home_dir); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1212 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1213 std::string local_rc; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1214 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1215 if (! home_rc.empty ()) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1216 { |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1217 int status = safe_source_file (home_rc, context, verbose, |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1218 require_file); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1219 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1220 if (status) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1221 exit_status = status; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1222 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1223 // Names alone are not enough. |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1224 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1225 sys::file_stat fs_home_rc (home_rc); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1226 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1227 if (fs_home_rc) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1228 { |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1229 // We want to check for curr_dir after executing home_rc |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1230 // because doing that may change the working directory. |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1231 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1232 local_rc = sys::env::make_absolute (initfile); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1233 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1234 home_rc_already_executed = same_file (home_rc, local_rc); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1235 } |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1236 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1237 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1238 if (! home_rc_already_executed) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1239 { |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1240 if (local_rc.empty ()) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1241 local_rc = sys::env::make_absolute (initfile); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1242 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1243 int status = safe_source_file (local_rc, context, verbose, |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1244 require_file); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1245 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1246 if (status) |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1247 exit_status = status; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1248 } |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1249 } |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1250 |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1251 if (m_interactive && verbose) |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1252 std::cout << std::endl; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1253 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1254 return exit_status; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1255 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1256 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1257 // Execute any code specified with --eval 'CODE' |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1258 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1259 int interpreter::execute_eval_option_code (void) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1260 { |
27530
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
1261 if (! m_app_context) |
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
1262 return 0; |
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
1263 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1264 const cmdline_options& options = m_app_context->options (); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1265 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1266 std::string code_to_eval = options.code_to_eval (); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1267 |
27532
2af853f94b97
use unwind_protect_var instead of unwind_protect object for a single var
John W. Eaton <jwe@octave.org>
parents:
27531
diff
changeset
|
1268 unwind_protect_var<bool> upv (m_interactive, false); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1269 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1270 int parse_status = 0; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1271 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1272 try |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1273 { |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1274 eval_string (code_to_eval, false, parse_status, 0); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1275 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1276 catch (const interrupt_exception&) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1277 { |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1278 recover_from_exception (); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1279 |
23087
9f406f0b36da
rework clean_up_and_exit (bug #50068)
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
1280 return 1; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1281 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
1282 catch (const execution_exception& ee) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1283 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
1284 handle_exception (ee); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1285 |
23087
9f406f0b36da
rework clean_up_and_exit (bug #50068)
John W. Eaton <jwe@octave.org>
parents:
23084
diff
changeset
|
1286 return 1; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1287 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1288 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1289 return parse_status; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1290 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1291 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1292 int interpreter::execute_command_line_file (void) |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1293 { |
27530
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
1294 if (! m_app_context) |
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
1295 return 0; |
7a9d2b0e6da8
be more defensive about using m_app_context in interpreter code
John W. Eaton <jwe@octave.org>
parents:
27529
diff
changeset
|
1296 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1297 const cmdline_options& options = m_app_context->options (); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1298 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1299 string_vector args = options.all_args (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1300 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1301 void (interpreter::*interactive_fptr) (bool) = &interpreter::interactive; |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1302 unwind_action restore_interactive (interactive_fptr, this, m_interactive); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1303 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1304 unwind_action restore_argv (&application::intern_argv, m_app_context, args); |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1305 |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1306 unwind_action restore_nargin (&interpreter::intern_nargin, this, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1307 args.numel () - 1); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1308 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1309 void (application::*program_invocation_name_fptr) (const std::string&) |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1310 = &application::program_invocation_name; |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1311 unwind_action restore_program_invocation_name |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1312 (program_invocation_name_fptr, m_app_context, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1313 application::program_invocation_name ()); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1314 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1315 void (application::*program_name_fptr) (const std::string&) |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1316 = &application::program_name; |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1317 unwind_action restore_program_name |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1318 (program_name_fptr, m_app_context, application::program_name ()); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1319 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1320 m_interactive = false; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1321 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1322 // If we are running an executable script (#! /bin/octave) then |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1323 // we should only see the args passed to the script. |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1324 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1325 string_vector script_args = options.remaining_args (); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1326 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1327 m_app_context->intern_argv (script_args); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23553
diff
changeset
|
1328 intern_nargin (script_args.numel () - 1); |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1329 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1330 std::string fname = script_args[0]; |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
1331 |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1332 m_app_context->set_program_names (fname); |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1333 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1334 std::string context; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1335 bool verbose = false; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1336 bool require_file = true; |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1337 |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27506
diff
changeset
|
1338 return safe_source_file (fname, context, verbose, require_file); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1339 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1340 |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1341 int interpreter::main_loop (void) |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1342 { |
30749
076e19eac74a
allow deletion of dynamic_library objects to be delayed
John W. Eaton <jwe@octave.org>
parents:
30747
diff
changeset
|
1343 command_editor::add_event_hook (release_unreferenced_dynamic_libraries); |
076e19eac74a
allow deletion of dynamic_library objects to be delayed
John W. Eaton <jwe@octave.org>
parents:
30747
diff
changeset
|
1344 |
29846
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29545
diff
changeset
|
1345 return m_evaluator.repl (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1346 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1347 |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1348 int interpreter::server_loop (void) |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1349 { |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29254
diff
changeset
|
1350 return m_evaluator.server_loop (); |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1351 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1352 |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23511
diff
changeset
|
1353 tree_evaluator& interpreter::get_evaluator (void) |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23511
diff
changeset
|
1354 { |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23627
diff
changeset
|
1355 return m_evaluator; |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23511
diff
changeset
|
1356 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1357 |
23738
8acd390d16c9
don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
1358 stream_list& interpreter::get_stream_list (void) |
8acd390d16c9
don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
1359 { |
8acd390d16c9
don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
1360 return m_stream_list; |
8acd390d16c9
don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
1361 } |
8acd390d16c9
don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
1362 |
23742
1f0daaf81955
don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents:
23738
diff
changeset
|
1363 url_handle_manager& interpreter::get_url_handle_manager (void) |
1f0daaf81955
don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents:
23738
diff
changeset
|
1364 { |
1f0daaf81955
don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents:
23738
diff
changeset
|
1365 return m_url_handle_manager; |
1f0daaf81955
don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents:
23738
diff
changeset
|
1366 } |
1f0daaf81955
don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents:
23738
diff
changeset
|
1367 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
1368 symbol_scope |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1369 interpreter::get_top_scope (void) const |
23609
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1370 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1371 return m_evaluator.get_top_scope (); |
23609
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1372 } |
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1373 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
1374 symbol_scope |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1375 interpreter::get_current_scope (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1376 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1377 return m_evaluator.get_current_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1378 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1379 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1380 symbol_scope |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1381 interpreter::require_current_scope (const std::string& who) const |
23609
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1382 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
1383 symbol_scope scope = get_current_scope (); |
23609
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1384 |
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1385 if (! scope) |
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1386 error ("%s: symbol table scope missing", who.c_str ()); |
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1387 |
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1388 return scope; |
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1389 } |
99989ab8f142
new convenience functions for accessing current scope
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1390 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23742
diff
changeset
|
1391 profiler& interpreter::get_profiler (void) |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23742
diff
changeset
|
1392 { |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23742
diff
changeset
|
1393 return m_evaluator.get_profiler (); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23742
diff
changeset
|
1394 } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23742
diff
changeset
|
1395 |
27408
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1396 int interpreter::chdir (const std::string& dir) |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1397 { |
27408
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1398 std::string xdir = sys::file_ops::tilde_expand (dir); |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1399 |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1400 int cd_ok = sys::env::chdir (xdir); |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1401 |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1402 if (! cd_ok) |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1403 error ("%s: %s", dir.c_str (), std::strerror (errno)); |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1404 |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1405 Vlast_chdir_time.stamp (); |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1406 |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1407 // FIXME: should these actions be handled as a list of functions |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1408 // to call so users can add their own chdir handlers? |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1409 |
28953
dff830c84726
Add function "dir_encoding" to set a file encoding per directory (bug #49685).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28851
diff
changeset
|
1410 m_load_path.read_dir_config ("."); |
27408
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1411 m_load_path.update (); |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1412 |
27409
a0d49e55acae
rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents:
27408
diff
changeset
|
1413 m_event_manager.directory_changed (sys::env::get_current_directory ()); |
27408
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1414 |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1415 return cd_ok; |
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
1416 } |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1417 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1418 void interpreter::mlock (bool skip_first) const |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1419 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1420 m_evaluator.mlock (skip_first); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1421 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1422 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1423 void interpreter::munlock (bool skip_first) const |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1424 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1425 m_evaluator.munlock (skip_first); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1426 } |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1427 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1428 bool interpreter::mislocked (bool skip_first) const |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1429 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1430 return m_evaluator.mislocked (skip_first); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1431 } |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1432 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1433 void interpreter::munlock (const char *nm) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1434 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1435 if (! nm) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1436 error ("munlock: invalid value for NAME"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1437 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1438 munlock (std::string (nm)); |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1439 } |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1440 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1441 void interpreter::munlock (const std::string& nm) |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1442 { |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1443 octave_value val = m_symbol_table.find_function (nm); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1444 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1445 if (val.is_defined ()) |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1446 { |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1447 octave_function *fcn = val.function_value (); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1448 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1449 if (fcn) |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1450 fcn->unlock (); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1451 } |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1452 } |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1453 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1454 bool interpreter::mislocked (const char *nm) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1455 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1456 if (! nm) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1457 error ("mislocked: invalid value for NAME"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1458 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1459 return mislocked (std::string (nm)); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1460 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
1461 |
23703
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1462 bool interpreter::mislocked (const std::string& nm) |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1463 { |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1464 bool retval = false; |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1465 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1466 octave_value val = m_symbol_table.find_function (nm); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1467 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1468 if (val.is_defined ()) |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1469 { |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1470 octave_function *fcn = val.function_value (); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1471 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1472 if (fcn) |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1473 retval = fcn->islocked (); |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1474 } |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1475 |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1476 return retval; |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1477 } |
6eb5f6199a5a
move mlock, munlock, and mislocked to interpreter class
John W. Eaton <jwe@octave.org>
parents:
23699
diff
changeset
|
1478 |
27015
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
1479 std::string interpreter::mfilename (const std::string& opt) const |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
1480 { |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
1481 return m_evaluator.mfilename (opt); |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
1482 } |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
1483 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1484 octave_value_list interpreter::eval_string (const std::string& eval_str, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1485 bool silent, int& parse_status, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1486 int nargout) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1487 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1488 return m_evaluator.eval_string (eval_str, silent, parse_status, nargout); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1489 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1490 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1491 octave_value interpreter::eval_string (const std::string& eval_str, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1492 bool silent, int& parse_status) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1493 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1494 return m_evaluator.eval_string (eval_str, silent, parse_status); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1495 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1496 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1497 octave_value_list interpreter::eval_string (const octave_value& arg, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1498 bool silent, int& parse_status, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1499 int nargout) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1500 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1501 return m_evaluator.eval_string (arg, silent, parse_status, nargout); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1502 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
25994
diff
changeset
|
1503 |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1504 octave_value_list interpreter::eval (const std::string& try_code, |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1505 int nargout) |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1506 { |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1507 return m_evaluator.eval (try_code, nargout); |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1508 } |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1509 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1510 octave_value_list interpreter::eval (const std::string& try_code, |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1511 const std::string& catch_code, |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1512 int nargout) |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1513 { |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1514 return m_evaluator.eval (try_code, catch_code, nargout); |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1515 } |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1516 |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1517 octave_value_list interpreter::evalin (const std::string& context, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1518 const std::string& try_code, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1519 int nargout) |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1520 { |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1521 return m_evaluator.evalin (context, try_code, nargout); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1522 } |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1523 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1524 octave_value_list interpreter::evalin (const std::string& context, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1525 const std::string& try_code, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1526 const std::string& catch_code, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1527 int nargout) |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1528 { |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1529 return m_evaluator.evalin (context, try_code, catch_code, nargout); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1530 } |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1531 |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1532 //! Evaluate an Octave function (built-in or interpreted) and return |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1533 //! the list of result values. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1534 //! |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1535 //! @param name The name of the function to call. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1536 //! @param args The arguments to the function. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1537 //! @param nargout The number of output arguments expected. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1538 //! @return A list of output values. The length of the list is not |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1539 //! necessarily the same as @c nargout. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1540 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1541 octave_value_list interpreter::feval (const char *name, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1542 const octave_value_list& args, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1543 int nargout) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1544 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1545 return feval (std::string (name), args, nargout); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1546 } |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1547 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1548 octave_value_list interpreter::feval (const std::string& name, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1549 const octave_value_list& args, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1550 int nargout) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1551 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1552 octave_value fcn = m_symbol_table.find_function (name, args); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1553 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1554 if (fcn.is_undefined ()) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1555 error ("feval: function '%s' not found", name.c_str ()); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1556 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1557 octave_function *of = fcn.function_value (); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1558 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1559 return of->call (m_evaluator, nargout, args); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1560 } |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1561 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1562 octave_value_list interpreter::feval (octave_function *fcn, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1563 const octave_value_list& args, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1564 int nargout) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1565 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1566 if (fcn) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1567 return fcn->call (m_evaluator, nargout, args); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1568 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1569 return octave_value_list (); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1570 } |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1571 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1572 octave_value_list interpreter::feval (const octave_value& val, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1573 const octave_value_list& args, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1574 int nargout) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1575 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1576 // FIXME: do we really want to silently return an empty ovl if |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1577 // the function object is undefined? It's essentially what the |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1578 // version above that accepts a pointer to an octave_function |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1579 // object does and some code was apparently written to rely on it |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1580 // (for example, __ode15__). |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1581 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1582 if (val.is_undefined ()) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1583 return ovl (); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1584 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1585 if (val.is_function ()) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1586 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1587 return feval (val.function_value (), args, nargout); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1588 } |
28427
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
28347
diff
changeset
|
1589 else if (val.is_function_handle () || val.is_inline_function ()) |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1590 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1591 // This covers function handles, inline functions, and anonymous |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1592 // functions. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1593 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1594 std::list<octave_value_list> arg_list; |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1595 arg_list.push_back (args); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1596 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1597 // FIXME: could we make octave_value::subsref a const method? |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1598 // It would be difficult because there are instances of |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1599 // incrementing the reference count inside subsref methods, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1600 // which means they can't be const with the current way of |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1601 // handling reference counting. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1602 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1603 octave_value xval = val; |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1604 return xval.subsref ("(", arg_list, nargout); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1605 } |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1606 else if (val.is_string ()) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1607 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1608 return feval (val.string_value (), args, nargout); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1609 } |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1610 else |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1611 error ("feval: first argument must be a string, inline function, or a function handle"); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1612 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1613 return ovl (); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1614 } |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1615 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1616 //! Evaluate an Octave function (built-in or interpreted) and return |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1617 //! the list of result values. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1618 //! |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1619 //! @param args The first element of @c args is the function to call. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1620 //! It may be the name of the function as a string, a function |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1621 //! handle, or an inline function. The remaining arguments are |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1622 //! passed to the function. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1623 //! @param nargout The number of output arguments expected. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1624 //! @return A list of output values. The length of the list is not |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1625 //! necessarily the same as @c nargout. |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1626 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1627 octave_value_list interpreter::feval (const octave_value_list& args, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1628 int nargout) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1629 { |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1630 if (args.length () == 0) |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1631 error ("feval: first argument must be a string, inline function, or a function handle"); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1632 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1633 octave_value f_arg = args(0); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1634 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1635 octave_value_list tmp_args = args.slice (1, args.length () - 1, true); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1636 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1637 return feval (f_arg, tmp_args, nargout); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1638 } |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1639 |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28427
diff
changeset
|
1640 octave_value interpreter::make_function_handle (const std::string& name) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28427
diff
changeset
|
1641 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28427
diff
changeset
|
1642 return m_evaluator.make_fcn_handle (name); |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28427
diff
changeset
|
1643 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28427
diff
changeset
|
1644 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1645 void interpreter::install_variable (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1646 const octave_value& value, bool global) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1647 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1648 m_evaluator.install_variable (name, value, global); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1649 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1650 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1651 octave_value interpreter::global_varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1652 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1653 return m_evaluator.global_varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1654 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1655 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1656 void interpreter::global_assign (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1657 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1658 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1659 m_evaluator.global_assign (name, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1660 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1661 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1662 octave_value interpreter::top_level_varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1663 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1664 return m_evaluator.top_level_varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1665 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1666 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1667 void interpreter::top_level_assign (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1668 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1669 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1670 m_evaluator.top_level_assign (name, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1671 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1672 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1673 bool interpreter::is_variable (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1674 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1675 return m_evaluator.is_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1676 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1677 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1678 bool interpreter::is_local_variable (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1679 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1680 return m_evaluator.is_local_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1681 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1682 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1683 octave_value interpreter::varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1684 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1685 return m_evaluator.varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1686 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1687 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1688 void interpreter::assign (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1689 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1690 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1691 m_evaluator.assign (name, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1692 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1693 |
27014
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26826
diff
changeset
|
1694 void interpreter::assignin (const std::string& context, |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26826
diff
changeset
|
1695 const std::string& name, |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26826
diff
changeset
|
1696 const octave_value& val) |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26826
diff
changeset
|
1697 { |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26826
diff
changeset
|
1698 m_evaluator.assignin (context, name, val); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26826
diff
changeset
|
1699 } |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26826
diff
changeset
|
1700 |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
1701 void interpreter::source_file (const std::string& file_name, |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
1702 const std::string& context, bool verbose, |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27506
diff
changeset
|
1703 bool require_file) |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
1704 { |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27506
diff
changeset
|
1705 m_evaluator.source_file (file_name, context, verbose, require_file); |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
1706 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
1707 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1708 bool interpreter::at_top_level (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1709 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1710 return m_evaluator.at_top_level (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1711 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1712 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1713 bool interpreter::isglobal (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1714 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1715 return m_evaluator.is_global (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1716 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1717 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1718 octave_value interpreter::find (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1719 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1720 return m_evaluator.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1721 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1722 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1723 void interpreter::clear_all (bool force) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1724 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1725 m_evaluator.clear_all (force); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1726 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1727 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1728 void interpreter::clear_objects (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1729 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1730 m_evaluator.clear_objects (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1731 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1732 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1733 void interpreter::clear_variable (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1734 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1735 m_evaluator.clear_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1736 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1737 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1738 void interpreter::clear_variable_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1739 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1740 m_evaluator.clear_variable_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1741 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1742 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1743 void interpreter::clear_variable_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1744 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1745 m_evaluator.clear_variable_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1746 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1747 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1748 void interpreter::clear_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1749 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1750 m_evaluator.clear_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1751 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1752 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1753 void interpreter::clear_global_variable (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1754 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1755 m_evaluator.clear_global_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1756 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1757 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1758 void interpreter::clear_global_variable_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1759 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1760 m_evaluator.clear_global_variable_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1761 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1762 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1763 void interpreter::clear_global_variable_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1764 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1765 m_evaluator.clear_global_variable_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1766 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1767 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1768 void interpreter::clear_global_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1769 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1770 m_evaluator.clear_global_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1771 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1772 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1773 void interpreter::clear_functions (bool force) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1774 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1775 m_symbol_table.clear_functions (force); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1776 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1777 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1778 void interpreter::clear_function (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1779 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1780 m_symbol_table.clear_function (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1781 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1782 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1783 void interpreter::clear_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1784 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1785 m_evaluator.clear_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1786 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1787 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1788 void interpreter::clear_function_pattern (const std::string& pat) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1789 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1790 m_symbol_table.clear_function_pattern (pat); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1791 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1792 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1793 void interpreter::clear_function_regexp (const std::string& pat) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1794 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1795 m_symbol_table.clear_function_regexp (pat); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1796 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1797 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1798 void interpreter::clear_symbol_pattern (const std::string& pat) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1799 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1800 return m_evaluator.clear_symbol_pattern (pat); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1801 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1802 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1803 void interpreter::clear_symbol_regexp (const std::string& pat) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1804 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1805 return m_evaluator.clear_symbol_regexp (pat); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1806 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1807 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1808 std::list<std::string> interpreter::global_variable_names (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1809 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1810 return m_evaluator.global_variable_names (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1811 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1812 |
27594
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27593
diff
changeset
|
1813 std::list<std::string> interpreter::top_level_variable_names (void) |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27593
diff
changeset
|
1814 { |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27593
diff
changeset
|
1815 return m_evaluator.top_level_variable_names (); |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27593
diff
changeset
|
1816 } |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27593
diff
changeset
|
1817 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1818 std::list<std::string> interpreter::variable_names (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1819 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1820 return m_evaluator.variable_names (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1821 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1822 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1823 std::list<std::string> interpreter::user_function_names (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1824 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1825 return m_symbol_table.user_function_names (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1826 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
1827 |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
1828 std::list<std::string> interpreter::autoloaded_functions (void) const |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
1829 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
1830 return m_evaluator.autoloaded_functions (); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
1831 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
1832 |
29292
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1833 // May be used to send an interrupt signal to the the interpreter from |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1834 // another thread (for example, the GUI). |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1835 |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1836 void interpreter::interrupt (void) |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1837 { |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1838 static int sigint = 0; |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1839 static bool first = true; |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1840 |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1841 if (first) |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1842 { |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1843 octave_get_sig_number ("SIGINT", &sigint); |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1844 first = false; |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1845 } |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1846 |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1847 // Send SIGINT to Octave and (optionally) all other processes in its |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1848 // process group. The signal handler for SIGINT will set a global |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1849 // variable indicating an interrupt has happened. That variable is |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1850 // checked in many places in the Octave interpreter and eventually |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1851 // results in an interrupt_exception being thrown. Finally, that |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1852 // exception is caught and returns control to one of the |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1853 // read-eval-print loops or to the server loop. We use a signal |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1854 // instead of just setting the global variables here so that we will |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1855 // probably send interrupt signals to any subprocesses as well as |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1856 // interrupt execution of the interpreter. |
29292
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1857 |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1858 pid_t pid |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1859 = m_interrupt_all_in_process_group ? 0 : octave_getpid_wrapper (); |
29295
b73ddb964093
allow interrupts to be sent to all processes in process group or just octave
John W. Eaton <jwe@octave.org>
parents:
29293
diff
changeset
|
1860 |
b73ddb964093
allow interrupts to be sent to all processes in process group or just octave
John W. Eaton <jwe@octave.org>
parents:
29293
diff
changeset
|
1861 octave_kill_wrapper (pid, sigint); |
29292
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1862 } |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
1863 |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1864 void interpreter::pause (void) |
27471 | 1865 { |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1866 // FIXME: To be reliable, these tree_evaluator functions must be |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1867 // made thread safe. |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1868 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1869 m_evaluator.break_on_next_statement (true); |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1870 m_evaluator.reset_debug_state (); |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1871 } |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1872 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1873 void interpreter::stop (void) |
27471 | 1874 { |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1875 // FIXME: To be reliable, these tree_evaluator functions must be |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1876 // made thread safe. |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1877 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1878 if (m_evaluator.in_debug_repl ()) |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1879 m_evaluator.dbquit (true); |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1880 else |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1881 interrupt (); |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1882 } |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1883 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1884 void interpreter::resume (void) |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1885 { |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1886 // FIXME: To be reliable, these tree_evaluator functions must be |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1887 // made thread safe. |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1888 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1889 // FIXME: Should there be any feeback about not doing anything if |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1890 // not in debug mode? |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1891 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1892 if (m_evaluator.in_debug_repl ()) |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1893 m_evaluator.dbcont (); |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1894 } |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29295
diff
changeset
|
1895 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1896 // Provided for convenience. Will be removed once we eliminate the |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1897 // old terminal widget. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1898 bool interpreter::experimental_terminal_widget (void) const |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1899 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1900 if (! m_app_context) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1901 return false; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1902 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1903 // Embedded interpreters don't execute command line options. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1904 const cmdline_options& options = m_app_context->options (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1905 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1906 return options.experimental_terminal_widget (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1907 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
1908 |
29446
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1909 void interpreter::add_debug_watch_expression (const std::string& expr) |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1910 { |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1911 m_evaluator.add_debug_watch_expression (expr); |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1912 } |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1913 |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1914 void interpreter::remove_debug_watch_expression (const std::string& expr) |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1915 { |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1916 m_evaluator.remove_debug_watch_expression (expr); |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1917 } |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1918 |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1919 void interpreter::clear_debug_watch_expressions (void) |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1920 { |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1921 m_evaluator.clear_debug_watch_expressions (); |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1922 } |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1923 |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1924 std::set<std::string> interpreter::debug_watch_expressions (void) const |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1925 { |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1926 return m_evaluator.debug_watch_expressions (); |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1927 } |
435fc29162c0
maintain a set of watch expressions for possible use in tracing/debugging
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
1928 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29163
diff
changeset
|
1929 void interpreter::handle_exception (const execution_exception& ee) |
27471 | 1930 { |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29163
diff
changeset
|
1931 m_error_system.save_exception (ee); |
27471 | 1932 |
27971
ec769a7ab9fb
fix more spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
1933 // FIXME: use a separate stream instead of std::cerr directly so that |
27471 | 1934 // error messages can be redirected more easily? Pass the message |
1935 // to an event manager function? | |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29446
diff
changeset
|
1936 m_error_system.display_exception (ee); |
27471 | 1937 |
1938 recover_from_exception (); | |
1939 } | |
1940 | |
23111
252975fdc444
more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
1941 void interpreter::recover_from_exception (void) |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
1942 { |
29293
8784f20b9b8c
new interpreter_event to signal that interpreter was interrupted
John W. Eaton <jwe@octave.org>
parents:
29292
diff
changeset
|
1943 if (octave_interrupt_state) |
8784f20b9b8c
new interpreter_event to signal that interpreter was interrupted
John W. Eaton <jwe@octave.org>
parents:
29292
diff
changeset
|
1944 m_event_manager.interpreter_interrupted (); |
8784f20b9b8c
new interpreter_event to signal that interpreter was interrupted
John W. Eaton <jwe@octave.org>
parents:
29292
diff
changeset
|
1945 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1946 can_interrupt = true; |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
1947 octave_interrupt_state = 0; |
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
1948 octave_signal_caught = 0; |
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
1949 octave_restore_signal_mask (); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
1950 catch_interrupts (); |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
1951 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1952 |
27542
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
1953 void interpreter::mark_for_deletion (const std::string& file) |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
1954 { |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
1955 m_tmp_files.insert (file); |
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
1956 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1957 |
27542
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
1958 void interpreter::cleanup_tmp_files (void) |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
1959 { |
27542
b8aa62c1deb5
eliminate global tmp_files variable
John W. Eaton <jwe@octave.org>
parents:
27532
diff
changeset
|
1960 m_tmp_files.cleanup (); |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
1961 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1962 |
27588
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27587
diff
changeset
|
1963 void interpreter::quit (int exit_status, bool force, bool confirm) |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1964 { |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1965 if (! force) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1966 { |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1967 try |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1968 { |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1969 bool cancel = false; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1970 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1971 if (symbol_exist ("finish.m", "file")) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1972 { |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1973 unwind_protect_var<bool> upv1 (m_executing_finish_script, true); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1974 unwind_protect_var<bool> upv2 (m_cancel_quit); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1975 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1976 evalin ("base", "finish", 0); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1977 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1978 cancel = m_cancel_quit; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1979 } |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1980 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1981 if (cancel) |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1982 return; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1983 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1984 // Check for confirmation. |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1985 |
27588
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27587
diff
changeset
|
1986 if (confirm && ! m_event_manager.confirm_shutdown ()) |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1987 return; |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1988 } |
27592
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1989 catch (const execution_exception&) |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1990 { |
27592
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1991 // Catch execution_exceptions so we don't throw an |
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1992 // exit_exception if there is an in finish.m. But throw it |
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1993 // again so that will be handled as any other |
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1994 // execution_exception by the evaluator. This way, errors |
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1995 // will be ignored properly and we won't exit if quit is |
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1996 // called recursively from finish.m. |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1997 |
27592
637279c8caba
* intepreter.cc (interpreter::quit): Fix exception handling logic.
John W. Eaton <jwe@octave.org>
parents:
27591
diff
changeset
|
1998 throw; |
27587
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
1999 } |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
2000 } |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
2001 |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
2002 throw exit_exception (exit_status); |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
2003 } |
494d6243c188
improve compatibility of quit function
John W. Eaton <jwe@octave.org>
parents:
27545
diff
changeset
|
2004 |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2005 void interpreter::add_atexit_fcn (const std::string& fname) |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2006 { |
27690
c81139d8dcc3
prevent atexit functions from adding new atexit functions
John W. Eaton <jwe@octave.org>
parents:
27689
diff
changeset
|
2007 if (m_executing_atexit) |
c81139d8dcc3
prevent atexit functions from adding new atexit functions
John W. Eaton <jwe@octave.org>
parents:
27689
diff
changeset
|
2008 return; |
c81139d8dcc3
prevent atexit functions from adding new atexit functions
John W. Eaton <jwe@octave.org>
parents:
27689
diff
changeset
|
2009 |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2010 m_atexit_fcns.push_front (fname); |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2011 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2012 |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2013 bool interpreter::remove_atexit_fcn (const std::string& fname) |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2014 { |
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2015 bool found = false; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2016 |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2017 for (auto it = m_atexit_fcns.begin (); |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2018 it != m_atexit_fcns.end (); it++) |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2019 { |
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2020 if (*it == fname) |
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2021 { |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2022 m_atexit_fcns.erase (it); |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2023 found = true; |
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2024 break; |
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2025 } |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2026 } |
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2027 |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23109
diff
changeset
|
2028 return found; |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2029 } |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2030 |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
2031 // Remove when corresponding public deprecated function is removed. |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
2032 void interpreter::add_atexit_function_deprecated (const std::string& fname) |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2033 { |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2034 interpreter& interp |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2035 = __get_interpreter__ ("interpreter::add_atexit_function"); |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2036 |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2037 interp.add_atexit_fcn (fname); |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2038 } |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2039 |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
2040 // Remove when corresponding public deprecated function is removed. |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
2041 bool interpreter::remove_atexit_function_deprecated (const std::string& fname) |
27689
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2042 { |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2043 interpreter& interp |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2044 = __get_interpreter__ ("interpreter::remove_atexit_function"); |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2045 |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2046 return interp.remove_atexit_fcn (fname); |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2047 } |
4f32af6abd4b
don't use static variable for list of interpreter atexit functions
John W. Eaton <jwe@octave.org>
parents:
27594
diff
changeset
|
2048 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2049 // What internal options get configured by --traditional. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2050 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2051 void interpreter::maximum_braindamage (void) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2052 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25404
diff
changeset
|
2053 m_input_system.PS1 (">> "); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25404
diff
changeset
|
2054 m_input_system.PS2 (""); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2055 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2056 m_evaluator.PS4 (""); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2057 |
25993
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25488
diff
changeset
|
2058 m_load_save_system.crash_dumps_octave_core (false); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25488
diff
changeset
|
2059 m_load_save_system.save_default_options ("-mat-binary"); |
f75bb9d659e0
eliminate global and file-scope static variables from load-save.cc (bug #54571)
John W. Eaton <jwe@octave.org>
parents:
25488
diff
changeset
|
2060 |
25994
f881d3e271d2
eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents:
25993
diff
changeset
|
2061 m_history_system.timestamp_format_string ("%%-- %D %I:%M %p --%%"); |
f881d3e271d2
eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents:
25993
diff
changeset
|
2062 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
2063 m_error_system.beep_on_error (true); |
29932
b39203a44db2
Call print_struct_array_contents(1) when '--traditional' option used.
Rik <rik@octave.org>
parents:
29912
diff
changeset
|
2064 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2065 Fconfirm_recursive_rmdir (octave_value (false)); |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
2066 Foptimize_diagonal_matrix (octave_value (false)); |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
2067 Foptimize_permutation_matrix (octave_value (false)); |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
2068 Foptimize_range (octave_value (false)); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2069 Ffixed_point_format (octave_value (true)); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2070 Fprint_empty_dimensions (octave_value (false)); |
29932
b39203a44db2
Call print_struct_array_contents(1) when '--traditional' option used.
Rik <rik@octave.org>
parents:
29912
diff
changeset
|
2071 Fprint_struct_array_contents (octave_value (true)); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2072 Fstruct_levels_to_print (octave_value (0)); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2073 |
29956
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
2074 m_error_system.disable_warning ("Octave:abbreviated-property-match"); |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
2075 m_error_system.disable_warning ("Octave:colon-nonscalar-argument"); |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
2076 m_error_system.disable_warning ("Octave:data-file-in-path"); |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
2077 m_error_system.disable_warning ("Octave:empty-index"); |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
2078 m_error_system.disable_warning ("Octave:function-name-clash"); |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
2079 m_error_system.disable_warning ("Octave:possible-matlab-short-circuit-operator"); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
2080 } |
25345
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2081 |
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2082 void interpreter::execute_pkg_add (const std::string& dir) |
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2083 { |
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2084 try |
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2085 { |
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2086 m_load_path.execute_pkg_add (dir); |
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2087 } |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
2088 catch (const interrupt_exception&) |
25345
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2089 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
2090 recover_from_exception (); |
25345
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2091 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
2092 catch (const execution_exception& ee) |
25345
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2093 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28953
diff
changeset
|
2094 handle_exception (ee); |
25345
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2095 } |
ce6f7a5cd68e
avoid global access of load path in interpreter class
John W. Eaton <jwe@octave.org>
parents:
25184
diff
changeset
|
2096 } |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2097 |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2098 OCTAVE_NAMESPACE_END |