Mercurial > octave
annotate libinterp/parse-tree/pt-eval.cc @ 30896:c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
* __eigs__.cc, bsxfun.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
debug.cc, error.cc, graphics.cc, graphics.in.h, gzfstream.h, ls-hdf5.cc,
lsode.cc, max.cc, oct-opengl.h, quad.cc, strfns.cc, utils.cc, utils.h,
variables.cc, __ode15__.cc, gzip.cc, cdef-manager.cc, ov-fcn-handle.cc,
ov-java.cc, ov-usr-fcn.cc, bp-table.cc, bp-table.h, lex.h, lex.ll,
oct-parse.yy, pt-eval.cc:
Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author | Rik <rik@octave.org> |
---|---|
date | Tue, 05 Apr 2022 08:33:58 -0700 |
parents | 97504d2edcc7 |
children | 4ed7dfe28584 |
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:
30326
diff
changeset
|
3 // Copyright (C) 2009-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 //////////////////////////////////////////////////////////////////////// |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21542
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21211
diff
changeset
|
27 # include "config.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <cctype> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
29619
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
32 #include <condition_variable> |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <iostream> |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
34 #include <list> |
29619
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
35 #include <mutex> |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
36 #include <string> |
29619
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
37 #include <thread> |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
39 #include "cmd-edit.h" |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
40 #include "file-ops.h" |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
41 #include "file-stat.h" |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
42 #include "lo-array-errwarn.h" |
27100
b453b586da16
improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
43 #include "lo-ieee.h" |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
44 #include "oct-env.h" |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
45 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
46 #include "bp-table.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
47 #include "call-stack.h" |
26975
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
48 #include "cdef-manager.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "defun.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20962
diff
changeset
|
51 #include "errwarn.h" |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
52 #include "event-manager.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 #include "input.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
54 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
55 #include "interpreter.h" |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
56 #include "octave.h" |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
26718
diff
changeset
|
57 #include "ov-classdef.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 #include "ov-fcn-handle.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 #include "ov-usr-fcn.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
60 #include "ov-re-sparse.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
61 #include "ov-cx-sparse.h" |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
62 #include "parse.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
63 #include "profiler.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 #include "pt-all.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
65 #include "pt-anon-scopes.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 #include "pt-eval.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
67 #include "pt-tm-const.h" |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
68 #include "stack-frame.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 #include "symtab.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 #include "unwind-prot.h" |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
71 #include "utils.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
72 #include "variables.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
74 OCTAVE_NAMESPACE_BEGIN |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
75 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
76 // Normal evaluator. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
78 class quit_debug_exception |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
79 { |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
80 public: |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
81 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
82 quit_debug_exception (bool all = false) : m_all (all) { } |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
83 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
84 quit_debug_exception (const quit_debug_exception&) = default; |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
85 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
86 quit_debug_exception& operator = (const quit_debug_exception&) = default; |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
87 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
88 ~quit_debug_exception (void) = default; |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
89 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
90 bool all (void) const { return m_all; } |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
91 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
92 private: |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
93 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
94 bool m_all; |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
95 }; |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
96 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
97 class debugger |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
98 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
99 public: |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
100 |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
101 enum execution_mode |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
102 { |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
103 EX_NORMAL = 0, |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
104 EX_CONTINUE = 1, |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
105 EX_QUIT = 2, |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
106 EX_QUIT_ALL = 3 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
107 }; |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
108 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
109 debugger (interpreter& interp, std::size_t level) |
30735
4335606e41ac
maint: remove unused variables identified by compiler warnings (Bug #62017)
Antonius Burgers <arburgers@gmail.com>
parents:
30723
diff
changeset
|
110 : m_interpreter (interp), m_level (level), |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
111 m_execution_mode (EX_NORMAL), m_in_debug_repl (false) |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
112 { } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
113 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
114 int server_loop (void); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
115 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
116 void repl (const std::string& prompt = "debug> "); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
117 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
118 bool in_debug_repl (void) const { return m_in_debug_repl; } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
119 |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
120 void dbcont (void) { m_execution_mode = EX_CONTINUE; } |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
121 |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
122 void dbquit (bool all = false) |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
123 { |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
124 if (all) |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
125 m_execution_mode = EX_QUIT_ALL; |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
126 else |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
127 m_execution_mode = EX_QUIT; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
128 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
129 |
27402
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
130 bool quitting_debugger (void) const; |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
131 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
132 private: |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
133 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
134 interpreter& m_interpreter; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
135 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
136 std::size_t m_level; |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
137 execution_mode m_execution_mode; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
138 bool m_in_debug_repl; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
139 }; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
140 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
141 // FIXME: Could the debugger server_loop and repl functions be merged |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
142 // with the corresponding tree_evaluator functions or do they need to |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
143 // remain separate? They perform nearly the same functions. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
144 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
145 int debugger::server_loop (void) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
146 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
147 // Process events from the event queue. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
148 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
149 tree_evaluator& tw = m_interpreter.get_evaluator (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
150 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
151 void (tree_evaluator::*server_mode_fptr) (bool) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
152 = &tree_evaluator::server_mode; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
153 unwind_action act (server_mode_fptr, &tw, true); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
154 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
155 int exit_status = 0; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
156 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
157 do |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
158 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
159 if (m_execution_mode == EX_CONTINUE || tw.dbstep_flag ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
160 break; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
161 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
162 if (quitting_debugger ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
163 break; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
164 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
165 try |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
166 { |
29294
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
167 // FIXME: Should we call octave_quit in the octave::sleep |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
168 // and/or command_editor::run_event_hooks functions? |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
169 |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
170 octave_quit (); |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
171 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
172 // FIXME: Running the event queue should be decoupled from |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
173 // the command_editor. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
174 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
175 // FIXME: Is it OK to use command_editor::run_event_hooks |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
176 // here? It may run more than one queued function per call, |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
177 // and it seems that the checks at the top of the loop |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
178 // probably need to be done after each individual event |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
179 // function is executed. For now, maybe the simplest thing |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
180 // would be to pass a predicate function (lambda expression) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
181 // to the command_editor::run_event_hooks and have it check |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
182 // that and break out of the eval loop(s) if the condition |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
183 // is met? |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
184 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
185 // FIXME: We should also use a condition variable to manage |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
186 // the execution of entries in the queue and eliminate the |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
187 // need for the busy-wait loop. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
188 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
189 command_editor::run_event_hooks (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
190 |
30749
076e19eac74a
allow deletion of dynamic_library objects to be delayed
John W. Eaton <jwe@octave.org>
parents:
30652
diff
changeset
|
191 release_unreferenced_dynamic_libraries (); |
076e19eac74a
allow deletion of dynamic_library objects to be delayed
John W. Eaton <jwe@octave.org>
parents:
30652
diff
changeset
|
192 |
29950
6549fa7558ba
eliminate some unnecessary octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
193 sleep (0.1); |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
194 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
195 catch (const interrupt_exception&) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
196 { |
29420
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
197 octave_interrupt_state = 1; |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
198 m_interpreter.recover_from_exception (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
199 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
200 // Required newline when the user does Ctrl+C at the prompt. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
201 if (m_interpreter.interactive ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
202 octave_stdout << "\n"; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
203 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
204 catch (const index_exception& e) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
205 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
206 m_interpreter.recover_from_exception (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
207 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
208 std::cerr << "error: unhandled index exception: " |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
209 << e.message () << " -- trying to return to prompt" |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
210 << std::endl; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
211 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
212 catch (const execution_exception& ee) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
213 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
214 error_system& es = m_interpreter.get_error_system (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
215 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
216 es.save_exception (ee); |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29493
diff
changeset
|
217 es.display_exception (ee); |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
218 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
219 if (m_interpreter.interactive ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
220 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
221 m_interpreter.recover_from_exception (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
222 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
223 else |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
224 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
225 // We should exit with a nonzero status. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
226 exit_status = 1; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
227 break; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
228 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
229 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
230 catch (const quit_debug_exception& qde) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
231 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
232 if (qde.all ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
233 throw; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
234 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
235 // Continue in this debug level. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
236 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
237 catch (const std::bad_alloc&) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
238 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
239 m_interpreter.recover_from_exception (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
240 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
241 std::cerr << "error: out of memory -- trying to return to prompt" |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
242 << std::endl; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
243 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
244 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
245 while (exit_status == 0); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
246 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
247 if (exit_status == EOF) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
248 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
249 if (m_interpreter.interactive ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
250 octave_stdout << "\n"; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
251 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
252 exit_status = 0; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
253 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
254 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
255 return exit_status; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
256 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
257 |
27533
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
258 void debugger::repl (const std::string& prompt_arg) |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
259 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
260 unwind_protect frame; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
261 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
262 frame.protect_var (m_in_debug_repl); |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
263 frame.protect_var (m_execution_mode); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
264 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
265 m_in_debug_repl = true; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
266 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
267 tree_evaluator& tw = m_interpreter.get_evaluator (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
268 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
269 bool silent = tw.quiet_breakpoint_flag (false); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
270 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
271 frame.add (&tree_evaluator::restore_frame, &tw, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
272 tw.current_call_stack_frame_number ()); |
27200
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
273 |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
274 tw.goto_frame (tw.debug_frame ()); |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
275 |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
276 octave_user_code *caller = tw.current_user_code (); |
27392
820a87b87c01
clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents:
27374
diff
changeset
|
277 std::string fcn_file_nm, fcn_nm; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
278 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
279 if (caller) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
280 { |
27392
820a87b87c01
clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents:
27374
diff
changeset
|
281 fcn_file_nm = caller->fcn_file_name (); |
820a87b87c01
clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents:
27374
diff
changeset
|
282 fcn_nm = fcn_file_nm.empty () ? caller->name () : fcn_file_nm; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
283 } |
27200
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
284 |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
285 int curr_debug_line = tw.current_line (); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
286 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
287 std::ostringstream buf; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
288 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
289 input_system& input_sys = m_interpreter.get_input_system (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
290 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
291 event_manager& evmgr = m_interpreter.get_event_manager (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
292 |
27392
820a87b87c01
clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents:
27374
diff
changeset
|
293 if (! fcn_nm.empty ()) |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
294 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
295 if (input_sys.gud_mode ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
296 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
297 static char ctrl_z = 'Z' & 0x1f; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
298 |
27392
820a87b87c01
clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents:
27374
diff
changeset
|
299 buf << ctrl_z << ctrl_z << fcn_nm << ':' << curr_debug_line; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
300 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
301 else |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
302 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
303 // FIXME: we should come up with a clean way to detect |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
304 // that we are stopped on the no-op command that marks the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
305 // end of a function or script. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
306 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
307 if (! silent) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
308 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
309 std::shared_ptr<stack_frame> frm = tw.current_user_frame (); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
310 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
311 frm->display_stopped_in_message (buf); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
312 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
313 |
27392
820a87b87c01
clean up use of interpreter in qt_interpreter_events::enter_debugger_event
John W. Eaton <jwe@octave.org>
parents:
27374
diff
changeset
|
314 evmgr.enter_debugger_event (fcn_nm, fcn_file_nm, curr_debug_line); |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
315 |
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
316 evmgr.set_workspace (); |
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
317 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
318 frame.add (&event_manager::execute_in_debugger_event, &evmgr, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
319 fcn_nm, curr_debug_line); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
320 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
321 if (! silent) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
322 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
323 std::string line_buf; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
324 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
325 if (caller) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
326 line_buf = caller->get_code_line (curr_debug_line); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
327 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
328 if (! line_buf.empty ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
329 buf << curr_debug_line << ": " << line_buf; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
330 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
331 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
332 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
333 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
334 if (silent) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
335 command_editor::erase_empty_line (true); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
336 |
27471 | 337 std::string stopped_in_msg = buf.str (); |
338 | |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
339 if (m_interpreter.server_mode ()) |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
340 { |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
341 if (! stopped_in_msg.empty ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
342 octave_stdout << stopped_in_msg << std::endl; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
343 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
344 evmgr.push_event_queue (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
345 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
346 frame.add (&event_manager::pop_event_queue, &evmgr); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
347 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
348 frame.add (&tree_evaluator::set_parser, &tw, tw.get_parser ()); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
349 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
350 std::shared_ptr<push_parser> |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
351 debug_parser (new push_parser (m_interpreter)); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
352 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
353 tw.set_parser (debug_parser); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
354 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
355 server_loop (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
356 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
357 else |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
358 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
359 if (! stopped_in_msg.empty ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
360 std::cerr << stopped_in_msg << std::endl; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
361 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
362 std::string tmp_prompt = prompt_arg; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
363 if (m_level > 0) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
364 tmp_prompt = "[" + std::to_string (m_level) + "]" + prompt_arg; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
365 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
366 frame.add (&input_system::set_PS1, &input_sys, input_sys.PS1 ()); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
367 input_sys.PS1 (tmp_prompt); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
368 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
369 if (! m_interpreter.interactive ()) |
27301
a2b1ba6c92d5
eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents:
27290
diff
changeset
|
370 { |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
371 void (interpreter::*interactive_fptr) (bool) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
372 = &interpreter::interactive; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
373 frame.add (interactive_fptr, &m_interpreter, |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
374 m_interpreter.interactive ()); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
375 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
376 m_interpreter.interactive (true); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
377 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
378 // FIXME: should debugging be possible in an embedded |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
379 // interpreter? |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
380 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
381 application *app = application::app (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
382 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
383 if (app) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
384 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
385 void (application::*forced_interactive_fptr) (bool) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
386 = &application::forced_interactive; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
387 frame.add (forced_interactive_fptr, app, |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
388 app->forced_interactive ()); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
389 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
390 app->forced_interactive (true); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
391 } |
27301
a2b1ba6c92d5
eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents:
27290
diff
changeset
|
392 } |
27533
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
393 |
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
394 #if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER) |
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
395 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
396 input_reader reader (m_interpreter); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
397 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
398 push_parser debug_parser (m_interpreter); |
27533
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
399 |
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
400 #else |
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
401 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
402 parser debug_parser (m_interpreter); |
27533
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
403 |
0abe70896e34
use push parser in debug repl if enabled
John W. Eaton <jwe@octave.org>
parents:
27519
diff
changeset
|
404 #endif |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
405 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
406 error_system& es = m_interpreter.get_error_system (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
407 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
408 while (m_in_debug_repl) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
409 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
410 if (m_execution_mode == EX_CONTINUE || tw.dbstep_flag ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
411 break; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
412 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
413 if (quitting_debugger ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
414 break; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
415 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
416 try |
27402
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
417 { |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
418 debug_parser.reset (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
419 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
420 #if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
421 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
422 int retval = 0; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
423 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
424 std::string prompt |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
425 = command_editor::decode_prompt_string (tmp_prompt); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
426 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
427 do |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
428 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
429 bool eof = false; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
430 std::string input_line = reader.get_input (prompt, eof); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
431 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
432 if (eof) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
433 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
434 retval = EOF; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
435 break; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
436 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
437 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
438 retval = debug_parser.run (input_line, false); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
439 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
440 prompt = command_editor::decode_prompt_string (input_sys.PS2 ()); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
441 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
442 while (retval < 0); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
443 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
444 #else |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
445 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
446 int retval = debug_parser.run (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
447 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
448 #endif |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
449 if (command_editor::interrupt (false)) |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
450 { |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
451 // Break regardless of m_execution_mode value. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
452 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
453 quitting_debugger (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
454 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
455 break; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
456 } |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
457 else |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
458 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
459 if (retval == 0) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
460 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
461 std::shared_ptr<tree_statement_list> stmt_list |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
462 = debug_parser.statement_list (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
463 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
464 if (stmt_list) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
465 stmt_list->accept (tw); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
466 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
467 if (octave_completion_matches_called) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
468 octave_completion_matches_called = false; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
469 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
470 // FIXME: the following statement is here because |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
471 // the last command may have been a dbup, dbdown, or |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
472 // dbstep command that changed the current debug |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
473 // frame. If so, we need to reset the current frame |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
474 // for the call stack. But is this right way to do |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
475 // this job? What if the statement list was |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
476 // something like "dbup; dbstack"? Will the call to |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
477 // dbstack use the right frame? If not, how can we |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
478 // fix this problem? |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
479 tw.goto_frame (tw.debug_frame ()); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
480 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
481 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
482 octave_quit (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
483 } |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
484 } |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
485 catch (const execution_exception& ee) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
486 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
487 es.save_exception (ee); |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29493
diff
changeset
|
488 es.display_exception (ee); |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
489 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
490 // Ignore errors when in debugging mode; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
491 m_interpreter.recover_from_exception (); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
492 } |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
493 catch (const quit_debug_exception& qde) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
494 { |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
495 if (qde.all ()) |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
496 throw; |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
497 |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
498 // Continue in this debug level. |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
499 } |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
500 } |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
501 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
502 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
503 |
27402
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
504 bool debugger::quitting_debugger (void) const |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
505 { |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
506 if (m_execution_mode == EX_QUIT) |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
507 { |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
508 // If there is no enclosing debug level or the top-level |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
509 // repl is not active, handle dbquit the same as dbcont. |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
510 |
29420
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
511 if (m_level > 0 || m_interpreter.server_mode () |
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
512 || m_interpreter.in_top_level_repl ()) |
27402
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
513 throw quit_debug_exception (); |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
514 else |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
515 return true; |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
516 } |
27402
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
517 |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
518 if (m_execution_mode == EX_QUIT_ALL) |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
519 { |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
520 // If the top-level repl is not active, handle "dbquit all" |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
521 // the same as dbcont. |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
522 |
29420
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
523 if (m_interpreter.server_mode () || m_interpreter.in_top_level_repl ()) |
27402
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
524 throw quit_debug_exception (true); |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
525 else |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
526 return true; |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
527 } |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
528 |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
529 return false; |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
530 } |
84d11fcb2f91
also check debugger execution mode after command editor interrupt
John W. Eaton <jwe@octave.org>
parents:
27392
diff
changeset
|
531 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
532 bool tree_evaluator::at_top_level (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
533 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
534 return m_call_stack.at_top_level (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
535 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
536 |
27015
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
537 std::string |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
538 tree_evaluator::mfilename (const std::string& opt) const |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
539 { |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
540 std::string fname; |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
541 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
542 octave_user_code *fcn = m_call_stack.current_user_code (); |
27015
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
543 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
544 if (fcn) |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
545 { |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
546 fname = fcn->fcn_file_name (); |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
547 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
548 if (fname.empty ()) |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
549 fname = fcn->name (); |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
550 } |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
551 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
552 if (opt == "fullpathext") |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
553 return fname; |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
554 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
555 std::size_t dpos = fname.rfind (sys::file_ops::dir_sep_char ()); |
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
556 std::size_t epos = fname.rfind ('.'); |
27015
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
557 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
558 if (epos <= dpos+1) |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
559 epos = std::string::npos; |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
560 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
561 if (epos != std::string::npos) |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
562 fname = fname.substr (0, epos); |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
563 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
564 if (opt == "fullpath") |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
565 return fname; |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
566 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
567 if (dpos != std::string::npos) |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
568 fname = fname.substr (dpos+1); |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
569 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
570 return fname; |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
571 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
572 |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
573 void tree_evaluator::parse_and_execute (const std::string& input, |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
574 bool& incomplete_parse) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
575 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
576 incomplete_parse = false; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
577 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
578 unwind_protect_var<bool> upv (m_in_top_level_repl, true); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
579 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
580 if (at_top_level ()) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
581 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
582 dbstep_flag (0); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
583 reset_debug_state (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
584 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
585 |
29307
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
586 // FIXME: OK to do this job here, or should it be in the functions |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
587 // that do the actual prompting? |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
588 |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
589 // Update the time stamp for the "prompt" so that automatically |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
590 // finding modified files based on file modification times will |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
591 // work. In the future, we may do something completely different to |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
592 // check for changes to files but for now, we rely on the prompt |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
593 // time stamp to limit the checks for file modification times. |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
594 |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
595 Vlast_prompt_time.stamp (); |
b2d62cfac9e6
update last prompt time stamp when parsing files in server loop
John W. Eaton <jwe@octave.org>
parents:
29306
diff
changeset
|
596 |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
597 bool eof = false; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
598 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
599 event_manager& evmgr = m_interpreter.get_event_manager (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
600 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
601 if (command_history::add (input)) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
602 evmgr.append_history (input); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
603 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
604 m_exit_status = m_parser->run (input, eof); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
605 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
606 if (m_exit_status == 0) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
607 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
608 std::shared_ptr<tree_statement_list> |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
609 stmt_list = m_parser->statement_list (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
610 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
611 if (stmt_list) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
612 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
613 command_editor::increment_current_command_number (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
614 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
615 eval (stmt_list, m_interpreter.interactive ()); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
616 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
617 evmgr.set_workspace (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
618 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
619 else if (m_parser->at_end_of_input ()) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
620 m_exit_status = EOF; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
621 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
622 else |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
623 incomplete_parse = true; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
624 |
29526
b65824235c7f
also reset parser when interpreter recovers from exception
John W. Eaton <jwe@octave.org>
parents:
29503
diff
changeset
|
625 // FIXME: Should we be checking m_exit_status or incomplete_parse or |
b65824235c7f
also reset parser when interpreter recovers from exception
John W. Eaton <jwe@octave.org>
parents:
29503
diff
changeset
|
626 // both here? Could EOF have a value other than -1, and is there |
b65824235c7f
also reset parser when interpreter recovers from exception
John W. Eaton <jwe@octave.org>
parents:
29503
diff
changeset
|
627 // possible confusion between that state and the parser returning -1? |
b65824235c7f
also reset parser when interpreter recovers from exception
John W. Eaton <jwe@octave.org>
parents:
29503
diff
changeset
|
628 |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
629 if (m_exit_status == -1) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
630 m_exit_status = 0; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
631 else |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
632 m_parser->reset (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
633 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
634 evmgr.pre_input_event (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
635 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
636 |
29619
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
637 void tree_evaluator::get_line_and_eval (void) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
638 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
639 std::mutex mtx; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
640 std::unique_lock<std::mutex> lock (mtx); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
641 std::condition_variable cv; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
642 bool incomplete_parse = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
643 bool evaluation_pending = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
644 bool exiting = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
645 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
646 input_system& input_sys = m_interpreter.get_input_system (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
647 event_manager& evmgr = m_interpreter.get_event_manager (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
648 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
649 while (true) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
650 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
651 // FIXME: Detect EOF? Use readline? If |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
652 // so, then we need to disable idle event loop hook function |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
653 // execution. |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
654 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
655 std::string ps = incomplete_parse ? input_sys.PS2 () : input_sys.PS1 (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
656 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
657 std::cout << command_editor::decode_prompt_string (ps); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
658 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
659 std::string input; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
660 std::getline (std::cin, input); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
661 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
662 if (input.empty ()) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
663 continue; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
664 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
665 incomplete_parse = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
666 evaluation_pending = true; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
667 exiting = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
668 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
669 evmgr.post_event |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
670 ([&] (interpreter& interp) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
671 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
672 // INTERPRETER THREAD |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
673 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
674 std::lock_guard<std::mutex> local_lock (mtx); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
675 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
676 try |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
677 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
678 interp.parse_and_execute (input, incomplete_parse); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
679 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
680 catch (const exit_exception&) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
681 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
682 evaluation_pending = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
683 exiting = true; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
684 cv.notify_all (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
685 throw; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
686 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
687 catch (const execution_exception& ee) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
688 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
689 error_system& es = m_interpreter.get_error_system (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
690 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
691 es.save_exception (ee); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
692 es.display_exception (ee); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
693 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
694 if (m_interpreter.interactive ()) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
695 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
696 m_interpreter.recover_from_exception (); |
29620
ad720f9c12b3
reset parser if parse error occurs parsing code in get_line_and_eval
John W. Eaton <jwe@octave.org>
parents:
29619
diff
changeset
|
697 m_parser->reset (); |
29619
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
698 evaluation_pending = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
699 cv.notify_all (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
700 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
701 else |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
702 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
703 evaluation_pending = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
704 cv.notify_all (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
705 throw exit_exception (1); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
706 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
707 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
708 catch (...) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
709 { |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
710 evaluation_pending = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
711 cv.notify_all (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
712 throw; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
713 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
714 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
715 evaluation_pending = false; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
716 cv.notify_all (); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
717 }); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
718 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
719 // Wait until evaluation is finished before prompting for input |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
720 // again. |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
721 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
722 cv.wait (lock, [&] { return ! evaluation_pending; }); |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
723 |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
724 if (exiting) |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
725 break; |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
726 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
727 } |
5cf985f5760a
move get_line_and_eval to parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
29572
diff
changeset
|
728 |
29846
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
729 int tree_evaluator::repl (void) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
730 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
731 // The big loop. Read, Eval, Print, Loop. Normally user |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
732 // interaction at the command line in a terminal session, but we may |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
733 // also end up here when reading from a pipe or when stdin is |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
734 // connected to a file by the magic of input redirection. |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
735 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
736 int exit_status = 0; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
737 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
738 // FIXME: should this choice be a command-line option? Note that we |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
739 // intend that the push parser interface only be used for |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
740 // interactive sessions. |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
741 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
742 #if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
743 static bool use_command_line_push_parser = true; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
744 #else |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
745 static bool use_command_line_push_parser = false; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
746 #endif |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
747 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
748 // The following logic is written as it is to allow easy transition |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
749 // to setting USE_COMMAND_LINE_PUSH_PARSER at run time and to |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
750 // simplify the logic of the main loop below by using the same |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
751 // base_parser::run interface for both push and pull parsers. |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
752 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
753 std::shared_ptr<base_parser> repl_parser; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
754 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
755 if (m_interpreter.interactive ()) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
756 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
757 if (use_command_line_push_parser) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
758 { |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
759 push_parser *pp |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
760 = new push_parser (m_interpreter, |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
761 new input_reader (m_interpreter)); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
762 |
29846
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
763 repl_parser = std::shared_ptr<base_parser> (pp); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
764 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
765 else |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
766 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
767 parser *pp = new parser (new lexer (m_interpreter)); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
768 repl_parser = std::shared_ptr<base_parser> (pp); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
769 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
770 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
771 else |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
772 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
773 parser *pp = new parser (new lexer (stdin, m_interpreter)); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
774 repl_parser = std::shared_ptr<base_parser> (pp); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
775 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
776 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
777 do |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
778 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
779 try |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
780 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
781 unwind_protect_var<bool> upv (m_in_top_level_repl, true); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
782 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
783 repl_parser->reset (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
784 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
785 if (at_top_level ()) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
786 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
787 dbstep_flag (0); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
788 reset_debug_state (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
789 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
790 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
791 exit_status = repl_parser->run (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
792 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
793 if (exit_status == 0) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
794 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
795 std::shared_ptr<tree_statement_list> |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
796 stmt_list = repl_parser->statement_list (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
797 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
798 if (stmt_list) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
799 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
800 command_editor::increment_current_command_number (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
801 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
802 eval (stmt_list, m_interpreter.interactive ()); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
803 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
804 else if (repl_parser->at_end_of_input ()) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
805 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
806 exit_status = EOF; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
807 break; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
808 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
809 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
810 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
811 catch (const interrupt_exception&) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
812 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
813 m_interpreter.recover_from_exception (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
814 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
815 // Required newline when the user does Ctrl+C at the prompt. |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
816 if (m_interpreter.interactive ()) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
817 octave_stdout << "\n"; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
818 } |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
819 catch (const index_exception& ie) |
29846
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
820 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
821 m_interpreter.recover_from_exception (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
822 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
823 std::cerr << "error: unhandled index exception: " |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
824 << ie.message () << " -- trying to return to prompt" |
29846
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
825 << std::endl; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
826 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
827 catch (const execution_exception& ee) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
828 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
829 error_system& es = m_interpreter.get_error_system (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
830 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
831 es.save_exception (ee); |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29493
diff
changeset
|
832 es.display_exception (ee); |
29846
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
833 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
834 if (m_interpreter.interactive ()) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
835 m_interpreter.recover_from_exception (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
836 else |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
837 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
838 // We should exit with a nonzero status. |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
839 exit_status = 1; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
840 break; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
841 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
842 } |
29847
c517a55a14ad
avoid crash with dbquit when executing command in terminal from gui (bug #60813)
John W. Eaton <jwe@octave.org>
parents:
29846
diff
changeset
|
843 catch (const quit_debug_exception&) |
c517a55a14ad
avoid crash with dbquit when executing command in terminal from gui (bug #60813)
John W. Eaton <jwe@octave.org>
parents:
29846
diff
changeset
|
844 { |
c517a55a14ad
avoid crash with dbquit when executing command in terminal from gui (bug #60813)
John W. Eaton <jwe@octave.org>
parents:
29846
diff
changeset
|
845 m_interpreter.recover_from_exception (); |
c517a55a14ad
avoid crash with dbquit when executing command in terminal from gui (bug #60813)
John W. Eaton <jwe@octave.org>
parents:
29846
diff
changeset
|
846 |
c517a55a14ad
avoid crash with dbquit when executing command in terminal from gui (bug #60813)
John W. Eaton <jwe@octave.org>
parents:
29846
diff
changeset
|
847 // FIXME: Does anything else need to happen here? |
c517a55a14ad
avoid crash with dbquit when executing command in terminal from gui (bug #60813)
John W. Eaton <jwe@octave.org>
parents:
29846
diff
changeset
|
848 } |
29846
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
849 catch (const std::bad_alloc&) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
850 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
851 m_interpreter.recover_from_exception (); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
852 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
853 std::cerr << "error: out of memory -- trying to return to prompt" |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
854 << std::endl; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
855 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
856 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
857 while (exit_status == 0); |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
858 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
859 if (exit_status == EOF) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
860 { |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
861 if (m_interpreter.interactive ()) |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
862 octave_stdout << "\n"; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
863 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
864 exit_status = 0; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
865 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
866 |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
867 return exit_status; |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
868 } |
78cb255c78a4
move top-level REPL from interpreter to evaluator
John W. Eaton <jwe@octave.org>
parents:
29832
diff
changeset
|
869 |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
870 int tree_evaluator::server_loop (void) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
871 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
872 // Process events from the event queue. |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
873 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
874 unwind_protect_var<bool> upv1 (m_server_mode, true); |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
875 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
876 m_exit_status = 0; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
877 |
29282
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
878 std::shared_ptr<push_parser> parser (new push_parser (m_interpreter)); |
0280fd549502
make debugging possible in server mode
John W. Eaton <jwe@octave.org>
parents:
29281
diff
changeset
|
879 unwind_protect_var<std::shared_ptr<push_parser>> upv2 (m_parser, parser); |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
880 |
29527
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
881 // FIXME: We are currently resetting the parser after every call to |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
882 // recover_from_exception. This action should probably be handled |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
883 // in a more consistent way, but resetting the parser in every call |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
884 // to interpreter::recover_from_exception appears to cause |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
885 // segfaults in the test suite. |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
886 |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
887 do |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
888 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
889 try |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
890 { |
29294
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
891 // FIXME: Should we call octave_quit in the octave::sleep |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
892 // and/or command_editor::run_event_hooks functions? |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
893 |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
894 octave_quit (); |
6867e1e12815
respond to interrupt signals when idle in the server loop
John W. Eaton <jwe@octave.org>
parents:
29282
diff
changeset
|
895 |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
896 // FIXME: Running the event queue should be decoupled from |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
897 // the command_editor. We should also use a condition |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
898 // variable to manage the execution of entries in the queue |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
899 // and eliminate the need for the busy-wait loop. |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
900 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
901 command_editor::run_event_hooks (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
902 |
30749
076e19eac74a
allow deletion of dynamic_library objects to be delayed
John W. Eaton <jwe@octave.org>
parents:
30652
diff
changeset
|
903 release_unreferenced_dynamic_libraries (); |
076e19eac74a
allow deletion of dynamic_library objects to be delayed
John W. Eaton <jwe@octave.org>
parents:
30652
diff
changeset
|
904 |
29950
6549fa7558ba
eliminate some unnecessary octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
905 sleep (0.1); |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
906 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
907 catch (const interrupt_exception&) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
908 { |
29420
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
909 octave_interrupt_state = 1; |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
910 m_interpreter.recover_from_exception (); |
29527
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
911 m_parser->reset (); |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
912 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
913 // Required newline when the user does Ctrl+C at the prompt. |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
914 if (m_interpreter.interactive ()) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
915 octave_stdout << "\n"; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
916 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
917 catch (const index_exception& e) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
918 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
919 m_interpreter.recover_from_exception (); |
29527
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
920 m_parser->reset (); |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
921 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
922 std::cerr << "error: unhandled index exception: " |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
923 << e.message () << " -- trying to return to prompt" |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
924 << std::endl; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
925 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
926 catch (const execution_exception& ee) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
927 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
928 error_system& es = m_interpreter.get_error_system (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
929 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
930 es.save_exception (ee); |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29493
diff
changeset
|
931 es.display_exception (ee); |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
932 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
933 if (m_interpreter.interactive ()) |
29527
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
934 { |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
935 m_interpreter.recover_from_exception (); |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
936 m_parser->reset (); |
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
937 } |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
938 else |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
939 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
940 // We should exit with a nonzero status. |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
941 m_exit_status = 1; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
942 break; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
943 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
944 } |
29420
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
945 catch (const quit_debug_exception&) |
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
946 { |
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
947 octave_interrupt_state = 1; |
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
948 m_interpreter.recover_from_exception (); |
29527
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
949 m_parser->reset (); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
950 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
951 catch (const exit_exception& xe) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
952 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
953 m_exit_status = xe.exit_status (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
954 break; |
29420
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
955 } |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
956 catch (const std::bad_alloc&) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
957 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
958 m_interpreter.recover_from_exception (); |
29527
c7569a4224bd
undo previous change; reset parser in server loop
John W. Eaton <jwe@octave.org>
parents:
29526
diff
changeset
|
959 m_parser->reset (); |
29281
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
960 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
961 std::cerr << "error: out of memory -- trying to return to prompt" |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
962 << std::endl; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
963 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
964 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
965 while (m_exit_status == 0); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
966 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
967 if (m_exit_status == EOF) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
968 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
969 if (m_interpreter.interactive ()) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
970 octave_stdout << "\n"; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
971 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
972 m_exit_status = 0; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
973 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
974 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
975 return m_exit_status; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
976 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
977 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
978 void tree_evaluator::eval (std::shared_ptr<tree_statement_list>& stmt_list, |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
979 bool interactive) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
980 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
981 try |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
982 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
983 stmt_list->accept (*this); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
984 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
985 octave_quit (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
986 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
987 if (! interactive) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
988 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
989 bool quit = (m_returning || m_breaking); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
990 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
991 if (m_returning) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
992 m_returning = 0; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
993 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
994 if (m_breaking) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
995 m_breaking--; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
996 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
997 if (quit) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
998 return; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
999 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1000 |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1001 if (octave_completion_matches_called) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1002 octave_completion_matches_called = false; |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1003 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1004 catch (const quit_debug_exception&) |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1005 { |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1006 m_interpreter.recover_from_exception (); |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1007 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1008 } |
6dd456257d81
move some eval-related functions from interpreter to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
29253
diff
changeset
|
1009 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1010 octave_value_list |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1011 tree_evaluator::eval_string (const std::string& eval_str, bool silent, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1012 int& parse_status, int nargout) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1013 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1014 octave_value_list retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1015 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
1016 parser eval_parser (eval_str, m_interpreter); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1017 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1018 do |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1019 { |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
1020 eval_parser.reset (); |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
1021 |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1022 // If we are looking at |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1023 // |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1024 // val = eval ("code"); |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1025 // |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1026 // then don't allow code to be parsed as a command. |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1027 |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1028 if (nargout > 0) |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1029 eval_parser.disallow_command_syntax (); |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1030 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
1031 parse_status = eval_parser.run (); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1032 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1033 if (parse_status == 0) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1034 { |
27504
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
1035 std::shared_ptr<tree_statement_list> stmt_list |
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
1036 = eval_parser.statement_list (); |
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
1037 |
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
1038 if (stmt_list) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1039 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1040 tree_statement *stmt = nullptr; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1041 |
27504
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
1042 if (stmt_list->length () == 1 |
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
1043 && (stmt = stmt_list->front ()) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1044 && stmt->is_expression ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1045 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1046 tree_expression *expr = stmt->expression (); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1047 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1048 if (silent) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1049 expr->set_print_flag (false); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1050 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27373
diff
changeset
|
1051 retval = expr->evaluate_n (*this, nargout); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1052 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1053 bool do_bind_ans = false; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1054 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1055 if (expr->is_identifier ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1056 do_bind_ans = ! is_variable (expr); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1057 else |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1058 do_bind_ans = ! expr->is_assignment_expression (); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1059 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1060 if (do_bind_ans && ! retval.empty ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1061 bind_ans (retval(0), expr->print_result ()); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1062 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1063 if (nargout == 0) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1064 retval = octave_value_list (); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1065 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1066 else if (nargout == 0) |
27504
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27480
diff
changeset
|
1067 stmt_list->accept (*this); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1068 else |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1069 error ("eval: invalid use of statement list"); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1070 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1071 if (returning () || breaking () || continuing ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1072 break; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1073 } |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1074 else if (eval_parser.at_end_of_input ()) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1075 break; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1076 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1077 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1078 while (parse_status == 0); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1079 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1080 return retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1081 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1082 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1083 octave_value tree_evaluator::eval_string (const std::string& eval_str, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1084 bool silent, int& parse_status) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1085 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1086 octave_value retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1087 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1088 octave_value_list tmp = eval_string (eval_str, silent, parse_status, 1); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1089 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1090 if (! tmp.empty ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1091 retval = tmp(0); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1092 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1093 return retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1094 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1095 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1096 octave_value_list tree_evaluator::eval_string (const octave_value& arg, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1097 bool silent, int& parse_status, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1098 int nargout) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1099 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1100 std::string s = arg.xstring_value ("eval: expecting string argument"); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1101 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1102 return eval_string (s, silent, parse_status, nargout); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1103 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1104 |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1105 octave_value_list tree_evaluator::eval (const std::string& try_code, |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1106 int nargout) |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1107 { |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1108 int parse_status = 0; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1109 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1110 return eval_string (try_code, nargout > 0, parse_status, nargout); |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1111 } |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1112 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1113 octave_value_list tree_evaluator::eval (const std::string& try_code, |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1114 const std::string& catch_code, |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1115 int nargout) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1116 { |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1117 octave_value_list retval; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1118 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27123
diff
changeset
|
1119 error_system& es = m_interpreter.get_error_system (); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27123
diff
changeset
|
1120 |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1121 int parse_status = 0; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1122 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1123 bool execution_error = false; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1124 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1125 octave_value_list tmp; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1126 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1127 try |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1128 { |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1129 tmp = eval_string (try_code, nargout > 0, parse_status, nargout); |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1130 } |
27471 | 1131 catch (const execution_exception& ee) |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1132 { |
27471 | 1133 es.save_exception (ee); |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27472
diff
changeset
|
1134 m_interpreter.recover_from_exception (); |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1135 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1136 execution_error = true; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1137 } |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1138 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1139 if (parse_status != 0 || execution_error) |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1140 { |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1141 tmp = eval_string (catch_code, nargout > 0, parse_status, nargout); |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1142 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1143 retval = (nargout > 0) ? tmp : octave_value_list (); |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1144 } |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1145 else |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1146 { |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1147 if (nargout > 0) |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1148 retval = tmp; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1149 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1150 // FIXME: we should really be rethrowing whatever |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1151 // exception occurred, not just throwing an |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1152 // execution exception. |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1153 if (execution_error) |
27480
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
1154 throw execution_exception (); |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1155 } |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1156 |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1157 return retval; |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1158 } |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
1159 |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1160 octave_value_list tree_evaluator::evalin (const std::string& context, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1161 const std::string& try_code, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1162 int nargout) |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1163 { |
29572
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
1164 unwind_action act ([=] (std::size_t frm) |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
1165 { |
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
1166 m_call_stack.restore_frame (frm); |
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
1167 }, m_call_stack.current_frame ()); |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1168 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1169 if (context == "caller") |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1170 m_call_stack.goto_caller_frame (); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1171 else if (context == "base") |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1172 m_call_stack.goto_base_frame (); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1173 else |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28727
diff
changeset
|
1174 error (R"(evalin: CONTEXT must be "caller" or "base")"); |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1175 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1176 int parse_status = 0; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1177 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1178 return eval_string (try_code, nargout > 0, parse_status, nargout); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1179 } |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1180 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1181 octave_value_list tree_evaluator::evalin (const std::string& context, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1182 const std::string& try_code, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1183 const std::string& catch_code, |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1184 int nargout) |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1185 { |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1186 octave_value_list retval; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1187 |
29572
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
1188 unwind_action act1 ([=] (std::size_t frm) |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
1189 { |
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
1190 m_call_stack.restore_frame (frm); |
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
1191 }, m_call_stack.current_frame ()); |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1192 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1193 if (context == "caller") |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1194 m_call_stack.goto_caller_frame (); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1195 else if (context == "base") |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1196 m_call_stack.goto_base_frame (); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1197 else |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28727
diff
changeset
|
1198 error (R"(evalin: CONTEXT must be "caller" or "base")"); |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1199 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27123
diff
changeset
|
1200 error_system& es = m_interpreter.get_error_system (); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27123
diff
changeset
|
1201 |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1202 int parse_status = 0; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1203 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1204 bool execution_error = false; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1205 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1206 octave_value_list tmp; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1207 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1208 try |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1209 { |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1210 tmp = eval_string (try_code, nargout > 0, parse_status, nargout); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1211 } |
27471 | 1212 catch (const execution_exception& ee) |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1213 { |
27471 | 1214 es.save_exception (ee); |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27472
diff
changeset
|
1215 m_interpreter.recover_from_exception (); |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1216 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1217 execution_error = true; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1218 } |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1219 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1220 if (parse_status != 0 || execution_error) |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1221 { |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1222 tmp = eval_string (catch_code, nargout > 0, parse_status, nargout); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1223 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1224 retval = (nargout > 0) ? tmp : octave_value_list (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1225 } |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1226 else |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1227 { |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1228 if (nargout > 0) |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1229 retval = tmp; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1230 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1231 // FIXME: we should really be rethrowing whatever |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1232 // exception occurred, not just throwing an |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1233 // execution exception. |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1234 if (execution_error) |
27480
63b417917f5e
remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
1235 throw execution_exception (); |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1236 } |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1237 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1238 return retval; |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1239 } |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
1240 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1241 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1242 tree_evaluator::visit_anon_fcn_handle (tree_anon_fcn_handle&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1243 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1244 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1245 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1246 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1247 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1248 tree_evaluator::visit_argument_list (tree_argument_list&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1249 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1250 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1251 } |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
1252 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1253 void |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1254 tree_evaluator::visit_arguments_block (tree_arguments_block&) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1255 { |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29724
diff
changeset
|
1256 warning ("function arguments validation blocks are not supported; INCORRECT RESULTS ARE POSSIBLE"); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1257 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1258 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1259 void |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1260 tree_evaluator::visit_args_block_attribute_list (tree_args_block_attribute_list&) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1261 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1262 panic_impossible (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1263 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1264 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1265 void |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1266 tree_evaluator::visit_args_block_validation_list (tree_args_block_validation_list&) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1267 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1268 panic_impossible (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1269 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1270 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1271 void |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1272 tree_evaluator::visit_arg_validation (tree_arg_validation&) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1273 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1274 panic_impossible (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1275 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1276 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1277 void |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1278 tree_evaluator::visit_arg_size_spec (tree_arg_size_spec&) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1279 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1280 panic_impossible (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1281 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1282 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1283 void |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1284 tree_evaluator::visit_arg_validation_fcns (tree_arg_validation_fcns&) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1285 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1286 panic_impossible (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1287 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1288 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29657
diff
changeset
|
1289 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1290 tree_evaluator::visit_binary_expression (tree_binary_expression&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1291 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1292 panic_impossible (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1293 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1294 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1295 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1296 tree_evaluator::visit_boolean_expression (tree_boolean_expression&) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1297 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1298 panic_impossible (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1299 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1300 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1301 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1302 tree_evaluator::visit_compound_binary_expression (tree_compound_binary_expression&) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1303 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1304 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1305 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1306 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1307 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1308 tree_evaluator::visit_break_command (tree_break_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1309 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1310 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1311 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
1312 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
1313 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
1314 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1315 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1316 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1317 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1318 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
1319 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1320 do_breakpoint (cmd.is_active_breakpoint (*this)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1321 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1322 if (m_in_loop_command) |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1323 m_breaking = 1; |
22785
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1324 else |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1325 error ("break must appear in a loop in the same file as loop command"); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1326 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1327 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1328 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1329 tree_evaluator::visit_colon_expression (tree_colon_expression&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1330 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1331 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1332 } |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
1333 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1334 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1335 tree_evaluator::visit_continue_command (tree_continue_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1336 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1337 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1338 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
1339 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
1340 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
1341 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1342 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1343 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1344 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1345 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
1346 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1347 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1348 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1349 if (m_in_loop_command) |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1350 m_continuing = 1; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1351 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1352 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1353 bool |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1354 tree_evaluator::statement_printing_enabled (void) |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1355 { |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
1356 return ! (m_silent_functions && (m_statement_context == SC_FUNCTION |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
1357 || m_statement_context == SC_SCRIPT)); |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1358 } |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1359 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1360 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1361 tree_evaluator::reset_debug_state (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1362 { |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
1363 m_debug_mode = (m_bp_table.have_breakpoints () |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
1364 || m_dbstep_flag != 0 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
1365 || m_break_on_next_stmt |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
1366 || in_debug_repl ()); |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1367 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1368 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1369 void |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1370 tree_evaluator::reset_debug_state (bool mode) |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1371 { |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
1372 m_debug_mode = mode; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1373 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1374 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1375 void |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1376 tree_evaluator::enter_debugger (const std::string& prompt) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1377 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27100
diff
changeset
|
1378 unwind_protect frame; |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27100
diff
changeset
|
1379 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1380 frame.add (command_history::ignore_entries, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1381 command_history::ignoring_entries ()); |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27100
diff
changeset
|
1382 |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27100
diff
changeset
|
1383 command_history::ignore_entries (false); |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27100
diff
changeset
|
1384 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1385 frame.add (&call_stack::restore_frame, &m_call_stack, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1386 m_call_stack.current_frame ()); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1387 |
27286
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1388 // Don't allow errors or warnings at the debug prompt to push us |
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1389 // into deeper levels of debugging. |
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1390 |
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1391 error_system& es = m_interpreter.get_error_system (); |
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1392 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1393 frame.add (&error_system::set_debug_on_error, &es, es.debug_on_error ()); |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1394 |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1395 frame.add (&error_system::set_debug_on_warning, &es, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
1396 es.debug_on_warning ()); |
27286
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1397 |
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1398 es.debug_on_error (false); |
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1399 es.debug_on_warning (false); |
52542cfcc7dc
always disable debug_on_error and debug_on_warning at debug prompt (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27282
diff
changeset
|
1400 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1401 // Go up to the nearest user code frame. |
27289
9dcbc0a449af
correctly set debug_frame when using "keyboard" (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27286
diff
changeset
|
1402 |
9dcbc0a449af
correctly set debug_frame when using "keyboard" (bug #56625)
John W. Eaton <jwe@octave.org>
parents:
27286
diff
changeset
|
1403 m_debug_frame = m_call_stack.dbupdown (0); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1404 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1405 // FIXME: probably we just want to print one line, not the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1406 // entire statement, which might span many lines... |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1407 // |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1408 // tree_print_code tpc (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1409 // stmt.accept (tpc); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1410 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1411 debugger *dbgr = new debugger (m_interpreter, m_debugger_stack.size ()); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1412 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1413 m_debugger_stack.push (dbgr); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1414 |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28806
diff
changeset
|
1415 frame.add ([=] (void) |
27222
f5b967060442
ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents:
27212
diff
changeset
|
1416 { |
f5b967060442
ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents:
27212
diff
changeset
|
1417 delete m_debugger_stack.top (); |
f5b967060442
ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents:
27212
diff
changeset
|
1418 m_debugger_stack.pop (); |
29305
477f7d6c61e4
reset debug state when popping debugger stack
John W. Eaton <jwe@octave.org>
parents:
29294
diff
changeset
|
1419 reset_debug_state (); |
27222
f5b967060442
ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents:
27212
diff
changeset
|
1420 }); |
f5b967060442
ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents:
27212
diff
changeset
|
1421 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1422 dbgr->repl (prompt); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1423 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1424 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1425 void |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1426 tree_evaluator::keyboard (const std::string& prompt) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1427 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1428 enter_debugger (prompt); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1429 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1430 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1431 void |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1432 tree_evaluator::dbupdown (int n, bool verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1433 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
1434 m_debug_frame = m_call_stack.dbupdown (n, verbose); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1435 } |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1436 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1437 Matrix |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1438 tree_evaluator::ignored_fcn_outputs (void) const |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1439 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1440 Matrix retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1441 |
27370
a2d3fa82b730
don't use stack to save and restore lvalue list value in evaluator (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27369
diff
changeset
|
1442 const std::list<octave_lvalue> *lvalues = m_lvalue_list; |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
1443 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
1444 if (! lvalues) |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1445 return retval; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1446 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1447 octave_idx_type nbh = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1448 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
1449 for (const auto& lval : *lvalues) |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1450 nbh += lval.is_black_hole (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1451 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1452 if (nbh > 0) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1453 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1454 retval.resize (1, nbh); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1455 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1456 octave_idx_type k = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1457 octave_idx_type l = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1458 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
1459 for (const auto& lval : *lvalues) |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1460 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1461 if (lval.is_black_hole ()) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1462 retval(l++) = k+1; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1463 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1464 k += lval.numel (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1465 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1466 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1467 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1468 return retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1469 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1470 |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1471 // If NAME is an operator (like "+", "-", ...), convert it to the |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1472 // corresponding function name ("plus", "minus", ...). |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1473 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1474 static std::string |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1475 get_operator_function_name (const std::string& name) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1476 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1477 // Bow to the god of compatibility. |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1478 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1479 // FIXME: it seems ugly to put this here, but there is no single |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1480 // function in the parser that converts from the operator name to |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1481 // the corresponding function name. At least try to do it without N |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1482 // string compares. |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1483 |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
30325
diff
changeset
|
1484 // FIXME: .+, .-, **, and .** are deprecated but still need to be |
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
30325
diff
changeset
|
1485 // handled here until they are removed. |
30325
f18f5cae2b06
deprecate/eliminate additional instances of '**', '.**', '**=', and '.*=='
John W. Eaton <jwe@octave.org>
parents:
30323
diff
changeset
|
1486 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1487 std::size_t len = name.length (); |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1488 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1489 if (len == 3 && name == ".**") |
30325
f18f5cae2b06
deprecate/eliminate additional instances of '**', '.**', '**=', and '.*=='
John W. Eaton <jwe@octave.org>
parents:
30323
diff
changeset
|
1490 // deprecated |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1491 return "power"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1492 else if (len == 2) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1493 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1494 if (name[0] == '.') |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1495 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1496 switch (name[1]) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1497 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1498 case '\'': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1499 return "transpose"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1500 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1501 case '+': |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
30325
diff
changeset
|
1502 // deprecated |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1503 return "plus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1504 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1505 case '-': |
30326
cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
John W. Eaton <jwe@octave.org>
parents:
30325
diff
changeset
|
1506 // deprecated |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1507 return "minus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1508 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1509 case '*': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1510 return "times"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1511 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1512 case '/': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1513 return "rdivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1514 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1515 case '^': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1516 return "power"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1517 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1518 case '\\': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1519 return "ldivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1520 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1521 default: |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1522 break; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1523 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1524 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1525 else if (name[1] == '=') |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1526 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1527 switch (name[0]) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1528 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1529 case '<': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1530 return "le"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1531 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1532 case '=': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1533 return "eq"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1534 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1535 case '>': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1536 return "ge"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1537 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1538 case '~': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1539 case '!': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1540 return "ne"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1541 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1542 default: |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1543 break; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1544 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1545 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1546 else if (name == "**") |
30325
f18f5cae2b06
deprecate/eliminate additional instances of '**', '.**', '**=', and '.*=='
John W. Eaton <jwe@octave.org>
parents:
30323
diff
changeset
|
1547 // deprecated |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1548 return "mpower"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1549 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1550 else if (len == 1) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1551 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1552 switch (name[0]) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1553 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1554 case '~': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1555 case '!': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1556 return "not"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1557 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1558 case '\'': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1559 return "ctranspose"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1560 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1561 case '+': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1562 return "plus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1563 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1564 case '-': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1565 return "minus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1566 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1567 case '*': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1568 return "mtimes"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1569 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1570 case '/': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1571 return "mrdivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1572 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1573 case '^': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1574 return "mpower"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1575 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1576 case '\\': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1577 return "mldivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1578 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1579 case '<': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1580 return "lt"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1581 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1582 case '>': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1583 return "gt"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1584 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1585 case '&': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1586 return "and"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1587 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1588 case '|': |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1589 return "or"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1590 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1591 default: |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1592 break; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1593 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1594 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1595 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1596 return name; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1597 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1598 |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1599 // Creates a function handle that takes into account the context, |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1600 // finding local, nested, private, or sub functions. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1601 |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1602 octave_value |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1603 tree_evaluator::make_fcn_handle (const std::string& name) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1604 { |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1605 octave_value retval; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1606 |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1607 // The str2func function can create a function handle with the name |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1608 // of an operator (for example, "+"). If so, it is converted to the |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1609 // name of the corresponding function ("+" -> "plus") and we create |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1610 // a simple function handle using that name. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1611 |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1612 std::string fcn_name = get_operator_function_name (name); |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1613 |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1614 // If FCN_NAME is different from NAME, then NAME is an operator. As |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1615 // of version 2020a, Matlab apparently uses the function name |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1616 // corresponding to the operator to search for private and local |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1617 // functions in the current scope but not(!) nested functions. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1618 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1619 bool name_is_operator = fcn_name != name; |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1620 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1621 std::size_t pos = fcn_name.find ('.'); |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1622 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1623 if (pos != std::string::npos) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1624 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1625 // Recognize (some of? which ones?) the following cases |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1626 // and create something other than a simple function handle? |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1627 // Should we just be checking for the last two when the first |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1628 // element of the dot-separated list is an object? If so, then |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1629 // should this syntax be limited to a dot-separated list with |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1630 // exactly two elements? |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1631 // |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1632 // object . method |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1633 // object . static-method |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1634 // |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1635 // Code to do that duplicates some of simple_fcn_handle::call. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1636 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1637 // Only accept expressions that contain one '.' separator. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1638 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1639 // FIXME: The logic here is a bit complicated. Is there a good |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1640 // way to simplify it? |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1641 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1642 std::string meth_nm = fcn_name.substr (pos+1); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1643 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1644 if (meth_nm.find ('.') == std::string::npos) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1645 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1646 std::string obj_nm = fcn_name.substr (0, pos); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1647 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1648 // If obj_nm is an object in the current scope with a |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1649 // method named meth_nm, create a classsimple handle. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1650 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1651 octave_value object = varval (obj_nm); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1652 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1653 if (object.is_defined () && object.is_classdef_object ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1654 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1655 octave_classdef *cdef = object.classdef_object_value (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1656 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1657 if (cdef) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1658 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1659 std::string class_nm = cdef->class_name (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1660 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1661 cdef_object cdef_obj = cdef->get_object (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1662 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1663 cdef_class cls = cdef_obj.get_class (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1664 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1665 cdef_method meth = cls.find_method (meth_nm); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1666 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1667 if (meth.ok ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1668 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1669 // If the method we found is static, create a |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1670 // new function name from the class name and |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1671 // method name and create a simple function |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1672 // handle below. Otherwise, create a class |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1673 // simple function handle. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1674 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1675 if (meth.is_static ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1676 fcn_name = class_nm + '.' + meth_nm; |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1677 else |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1678 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1679 octave_value meth_fcn = meth.get_function (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1680 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1681 octave_fcn_handle *fh |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1682 = new octave_fcn_handle (object, meth_fcn, |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1683 class_nm, meth_nm); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1684 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1685 return octave_value (fh); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1686 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1687 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1688 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1689 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1690 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1691 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1692 // We didn't match anything above, so create handle to SIMPLE |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1693 // package function or static class method. Function resolution |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1694 // is performed when the handle is used. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1695 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1696 return octave_value (new octave_fcn_handle (fcn_name)); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1697 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1698 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1699 // If the function name refers to a sub/local/private function or a |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1700 // class method/constructor, create scoped function handle that is |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1701 // bound to that function. Use the same precedence list as |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1702 // fcn_info::find but limit search to the following types of |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1703 // functions: |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1704 // |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1705 // nested functions (and subfunctions) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1706 // local functions in the current file |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1707 // private function |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1708 // class method |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1709 // |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1710 // For anything else we create a simple function handle that will be |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1711 // resolved dynamically in the scope where it is evaluated. |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1712 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1713 symbol_scope curr_scope = get_current_scope (); |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1714 |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1715 symbol_table& symtab = m_interpreter.get_symbol_table (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1716 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1717 if (curr_scope) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1718 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1719 octave_value ov_fcn |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1720 = symtab.find_scoped_function (fcn_name, curr_scope); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1721 |
29422
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1722 // If name is operator, we are in Fstr2func, so skip the stack |
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1723 // frame for that function. |
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1724 |
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1725 bool skip_first = name_is_operator; |
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1726 octave_function *curr_fcn = current_function (skip_first); |
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1727 |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1728 if (ov_fcn.is_defined ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1729 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1730 octave_function *fcn = ov_fcn.function_value (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1731 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1732 if (fcn->is_nested_function ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1733 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1734 if (! name_is_operator) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1735 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1736 // Get current stack frame and return handle to nested |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1737 // function. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1738 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1739 std::shared_ptr<stack_frame> frame |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1740 = m_call_stack.get_current_stack_frame (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1741 |
29422
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1742 // If we are creating a handle to the current |
29832
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1743 // function or a handle to a sibling function (i.e., |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1744 // not a child of the current function), then use |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1745 // the calling stack frame as the context instead of |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1746 // the current stack frame. |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1747 |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1748 // FIXME: Do we need both checks here or is it |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1749 // sufficient to check that the parent of curr_fcn |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1750 // is the same as the parent of fcn? Is there any |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1751 // case where curr_fcn could be nullptr, or does |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1752 // that indicate an internal error of some kind? |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1753 |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1754 if (curr_fcn |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1755 && (fcn_name == curr_fcn->name () |
6d1224698acf
fix scoping issue for handles to sibling nested functions (bug #60845)
John W. Eaton <jwe@octave.org>
parents:
29656
diff
changeset
|
1756 || fcn->parent_fcn_name () == curr_fcn->parent_fcn_name ())) |
29422
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1757 frame = frame->access_link (); |
8b9e3f0bd06f
fix context link when creating handle to nested function
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1758 |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1759 octave_fcn_handle *fh |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1760 = new octave_fcn_handle (ov_fcn, fcn_name, frame); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1761 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1762 return octave_value (fh); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1763 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1764 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1765 else if (fcn->is_subfunction () |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1766 /* || fcn->is_localfunction () */ |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1767 || fcn->is_private_function ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1768 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1769 // Create handle to SCOPED function (sub/local function |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1770 // or private function). |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1771 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1772 std::list<std::string> parentage = fcn->parent_fcn_names (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1773 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1774 octave_fcn_handle *fh |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1775 = new octave_fcn_handle (ov_fcn, fcn_name, parentage); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1776 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1777 return octave_value (fh); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1778 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1779 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1780 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1781 if (curr_fcn && (curr_fcn->is_class_method () |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1782 || curr_fcn->is_class_constructor ())) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1783 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1784 std::string dispatch_class = curr_fcn->dispatch_class (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1785 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1786 octave_value ov_meth |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1787 = symtab.find_method (fcn_name, dispatch_class); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1788 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1789 if (ov_meth.is_defined ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1790 { |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1791 octave_function *fcn = ov_meth.function_value (); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1792 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1793 // FIXME: do we need to check that it is a method of |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1794 // dispatch_class, or is it sufficient to just check |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1795 // that it is a method? |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1796 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1797 if (fcn->is_class_method ()) |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1798 { |
28481
1be719d8b375
fix dispatch error with classsimple function handle (bug #58572)
John W. Eaton <jwe@octave.org>
parents:
28439
diff
changeset
|
1799 // Create CLASSSIMPLE handle to method but don't |
1be719d8b375
fix dispatch error with classsimple function handle (bug #58572)
John W. Eaton <jwe@octave.org>
parents:
28439
diff
changeset
|
1800 // bind to the method. Lookup will be done later. |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1801 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1802 octave_fcn_handle *fh |
28481
1be719d8b375
fix dispatch error with classsimple function handle (bug #58572)
John W. Eaton <jwe@octave.org>
parents:
28439
diff
changeset
|
1803 = new octave_fcn_handle (dispatch_class, fcn_name); |
28439
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1804 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1805 return octave_value (fh); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1806 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1807 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1808 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1809 } |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1810 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1811 octave_value ov_fcn = symtab.find_user_function (fcn_name); |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1812 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1813 // Create handle to SIMPLE function. If the function is not found |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1814 // now, then we will look for it again when the handle is used. |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1815 |
e760fef2829c
refactor octave_fcn_handle class
John W. Eaton <jwe@octave.org>
parents:
28433
diff
changeset
|
1816 return octave_value (new octave_fcn_handle (ov_fcn, fcn_name)); |
28433
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1817 } |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1818 |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1819 /* |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1820 %!test |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1821 %! x = {".**", "power"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1822 %! ".'", "transpose"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1823 %! ".+", "plus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1824 %! ".-", "minus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1825 %! ".*", "times"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1826 %! "./", "rdivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1827 %! ".^", "power"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1828 %! ".\\", "ldivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1829 %! "<=", "le"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1830 %! "==", "eq"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1831 %! ">=", "ge"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1832 %! "!=", "ne"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1833 %! "~=", "ne"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1834 %! "**", "mpower"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1835 %! "~", "not"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1836 %! "!", "not"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1837 %! "\'", "ctranspose"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1838 %! "+", "plus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1839 %! "-", "minus"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1840 %! "*", "mtimes"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1841 %! "/", "mrdivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1842 %! "^", "mpower"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1843 %! "\\", "mldivide"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1844 %! "<", "lt"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1845 %! ">", "gt"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1846 %! "&", "and"; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1847 %! "|", "or"}; |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1848 %! for i = 1:rows (x) |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1849 %! assert (functions (str2func (x{i,1})).function, x{i,2}); |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1850 %! endfor |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1851 */ |
d05a4194f1ad
move make_fcn_handle to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
1852 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1853 octave_value |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1854 tree_evaluator::evaluate (tree_decl_elt *elt) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1855 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1856 // Do not allow functions to return null values. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1857 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1858 tree_identifier *id = elt->ident (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1859 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
1860 return id ? id->evaluate (*this).storable_value () : octave_value (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1861 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1862 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1863 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1864 tree_evaluator::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:
26512
diff
changeset
|
1865 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1866 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1867 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1868 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1869 return frame->is_variable (name); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1870 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1871 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1872 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1873 tree_evaluator::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:
26512
diff
changeset
|
1874 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1875 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1876 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1877 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1878 return frame->is_local_variable (name); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1879 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1880 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1881 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1882 tree_evaluator::is_variable (const tree_expression *expr) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1883 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1884 if (expr->is_identifier ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1885 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1886 const tree_identifier *id |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1887 = dynamic_cast<const tree_identifier *> (expr); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1888 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1889 if (id->is_black_hole ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1890 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1891 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1892 return is_variable (id->symbol ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1893 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1894 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1895 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1896 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1897 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1898 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1899 tree_evaluator::is_defined (const tree_expression *expr) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1900 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1901 if (expr->is_identifier ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1902 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1903 const tree_identifier *id |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1904 = dynamic_cast<const tree_identifier *> (expr); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1905 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1906 return is_defined (id->symbol ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1907 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1908 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1909 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1910 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1911 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1912 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1913 tree_evaluator::is_variable (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1914 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1915 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1916 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1917 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1918 return frame->is_variable (sym); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1919 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1920 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1921 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1922 tree_evaluator::is_defined (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1923 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1924 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1925 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1926 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1927 return frame->is_defined (sym); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1928 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1929 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1930 bool tree_evaluator::is_global (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1931 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1932 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1933 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1934 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1935 return frame->is_global (name); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1936 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1937 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1938 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1939 tree_evaluator::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1940 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1941 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1942 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1943 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1944 return frame->varval (sym); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1945 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1946 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1947 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1948 tree_evaluator::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:
26512
diff
changeset
|
1949 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1950 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1951 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1952 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1953 return frame->varval (name); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1954 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1955 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1956 void tree_evaluator::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:
26512
diff
changeset
|
1957 const octave_value& value, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1958 bool global) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1959 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1960 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1961 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1962 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
1963 return frame->install_variable (name, value, global); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1964 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1965 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1966 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1967 tree_evaluator::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:
26512
diff
changeset
|
1968 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1969 return m_call_stack.global_varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1970 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1971 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
1972 octave_value& |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
1973 tree_evaluator::global_varref (const std::string& name) |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
1974 { |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
1975 return m_call_stack.global_varref (name); |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
1976 } |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
1977 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1978 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1979 tree_evaluator::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:
26512
diff
changeset
|
1980 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1981 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1982 m_call_stack.global_varref (name) = val; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1983 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1984 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1985 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1986 tree_evaluator::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:
26512
diff
changeset
|
1987 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1988 return m_call_stack.get_top_level_value (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1989 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1990 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1991 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1992 tree_evaluator::top_level_assign (const std::string& name, |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1993 const octave_value& val) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1994 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1995 m_call_stack.set_top_level_value (name, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1996 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1997 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1998 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1999 tree_evaluator::assign (const std::string& name, const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2000 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2001 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2002 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2003 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2004 frame->assign (name, val); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2005 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2006 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2007 void |
27014
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2008 tree_evaluator::assignin (const std::string& context, |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2009 const std::string& name, const octave_value& val) |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2010 { |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2011 // FIXME: Can this be done without an unwind-protect frame, simply |
27971
ec769a7ab9fb
fix more spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
2012 // by getting a reference to the caller or base stack frame and |
27014
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2013 // calling assign on that? |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2014 |
29572
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
2015 unwind_action act ([=] (std::size_t frm) |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
2016 { |
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
2017 m_call_stack.restore_frame (frm); |
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
2018 }, m_call_stack.current_frame ()); |
27014
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2019 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2020 if (context == "caller") |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2021 m_call_stack.goto_caller_frame (); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2022 else if (context == "base") |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2023 m_call_stack.goto_base_frame (); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2024 else |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28727
diff
changeset
|
2025 error (R"(assignin: CONTEXT must be "caller" or "base")"); |
27014
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2026 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2027 if (valid_identifier (name)) |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2028 { |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2029 // Put the check here so that we don't slow down assignments |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2030 // generally. Any that go through Octave's parser should have |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2031 // already been checked. |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2032 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2033 if (iskeyword (name)) |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2034 error ("assignin: invalid assignment to keyword '%s'", |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2035 name.c_str ()); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2036 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2037 assign (name, val); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2038 } |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2039 else |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2040 error ("assignin: invalid variable name '%s'", name.c_str ()); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2041 } |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2042 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
2043 void |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2044 tree_evaluator::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
|
2045 const std::string& context, |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
2046 bool verbose, 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
|
2047 { |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2048 // Map from absolute name of script file to recursion level. We |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2049 // use a map instead of simply placing a limit on recursion in the |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2050 // source_file function so that two mutually recursive scripts |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2051 // written as |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2052 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2053 // foo1.m: |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2054 // ------ |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2055 // foo2 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2056 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2057 // foo2.m: |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2058 // ------ |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2059 // foo1 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2060 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2061 // and called with |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2062 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2063 // foo1 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2064 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2065 // (for example) will behave the same if they are written as |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2066 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2067 // foo1.m: |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2068 // ------ |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2069 // source ("foo2.m") |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2070 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2071 // foo2.m: |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2072 // ------ |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2073 // source ("foo1.m") |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2074 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2075 // and called with |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2076 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2077 // source ("foo1.m") |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2078 // |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2079 // (for example). |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2080 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2081 static std::map<std::string, int> source_call_depth; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2082 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2083 std::string file_full_name |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2084 = sys::file_ops::tilde_expand (file_name); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2085 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2086 std::size_t pos |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2087 = file_full_name.find_last_of (sys::file_ops::dir_sep_str ()); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2088 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2089 std::string dir_name = file_full_name.substr (0, pos); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2090 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2091 file_full_name = sys::env::make_absolute (file_full_name); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2092 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2093 unwind_protect frame; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2094 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2095 if (source_call_depth.find (file_full_name) == source_call_depth.end ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2096 source_call_depth[file_full_name] = -1; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2097 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2098 frame.protect_var (source_call_depth[file_full_name]); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2099 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2100 source_call_depth[file_full_name]++; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2101 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2102 if (source_call_depth[file_full_name] >= max_recursion_depth ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2103 error ("max_recursion_depth exceeded"); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2104 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2105 if (! context.empty ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2106 { |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
2107 frame.add (&call_stack::restore_frame, &m_call_stack, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
2108 m_call_stack.current_frame ()); |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2109 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2110 if (context == "caller") |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2111 m_call_stack.goto_caller_frame (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2112 else if (context == "base") |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2113 m_call_stack.goto_base_frame (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2114 else |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28727
diff
changeset
|
2115 error (R"(source: CONTEXT must be "caller" or "base")"); |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2116 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2117 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2118 // Find symbol name that would be in symbol_table, if it were loaded. |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2119 std::size_t dir_end |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2120 = file_name.find_last_of (sys::file_ops::dir_sep_chars ()); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2121 dir_end = (dir_end == std::string::npos) ? 0 : dir_end + 1; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2122 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2123 std::size_t extension = file_name.find_last_of ('.'); |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2124 if (extension == std::string::npos) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2125 extension = file_name.length (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2126 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2127 std::string symbol = file_name.substr (dir_end, extension - dir_end); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2128 std::string full_name = sys::canonicalize_file_name (file_name); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2129 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2130 // Check if this file is already loaded (or in the path) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2131 symbol_table& symtab = m_interpreter.get_symbol_table (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2132 octave_value ov_code = symtab.fcn_table_find (symbol); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2133 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2134 // For compatibility with Matlab, accept both scripts and |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2135 // functions. |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2136 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2137 if (ov_code.is_user_code ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2138 { |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2139 octave_user_code *code = ov_code.user_code_value (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2140 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2141 if (! code |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2142 || (sys::canonicalize_file_name (code->fcn_file_name ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2143 != full_name)) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2144 { |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2145 // Wrong file, so load it below. |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2146 ov_code = octave_value (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2147 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2148 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2149 else |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2150 { |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2151 // Not a script, so load it below. |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2152 ov_code = octave_value (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2153 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2154 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2155 // If no symbol of this name, or the symbol is for a different |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2156 // file, load. |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2157 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2158 if (ov_code.is_undefined ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2159 { |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2160 try |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2161 { |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
2162 ov_code = parse_fcn_file (m_interpreter, file_full_name, |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
2163 file_name, dir_name, "", "", |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
2164 require_file, true, false, false); |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2165 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
2166 catch (execution_exception& ee) |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2167 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
2168 error (ee, "source: error sourcing file '%s'", |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2169 file_full_name.c_str ()); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2170 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2171 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2172 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2173 // Return or error if we don't have a valid script or function. |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2174 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2175 if (ov_code.is_undefined ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2176 return; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2177 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2178 if (! ov_code.is_user_code ()) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2179 error ("source: %s is not a script", full_name.c_str ()); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2180 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2181 if (verbose) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2182 { |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2183 octave_stdout << "executing commands from " << full_name << " ... "; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2184 octave_stdout.flush (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2185 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2186 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2187 octave_user_code *code = ov_code.user_code_value (); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2188 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2189 code->call (*this, 0, octave_value_list ()); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2190 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2191 if (verbose) |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2192 octave_stdout << "done." << std::endl; |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2193 } |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2194 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
2195 void |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2196 tree_evaluator::set_auto_fcn_var (stack_frame::auto_var_type avt, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2197 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2198 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2199 m_call_stack.set_auto_fcn_var (avt, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2200 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2201 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2202 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2203 tree_evaluator::get_auto_fcn_var (stack_frame::auto_var_type avt) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2204 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2205 return m_call_stack.get_auto_fcn_var (avt); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2206 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2207 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2208 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2209 tree_evaluator::define_parameter_list_from_arg_vector |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2210 (tree_parameter_list *param_list, const octave_value_list& args) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2211 { |
30285
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
2212 if (! param_list || param_list->varargs_only ()) |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
2213 return; |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
2214 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2215 int i = -1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2216 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
2217 for (tree_decl_elt *elt : *param_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2218 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2219 i++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2220 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2221 octave_lvalue ref = elt->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2222 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2223 if (i < args.length ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2224 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2225 if (args(i).is_defined () && args(i).is_magic_colon ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2226 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2227 if (! eval_decl_elt (elt)) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2228 error ("no default value for argument %d", i+1); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2229 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2230 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2231 ref.define (args(i)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2232 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2233 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2234 eval_decl_elt (elt); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2235 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2236 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2237 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2238 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2239 tree_evaluator::undefine_parameter_list (tree_parameter_list *param_list) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2240 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
2241 for (tree_decl_elt *elt : *param_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2242 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2243 octave_lvalue ref = elt->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2244 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2245 ref.assign (octave_value::op_asn_eq, octave_value ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2246 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2247 } |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2248 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2249 // END is documented in op-kw-docs. |
29968
7aa4d8c049e5
eliminate obsolete DEFCONSTFUN and DEFCONSTMETHOD macros
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
2250 DEFMETHOD (end, interp, args, , |
7aa4d8c049e5
eliminate obsolete DEFCONSTFUN and DEFCONSTMETHOD macros
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
2251 doc: /* -*- texinfo -*- |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2252 @deftypefn {} {} end |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2253 Last element of an array or the end of any @code{for}, @code{parfor}, |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2254 @code{if}, @code{do}, @code{while}, @code{function}, @code{switch}, |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2255 @code{try}, or @code{unwind_protect} block. |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2256 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2257 As an index of an array, the magic index @qcode{"end"} refers to the |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2258 last valid entry in an indexing operation. |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2259 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2260 Example: |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2261 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2262 @example |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2263 @group |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2264 @var{x} = [ 1 2 3; 4 5 6 ]; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2265 @var{x}(1,end) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2266 @result{} 3 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2267 @var{x}(end,1) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2268 @result{} 4 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2269 @var{x}(end,end) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2270 @result{} 6 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2271 @end group |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2272 @end example |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2273 @seealso{for, parfor, if, do, while, function, switch, try, unwind_protect} |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2274 @end deftypefn */) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2275 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2276 tree_evaluator& tw = interp.get_evaluator (); |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2277 |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2278 return tw.evaluate_end_expression (args); |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2279 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2280 |
27100
b453b586da16
improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2281 /* |
28617
0bac488f17fa
throw error if 'end' is applied to undefined symbol (bug #58830)
John W. Eaton <jwe@octave.org>
parents:
28560
diff
changeset
|
2282 %!test <*58830> |
0bac488f17fa
throw error if 'end' is applied to undefined symbol (bug #58830)
John W. Eaton <jwe@octave.org>
parents:
28560
diff
changeset
|
2283 %! fail ("__undef_sym__ (end)", |
0bac488f17fa
throw error if 'end' is applied to undefined symbol (bug #58830)
John W. Eaton <jwe@octave.org>
parents:
28560
diff
changeset
|
2284 %! "invalid use of 'end': may only be used to index existing value"); |
28696
2a47fa406ed8
allow 'end' indexing to work for nested function calls (bug #58953)
John W. Eaton <jwe@octave.org>
parents:
28617
diff
changeset
|
2285 |
30322 | 2286 %!test <*58953> |
28696
2a47fa406ed8
allow 'end' indexing to work for nested function calls (bug #58953)
John W. Eaton <jwe@octave.org>
parents:
28617
diff
changeset
|
2287 %! x = 1:10; |
2a47fa406ed8
allow 'end' indexing to work for nested function calls (bug #58953)
John W. Eaton <jwe@octave.org>
parents:
28617
diff
changeset
|
2288 %! assert (x(end), 10); |
2a47fa406ed8
allow 'end' indexing to work for nested function calls (bug #58953)
John W. Eaton <jwe@octave.org>
parents:
28617
diff
changeset
|
2289 %! assert (x(minus (end, 1)), 9); |
2a47fa406ed8
allow 'end' indexing to work for nested function calls (bug #58953)
John W. Eaton <jwe@octave.org>
parents:
28617
diff
changeset
|
2290 %! assert (x(minus (minus (end, 1), 1)), 8); |
27100
b453b586da16
improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2291 */ |
b453b586da16
improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2292 |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2293 octave_value_list |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2294 tree_evaluator::convert_to_const_vector (tree_argument_list *args) |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2295 { |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2296 std::list<octave_value> arg_vals; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2297 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2298 for (auto elt : *args) |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2299 { |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2300 // FIXME: is it possible for elt to be invalid? |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2301 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2302 if (! elt) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2303 break; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2304 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2305 octave_value tmp = elt->evaluate (*this); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2306 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2307 if (tmp.is_cs_list ()) |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2308 { |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2309 octave_value_list tmp_ovl = tmp.list_value (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2310 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2311 for (octave_idx_type i = 0; i < tmp_ovl.length (); i++) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2312 arg_vals.push_back (tmp_ovl(i)); |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2313 } |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2314 else if (tmp.is_defined ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2315 arg_vals.push_back (tmp); |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2316 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2317 |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
2318 return octave_value_list (arg_vals); |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2319 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2320 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2321 octave_value_list |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2322 tree_evaluator::convert_return_list_to_const_vector |
28540
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2323 (tree_parameter_list *ret_list, int nargout, const Matrix& ignored_outputs, |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2324 const Cell& varargout) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2325 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2326 octave_idx_type vlen = varargout.numel (); |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2327 int len = ret_list->length (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2328 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2329 // Special case. Will do a shallow copy. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2330 if (len == 0) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2331 return varargout; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2332 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2333 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2334 int i = 0; |
28540
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2335 int k = 0; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2336 int num_ignored = ignored_outputs.numel (); |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2337 int ignored = num_ignored > 0 ? ignored_outputs(k) - 1 : -1; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2338 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2339 if (nargout <= len) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2340 { |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2341 int nout = nargout > 0 ? nargout : 1; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2342 octave_value_list retval (nout); |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2343 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2344 for (tree_decl_elt *elt : *ret_list) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2345 { |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2346 if (nargout == 0 && ! is_defined (elt->ident ())) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2347 break; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2348 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2349 if (ignored >= 0 && i == ignored) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2350 { |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2351 i++; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2352 k++; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2353 ignored = k < num_ignored ? ignored_outputs(k) - 1 : -1; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2354 } |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2355 else |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2356 retval(i++) = evaluate (elt); |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2357 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2358 if (i == nout) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2359 break; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2360 } |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2361 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2362 return retval; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2363 } |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2364 else |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2365 { |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2366 octave_value_list retval (len + vlen); |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2367 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2368 for (tree_decl_elt *elt : *ret_list) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2369 { |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2370 if (ignored >= 0 && i == ignored) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2371 { |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2372 i++; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2373 k++; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2374 ignored = k < num_ignored ? ignored_outputs(k) - 1 : -1; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2375 } |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2376 else |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2377 retval(i++) = evaluate (elt); |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2378 } |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2379 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2380 for (octave_idx_type j = 0; j < vlen; j++) |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2381 retval(i++) = varargout(j); |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2382 |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2383 return retval; |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
2384 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2385 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2386 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2387 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2388 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2389 tree_evaluator::eval_decl_elt (tree_decl_elt *elt) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2390 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2391 bool retval = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2392 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2393 tree_identifier *id = elt->ident (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2394 tree_expression *expr = elt->expression (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2395 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2396 if (id && expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2397 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2398 octave_lvalue ult = id->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2399 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27373
diff
changeset
|
2400 octave_value init_val = expr->evaluate (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2401 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2402 ult.assign (octave_value::op_asn_eq, init_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2403 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2404 retval = true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2405 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2406 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2407 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2408 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2409 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2410 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2411 tree_evaluator::switch_case_label_matches (tree_switch_case *expr, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2412 const octave_value& val) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2413 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2414 tree_expression *label = expr->case_label (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2415 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27373
diff
changeset
|
2416 octave_value label_value = label->evaluate (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2417 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2418 if (label_value.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2419 { |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23563
diff
changeset
|
2420 if (label_value.iscell ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2421 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2422 Cell cell (label_value.cell_value ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2423 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2424 for (octave_idx_type i = 0; i < cell.rows (); i++) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2425 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2426 for (octave_idx_type j = 0; j < cell.columns (); j++) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2427 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2428 bool match = val.is_equal (cell(i,j)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2429 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2430 if (match) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2431 return true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2432 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2433 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2434 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2435 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2436 return val.is_equal (label_value); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2437 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2438 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2439 return false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2440 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2441 |
27210
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2442 void tree_evaluator::push_stack_frame (const symbol_scope& scope) |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2443 { |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2444 m_call_stack.push (scope); |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2445 } |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2446 |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2447 void tree_evaluator::push_stack_frame (octave_user_function *fcn, |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2448 const std::shared_ptr<stack_frame>& closure_frames) |
27210
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2449 { |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
2450 m_call_stack.push (fcn, closure_frames); |
27210
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2451 } |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2452 |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
2453 void tree_evaluator::push_stack_frame (octave_user_function *fcn, |
29477
34d06c73b48d
hold references to closure frames in anon functions if needed (bug #60237)
John W. Eaton <jwe@octave.org>
parents:
29475
diff
changeset
|
2454 const stack_frame::local_vars_map& local_vars, |
34d06c73b48d
hold references to closure frames in anon functions if needed (bug #60237)
John W. Eaton <jwe@octave.org>
parents:
29475
diff
changeset
|
2455 const std::shared_ptr<stack_frame>& closure_frames) |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
2456 { |
29477
34d06c73b48d
hold references to closure frames in anon functions if needed (bug #60237)
John W. Eaton <jwe@octave.org>
parents:
29475
diff
changeset
|
2457 m_call_stack.push (fcn, local_vars, closure_frames); |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
2458 } |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
2459 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
2460 void tree_evaluator::push_stack_frame (octave_user_script *script) |
27210
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2461 { |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
2462 m_call_stack.push (script); |
27210
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2463 } |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2464 |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2465 void tree_evaluator::push_stack_frame (octave_function *fcn) |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2466 { |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2467 m_call_stack.push (fcn); |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2468 } |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2469 |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2470 void tree_evaluator::pop_stack_frame (void) |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2471 { |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2472 m_call_stack.pop (); |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2473 } |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2474 |
27200
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2475 int tree_evaluator::current_line (void) const |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2476 { |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2477 return m_call_stack.current_line (); |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2478 } |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2479 |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2480 int tree_evaluator::current_column (void) const |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2481 { |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2482 return m_call_stack.current_column (); |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2483 } |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2484 |
27205
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2485 int tree_evaluator::debug_user_code_line (void) const |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2486 { |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2487 return m_call_stack.debug_user_code_line (); |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2488 } |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2489 |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2490 int tree_evaluator::debug_user_code_column (void) const |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2491 { |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2492 return m_call_stack.debug_user_code_column (); |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2493 } |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2494 |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2495 void tree_evaluator::debug_where (std::ostream& os) const |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2496 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2497 std::shared_ptr<stack_frame> frm = m_call_stack.current_user_frame (); |
27205
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2498 |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2499 frm->display_stopped_in_message (os); |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2500 } |
6648d1ae05fe
eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents:
27204
diff
changeset
|
2501 |
27200
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2502 octave_user_code * tree_evaluator::current_user_code (void) const |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2503 { |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2504 return m_call_stack.current_user_code (); |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2505 } |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2506 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
2507 unwind_protect * tree_evaluator::curr_fcn_unwind_protect_frame (void) |
27204
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2508 { |
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2509 return m_call_stack.curr_fcn_unwind_protect_frame (); |
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2510 } |
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2511 |
27202
23962b243bad
eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents:
27201
diff
changeset
|
2512 octave_user_code * tree_evaluator::debug_user_code (void) const |
23962b243bad
eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents:
27201
diff
changeset
|
2513 { |
23962b243bad
eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents:
27201
diff
changeset
|
2514 return m_call_stack.debug_user_code (); |
23962b243bad
eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents:
27201
diff
changeset
|
2515 } |
23962b243bad
eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents:
27201
diff
changeset
|
2516 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2517 octave_function * tree_evaluator::current_function (bool skip_first) const |
27201
bd49997051ef
eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents:
27200
diff
changeset
|
2518 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2519 return m_call_stack.current_function (skip_first); |
27201
bd49997051ef
eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents:
27200
diff
changeset
|
2520 } |
bd49997051ef
eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents:
27200
diff
changeset
|
2521 |
27204
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2522 octave_function * tree_evaluator::caller_function (void) const |
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2523 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2524 return m_call_stack.current_function (true); |
27204
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2525 } |
9a3e92d02a03
eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents:
27203
diff
changeset
|
2526 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2527 bool tree_evaluator::goto_frame (std::size_t n, bool verbose) |
27200
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2528 { |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2529 return m_call_stack.goto_frame (n, verbose); |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2530 } |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2531 |
27206
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2532 void tree_evaluator::goto_caller_frame (void) |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2533 { |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2534 m_call_stack.goto_caller_frame (); |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2535 } |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2536 |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2537 void tree_evaluator::goto_base_frame (void) |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2538 { |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2539 m_call_stack.goto_base_frame (); |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2540 } |
4e4a9d7b436e
eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents:
27205
diff
changeset
|
2541 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2542 void tree_evaluator::restore_frame (std::size_t n) |
27200
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2543 { |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2544 return m_call_stack.restore_frame (n); |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2545 } |
dc1edf932248
eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
2546 |
27208
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2547 std::string tree_evaluator::get_dispatch_class (void) const |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2548 { |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2549 return m_call_stack.get_dispatch_class (); |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2550 } |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2551 |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2552 void tree_evaluator::set_dispatch_class (const std::string& class_name) |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2553 { |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2554 m_call_stack.set_dispatch_class (class_name); |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2555 } |
5b40cf4896f0
eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents:
27206
diff
changeset
|
2556 |
27210
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2557 bool |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2558 tree_evaluator::is_class_method_executing (std::string& dclass) const |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2559 { |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2560 return m_call_stack.is_class_method_executing (dclass); |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2561 } |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2562 |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2563 bool |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2564 tree_evaluator::is_class_constructor_executing (std::string& dclass) const |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2565 { |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2566 return m_call_stack.is_class_constructor_executing (dclass); |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2567 } |
bd684aad1821
eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents:
27208
diff
changeset
|
2568 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2569 std::list<std::shared_ptr<stack_frame>> |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2570 tree_evaluator::backtrace_frames (octave_idx_type& curr_user_frame) const |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2571 { |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2572 return m_call_stack.backtrace_frames (curr_user_frame); |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2573 } |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2574 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2575 std::list<std::shared_ptr<stack_frame>> |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2576 tree_evaluator::backtrace_frames (void) const |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2577 { |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2578 return m_call_stack.backtrace_frames (); |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2579 } |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2580 |
27471 | 2581 std::list<frame_info> |
2582 tree_evaluator::backtrace_info (octave_idx_type& curr_user_frame, | |
2583 bool print_subfn) const | |
2584 { | |
2585 return m_call_stack.backtrace_info (curr_user_frame, print_subfn); | |
2586 } | |
2587 | |
2588 std::list<frame_info> tree_evaluator::backtrace_info (void) const | |
2589 { | |
2590 return m_call_stack.backtrace_info (); | |
2591 } | |
2592 | |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2593 octave_map |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2594 tree_evaluator::backtrace (octave_idx_type& curr_user_frame, |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2595 bool print_subfn) const |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2596 { |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2597 return m_call_stack.backtrace (curr_user_frame, print_subfn); |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2598 } |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2599 |
27471 | 2600 octave_map tree_evaluator::backtrace (void) const |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2601 { |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2602 return m_call_stack.backtrace (); |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2603 } |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2604 |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2605 octave_map tree_evaluator::empty_backtrace (void) const |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2606 { |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2607 return m_call_stack.empty_backtrace (); |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2608 } |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2609 |
27471 | 2610 std::string tree_evaluator::backtrace_message (void) const |
2611 { | |
2612 std::list<frame_info> frames = backtrace_info (); | |
2613 | |
2614 std::ostringstream buf; | |
2615 | |
2616 for (const auto& frm : frames) | |
2617 { | |
2618 buf << " " << frm.fcn_name (); | |
2619 | |
2620 int line = frm.line (); | |
2621 | |
2622 if (line > 0) | |
2623 { | |
2624 buf << " at line " << line; | |
2625 | |
2626 int column = frm.column (); | |
2627 | |
2628 if (column > 0) | |
2629 buf << " column " << column; | |
2630 | |
2631 buf << "\n"; | |
2632 } | |
2633 } | |
2634 | |
2635 return buf.str (); | |
2636 } | |
2637 | |
27001
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2638 void tree_evaluator::push_dummy_scope (const std::string& name) |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2639 { |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2640 symbol_scope dummy_scope (name + "$dummy"); |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2641 |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2642 m_call_stack.push (dummy_scope); |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2643 } |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2644 |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2645 void tree_evaluator::pop_scope (void) |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2646 { |
27001
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2647 m_call_stack.pop (); |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2648 } |
3cea1cfb37d3
move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents:
26975
diff
changeset
|
2649 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2650 symbol_scope tree_evaluator::get_top_scope (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2651 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2652 return m_call_stack.top_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2653 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2654 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2655 symbol_scope tree_evaluator::get_current_scope (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2656 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2657 return m_call_stack.current_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2658 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2659 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2660 void tree_evaluator::mlock (bool skip_first) const |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2661 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2662 octave_function *fcn = m_call_stack.current_function (skip_first); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2663 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2664 if (! fcn) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2665 error ("mlock: invalid use outside a function"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2666 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2667 if (fcn->is_builtin_function ()) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2668 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2669 warning ("mlock: locking built-in function has no effect"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2670 return; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2671 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2672 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2673 fcn->lock (); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2674 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2675 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2676 void tree_evaluator::munlock (bool skip_first) const |
27212
f84c5528e932
eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents:
27211
diff
changeset
|
2677 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2678 octave_function *fcn = m_call_stack.current_function (skip_first); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2679 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2680 if (! fcn) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2681 error ("munlock: invalid use outside a function"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2682 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2683 if (fcn->is_builtin_function ()) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2684 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2685 warning ("munlock: unlocking built-in function has no effect"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2686 return; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2687 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2688 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2689 fcn->unlock (); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2690 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2691 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2692 bool tree_evaluator::mislocked (bool skip_first) const |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2693 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2694 octave_function *fcn = m_call_stack.current_function (skip_first); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2695 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2696 if (! fcn) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2697 error ("mislocked: invalid use outside a function"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2698 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2699 return fcn->islocked (); |
27212
f84c5528e932
eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents:
27211
diff
changeset
|
2700 } |
f84c5528e932
eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents:
27211
diff
changeset
|
2701 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2702 octave_value |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2703 tree_evaluator::max_stack_depth (const octave_value_list& args, int nargout) |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2704 { |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2705 return m_call_stack.max_stack_depth (args, nargout); |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2706 } |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2707 |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2708 void tree_evaluator::display_call_stack (void) const |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2709 { |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2710 m_call_stack.display (); |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2711 } |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27210
diff
changeset
|
2712 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2713 octave_value tree_evaluator::find (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2714 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2715 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2716 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2717 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2718 octave_value val = frame->varval (name); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2719 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2720 if (val.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2721 return val; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2722 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2723 // Subfunction. I think it only makes sense to check for |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2724 // subfunctions if we are currently executing a function defined |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2725 // from a .m file. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2726 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2727 octave_value fcn = frame->find_subfunction (name); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2728 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2729 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2730 return fcn; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2731 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2732 symbol_table& symtab = m_interpreter.get_symbol_table (); |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2733 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2734 return symtab.fcn_table_find (name, ovl ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2735 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2736 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2737 void tree_evaluator::clear_objects (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2738 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2739 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2740 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2741 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2742 frame->clear_objects (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2743 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2744 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2745 void tree_evaluator::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:
26512
diff
changeset
|
2746 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2747 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2748 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2749 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2750 frame->clear_variable (name); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2751 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2752 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2753 void tree_evaluator::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:
26512
diff
changeset
|
2754 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2755 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2756 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2757 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2758 frame->clear_variable_pattern (pattern); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2759 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2760 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2761 void tree_evaluator::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:
26512
diff
changeset
|
2762 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2763 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2764 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2765 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2766 frame->clear_variable_regexp (pattern); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2767 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2768 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2769 void tree_evaluator::clear_variables (void) |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2770 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2771 std::shared_ptr<stack_frame> frame |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2772 = m_call_stack.get_current_stack_frame (); |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2773 |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28256
diff
changeset
|
2774 frame->clear_variables (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2775 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2776 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2777 void tree_evaluator::clear_global_variable (const std::string& name) |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2778 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2779 m_call_stack.clear_global_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2780 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2781 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2782 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2783 tree_evaluator::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:
26512
diff
changeset
|
2784 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2785 m_call_stack.clear_global_variable_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2786 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2787 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2788 void tree_evaluator::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:
26512
diff
changeset
|
2789 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2790 m_call_stack.clear_global_variable_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2791 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2792 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2793 void tree_evaluator::clear_global_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2794 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2795 m_call_stack.clear_global_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2796 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2797 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2798 void tree_evaluator::clear_all (bool force) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2799 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2800 // FIXME: should this also clear objects? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2801 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2802 clear_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2803 clear_global_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2804 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2805 symbol_table& symtab = m_interpreter.get_symbol_table (); |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2806 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2807 symtab.clear_functions (force); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2808 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2809 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2810 void tree_evaluator::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:
26512
diff
changeset
|
2811 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2812 // FIXME: are we supposed to do both here? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2813 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2814 clear_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2815 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2816 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2817 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2818 symtab.clear_function (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2819 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2820 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2821 void tree_evaluator::clear_symbol_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2822 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2823 // FIXME: are we supposed to do both here? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2824 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2825 clear_variable_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2826 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2827 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2828 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2829 symtab.clear_function_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2830 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2831 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2832 void tree_evaluator::clear_symbol_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2833 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2834 // FIXME: are we supposed to do both here? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2835 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2836 clear_variable_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2837 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2838 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2839 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2840 symtab.clear_function_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2841 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2842 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2843 std::list<std::string> tree_evaluator::global_variable_names (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2844 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2845 return m_call_stack.global_variable_names (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2846 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2847 |
27594
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27540
diff
changeset
|
2848 std::list<std::string> tree_evaluator::top_level_variable_names (void) const |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27540
diff
changeset
|
2849 { |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27540
diff
changeset
|
2850 return m_call_stack.top_level_variable_names (); |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27540
diff
changeset
|
2851 } |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27540
diff
changeset
|
2852 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2853 std::list<std::string> tree_evaluator::variable_names (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2854 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2855 return m_call_stack.variable_names (); |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2856 } |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2857 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2858 // Return a pointer to the user-defined function FNAME. If FNAME is empty, |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2859 // search backward for the first user-defined function in the |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2860 // current call stack. |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2861 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2862 octave_user_code * |
26975
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2863 tree_evaluator::get_user_code (const std::string& fname, |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2864 const std::string& class_name) |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2865 { |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2866 octave_user_code *user_code = nullptr; |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2867 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2868 if (fname.empty ()) |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2869 user_code = m_call_stack.debug_user_code (); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2870 else |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2871 { |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2872 std::string name = fname; |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2873 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2874 if (sys::file_ops::dir_sep_char () != '/' && name[0] == '@') |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2875 { |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2876 auto beg = name.begin () + 2; // never have @/method |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2877 auto end = name.end () - 1; // never have trailing '/' |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2878 std::replace (beg, end, '/', sys::file_ops::dir_sep_char ()); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2879 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2880 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2881 std::size_t name_len = name.length (); |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2882 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2883 if (name_len > 2 && name.substr (name_len-2) == ".m") |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2884 name = name.substr (0, name_len-2); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2885 |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2886 if (name.empty ()) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2887 return nullptr; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2888 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2889 symbol_table& symtab = m_interpreter.get_symbol_table (); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2890 |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2891 octave_value fcn; |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2892 std::size_t p2 = std::string::npos; |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2893 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2894 if (name[0] == '@') |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2895 { |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
2896 std::size_t p1 = name.find (sys::file_ops::dir_sep_char (), 1); |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2897 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2898 if (p1 == std::string::npos) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2899 return nullptr; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2900 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2901 std::string dispatch_type = name.substr (1, p1-1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2902 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2903 p2 = name.find ('>', p1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2904 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2905 std::string method = name.substr (p1+1, p2-1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2906 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2907 fcn = symtab.find_method (method, dispatch_type); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2908 } |
26975
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2909 else if (! class_name.empty ()) |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2910 { |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2911 cdef_manager& cdm = m_interpreter.get_cdef_manager (); |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2912 |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2913 fcn = cdm.find_method (class_name, name); |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2914 |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2915 // If there is no classdef method, then try legacy classes. |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2916 if (fcn.is_undefined ()) |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2917 fcn = symtab.find_method (name, class_name); |
de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents:
26924
diff
changeset
|
2918 } |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2919 else |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2920 { |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2921 p2 = name.find ('>'); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2922 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2923 std::string main_fcn = name.substr (0, p2); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2924 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2925 fcn = symtab.find_function (main_fcn); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2926 } |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2927 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2928 // List of function names sub1>sub2>... |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2929 std::string subfuns; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2930 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2931 if (p2 != std::string::npos) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2932 subfuns = name.substr (p2+1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2933 |
26179
a0b63c183d4b
Do not attempt to extract user code from oct-files (bug #55184).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26164
diff
changeset
|
2934 if (fcn.is_defined () && fcn.is_user_code ()) |
a0b63c183d4b
Do not attempt to extract user code from oct-files (bug #55184).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26164
diff
changeset
|
2935 user_code = fcn.user_code_value (); |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2936 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2937 if (! user_code || subfuns.empty ()) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2938 return user_code; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2939 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2940 fcn = user_code->find_subfunction (subfuns); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2941 |
27178
e3b2d4e442c4
improve message for setting breakpoint in nonexistent function (bug #56157)
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2942 if (fcn.is_undefined ()) |
e3b2d4e442c4
improve message for setting breakpoint in nonexistent function (bug #56157)
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2943 return nullptr; |
e3b2d4e442c4
improve message for setting breakpoint in nonexistent function (bug #56157)
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2944 |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
2945 user_code = fcn.user_code_value (); |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2946 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2947 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2948 return user_code; |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2949 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2950 |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2951 std::string |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2952 tree_evaluator::current_function_name (bool skip_first) const |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2953 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
2954 octave_function *curfcn = m_call_stack.current_function (skip_first); |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2955 |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2956 if (curfcn) |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2957 return curfcn->name (); |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2958 |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2959 return ""; |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2960 } |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2961 |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2962 bool |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2963 tree_evaluator::in_user_code (void) const |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2964 { |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2965 return m_call_stack.current_user_code () != nullptr; |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2966 } |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27179
diff
changeset
|
2967 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2968 void |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2969 tree_evaluator::visit_decl_command (tree_decl_command& cmd) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2970 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2971 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2972 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
2973 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
2974 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
2975 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2976 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2977 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2978 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2979 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
2980 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
2981 do_breakpoint (cmd.is_active_breakpoint (*this)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2982 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
2983 // FIXME: tree_decl_init_list is not derived from tree, so should it |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
2984 // really have an accept method? |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
2985 |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2986 tree_decl_init_list *init_list = cmd.initializer_list (); |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2987 |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2988 if (init_list) |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2989 init_list->accept (*this); |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2990 } |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2991 |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2992 void |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2993 tree_evaluator::visit_decl_elt (tree_decl_elt& elt) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2994 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2995 tree_identifier *id = elt.ident (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2996 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2997 if (id) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2998 { |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
2999 if (elt.is_global ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3000 m_call_stack.make_global (id->symbol ()); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
3001 else if (elt.is_persistent ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3002 m_call_stack.make_persistent (id->symbol ()); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
3003 else |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
3004 error ("declaration list element not global or persistent"); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3005 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
3006 octave_lvalue ult = id->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3007 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3008 if (ult.is_undefined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3009 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3010 tree_expression *expr = elt.expression (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3011 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3012 octave_value init_val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3013 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3014 if (expr) |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27373
diff
changeset
|
3015 init_val = expr->evaluate (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3016 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3017 init_val = Matrix (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3018 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3019 ult.assign (octave_value::op_asn_eq, init_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3020 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3021 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3022 } |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24690
diff
changeset
|
3023 |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3024 template <typename T> |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3025 void |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3026 tree_evaluator::execute_range_loop (const range<T>& rng, int line, |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3027 octave_lvalue& ult, |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3028 tree_statement_list *loop_body) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3029 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3030 octave_idx_type steps = rng.numel (); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3031 |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
3032 if (math::isinf (rng.limit ())) |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3033 warning_with_id ("Octave:infinite-loop", |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3034 "FOR loop limit is infinite, will stop after %" |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3035 OCTAVE_IDX_TYPE_FORMAT " steps", steps); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3036 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3037 for (octave_idx_type i = 0; i < steps; i++) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3038 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3039 if (m_echo_state) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3040 m_echo_file_pos = line; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3041 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3042 octave_value val (rng.elem (i)); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3043 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3044 ult.assign (octave_value::op_asn_eq, val); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3045 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3046 if (loop_body) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3047 loop_body->accept (*this); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3048 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3049 if (quit_loop_now ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3050 break; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3051 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3052 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3053 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3054 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3055 tree_evaluator::visit_simple_for_command (tree_simple_for_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3056 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3057 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3058 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3059 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3060 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3061 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3062 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3063 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3064 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3065 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3066 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3067 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3068 do_breakpoint (cmd.is_active_breakpoint (*this)); |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13226
diff
changeset
|
3069 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3070 // FIXME: need to handle PARFOR loops here using cmd.in_parallel () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3071 // and cmd.maxproc_expr (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3072 |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
3073 unwind_protect_var<bool> upv (m_in_loop_command, true); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3074 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3075 tree_expression *expr = cmd.control_expr (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3076 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3077 octave_value rhs = expr->evaluate (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3078 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3079 if (rhs.is_undefined ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3080 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3081 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3082 tree_expression *lhs = cmd.left_hand_side (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3083 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
3084 octave_lvalue ult = lhs->lvalue (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3085 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3086 tree_statement_list *loop_body = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3087 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3088 if (rhs.is_range ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3089 { |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3090 // FIXME: is there a better way to dispatch here? |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3091 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3092 if (rhs.is_double_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3093 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3094 execute_range_loop (rhs.range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3095 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3096 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3097 |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30749
diff
changeset
|
3098 // For now, disable all but range<double>. |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30749
diff
changeset
|
3099 |
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30749
diff
changeset
|
3100 #if 0 |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3101 if (rhs.is_int64_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3102 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3103 execute_range_loop (rhs.int64_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3104 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3105 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3106 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3107 if (rhs.is_uint64_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3108 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3109 execute_range_loop (rhs.uint64_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3110 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3111 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3112 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3113 if (rhs.is_int32_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3114 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3115 execute_range_loop (rhs.int32_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3116 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3117 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3118 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3119 if (rhs.is_uint32_type ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3120 { |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3121 execute_range_loop (rhs.uint32_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3122 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3123 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3124 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3125 if (rhs.is_int16_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3126 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3127 execute_range_loop (rhs.int16_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3128 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3129 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3130 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3131 if (rhs.is_uint16_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3132 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3133 execute_range_loop (rhs.uint16_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3134 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3135 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3136 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3137 if (rhs.is_int8_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3138 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3139 execute_range_loop (rhs.int8_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3140 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3141 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3142 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3143 if (rhs.is_uint8_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3144 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3145 execute_range_loop (rhs.uint8_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3146 return; |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3147 } |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3148 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3149 if (rhs.is_single_type ()) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3150 { |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3151 execute_range_loop (rhs.float_range_value (), line, ult, loop_body); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3152 return; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3153 } |
30835
2989202f92f8
only allow range<FLOAT> to be instantiated
John W. Eaton <jwe@octave.org>
parents:
30749
diff
changeset
|
3154 #endif |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3155 } |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3156 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3157 if (rhs.is_scalar_type ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3158 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3159 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3160 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3161 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3162 ult.assign (octave_value::op_asn_eq, rhs); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3163 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3164 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3165 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3166 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3167 // Maybe decrement break and continue states. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3168 quit_loop_now (); |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3169 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3170 return; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3171 } |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3172 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3173 // Also handle any range types not explicitly handled above, though |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3174 // not as efficiently as the specialized code above. |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3175 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3176 if (rhs.is_range () || rhs.is_matrix_type () || rhs.iscell () |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3177 || rhs.is_string () || rhs.isstruct ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3178 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3179 // A matrix or cell is reshaped to 2 dimensions and iterated by |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3180 // columns. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3181 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3182 dim_vector dv = rhs.dims ().redim (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3183 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3184 octave_idx_type nrows = dv(0); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3185 octave_idx_type steps = dv(1); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3186 |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3187 octave_value arg = rhs; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3188 if (rhs.ndims () > 2) |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3189 arg = arg.reshape (dv); |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3190 |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3191 if (nrows > 0 && steps > 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3192 { |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3193 octave_value_list idx; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3194 octave_idx_type iidx; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3195 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3196 // for row vectors, use single index to speed things up. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3197 if (nrows == 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3198 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3199 idx.resize (1); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3200 iidx = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3201 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3202 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3203 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3204 idx.resize (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3205 idx(0) = octave_value::magic_colon_t; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3206 iidx = 1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3207 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3208 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3209 for (octave_idx_type i = 1; i <= steps; i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3210 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3211 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3212 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3213 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28619
diff
changeset
|
3214 // index_op expects one-based indices. |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3215 idx(iidx) = i; |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28619
diff
changeset
|
3216 octave_value val = arg.index_op (idx); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3217 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3218 ult.assign (octave_value::op_asn_eq, val); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3219 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3220 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3221 loop_body->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3222 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3223 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3224 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3225 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3226 } |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3227 else |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3228 { |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3229 // Handle empty cases, while still assigning to loop var. |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
3230 ult.assign (octave_value::op_asn_eq, arg); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3231 } |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3232 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3233 return; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3234 } |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3235 |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3236 error ("invalid type in for loop expression near line %d, column %d", |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
3237 cmd.line (), cmd.column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3238 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3239 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3240 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3241 tree_evaluator::visit_complex_for_command (tree_complex_for_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3242 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3243 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3244 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3245 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3246 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3247 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3248 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3249 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3250 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3251 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3252 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3253 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3254 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3255 |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
3256 unwind_protect_var<bool> upv (m_in_loop_command, true); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3257 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3258 tree_expression *expr = cmd.control_expr (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3259 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27373
diff
changeset
|
3260 octave_value rhs = expr->evaluate (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3261 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3262 if (rhs.is_undefined ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3263 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3264 |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
3265 if (! rhs.isstruct ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3266 error ("in statement 'for [X, Y] = VAL', VAL must be a structure"); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3267 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3268 // Cycle through structure elements. First element of id_list |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3269 // is set to value and the second is set to the name of the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3270 // structure element. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3271 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3272 tree_argument_list *lhs = cmd.left_hand_side (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3273 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
3274 auto p = lhs->begin (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3275 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3276 tree_expression *elt = *p++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3277 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
3278 octave_lvalue val_ref = elt->lvalue (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3279 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3280 elt = *p; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3281 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
3282 octave_lvalue key_ref = elt->lvalue (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3283 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3284 const octave_map tmp_val = rhs.map_value (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3285 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3286 tree_statement_list *loop_body = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3287 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3288 string_vector keys = tmp_val.keys (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3289 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3290 octave_idx_type nel = keys.numel (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3291 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3292 for (octave_idx_type i = 0; i < nel; i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3293 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3294 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3295 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3296 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3297 std::string key = keys[i]; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3298 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3299 const Cell val_lst = tmp_val.contents (key); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3300 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3301 octave_idx_type n = val_lst.numel (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3302 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3303 octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3304 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3305 val_ref.assign (octave_value::op_asn_eq, val); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3306 key_ref.assign (octave_value::op_asn_eq, key); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3307 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3308 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3309 loop_body->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3310 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3311 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3312 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3313 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3314 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3315 |
28518
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3316 void tree_evaluator::visit_spmd_command (tree_spmd_command& cmd) |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3317 { |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3318 // For now, we just execute the commands serially. |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3319 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3320 tree_statement_list *body = cmd.body (); |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3321 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3322 if (body) |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3323 body->accept (*this); |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3324 } |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28481
diff
changeset
|
3325 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3326 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3327 tree_evaluator::visit_octave_user_script (octave_user_script&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3328 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3329 // ?? |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3330 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3331 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3332 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3333 octave_value_list |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3334 tree_evaluator::execute_user_script (octave_user_script& user_script, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3335 int nargout, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3336 const octave_value_list& args) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3337 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3338 octave_value_list retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3339 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3340 std::string file_name = user_script.fcn_file_name (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3341 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3342 if (args.length () != 0 || nargout != 0) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3343 error ("invalid call to script %s", file_name.c_str ()); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3344 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3345 tree_statement_list *cmd_list = user_script.body (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3346 |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
3347 if (! cmd_list) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3348 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3349 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3350 // FIXME: Maybe this check belongs in the places where we push a new |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3351 // stack frame? Or in the call_stack push method itself? |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3352 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
3353 if (m_call_stack.size () >= static_cast<std::size_t> (m_max_recursion_depth)) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3354 error ("max_recursion_depth exceeded"); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3355 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3356 unwind_protect_var<stmt_list_type> upv (m_statement_context, SC_SCRIPT); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3357 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3358 profiler::enter<octave_user_script> block (m_profiler, user_script); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3359 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3360 if (echo ()) |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3361 push_echo_state (tree_evaluator::ECHO_SCRIPTS, file_name); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3362 |
29420
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3363 // FIXME: Should we be using tree_evaluator::eval here? |
4ee5a22dd4fe
fix interrupt and dbquit behavior when using server mode
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3364 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3365 cmd_list->accept (*this); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3366 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3367 if (m_returning) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3368 m_returning = 0; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3369 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3370 if (m_breaking) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3371 m_breaking--; |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3372 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3373 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3374 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3375 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3376 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3377 tree_evaluator::visit_octave_user_function (octave_user_function&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3378 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3379 // ?? |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3380 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3381 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3382 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3383 octave_value_list |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3384 tree_evaluator::execute_user_function (octave_user_function& user_function, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3385 int nargout, |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3386 const octave_value_list& xargs) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3387 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3388 octave_value_list retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3389 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3390 // If this function is a classdef constructor, extract the first input |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3391 // argument, which must be the partially constructed object instance. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3392 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3393 octave_value_list args (xargs); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3394 octave_value_list ret_args; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3395 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3396 int nargin = args.length (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3397 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3398 if (user_function.is_classdef_constructor ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3399 { |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3400 if (nargin > 0) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3401 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3402 ret_args = args.slice (0, 1, true); |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3403 --nargin; |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3404 args = args.slice (1, nargin, true); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3405 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3406 else |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3407 panic_impossible (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3408 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3409 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3410 // FIXME: this probably shouldn't be a double-precision matrix. |
28540
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
3411 Matrix ignored_outputs = ignored_fcn_outputs (); |
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
3412 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3413 tree_parameter_list *param_list = user_function.parameter_list (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3414 |
30285
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3415 bool takes_varargs = false; |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3416 int max_inputs = 0; |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3417 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3418 if (param_list) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3419 { |
30285
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3420 takes_varargs = param_list->takes_varargs (); |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3421 max_inputs = param_list->length (); |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3422 } |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3423 |
30285
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3424 if (! takes_varargs && nargin > max_inputs) |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3425 { |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3426 std::string name = user_function.name (); |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3427 |
30652
a3a52d968f71
Print function name for too many arguments of anonymous function (bug #61842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30635
diff
changeset
|
3428 if (name.empty ()) |
a3a52d968f71
Print function name for too many arguments of anonymous function (bug #61842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30635
diff
changeset
|
3429 name = "@<anonymous>"; |
a3a52d968f71
Print function name for too many arguments of anonymous function (bug #61842).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30635
diff
changeset
|
3430 |
30635
064a8fbf9162
Assign error ID when parser fails because of incorrect number of function inputs/outputs (bug #61789)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
3431 error_with_id ("Octave:invalid-fun-call", |
064a8fbf9162
Assign error ID when parser fails because of incorrect number of function inputs/outputs (bug #61789)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
3432 "%s: function called with too many inputs", |
064a8fbf9162
Assign error ID when parser fails because of incorrect number of function inputs/outputs (bug #61789)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
3433 name.c_str ()); |
30285
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3434 } |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3435 |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3436 define_parameter_list_from_arg_vector (param_list, args); |
fca639cb78b8
detect fcn called with too many args when arg list not present (bug #61471)
John W. Eaton <jwe@octave.org>
parents:
30203
diff
changeset
|
3437 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3438 tree_parameter_list *ret_list = user_function.return_list (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3439 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3440 if (ret_list && ! ret_list->takes_varargs ()) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3441 { |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3442 int max_outputs = ret_list->length (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3443 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3444 if (nargout > max_outputs) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3445 { |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3446 std::string name = user_function.name (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3447 |
30635
064a8fbf9162
Assign error ID when parser fails because of incorrect number of function inputs/outputs (bug #61789)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
3448 error_with_id ("Octave:invalid-fun-call", |
064a8fbf9162
Assign error ID when parser fails because of incorrect number of function inputs/outputs (bug #61789)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
3449 "%s: function called with too many outputs", |
064a8fbf9162
Assign error ID when parser fails because of incorrect number of function inputs/outputs (bug #61789)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
3450 name.c_str ()); |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3451 } |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3452 } |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3453 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3454 bind_auto_fcn_vars (xargs.name_tags (), ignored_outputs, nargin, |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3455 nargout, user_function.takes_varargs (), |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3456 user_function.all_va_args (args)); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3457 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3458 // For classdef constructor, pre-populate the output arguments |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3459 // with the pre-initialized object instance, extracted above. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3460 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3461 if (user_function.is_classdef_constructor ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3462 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3463 if (! ret_list) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3464 error ("%s: invalid classdef constructor, no output argument defined", |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3465 user_function.dispatch_class ().c_str ()); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3466 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3467 define_parameter_list_from_arg_vector (ret_list, ret_args); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3468 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3469 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3470 // FIXME: Maybe this check belongs in the places where we push a |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3471 // new stack frame? Or in the call_stack push method itself? |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3472 |
29572
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
3473 if (m_call_stack.size () >= static_cast<std::size_t> (m_max_recursion_depth)) |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3474 error ("max_recursion_depth exceeded"); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3475 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3476 unwind_action act2 ([&user_function] () { |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3477 user_function.restore_warning_states (); |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3478 }); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3479 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3480 // Evaluate the commands that make up the function. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3481 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3482 unwind_protect_var<stmt_list_type> upv (m_statement_context, SC_FUNCTION); |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
3483 |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3484 tree_statement_list *cmd_list = user_function.body (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3485 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3486 if (cmd_list) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3487 { |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3488 profiler::enter<octave_user_function> |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3489 block (m_profiler, user_function); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3490 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3491 if (echo ()) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3492 push_echo_state (tree_evaluator::ECHO_FUNCTIONS, |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3493 user_function.fcn_file_name ()); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3494 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3495 if (user_function.is_special_expr ()) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3496 { |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30653
diff
changeset
|
3497 panic_if (cmd_list->length () != 1); |
28562
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3498 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3499 tree_statement *stmt = cmd_list->front (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3500 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3501 tree_expression *expr = stmt->expression (); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3502 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3503 if (expr) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3504 { |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3505 m_call_stack.set_location (stmt->line (), stmt->column ()); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3506 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3507 retval = expr->evaluate_n (*this, nargout); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3508 } |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3509 } |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3510 else |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3511 cmd_list->accept (*this); |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3512 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3513 if (m_returning) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3514 m_returning = 0; |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3515 |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3516 if (m_breaking) |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3517 m_breaking--; |
b0b80efecea1
error for functions called with too many inputs or outputs
John W. Eaton <jwe@octave.org>
parents:
28561
diff
changeset
|
3518 } |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3519 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3520 // Copy return values out. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3521 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3522 if (ret_list && ! user_function.is_special_expr ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3523 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3524 Cell varargout; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3525 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3526 if (ret_list->takes_varargs ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3527 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3528 octave_value varargout_varval = varval ("varargout"); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3529 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3530 if (varargout_varval.is_defined ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3531 varargout = varargout_varval.xcell_value ("varargout must be a cell array object"); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3532 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3533 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3534 retval = convert_return_list_to_const_vector (ret_list, nargout, |
28540
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
3535 ignored_outputs, |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3536 varargout); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3537 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3538 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3539 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3540 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
3541 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3542 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3543 tree_evaluator::visit_octave_user_function_header (octave_user_function&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3544 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3545 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3546 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3547 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3548 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3549 tree_evaluator::visit_octave_user_function_trailer (octave_user_function&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3550 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3551 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3552 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3553 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3554 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3555 tree_evaluator::visit_function_def (tree_function_def& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3556 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3557 octave_value fcn = cmd.function (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3558 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3559 octave_function *f = fcn.function_value (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3560 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3561 if (f) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3562 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3563 std::string nm = f->name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3564 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
3565 symbol_table& symtab = m_interpreter.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
3566 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
3567 symtab.install_cmdline_function (nm, fcn); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3568 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3569 // Make sure that any variable with the same name as the new |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3570 // function is cleared. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3571 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3572 assign (nm); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3573 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3574 } |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
3575 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3576 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3577 tree_evaluator::visit_identifier (tree_identifier&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3578 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3579 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3580 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3581 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3582 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3583 tree_evaluator::visit_if_clause (tree_if_clause&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3584 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3585 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3586 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3587 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3588 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3589 tree_evaluator::visit_if_command (tree_if_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3590 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3591 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3592 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3593 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3594 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3595 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3596 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3597 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3598 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3599 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3600 // FIXME: tree_if_command_list is not derived from tree, so should it |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3601 // really have an accept method? |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3602 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3603 tree_if_command_list *lst = cmd.cmd_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3604 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3605 if (lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3606 lst->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3607 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3608 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3609 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3610 tree_evaluator::visit_if_command_list (tree_if_command_list& lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3611 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
3612 for (tree_if_clause *tic : lst) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3613 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3614 tree_expression *expr = tic->condition (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3615 |
27761
223981108144
fix stack frame location info when using debugger (bug #57315)
John W. Eaton <jwe@octave.org>
parents:
27725
diff
changeset
|
3616 if (! (in_debug_repl () |
223981108144
fix stack frame location info when using debugger (bug #57315)
John W. Eaton <jwe@octave.org>
parents:
27725
diff
changeset
|
3617 && m_call_stack.current_frame () == m_debug_frame)) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
3618 m_call_stack.set_location (tic->line (), tic->column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3619 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3620 if (m_debug_mode && ! tic->is_else_clause ()) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3621 do_breakpoint (tic->is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3622 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3623 if (tic->is_else_clause () || is_logically_true (expr, "if")) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3624 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3625 tree_statement_list *stmt_lst = tic->commands (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3626 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3627 if (stmt_lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3628 stmt_lst->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3629 |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
3630 break; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3631 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3632 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3633 } |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24690
diff
changeset
|
3634 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3635 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3636 tree_evaluator::visit_index_expression (tree_index_expression&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3637 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3638 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3639 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3640 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3641 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3642 tree_evaluator::visit_matrix (tree_matrix&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3643 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3644 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3645 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3646 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3647 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3648 tree_evaluator::visit_cell (tree_cell&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3649 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3650 panic_impossible (); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3651 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3652 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3653 void |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3654 tree_evaluator::visit_multi_assignment (tree_multi_assignment&) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3655 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3656 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3657 } |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
3658 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3659 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3660 tree_evaluator::visit_no_op_command (tree_no_op_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3661 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3662 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3663 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3664 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3665 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3666 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3667 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3668 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3669 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3670 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3671 if (m_debug_mode && cmd.is_end_of_fcn_or_script ()) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3672 do_breakpoint (cmd.is_active_breakpoint (*this), true); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3673 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3674 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3675 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3676 tree_evaluator::visit_constant (tree_constant&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3677 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3678 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3679 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3680 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3681 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3682 tree_evaluator::visit_fcn_handle (tree_fcn_handle&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3683 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3684 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3685 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3686 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3687 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3688 tree_evaluator::visit_parameter_list (tree_parameter_list&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3689 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3690 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3691 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3692 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3693 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3694 tree_evaluator::visit_postfix_expression (tree_postfix_expression&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3695 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3696 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3697 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3698 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3699 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3700 tree_evaluator::visit_prefix_expression (tree_prefix_expression&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3701 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3702 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3703 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3704 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3705 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3706 tree_evaluator::visit_return_command (tree_return_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3707 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3708 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3709 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3710 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3711 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3712 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3713 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3714 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3715 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3716 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3717 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3718 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3719 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3720 // Act like dbcont. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3721 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
3722 if (in_debug_repl () && m_call_stack.current_frame () == m_debug_frame) |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
3723 dbcont (); |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
3724 else if (m_statement_context == SC_FUNCTION |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
3725 || m_statement_context == SC_SCRIPT |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3726 || m_in_loop_command) |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3727 m_returning = 1; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3728 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3729 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3730 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3731 tree_evaluator::visit_simple_assignment (tree_simple_assignment&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3732 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3733 panic_impossible (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3734 } |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
3735 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3736 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3737 tree_evaluator::visit_statement (tree_statement& stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3738 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3739 tree_command *cmd = stmt.command (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3740 tree_expression *expr = stmt.expression (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3741 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3742 if (cmd || expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3743 { |
27761
223981108144
fix stack frame location info when using debugger (bug #57315)
John W. Eaton <jwe@octave.org>
parents:
27725
diff
changeset
|
3744 if (! (in_debug_repl () |
223981108144
fix stack frame location info when using debugger (bug #57315)
John W. Eaton <jwe@octave.org>
parents:
27725
diff
changeset
|
3745 && m_call_stack.current_frame () == m_debug_frame)) |
27540
6971bc1a2f92
deprecate unecessary global variable Vtrack_line_num
John W. Eaton <jwe@octave.org>
parents:
27533
diff
changeset
|
3746 m_call_stack.set_location (stmt.line (), stmt.column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3747 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3748 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3749 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3750 if (cmd) |
28560
af1a9c1db88e
reset pointer to lvalue list before executing commands (bug #58748, bug #58751)
John W. Eaton <jwe@octave.org>
parents:
28540
diff
changeset
|
3751 { |
af1a9c1db88e
reset pointer to lvalue list before executing commands (bug #58748, bug #58751)
John W. Eaton <jwe@octave.org>
parents:
28540
diff
changeset
|
3752 unwind_protect_var<const std::list<octave_lvalue> *> |
af1a9c1db88e
reset pointer to lvalue list before executing commands (bug #58748, bug #58751)
John W. Eaton <jwe@octave.org>
parents:
28540
diff
changeset
|
3753 upv (m_lvalue_list, nullptr); |
af1a9c1db88e
reset pointer to lvalue list before executing commands (bug #58748, bug #58751)
John W. Eaton <jwe@octave.org>
parents:
28540
diff
changeset
|
3754 |
af1a9c1db88e
reset pointer to lvalue list before executing commands (bug #58748, bug #58751)
John W. Eaton <jwe@octave.org>
parents:
28540
diff
changeset
|
3755 cmd->accept (*this); |
af1a9c1db88e
reset pointer to lvalue list before executing commands (bug #58748, bug #58751)
John W. Eaton <jwe@octave.org>
parents:
28540
diff
changeset
|
3756 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3757 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3758 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3759 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3760 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3761 int line = stmt.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3762 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3763 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3764 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3765 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3766 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3767 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3768 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3769 do_breakpoint (expr->is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3770 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3771 // FIXME: maybe all of this should be packaged in |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3772 // one virtual function that returns a flag saying whether |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3773 // or not the expression will take care of binding ans and |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3774 // printing the result. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3775 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3776 // FIXME: it seems that we should just have to |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3777 // evaluate the expression and that should take care of |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3778 // everything, binding ans as necessary? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3779 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
3780 octave_value tmp_result = expr->evaluate (*this, 0); |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3781 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3782 if (tmp_result.is_defined ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3783 { |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3784 bool do_bind_ans = false; |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3785 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3786 if (expr->is_identifier ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3787 do_bind_ans = ! is_variable (expr); |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3788 else |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3789 do_bind_ans = ! expr->is_assignment_expression (); |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3790 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3791 if (do_bind_ans) |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3792 bind_ans (tmp_result, expr->print_result () |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
3793 && statement_printing_enabled ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3794 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3795 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3796 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3797 catch (const std::bad_alloc&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3798 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3799 // FIXME: We want to use error_with_id here so that give users |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3800 // control over this error message but error_with_id will |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3801 // require some memory allocations. Is there anything we can |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3802 // do to make those more likely to succeed? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3803 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3804 error_with_id ("Octave:bad-alloc", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3805 "out of memory or dimension too large for Octave's index type"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3806 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
3807 catch (const interrupt_exception&) |
24583
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3808 { |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3809 // If we are debugging, then continue with next statement. |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3810 // Otherwise, jump out of here. |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3811 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3812 if (m_debug_mode) |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27472
diff
changeset
|
3813 m_interpreter.recover_from_exception (); |
24583
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3814 else |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3815 throw; |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3816 } |
28980
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3817 catch (const execution_exception& ee) |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3818 { |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3819 error_system& es = m_interpreter.get_error_system (); |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3820 |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3821 if ((m_interpreter.interactive () |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3822 || application::forced_interactive ()) |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3823 && ((es.debug_on_error () |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3824 && m_bp_table.debug_on_err (es.last_error_id ())) |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3825 || (es.debug_on_caught () |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3826 && m_bp_table.debug_on_caught (es.last_error_id ()))) |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3827 && in_user_code ()) |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3828 { |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3829 es.save_exception (ee); |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29493
diff
changeset
|
3830 es.display_exception (ee); |
28980
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3831 |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3832 enter_debugger (); |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3833 |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3834 // It doesn't make sense to continue execution after an |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3835 // error occurs so force the debugger to quit all debug |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3836 // levels and return the the top prompt. |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3837 |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3838 throw quit_debug_exception (true); |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3839 } |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3840 else |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3841 throw; |
a745a046b705
handle debug_on_interrupt when execution_exception is caught (bug #59306)
John W. Eaton <jwe@octave.org>
parents:
28804
diff
changeset
|
3842 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3843 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3844 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3845 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3846 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3847 tree_evaluator::visit_statement_list (tree_statement_list& lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3848 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3849 // FIXME: commented out along with else clause below. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3850 // static octave_value_list empty_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3851 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
3852 auto p = lst.begin (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3853 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3854 if (p != lst.end ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3855 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3856 while (true) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3857 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3858 tree_statement *elt = *p++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3859 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3860 if (! elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3861 error ("invalid statement found in statement list!"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3862 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3863 octave_quit (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3864 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3865 elt->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3866 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3867 if (m_breaking || m_continuing) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3868 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3869 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3870 if (m_returning) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3871 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3872 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3873 if (p == lst.end ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3874 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3875 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3876 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3877 // Clear previous values before next statement is |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3878 // evaluated so that we aren't holding an extra |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3879 // reference to a value that may be used next. For |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3880 // example, in code like this: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3881 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3882 // X = rand (N); # refcount for X should be 1 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3883 // # after this statement |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3884 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3885 // X(idx) = val; # no extra copy of X should be |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3886 // # needed, but we will be faked |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3887 // # out if retval is not cleared |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3888 // # between statements here |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3889 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3890 // result_values = empty_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3891 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3892 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3893 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3894 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3895 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3896 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3897 tree_evaluator::visit_switch_case (tree_switch_case&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3898 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3899 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3900 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3901 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3902 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3903 tree_evaluator::visit_switch_case_list (tree_switch_case_list&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3904 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3905 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3906 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3907 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3908 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3909 tree_evaluator::visit_switch_command (tree_switch_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3910 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3911 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3912 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3913 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3914 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3915 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3916 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3917 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3918 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3919 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3920 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3921 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3922 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3923 tree_expression *expr = cmd.switch_value (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3924 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3925 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3926 error ("missing value in switch command near line %d, column %d", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3927 cmd.line (), cmd.column ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3928 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27373
diff
changeset
|
3929 octave_value val = expr->evaluate (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3930 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3931 tree_switch_case_list *lst = cmd.case_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3932 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3933 if (lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3934 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
3935 for (tree_switch_case *t : *lst) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3936 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3937 if (t->is_default_case () || switch_case_label_matches (t, val)) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3938 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3939 tree_statement_list *stmt_lst = t->commands (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3940 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3941 if (stmt_lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3942 stmt_lst->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3943 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3944 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3945 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3946 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3947 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3948 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3949 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3950 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3951 tree_evaluator::visit_try_catch_command (tree_try_catch_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3952 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3953 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3954 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3955 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3956 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
3957 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3958 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3959 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3960 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3961 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3962 bool execution_error = false; |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3963 octave_scalar_map err_map; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3964 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3965 tree_statement_list *try_code = cmd.body (); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3966 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3967 if (try_code) |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3968 { |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3969 // unwind frame before catch block |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3970 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3971 unwind_protect frame; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3972 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3973 interpreter_try (frame); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3974 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3975 // The catch code is *not* added to unwind_protect stack; it |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3976 // doesn't need to be run on interrupts. |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3977 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3978 try |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3979 { |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3980 try_code->accept (*this); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3981 } |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3982 catch (const execution_exception& ee) |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3983 { |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3984 execution_error = true; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3985 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3986 error_system& es = m_interpreter.get_error_system (); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3987 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3988 es.save_exception (ee); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3989 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3990 err_map.assign ("message", es.last_error_message ()); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3991 err_map.assign ("identifier", es.last_error_id ()); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3992 err_map.assign ("stack", es.last_error_stack ()); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3993 |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27472
diff
changeset
|
3994 m_interpreter.recover_from_exception (); |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3995 } |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3996 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3997 // Actions attached to unwind_protect frame will run here, prior |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3998 // to executing the catch block. |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3999 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4000 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4001 if (execution_error) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4002 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4003 tree_statement_list *catch_code = cmd.cleanup (); |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4004 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4005 if (catch_code) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4006 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4007 tree_identifier *expr_id = cmd.identifier (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4008 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4009 if (expr_id) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4010 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
4011 octave_lvalue ult = expr_id->lvalue (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4012 |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
4013 ult.assign (octave_value::op_asn_eq, err_map); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4014 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4015 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4016 // perform actual "catch" block |
26451
0ab258611cc5
pt-eval.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
4017 catch_code->accept (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4018 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4019 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4020 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4021 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4022 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4023 tree_evaluator::do_unwind_protect_cleanup_code (tree_statement_list *list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4024 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4025 unwind_protect frame; |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4026 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4027 frame.protect_var (octave_interrupt_state); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4028 octave_interrupt_state = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4029 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4030 // We want to preserve the last location info for possible |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4031 // backtracking. |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
4032 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
4033 frame.add (&call_stack::set_line, &m_call_stack, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
4034 m_call_stack.current_line ()); |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
4035 |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
4036 frame.add (&call_stack::set_column, &m_call_stack, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
4037 m_call_stack.current_column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4038 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4039 // Similarly, if we have seen a return or break statement, allow all |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4040 // the cleanup code to run before returning or handling the break. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4041 // We don't have to worry about continue statements because they can |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4042 // only occur in loops. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4043 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
4044 frame.protect_var (m_returning); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
4045 m_returning = 0; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
4046 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
4047 frame.protect_var (m_breaking); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
4048 m_breaking = 0; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4049 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4050 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4051 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4052 if (list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4053 list->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4054 } |
27471 | 4055 catch (const execution_exception& ee) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4056 { |
27471 | 4057 error_system& es = m_interpreter.get_error_system (); |
4058 | |
4059 es.save_exception (ee); | |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27472
diff
changeset
|
4060 m_interpreter.recover_from_exception (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4061 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
4062 if (m_breaking || m_returning) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4063 frame.discard (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4064 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4065 frame.run (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4066 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4067 frame.discard (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4068 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4069 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4070 } |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4071 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4072 // The unwind_protects are popped off the stack in the reverse of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4073 // the order they are pushed on. |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4074 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4075 // FIXME: these statements say that if we see a break or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4076 // return statement in the cleanup block, that we want to use the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4077 // new value of the breaking or returning flag instead of restoring |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4078 // the previous value. Is that the right thing to do? I think so. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4079 // Consider the case of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4080 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4081 // function foo () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4082 // unwind_protect |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4083 // fprintf (stderr, "1: this should always be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4084 // break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4085 // fprintf (stderr, "1: this should never be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4086 // unwind_protect_cleanup |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4087 // fprintf (stderr, "2: this should always be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4088 // return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4089 // fprintf (stderr, "2: this should never be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4090 // end_unwind_protect |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4091 // endfunction |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4092 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4093 // If we reset the value of the breaking flag, both the returning |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4094 // flag and the breaking flag will be set, and we shouldn't have |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4095 // both. So, use the most recent one. If there is no return or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4096 // break in the cleanup block, the values should be reset to |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4097 // whatever they were when the cleanup block was entered. |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4098 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
4099 if (m_breaking || m_returning) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4100 frame.discard (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4101 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4102 frame.run (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4103 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
4104 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4105 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4106 tree_evaluator::visit_unwind_protect_command (tree_unwind_protect_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4107 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4108 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4109 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4110 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4111 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4112 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4113 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4114 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4115 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4116 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4117 tree_statement_list *cleanup_code = cmd.cleanup (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4118 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4119 tree_statement_list *unwind_protect_code = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4120 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4121 if (unwind_protect_code) |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4122 { |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4123 try |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4124 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4125 unwind_protect_code->accept (*this); |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4126 } |
27471 | 4127 catch (const execution_exception& ee) |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4128 { |
27471 | 4129 error_system& es = m_interpreter.get_error_system (); |
4130 | |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4131 // FIXME: Maybe we should be able to temporarily set the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4132 // interpreter's exception handling state to something "safe" |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4133 // while the cleanup block runs instead of just resetting it |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4134 // here? |
27471 | 4135 es.save_exception (ee); |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27472
diff
changeset
|
4136 m_interpreter.recover_from_exception (); |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4137 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4138 // Run the cleanup code on exceptions, so that it is run even |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4139 // in case of interrupt or out-of-memory. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4140 do_unwind_protect_cleanup_code (cleanup_code); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4141 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4142 // If an error occurs inside the cleanup code, a new |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4143 // exception will be thrown instead of the original. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4144 throw; |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4145 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4146 catch (const interrupt_exception&) |
23612
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
4147 { |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
4148 // The comments above apply here as well. |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27472
diff
changeset
|
4149 m_interpreter.recover_from_exception (); |
23612
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
4150 do_unwind_protect_cleanup_code (cleanup_code); |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
4151 throw; |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
4152 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4153 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4154 // Also execute the unwind_protect_cleanump code if the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4155 // unwind_protect block runs without error. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4156 do_unwind_protect_cleanup_code (cleanup_code); |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4157 } |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
4158 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4159 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4160 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4161 tree_evaluator::visit_while_command (tree_while_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4162 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4163 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4164 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4165 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4166 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4167 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4168 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4169 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4170 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4171 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4172 |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
4173 unwind_protect_var<bool> upv (m_in_loop_command, true); |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
4174 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4175 tree_expression *expr = cmd.condition (); |
20824
8848e35e5ef8
better handling of exceptions in unwind-protect blocks
John W. Eaton <jwe@octave.org>
parents:
20784
diff
changeset
|
4176 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4177 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4178 panic_impossible (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4179 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4180 for (;;) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4181 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4182 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4183 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4184 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
4185 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
4186 do_breakpoint (cmd.is_active_breakpoint (*this)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4187 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4188 if (is_logically_true (expr, "while")) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4189 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4190 tree_statement_list *loop_body = cmd.body (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4191 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4192 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4193 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4194 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4195 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4196 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4197 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4198 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4199 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4200 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4201 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
4202 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4203 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4204 tree_evaluator::visit_do_until_command (tree_do_until_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4205 { |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4206 int line = cmd.line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4207 if (line < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4208 line = 1; |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4209 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4210 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4211 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4212 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4213 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4214 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4215 |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
4216 unwind_protect_var<bool> upv (m_in_loop_command, true); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4217 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4218 tree_expression *expr = cmd.condition (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4219 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4220 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4221 panic_impossible (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4222 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4223 for (;;) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4224 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4225 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4226 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4227 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4228 tree_statement_list *loop_body = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4229 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4230 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4231 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4232 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4233 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4234 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4235 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
4236 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
4237 do_breakpoint (cmd.is_active_breakpoint (*this)); |
18325
2a8243d8327a
jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents:
18270
diff
changeset
|
4238 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4239 if (is_logically_true (expr, "do-until")) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4240 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4241 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4242 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4243 |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4244 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4245 tree_evaluator::visit_superclass_ref (tree_superclass_ref&) |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4246 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4247 panic_impossible (); |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4248 } |
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4249 |
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4250 void |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4251 tree_evaluator::visit_metaclass_query (tree_metaclass_query&) |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4252 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4253 panic_impossible (); |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4254 } |
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
4255 |
23702
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4256 void tree_evaluator::bind_ans (const octave_value& val, bool print) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4257 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4258 static std::string ans = "ans"; |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4259 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4260 if (val.is_defined ()) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4261 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4262 if (val.is_cs_list ()) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4263 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4264 octave_value_list lst = val.list_value (); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4265 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4266 for (octave_idx_type i = 0; i < lst.length (); i++) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4267 bind_ans (lst(i), print); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4268 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4269 else |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4270 { |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4271 // FIXME: Maybe assign could also return the assigned value, |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4272 // just for convenience? |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4273 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
4274 assign (ans, val); |
23702
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4275 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4276 if (print) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4277 { |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4278 // Use varval instead of displaying VAL directly so that |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4279 // we get the right type and value for things like |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4280 // magic_int values that may mutate when stored. |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4281 |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28562
diff
changeset
|
4282 octave_value_list args = ovl (varval (ans)); |
23702
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4283 args.stash_name_tags (string_vector (ans)); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4284 feval ("display", args); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4285 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4286 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4287 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4288 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
4289 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4290 void |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4291 tree_evaluator::do_breakpoint (tree_statement& stmt) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4292 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
4293 do_breakpoint (stmt.is_active_breakpoint (*this), |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
4294 stmt.is_end_of_fcn_or_script ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4295 } |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
4296 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4297 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4298 tree_evaluator::do_breakpoint (bool is_breakpoint, |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4299 bool is_end_of_fcn_or_script) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4300 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4301 bool break_on_this_statement = false; |
21542
7ba48ff6ce83
Record correct line number with "until" command (bug #43249)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
4302 |
25405
df2f3af2c6c5
eliminate unused octave_debug_on_interrupt_state variable
John W. Eaton <jwe@octave.org>
parents:
25404
diff
changeset
|
4303 if (is_breakpoint) |
27233
fc668ac9ce7c
re-enter debugger when doing dbstep (bug #56150)
John W. Eaton <jwe@octave.org>
parents:
27222
diff
changeset
|
4304 break_on_this_statement = true; |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4305 else if (m_dbstep_flag > 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4306 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4307 if (m_call_stack.current_frame () == m_debug_frame) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4308 { |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4309 if (m_dbstep_flag == 1 || is_end_of_fcn_or_script) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4310 { |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30326
diff
changeset
|
4311 // We get here if we are doing a "dbstep" or a "dbstep N" and |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30326
diff
changeset
|
4312 // the count has reached 1 so that we must stop and return to |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30326
diff
changeset
|
4313 // debug prompt. Alternatively, "dbstep N" has been used but |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30326
diff
changeset
|
4314 // the end of the frame has been reached so we stop at the last |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30326
diff
changeset
|
4315 // line and return to prompt. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4316 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4317 break_on_this_statement = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4318 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4319 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4320 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4321 // Executing "dbstep N". Decrease N by one and continue. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4322 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4323 m_dbstep_flag--; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4324 } |
15574
d20cbfec6df7
Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
4325 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4326 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4327 else if (m_dbstep_flag == 1 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4328 && m_call_stack.current_frame () < m_debug_frame) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4329 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4330 // We stepped out from the end of a function. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4331 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4332 m_debug_frame = m_call_stack.current_frame (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4333 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4334 break_on_this_statement = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4335 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4336 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4337 else if (m_dbstep_flag == -1) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4338 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4339 // We get here if we are doing a "dbstep in". |
16396
c6a13c1900fc
make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
4340 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4341 break_on_this_statement = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4342 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4343 m_debug_frame = m_call_stack.current_frame (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4344 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4345 else if (m_dbstep_flag == -2) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4346 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4347 // We get here if we are doing a "dbstep out". Check for end of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4348 // function and whether the current frame is the same as the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4349 // cached value because we want to step out from the frame where |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4350 // "dbstep out" was evaluated, not from any functions called from |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4351 // that frame. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4352 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4353 if (is_end_of_fcn_or_script |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4354 && m_call_stack.current_frame () == m_debug_frame) |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
4355 m_dbstep_flag = -1; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4356 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4357 |
29306
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
4358 if (! break_on_this_statement) |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
4359 break_on_this_statement = m_break_on_next_stmt; |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
4360 |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
4361 m_break_on_next_stmt = false; |
0231189f630d
provide interpreter methods for pausing, resuming, and stopping evaluation
John W. Eaton <jwe@octave.org>
parents:
29305
diff
changeset
|
4362 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4363 if (break_on_this_statement) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
4364 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4365 m_dbstep_flag = 0; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4366 |
27233
fc668ac9ce7c
re-enter debugger when doing dbstep (bug #56150)
John W. Eaton <jwe@octave.org>
parents:
27222
diff
changeset
|
4367 enter_debugger (); |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
4368 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
4369 } |
10219
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
4370 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4371 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4372 tree_evaluator::is_logically_true (tree_expression *expr, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4373 const char *warn_for) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4374 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4375 bool expr_value = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4376 |
30203
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
29968
diff
changeset
|
4377 m_call_stack.set_location (expr->line (), expr->column ()); |
75fb18f0469a
fix file position info for errors in conditional expressions (bug #61201)
John W. Eaton <jwe@octave.org>
parents:
29968
diff
changeset
|
4378 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27373
diff
changeset
|
4379 octave_value t1 = expr->evaluate (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4380 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4381 if (t1.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4382 return t1.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4383 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4384 error ("%s: undefined value used in conditional expression", warn_for); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4385 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4386 return expr_value; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
4387 } |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
4388 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4389 octave_value |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4390 tree_evaluator::max_recursion_depth (const octave_value_list& args, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4391 int nargout) |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4392 { |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4393 return set_internal_variable (m_max_recursion_depth, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4394 "max_recursion_depth", 0); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4395 } |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4396 |
27203
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4397 symbol_info_list |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4398 tree_evaluator::glob_symbol_info (const std::string& pattern) const |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4399 { |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4400 return m_call_stack.glob_symbol_info (pattern); |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4401 } |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4402 |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4403 symbol_info_list |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4404 tree_evaluator::regexp_symbol_info (const std::string& pattern) const |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4405 { |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4406 return m_call_stack.regexp_symbol_info (pattern); |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4407 } |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4408 |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4409 symbol_info_list |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4410 tree_evaluator::get_symbol_info (void) |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4411 { |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4412 return m_call_stack.get_symbol_info (); |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4413 } |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4414 |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4415 symbol_info_list |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4416 tree_evaluator::top_scope_symbol_info (void) const |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4417 { |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4418 return m_call_stack.top_scope_symbol_info (); |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4419 } |
79065f9d5553
eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents:
27202
diff
changeset
|
4420 |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4421 octave_map tree_evaluator::get_autoload_map (void) const |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4422 { |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30836
diff
changeset
|
4423 Cell fcn_names (dim_vector (m_autoload_map.size (), 1)); |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4424 Cell file_names (dim_vector (m_autoload_map.size (), 1)); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4425 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4426 octave_idx_type i = 0; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4427 for (const auto& fcn_fname : m_autoload_map) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4428 { |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30836
diff
changeset
|
4429 fcn_names(i) = fcn_fname.first; |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4430 file_names(i) = fcn_fname.second; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4431 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4432 i++; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4433 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4434 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4435 octave_map m; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4436 |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30836
diff
changeset
|
4437 m.assign ("function", fcn_names); |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4438 m.assign ("file", file_names); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4439 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4440 return m; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4441 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4442 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4443 std::string tree_evaluator::lookup_autoload (const std::string& nm) const |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4444 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4445 std::string retval; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4446 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4447 auto p = m_autoload_map.find (nm); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4448 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4449 if (p != m_autoload_map.end ()) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4450 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4451 load_path& lp = m_interpreter.get_load_path (); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4452 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4453 retval = lp.find_file (p->second); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4454 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4455 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4456 return retval; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4457 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4458 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4459 std::list<std::string> tree_evaluator::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
|
4460 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4461 std::list<std::string> names; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4462 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4463 for (const auto& fcn_fname : m_autoload_map) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4464 names.push_back (fcn_fname.first); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4465 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4466 return names; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4467 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4468 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4469 std::list<std::string> |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4470 tree_evaluator::reverse_lookup_autoload (const std::string& nm) const |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4471 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4472 std::list<std::string> names; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4473 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4474 for (const auto& fcn_fname : m_autoload_map) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4475 if (nm == fcn_fname.second) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4476 names.push_back (fcn_fname.first); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4477 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4478 return names; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4479 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4480 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4481 void tree_evaluator::add_autoload (const std::string& fcn, |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4482 const std::string& nm) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4483 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4484 std::string file_name = check_autoload_file (nm); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4485 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4486 m_autoload_map[fcn] = file_name; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4487 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4488 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4489 void tree_evaluator::remove_autoload (const std::string& fcn, |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4490 const std::string& nm) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4491 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4492 check_autoload_file (nm); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4493 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4494 // Remove function from symbol table and autoload map. |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4495 symbol_table& symtab = m_interpreter.get_symbol_table (); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4496 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4497 symtab.clear_dld_function (fcn); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4498 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4499 m_autoload_map.erase (fcn); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4500 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
4501 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4502 octave_value |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4503 tree_evaluator::whos_line_format (const octave_value_list& args, int nargout) |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4504 { |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4505 return set_internal_variable (m_whos_line_format, args, nargout, |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4506 "whos_line_format"); |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4507 } |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4508 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4509 octave_value |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4510 tree_evaluator::silent_functions (const octave_value_list& args, int nargout) |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4511 { |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4512 return set_internal_variable (m_silent_functions, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4513 "silent_functions"); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4514 } |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4515 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4516 octave_value |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4517 tree_evaluator::string_fill_char (const octave_value_list& args, int nargout) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4518 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4519 return set_internal_variable (m_string_fill_char, args, nargout, |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4520 "string_fill_char"); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4521 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4522 |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4523 // Final step of processing an indexing error. Add the name of the |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4524 // variable being indexed, if any, then issue an error. (Will this also |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4525 // be needed by pt-lvalue, which calls subsref?) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4526 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29163
diff
changeset
|
4527 void tree_evaluator::final_index_error (index_exception& ie, |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4528 const tree_expression *expr) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4529 { |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4530 std::string extra_message; |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4531 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
4532 if (is_variable (expr)) |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4533 { |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4534 std::string var = expr->name (); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4535 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29163
diff
changeset
|
4536 ie.set_var (var); |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4537 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4538 symbol_table& symtab = m_interpreter.get_symbol_table (); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4539 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4540 octave_value fcn = symtab.find_function (var); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4541 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4542 if (fcn.is_function ()) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4543 { |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4544 octave_function *fp = fcn.function_value (); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4545 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4546 if (fp && fp->name () == var) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4547 extra_message |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4548 = " (note: variable '" + var + "' shadows function)"; |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4549 } |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4550 } |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4551 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29163
diff
changeset
|
4552 std::string msg = ie.message () + extra_message; |
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29163
diff
changeset
|
4553 |
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29163
diff
changeset
|
4554 error_with_id (ie.err_id (), "%s", msg.c_str ()); |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4555 } |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
4556 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
27001
diff
changeset
|
4557 octave_value |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
27001
diff
changeset
|
4558 tree_evaluator::do_who (int argc, const string_vector& argv, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
27001
diff
changeset
|
4559 bool return_list, bool verbose) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
27001
diff
changeset
|
4560 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
27001
diff
changeset
|
4561 return m_call_stack.do_who (argc, argv, return_list, verbose); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
27001
diff
changeset
|
4562 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
27001
diff
changeset
|
4563 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4564 octave_value_list |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4565 tree_evaluator::make_value_list (tree_argument_list *args, |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4566 const string_vector& arg_nm) |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4567 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4568 octave_value_list retval; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4569 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4570 if (args) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4571 { |
27373
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
4572 unwind_protect_var<const std::list<octave_lvalue> *> |
25627c524ad8
where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
4573 upv (m_lvalue_list, nullptr); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4574 |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4575 int len = args->length (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4576 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4577 unwind_protect_var<int> upv2 (m_index_position); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4578 unwind_protect_var<int> upv3 (m_num_indices); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4579 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4580 m_num_indices = len; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4581 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4582 std::list<octave_value> arg_vals; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4583 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4584 int k = 0; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4585 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4586 for (auto elt : *args) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4587 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4588 // FIXME: is it possible for elt to be invalid? |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4589 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4590 if (! elt) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4591 break; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4592 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4593 m_index_position = k++; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4594 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4595 octave_value tmp = elt->evaluate (*this); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4596 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4597 if (tmp.is_cs_list ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4598 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4599 octave_value_list tmp_ovl = tmp.list_value (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4600 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4601 for (octave_idx_type i = 0; i < tmp_ovl.length (); i++) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4602 arg_vals.push_back (tmp_ovl(i)); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4603 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4604 else if (tmp.is_defined ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4605 arg_vals.push_back (tmp); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4606 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4607 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4608 retval = octave_value_list (arg_vals); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4609 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4610 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4611 octave_idx_type n = retval.length (); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4612 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4613 if (n > 0) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4614 retval.stash_name_tags (arg_nm); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4615 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4616 return retval; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4617 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4618 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4619 std::list<octave_lvalue> |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4620 tree_evaluator::make_lvalue_list (tree_argument_list *lhs) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4621 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4622 std::list<octave_lvalue> retval; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4623 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4624 for (tree_expression *elt : *lhs) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4625 retval.push_back (elt->lvalue (*this)); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4626 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4627 return retval; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4628 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27370
diff
changeset
|
4629 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4630 void |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4631 tree_evaluator::push_echo_state (int type, const std::string& file_name, |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4632 int pos) |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4633 { |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4634 unwind_protect *frame = m_call_stack.curr_fcn_unwind_protect_frame (); |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4635 |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4636 if (frame) |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4637 { |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4638 push_echo_state_cleanup (*frame); |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4639 |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4640 set_echo_state (type, file_name, pos); |
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
4641 } |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4642 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4643 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4644 void |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4645 tree_evaluator::set_echo_state (int type, const std::string& file_name, |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4646 int pos) |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4647 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4648 m_echo_state = echo_this_file (file_name, type); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4649 m_echo_file_name = file_name; |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4650 m_echo_file_pos = pos; |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4651 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4652 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4653 void |
25653
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4654 tree_evaluator::uwp_set_echo_state (bool state, const std::string& file_name, |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4655 int pos) |
25653
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4656 { |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4657 m_echo_state = state; |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4658 m_echo_file_name = file_name; |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4659 m_echo_file_pos = pos; |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4660 } |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4661 |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
4662 void |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4663 tree_evaluator::maybe_set_echo_state (void) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4664 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
4665 octave_function *caller = caller_function (); |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4666 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4667 if (caller && caller->is_user_code ()) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4668 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4669 octave_user_code *fcn = dynamic_cast<octave_user_code *> (caller); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4670 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4671 int type = fcn->is_user_function () ? ECHO_FUNCTIONS : ECHO_SCRIPTS; |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4672 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4673 std::string file_name = fcn->fcn_file_name (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4674 |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4675 // We want the line where "echo" was called, not the line number |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4676 // stored in the stack frame that was created for the echo |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4677 // function (that will always be -1). |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4678 |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4679 int pos = m_call_stack.current_user_code_line (); |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4680 |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4681 if (pos < 0) |
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
4682 pos = 1; |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4683 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4684 set_echo_state (type, file_name, pos); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4685 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4686 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4687 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4688 void |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4689 tree_evaluator::push_echo_state_cleanup (unwind_protect& frame) |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4690 { |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
4691 frame.add (&tree_evaluator::uwp_set_echo_state, this, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29171
diff
changeset
|
4692 m_echo_state, m_echo_file_name, m_echo_file_pos); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4693 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4694 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4695 bool tree_evaluator::maybe_push_echo_state_cleanup (void) |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4696 { |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4697 // This function is expected to be called from ECHO, which would be |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4698 // the top of the call stack. If the caller of ECHO is a |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
4699 // user-defined function or script, then set up unwind-protect |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4700 // elements to restore echo state. |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4701 |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
4702 unwind_protect *frame = m_call_stack.curr_fcn_unwind_protect_frame (); |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
4703 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
4704 if (frame) |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4705 { |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
4706 push_echo_state_cleanup (*frame); |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
4707 return true; |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4708 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4709 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4710 return false; |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4711 } |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4712 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4713 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4714 octave_value |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4715 tree_evaluator::echo (const octave_value_list& args, int) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4716 { |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4717 bool cleanup_pushed = maybe_push_echo_state_cleanup (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4718 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4719 string_vector argv = args.make_argv (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4720 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4721 switch (args.length ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4722 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4723 case 0: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4724 if ((m_echo & ECHO_SCRIPTS) || (m_echo & ECHO_FUNCTIONS)) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4725 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4726 m_echo = ECHO_OFF; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4727 m_echo_files.clear (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4728 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4729 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4730 m_echo = ECHO_SCRIPTS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4731 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4732 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4733 case 1: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4734 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4735 std::string arg0 = argv[0]; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4736 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4737 if (arg0 == "on") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4738 m_echo = ECHO_SCRIPTS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4739 else if (arg0 == "off") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4740 m_echo = ECHO_OFF; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4741 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4742 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4743 std::string file = fcn_file_in_path (arg0); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4744 file = sys::env::make_absolute (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4745 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4746 if (file.empty ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4747 error ("echo: no such file %s", arg0.c_str ()); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4748 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4749 if (m_echo & ECHO_ALL) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4750 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4751 // Echo is enabled for all functions, so turn it off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4752 // for this one. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4753 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4754 m_echo_files[file] = false; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4755 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4756 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4757 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4758 // Echo may be enabled for specific functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4759 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4760 auto p = m_echo_files.find (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4761 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4762 if (p == m_echo_files.end ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4763 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4764 // Not this one, so enable it. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4765 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4766 m_echo |= ECHO_FUNCTIONS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4767 m_echo_files[file] = true; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4768 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4769 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4770 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4771 // This one is already in the list. Flip the |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4772 // status for it. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4773 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4774 p->second = ! p->second; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4775 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4776 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4777 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4778 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4779 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4780 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4781 case 2: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4782 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4783 std::string arg0 = argv[0]; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4784 std::string arg1 = argv[1]; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4785 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4786 if (arg1 == "on" || arg1 == "off") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4787 std::swap (arg0, arg1); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4788 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4789 if (arg0 == "on") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4790 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4791 if (arg1 == "all") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4792 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4793 m_echo = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_ALL); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4794 m_echo_files.clear (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4795 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4796 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4797 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4798 std::string file = fcn_file_in_path (arg1); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4799 file = sys::env::make_absolute (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4800 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4801 if (file.empty ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4802 error ("echo: no such file %s", arg1.c_str ()); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4803 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4804 m_echo |= ECHO_FUNCTIONS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4805 m_echo_files[file] = true; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4806 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4807 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4808 else if (arg0 == "off") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4809 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4810 if (arg1 == "all") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4811 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4812 m_echo = ECHO_OFF; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4813 m_echo_files.clear (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4814 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4815 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4816 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4817 std::string file = fcn_file_in_path (arg1); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4818 file = sys::env::make_absolute (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4819 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4820 if (file.empty ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4821 error ("echo: no such file %s", arg1.c_str ()); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4822 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4823 m_echo_files[file] = false; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4824 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4825 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4826 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4827 print_usage (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4828 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4829 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4830 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4831 default: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4832 print_usage (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4833 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4834 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4835 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4836 if (cleanup_pushed) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4837 maybe_set_echo_state (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
4838 |
23913
062ce545b21e
mark octave_value from octave_value_list constructor explicit
John W. Eaton <jwe@octave.org>
parents:
23876
diff
changeset
|
4839 return octave_value (); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4840 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4841 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4842 bool tree_evaluator::in_debug_repl (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4843 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4844 return (m_debugger_stack.empty () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4845 ? false : m_debugger_stack.top()->in_debug_repl ()); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4846 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4847 |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4848 void tree_evaluator::dbcont (void) |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4849 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4850 if (! m_debugger_stack.empty ()) |
27282
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4851 m_debugger_stack.top()->dbcont (); |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4852 } |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4853 |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4854 void tree_evaluator::dbquit (bool all) |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4855 { |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4856 if (! m_debugger_stack.empty ()) |
49c60d16866f
improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
4857 m_debugger_stack.top()->dbquit (all); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4858 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
4859 |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4860 static octave_value end_value (const octave_value& value, |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4861 octave_idx_type index_position, |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4862 octave_idx_type num_indices) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4863 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4864 dim_vector dv = value.dims (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4865 int ndims = dv.ndims (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4866 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4867 if (num_indices < ndims) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4868 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4869 for (int i = num_indices; i < ndims; i++) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4870 dv(num_indices-1) *= dv(i); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4871 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4872 if (num_indices == 1) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4873 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4874 ndims = 2; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4875 dv.resize (ndims); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4876 dv(1) = 1; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4877 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4878 else |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4879 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4880 ndims = num_indices; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4881 dv.resize (ndims); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4882 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4883 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4884 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4885 return (index_position < ndims |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4886 ? octave_value (dv(index_position)) : octave_value (1.0)); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4887 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4888 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4889 octave_value_list |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4890 tree_evaluator::evaluate_end_expression (const octave_value_list& args) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4891 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4892 int nargin = args.length (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4893 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4894 if (nargin != 0 && nargin != 3) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4895 print_usage (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4896 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4897 if (nargin == 3) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4898 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4899 octave_idx_type index_position |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4900 = args(1).xidx_type_value ("end: K must be integer value"); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4901 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4902 if (index_position < 1) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4903 error ("end: K must be greater than zero"); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4904 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4905 octave_idx_type num_indices |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4906 = args(2).xidx_type_value ("end: N must be integer value"); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4907 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4908 if (num_indices < 1) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4909 error ("end: N must be greater than zero"); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4910 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4911 return end_value (args(0), index_position-1, num_indices); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4912 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4913 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4914 // If m_indexed_object is undefined, then this use of 'end' is |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4915 // either appearing in a function call argument list or in an |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4916 // attempt to index an undefined symbol. There seems to be no |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4917 // reasonable way to provide a better error message. So just fail |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4918 // with an invalid use message. See bug #58830. |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4919 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4920 if (m_indexed_object.is_undefined ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4921 error ("invalid use of 'end': may only be used to index existing value"); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4922 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4923 octave_value expr_result; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4924 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4925 if (m_index_list.empty ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4926 expr_result = m_indexed_object; |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4927 else |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4928 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4929 try |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4930 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4931 // When evaluating "end" with no arguments, we should have |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4932 // been called from the built-in Fend function that appears |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4933 // in the context of an argument list. Fend will be |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4934 // evaluated in its own stack frame. But we need to |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4935 // evaluate the partial expression that the special "end" |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4936 // token applies to in the calling stack frame. |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4937 |
29572
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29527
diff
changeset
|
4938 unwind_action act ([=] (std::size_t frm) |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4939 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4940 m_call_stack.restore_frame (frm); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4941 }, m_call_stack.current_frame ()); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4942 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
4943 std::size_t n = m_call_stack.find_current_user_frame (); |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4944 m_call_stack.goto_frame (n); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4945 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4946 // End is only valid inside argument lists used for |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4947 // indexing. The dispatch class is set by the function that |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4948 // evaluates the argument list. |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4949 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4950 // Silently ignore extra output values. |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4951 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4952 octave_value_list tmp |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4953 = m_indexed_object.subsref (m_index_type, m_index_list, 1); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4954 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4955 expr_result = tmp.length () ? tmp(0) : octave_value (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4956 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4957 if (expr_result.is_cs_list ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4958 err_indexed_cs_list (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4959 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
4960 catch (const index_exception&) |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4961 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4962 error ("error evaluating partial expression for END"); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4963 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4964 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4965 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4966 if (expr_result.isobject ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4967 { |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4968 // FIXME: is there a better way to lookup and execute a method |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4969 // that handles all the details like setting the dispatch class |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4970 // appropriately? |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4971 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4972 std::string dispatch_class = expr_result.class_name (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4973 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4974 symbol_table& symtab = m_interpreter.get_symbol_table (); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4975 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4976 octave_value meth = symtab.find_method ("end", dispatch_class); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4977 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4978 if (meth.is_defined ()) |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4979 return m_interpreter.feval |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4980 (meth, ovl (expr_result, m_index_position+1, m_num_indices), 1); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4981 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4982 |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4983 return end_value (expr_result, m_index_position, m_num_indices); |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4984 } |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28726
diff
changeset
|
4985 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4986 octave_value |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4987 tree_evaluator::PS4 (const octave_value_list& args, int nargout) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4988 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4989 return set_internal_variable (m_PS4, args, nargout, "PS4"); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4990 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4991 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4992 bool tree_evaluator::echo_this_file (const std::string& file, int type) const |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4993 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4994 if ((type & m_echo) == ECHO_SCRIPTS) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4995 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4996 // Asking about scripts and echo is enabled for them. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4997 return true; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4998 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4999 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5000 if ((type & m_echo) == ECHO_FUNCTIONS) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5001 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5002 // Asking about functions and echo is enabled for functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5003 // Now, which ones? |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5004 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5005 auto p = m_echo_files.find (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5006 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5007 if (m_echo & ECHO_ALL) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5008 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5009 // Return true ulness echo was turned off for a specific |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5010 // file. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5011 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5012 return (p == m_echo_files.end () || p->second); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5013 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5014 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5015 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5016 // Return true if echo is specifically enabled for this file. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5017 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5018 return p != m_echo_files.end () && p->second; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5019 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5020 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5021 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5022 return false; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5023 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5024 |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
5025 void tree_evaluator::echo_code (int line) |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5026 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5027 std::string prefix = command_editor::decode_prompt_string (m_PS4); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5028 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
5029 octave_function *curr_fcn = m_call_stack.current_function (); |
23728
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5030 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5031 if (curr_fcn && curr_fcn->is_user_code ()) |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5032 { |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5033 octave_user_code *code = dynamic_cast<octave_user_code *> (curr_fcn); |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5034 |
29339
93530bb4bd6f
improve behavior of echo (bug #56068)
John W. Eaton <jwe@octave.org>
parents:
29307
diff
changeset
|
5035 int num_lines = line - m_echo_file_pos + 1; |
23728
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5036 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5037 std::deque<std::string> lines |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5038 = code->get_code_lines (m_echo_file_pos, num_lines); |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5039 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5040 for (auto& elt : lines) |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5041 octave_stdout << prefix << elt << std::endl; |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
5042 } |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5043 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
5044 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5045 // Decide if it's time to quit a for or while loop. |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5046 bool tree_evaluator::quit_loop_now (void) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5047 { |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5048 octave_quit (); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5049 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5050 // Maybe handle 'continue N' someday... |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5051 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5052 if (m_continuing) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5053 m_continuing--; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5054 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5055 bool quit = (m_returning || m_breaking || m_continuing); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5056 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5057 if (m_breaking) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5058 m_breaking--; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5059 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5060 return quit; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
5061 } |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5062 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5063 void tree_evaluator::bind_auto_fcn_vars (const string_vector& arg_names, |
28540
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
5064 const Matrix& ignored_outputs, |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5065 int nargin, int nargout, |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5066 bool takes_varargs, |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5067 const octave_value_list& va_args) |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5068 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5069 set_auto_fcn_var (stack_frame::ARG_NAMES, Cell (arg_names)); |
28540
ea5a632b2553
improve error checking for undefined function outputs (bug #58686, #58695)
John W. Eaton <jwe@octave.org>
parents:
28532
diff
changeset
|
5070 set_auto_fcn_var (stack_frame::IGNORED, ignored_outputs); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5071 set_auto_fcn_var (stack_frame::NARGIN, nargin); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5072 set_auto_fcn_var (stack_frame::NARGOUT, nargout); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5073 set_auto_fcn_var (stack_frame::SAVED_WARNING_STATES, octave_value ()); |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5074 |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5075 if (takes_varargs) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5076 assign ("varargin", va_args.cell_value ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5077 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
5078 |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5079 std::string |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5080 tree_evaluator::check_autoload_file (const std::string& nm) const |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5081 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5082 if (sys::env::absolute_pathname (nm)) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5083 return nm; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5084 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5085 std::string full_name = nm; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5086 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
5087 octave_user_code *fcn = m_call_stack.current_user_code (); |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5088 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5089 bool found = false; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5090 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5091 if (fcn) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5092 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5093 std::string fname = fcn->fcn_file_name (); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5094 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5095 if (! fname.empty ()) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5096 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5097 fname = sys::env::make_absolute (fname); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5098 fname = fname.substr (0, fname.find_last_of (sys::file_ops::dir_sep_str ()) + 1); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5099 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5100 sys::file_stat fs (fname + nm); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5101 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5102 if (fs.exists ()) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5103 { |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5104 full_name = fname + nm; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5105 found = true; |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5106 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5107 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5108 } |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5109 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5110 if (! found) |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5111 warning_with_id ("Octave:autoload-relative-file-name", |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5112 "autoload: '%s' is not an absolute filename", |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5113 nm.c_str ()); |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5114 |
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
5115 return full_name; |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
5116 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5117 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5118 DEFMETHOD (max_recursion_depth, interp, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5119 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5120 @deftypefn {} {@var{val} =} max_recursion_depth () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5121 @deftypefnx {} {@var{old_val} =} max_recursion_depth (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
5122 @deftypefnx {} {@var{old_val} =} max_recursion_depth (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5123 Query or set the internal limit on the number of times a function may |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5124 be called recursively. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5125 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5126 If the limit is exceeded, an error message is printed and control returns to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5127 the top level. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5128 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5129 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5130 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5131 The original variable value is restored when exiting the function. |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24738
diff
changeset
|
5132 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24738
diff
changeset
|
5133 @seealso{max_stack_depth} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5134 @end deftypefn */) |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
5135 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
5136 tree_evaluator& tw = interp.get_evaluator (); |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5137 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5138 return tw.max_recursion_depth (args, nargout); |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
5139 } |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
5140 |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5141 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5142 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5143 %! orig_val = max_recursion_depth (); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5144 %! old_val = max_recursion_depth (2*orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5145 %! assert (orig_val, old_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5146 %! assert (max_recursion_depth (), 2*orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5147 %! max_recursion_depth (orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5148 %! assert (max_recursion_depth (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
5149 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
5150 %!error max_recursion_depth (1, 2) |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5151 */ |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5152 |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5153 DEFMETHOD (whos_line_format, interp, args, nargout, |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5154 doc: /* -*- texinfo -*- |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5155 @deftypefn {} {@var{val} =} whos_line_format () |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5156 @deftypefnx {} {@var{old_val} =} whos_line_format (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
5157 @deftypefnx {} {@var{old_val} =} whos_line_format (@var{new_val}, "local") |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5158 Query or set the format string used by the command @code{whos}. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5159 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5160 A full format string is: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5161 @c Set example in small font to prevent overfull line |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5162 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5163 @smallexample |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5164 %[modifier]<command>[:width[:left-min[:balance]]]; |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5165 @end smallexample |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5166 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5167 The following command sequences are available: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5168 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5169 @table @code |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5170 @item %a |
29856
56b3e2af0298
Add 's'=sparse attribute for whos function (bug #60687)
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
5171 Prints attributes of variables (c=complex, s=sparse, f=formal parameter, |
56b3e2af0298
Add 's'=sparse attribute for whos function (bug #60687)
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
5172 g=global, p=persistent). |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5173 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5174 @item %b |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5175 Prints number of bytes occupied by variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5176 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5177 @item %c |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5178 Prints class names of variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5179 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5180 @item %e |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5181 Prints elements held by variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5182 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5183 @item %n |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5184 Prints variable names. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5185 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5186 @item %s |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5187 Prints dimensions of variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5188 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5189 @item %t |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5190 Prints type names of variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5191 @end table |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5192 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5193 Every command may also have an alignment modifier: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5194 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5195 @table @code |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5196 @item l |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5197 Left alignment. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5198 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5199 @item r |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5200 Right alignment (default). |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5201 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5202 @item c |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5203 Column-aligned (only applicable to command %s). |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5204 @end table |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5205 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5206 The @code{width} parameter is a positive integer specifying the minimum |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5207 number of columns used for printing. No maximum is needed as the field will |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5208 auto-expand as required. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5209 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5210 The parameters @code{left-min} and @code{balance} are only available when |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5211 the column-aligned modifier is used with the command @samp{%s}. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5212 @code{balance} specifies the column number within the field width which |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5213 will be aligned between entries. Numbering starts from 0 which indicates |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5214 the leftmost column. @code{left-min} specifies the minimum field width to |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5215 the left of the specified balance column. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5216 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5217 The default format is: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5218 |
29856
56b3e2af0298
Add 's'=sparse attribute for whos function (bug #60687)
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
5219 @example |
56b3e2af0298
Add 's'=sparse attribute for whos function (bug #60687)
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
5220 " %la:5; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;@backslashchar{}n" |
56b3e2af0298
Add 's'=sparse attribute for whos function (bug #60687)
Rik <rik@octave.org>
parents:
29848
diff
changeset
|
5221 @end example |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5222 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5223 When called from inside a function with the @qcode{"local"} option, the |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5224 variable is changed locally for the function and any subroutines it calls. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5225 The original variable value is restored when exiting the function. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5226 @seealso{whos} |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5227 @end deftypefn */) |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5228 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
5229 tree_evaluator& tw = interp.get_evaluator (); |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5230 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5231 return tw.whos_line_format (args, nargout); |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5232 } |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
5233 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5234 DEFMETHOD (silent_functions, interp, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5235 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5236 @deftypefn {} {@var{val} =} silent_functions () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5237 @deftypefnx {} {@var{old_val} =} silent_functions (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
5238 @deftypefnx {} {@var{old_val} =} silent_functions (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5239 Query or set the internal variable that controls whether internal |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5240 output from a function is suppressed. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5241 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5242 If this option is disabled, Octave will display the results produced by |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5243 evaluating expressions within a function body that are not terminated with |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5244 a semicolon. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5245 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5246 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5247 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5248 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
5249 @end deftypefn */) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5250 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
5251 tree_evaluator& tw = interp.get_evaluator (); |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5252 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
5253 return tw.silent_functions (args, nargout); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5254 } |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5255 |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5256 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5257 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5258 %! orig_val = silent_functions (); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5259 %! old_val = silent_functions (! orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5260 %! assert (orig_val, old_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5261 %! assert (silent_functions (), ! orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5262 %! silent_functions (orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5263 %! assert (silent_functions (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
5264 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
5265 %!error silent_functions (1, 2) |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
5266 */ |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5267 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5268 DEFMETHOD (string_fill_char, interp, args, nargout, |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5269 doc: /* -*- texinfo -*- |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5270 @deftypefn {} {@var{val} =} string_fill_char () |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5271 @deftypefnx {} {@var{old_val} =} string_fill_char (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
5272 @deftypefnx {} {@var{old_val} =} string_fill_char (@var{new_val}, "local") |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5273 Query or set the internal variable used to pad all rows of a character |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5274 matrix to the same length. |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5275 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5276 The value must be a single character and the default is @qcode{" "} (a |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5277 single space). For example: |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5278 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5279 @example |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5280 @group |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5281 string_fill_char ("X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5282 [ "these"; "are"; "strings" ] |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5283 @result{} "theseXX" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5284 "areXXXX" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5285 "strings" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5286 @end group |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5287 @end example |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5288 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5289 When called from inside a function with the @qcode{"local"} option, the |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5290 variable is changed locally for the function and any subroutines it calls. |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5291 The original variable value is restored when exiting the function. |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5292 @end deftypefn */) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5293 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
5294 tree_evaluator& tw = interp.get_evaluator (); |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5295 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5296 return tw.string_fill_char (args, nargout); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5297 } |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5298 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5299 /* |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5300 ## string_fill_char() function call must be outside of %!test block |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5301 ## due to the way a %!test block is wrapped inside a function |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5302 %!shared orig_val, old_val |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5303 %! orig_val = string_fill_char (); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5304 %! old_val = string_fill_char ("X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5305 %!test |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5306 %! assert (orig_val, old_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5307 %! assert (string_fill_char (), "X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5308 %! assert (["these"; "are"; "strings"], ["theseXX"; "areXXXX"; "strings"]); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5309 %! string_fill_char (orig_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5310 %! assert (string_fill_char (), orig_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5311 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5312 %!assert ( [ [], {1} ], {1} ) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5313 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
5314 %!error string_fill_char (1, 2) |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
5315 */ |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5316 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5317 DEFMETHOD (PS4, interp, args, nargout, |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5318 doc: /* -*- texinfo -*- |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5319 @deftypefn {} {@var{val} =} PS4 () |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5320 @deftypefnx {} {@var{old_val} =} PS4 (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
5321 @deftypefnx {} {@var{old_val} =} PS4 (@var{new_val}, "local") |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5322 Query or set the character string used to prefix output produced |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5323 when echoing commands is enabled. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5324 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5325 The default value is @qcode{"+ "}. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5326 @xref{Diary and Echo Commands}, for a description of echoing commands. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5327 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5328 When called from inside a function with the @qcode{"local"} option, the |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5329 variable is changed locally for the function and any subroutines it calls. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5330 The original variable value is restored when exiting the function. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5331 @seealso{echo, PS1, PS2} |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5332 @end deftypefn */) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5333 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
5334 tree_evaluator& tw = interp.get_evaluator (); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5335 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5336 return tw.PS4 (args, nargout); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5337 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5338 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5339 DEFMETHOD (echo, interp, args, nargout, |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5340 doc: /* -*- texinfo -*- |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5341 @deftypefn {} {} echo |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5342 @deftypefnx {} {} echo on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5343 @deftypefnx {} {} echo off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5344 @deftypefnx {} {} echo on all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5345 @deftypefnx {} {} echo off all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5346 @deftypefnx {} {} echo @var{function} on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5347 @deftypefnx {} {} echo @var{function} off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5348 Control whether commands are displayed as they are executed. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5349 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5350 Valid options are: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5351 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5352 @table @code |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5353 @item on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5354 Enable echoing of commands as they are executed in script files. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5355 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5356 @item off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5357 Disable echoing of commands as they are executed in script files. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5358 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5359 @item on all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5360 Enable echoing of commands as they are executed in script files and |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5361 functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5362 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5363 @item off all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5364 Disable echoing of commands as they are executed in script files and |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5365 functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5366 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5367 @item @var{function} on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5368 Enable echoing of commands as they are executed in the named function. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5369 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5370 @item @var{function} off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5371 Disable echoing of commands as they are executed in the named function. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5372 @end table |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5373 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5374 @noindent |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5375 With no arguments, @code{echo} toggles the current echo state. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5376 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5377 @seealso{PS4} |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5378 @end deftypefn */) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5379 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
5380 tree_evaluator& tw = interp.get_evaluator (); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5381 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5382 return tw.echo (args, nargout); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5383 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5384 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5385 /* |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5386 %!error echo ([]) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5387 %!error echo (0) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5388 %!error echo ("") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5389 %!error echo ("Octave") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5390 %!error echo ("off", "invalid") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5391 %!error echo ("on", "invalid") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5392 %!error echo ("on", "all", "all") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
5393 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29956
diff
changeset
|
5394 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29956
diff
changeset
|
5395 OCTAVE_NAMESPACE_END |