annotate libinterp/parse-tree/pt-eval.cc @ 27373:25627c524ad8

where possible, use new unwind-protect classes in evaluator Files affected: pt-assign.cc, pt-cell.cc, pt-eval.cc, and pt-idx.cc.
author John W. Eaton <jwe@octave.org>
date Wed, 04 Sep 2019 12:17:50 -0400
parents fcaecdbc8d8a
children d171d356767b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26179
diff changeset
3 Copyright (C) 2009-2019 John W. Eaton
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22703
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22703
diff changeset
10 (at your option) any later version.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22703
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22703
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22703
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22703
diff changeset
15 GNU General Public License for more details.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
19 <https://www.gnu.org/licenses/>.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21542
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21211
diff changeset
24 # include "config.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include <cctype>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <iostream>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25407
diff changeset
30 #include <list>
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25407
diff changeset
31 #include <string>
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
33 #include "cmd-edit.h"
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
34 #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
35 #include "file-stat.h"
27100
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
36 #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
37 #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
38
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23110
diff changeset
39 #include "bp-table.h"
22091
0f6fc2ec3b1a move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
40 #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
41 #include "cdef-manager.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include "defun.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #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
44 #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
45 #include "event-manager.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 #include "input.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
47 #include "interpreter-private.h"
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 22091
diff changeset
48 #include "interpreter.h"
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
49 #include "octave.h"
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26718
diff changeset
50 #include "ov-classdef.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 #include "ov-fcn-handle.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 #include "ov-usr-fcn.h"
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
53 #include "ov-re-sparse.h"
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
54 #include "ov-cx-sparse.h"
26686
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26662
diff changeset
55 #include "parse.h"
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
56 #include "profiler.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 #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
58 #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
59 #include "pt-eval.h"
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
60 #include "pt-tm-const.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 #include "symtab.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 #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
63 #include "utils.h"
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
64 #include "variables.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
14899
f25d2224fa02 Initial JIT support
Max Brister <max@2bass.com>
parents: 14429
diff changeset
66 //FIXME: This should be part of tree_evaluator
f25d2224fa02 Initial JIT support
Max Brister <max@2bass.com>
parents: 14429
diff changeset
67 #include "pt-jit.h"
15310
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15244
diff changeset
68
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
69 namespace octave
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 {
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
71 // Normal evaluator.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
73 class quit_debug_exception
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
74 {
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
75 public:
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
76
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
77 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
78
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
79 quit_debug_exception (const quit_debug_exception&) = default;
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
80
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
81 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
82
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
83 ~quit_debug_exception (void) = default;
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
84
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
85 bool all (void) const { return m_all; }
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
86
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
87 private:
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
88
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
89 bool m_all;
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
90 };
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
91
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
92 class debugger
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
93 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
94 public:
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
95
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
96 enum execution_mode
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
97 {
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
98 EX_NORMAL = 0,
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
99 EX_CONTINUE = 1,
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
100 EX_QUIT = 2,
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
101 EX_QUIT_ALL = 3
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
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
104 debugger (interpreter& interp, size_t level)
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
105 : m_interpreter (interp), m_level (level), m_debug_frame (0),
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
106 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
107 { }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
108
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
109 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
110
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
111 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
112
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
113 void dbcont (void)
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
114 {
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
115 m_execution_mode = EX_CONTINUE;
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
116 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
117
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
118 void dbquit (bool all = false)
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
119 {
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
120 if (all)
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
121 m_execution_mode = EX_QUIT_ALL;
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
122 else
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
123 m_execution_mode = EX_QUIT;
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
124 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
125
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
126 private:
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
127
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
128 interpreter& m_interpreter;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
129
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
130 size_t m_level;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
131 size_t m_debug_frame;
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
132 execution_mode m_execution_mode;
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
133 bool m_in_debug_repl;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
134 };
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
135
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
136 void debugger::repl (const std::string& prompt)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
137 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
138 unwind_protect frame;
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 frame.protect_var (m_in_debug_repl);
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
141 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
142
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
143 m_in_debug_repl = true;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
144
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
145 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
146
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
147 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
148
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
149 frame.add_method (tw, &tree_evaluator::restore_frame,
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
150 tw.current_call_stack_frame_number ());
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
151
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
152 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
153
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
154 octave_user_code *caller = tw.current_user_code ();
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
155 std::string nm;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
156
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
157 if (caller)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
158 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
159 nm = caller->fcn_file_name ();
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
160
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
161 if (nm.empty ())
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
162 nm = caller->name ();
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
163 }
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
164
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
165 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
166
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
167 std::ostringstream buf;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
168
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
169 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
170
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
171 if (! nm.empty ())
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
172 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
173 if (input_sys.gud_mode ())
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
174 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
175 static char ctrl_z = 'Z' & 0x1f;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
176
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
177 buf << ctrl_z << ctrl_z << nm << ':' << curr_debug_line;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
178 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
179 else
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
180 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
181 // 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
182 // 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
183 // end of a function or script.
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
184
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
185 if (! silent)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
186 {
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
187 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
188
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
189 frm->display_stopped_in_message (buf);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
190 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
191
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
192 event_manager& evmgr = m_interpreter.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
193
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
194 evmgr.enter_debugger_event (nm, curr_debug_line);
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
195
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
196 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
197
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
198 frame.add ([nm, curr_debug_line] (event_manager& ol) {
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27240
diff changeset
199 ol.execute_in_debugger_event (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
200 }, std::ref (evmgr));
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
201
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
202 if (! silent)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
203 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
204 std::string line_buf;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
205
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
206 if (caller)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
207 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
208
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
209 if (! line_buf.empty ())
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
210 buf << curr_debug_line << ": " << line_buf;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
211 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
212 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
213 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
214
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
215 if (silent)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
216 command_editor::erase_empty_line (true);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
217
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
218 std::string msg = buf.str ();
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
219
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
220 if (! msg.empty ())
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
221 std::cerr << msg << std::endl;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
222
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
223 std::string tmp_prompt = prompt;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
224 if (m_level > 0)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
225 tmp_prompt = "[" + std::to_string (m_level) + "]" + prompt;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
226
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
227 frame.add_method (input_sys, &input_system::set_PS1, input_sys.PS1 ());
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
228 input_sys.PS1 (tmp_prompt);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
229
27301
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
230 if (! m_interpreter.interactive ())
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
231 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
232
27301
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
233 frame.add_method (m_interpreter, &interpreter::interactive,
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
234 m_interpreter.interactive ());
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
235
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
236 m_interpreter.interactive (true);
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
237
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
238 // FIXME: should debugging be possible in an embedded
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
239 // interpreter?
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
240
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
241 application *app = application::app ();
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
242
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
243 if (app)
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
244 {
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
245 frame.add_method (app, &application::forced_interactive,
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
246 app->forced_interactive ());
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
247
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
248 app->forced_interactive (true);
a2b1ba6c92d5 eliminate unnecessary application::interative function
John W. Eaton <jwe@octave.org>
parents: 27290
diff changeset
249 }
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
250 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
251
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
252 parser curr_parser (m_interpreter);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
253
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
254 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
255
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
256 while (m_in_debug_repl)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
257 {
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
258 if (m_execution_mode == EX_CONTINUE || tw.dbstep_flag ())
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
259 break;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
260
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
261 if (m_execution_mode == EX_QUIT)
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
262 {
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
263 // If there is no enclosing debug level or the top-level
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
264 // repl is not active, handle dbquit the same as dbcont.
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
265
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
266 if (m_level > 0 || tw.in_top_level_repl ())
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
267 throw quit_debug_exception ();
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
268 else
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
269 break;
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
270 }
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
271
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
272 if (m_execution_mode == EX_QUIT_ALL)
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
273 {
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
274 // If the top-level repl is not active, handle "dbquit all"
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
275 // the same as dbcont.
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
276
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
277 if (tw.in_top_level_repl ())
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
278 throw quit_debug_exception (true);
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
279 else
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
280 break;
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
281 }
27240
336c640c481b make "dbquit all" work and fix dbquit compatibility (bug #56616)
John W. Eaton <jwe@octave.org>
parents: 27234
diff changeset
282
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
283 try
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
284 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
285 Vtrack_line_num = false;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
286
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
287 es.reset ();
27037
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 curr_parser.reset ();
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
290
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
291 int retval = curr_parser.run ();
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
292
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
293 if (command_editor::interrupt (false))
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
294 break;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
295 else
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 if (retval == 0 && curr_parser.m_stmt_list)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
298 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
299 curr_parser.m_stmt_list->accept (tw);
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 if (octave_completion_matches_called)
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
302 octave_completion_matches_called = false;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
303
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
304 // FIXME: the following statement is here because
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
305 // the last command may have been a dbup, dbdown, or
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
306 // dbstep command that changed the current debug
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
307 // frame. If so, we need to reset the current frame
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
308 // for the call stack. But is this right way to do
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
309 // this job? What if the statement list was
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
310 // something like "dbup; dbstack"? Will the call to
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
311 // dbstack use the right frame? If not, how can we
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
312 // fix this problem?
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
313 tw.goto_frame (tw.debug_frame ());
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
314 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
315
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
316 octave_quit ();
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
317 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
318 }
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
319 catch (const execution_exception& ee)
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
320 {
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
321 std::string stack_trace = ee.info ();
27037
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 if (! stack_trace.empty ())
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
324 std::cerr << stack_trace;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
325
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
326 // Ignore errors when in debugging mode;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
327 interpreter::recover_from_exception ();
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
328 }
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
329 catch (const quit_debug_exception& qde)
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
330 {
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
331 if (qde.all ())
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
332 throw;
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
333
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
334 // Continue in this debug level.
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
335 }
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
336 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
337 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
338
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
339 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
340 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
341 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
342 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
343
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
344 int tree_evaluator::repl (bool interactive)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
345 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
346 int retval = 0;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
347
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
348 // The parser takes ownership of the lexer and will delete it when
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
349 // the parser goes out of scope.
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
350
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
351 parser repl_parser (interactive
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
352 ? new lexer (m_interpreter)
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
353 : new lexer (stdin, m_interpreter));
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
354
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
355 error_system& es = m_interpreter.get_error_system ();
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
356
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
357 do
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
358 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
359 try
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
360 {
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
361 unwind_protect_var<bool> upv (m_in_top_level_repl, true);
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
362
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
363 es.reset ();
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
364
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
365 repl_parser.reset ();
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
366
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
367 if (at_top_level ())
27290
9b053ba971b2 reset m_dbstep_flag at top level in main evaluator REPL (bug #56625)
John W. Eaton <jwe@octave.org>
parents: 27289
diff changeset
368 {
9b053ba971b2 reset m_dbstep_flag at top level in main evaluator REPL (bug #56625)
John W. Eaton <jwe@octave.org>
parents: 27289
diff changeset
369 m_dbstep_flag = 0;
9b053ba971b2 reset m_dbstep_flag at top level in main evaluator REPL (bug #56625)
John W. Eaton <jwe@octave.org>
parents: 27289
diff changeset
370 reset_debug_state ();
9b053ba971b2 reset m_dbstep_flag at top level in main evaluator REPL (bug #56625)
John W. Eaton <jwe@octave.org>
parents: 27289
diff changeset
371 }
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
372
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
373 retval = repl_parser.run ();
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
374
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
375 if (retval == 0)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
376 {
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
377 if (repl_parser.m_stmt_list)
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
378 {
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
379 repl_parser.m_stmt_list->accept (*this);
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
380
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
381 octave_quit ();
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
382
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
383 if (! interactive)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
384 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
385 bool quit = (m_returning || m_breaking);
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
386
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
387 if (m_returning)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
388 m_returning = 0;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
389
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
390 if (m_breaking)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
391 m_breaking--;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
392
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
393 if (quit)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
394 break;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
395 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
396
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
397 if (octave_completion_matches_called)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
398 octave_completion_matches_called = false;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
399 else
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
400 command_editor::increment_current_command_number ();
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
401 }
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
402 else if (repl_parser.m_lexer.m_end_of_input)
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
403 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
404 retval = EOF;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
405 break;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
406 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
407 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
408 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
409 catch (const interrupt_exception&)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
410 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
411 m_interpreter.recover_from_exception ();
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
412
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
413 // Required newline when the user does Ctrl+C at the prompt.
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
414 if (interactive)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
415 octave_stdout << "\n";
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
416 }
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
417 catch (const quit_debug_exception&)
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
418 {
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
419 m_interpreter.recover_from_exception ();
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
420 }
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
421 catch (const index_exception& e)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
422 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
423 m_interpreter.recover_from_exception ();
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
424
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
425 std::cerr << "error: unhandled index exception: "
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
426 << e.message () << " -- trying to return to prompt"
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
427 << std::endl;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
428 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
429 catch (const execution_exception& e)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
430 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
431 std::string stack_trace = e.info ();
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
432
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
433 if (! stack_trace.empty ())
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
434 std::cerr << stack_trace;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
435
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
436 if (interactive)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
437 m_interpreter.recover_from_exception ();
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
438 else
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
439 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
440 // We should exit with a nonzero status.
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
441 retval = 1;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
442 break;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
443 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
444 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
445 catch (const std::bad_alloc&)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
446 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
447 m_interpreter.recover_from_exception ();
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
448
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
449 std::cerr << "error: out of memory -- trying to return to prompt"
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
450 << std::endl;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
451 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
452
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
453 #if defined (DBSTOP_NANINF)
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
454 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
455
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
456 if (es.debug_on_naninf ())
25404
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
457 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
458 if (setjump (naninf_jump) != 0)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
459 debug_or_throw_exception (true); // true = stack trace
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
460 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
461 #endif
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
462 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
463 while (retval == 0);
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
464
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
465 if (retval == EOF)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
466 {
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
467 if (interactive)
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
468 octave_stdout << "\n";
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
469
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
470 retval = 0;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
471 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
472
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
473 return retval;
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
474 }
e37d857716c3 move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents: 25403
diff changeset
475
27015
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
476 std::string
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
477 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
478 {
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
479 std::string fname;
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
480
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
481 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
482
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
483 if (fcn)
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
484 {
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
485 fname = fcn->fcn_file_name ();
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
486
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
487 if (fname.empty ())
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
488 fname = fcn->name ();
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
489 }
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
490
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
491 if (opt == "fullpathext")
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
492 return fname;
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
493
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
494 size_t dpos = fname.rfind (sys::file_ops::dir_sep_char ());
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
495 size_t epos = fname.rfind ('.');
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
496
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
497 if (epos <= dpos+1)
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
498 epos = std::string::npos;
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
499
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
500 if (epos != std::string::npos)
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
501 fname = fname.substr (0, epos);
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
502
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
503 if (opt == "fullpath")
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
504 return fname;
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
505
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
506 if (dpos != std::string::npos)
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
507 fname = fname.substr (dpos+1);
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
508
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
509 return fname;
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
510 }
4d9e1a832a55 move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27014
diff changeset
511
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
512 octave_value_list
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
513 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
514 int& parse_status, int nargout)
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
515 {
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
516 octave_value_list retval;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
517
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
518 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
519
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
520 do
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
521 {
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
522 eval_parser.reset ();
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
523
26662
05fc703b419a update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
524 // 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
525 //
05fc703b419a update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
526 // val = eval ("code");
05fc703b419a update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
527 //
05fc703b419a update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
528 // 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
529
05fc703b419a update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
530 if (nargout > 0)
05fc703b419a update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
531 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
532
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
533 parse_status = eval_parser.run ();
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
534
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
535 if (parse_status == 0)
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
536 {
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
537 if (eval_parser.m_stmt_list)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
538 {
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
539 tree_statement *stmt = nullptr;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
540
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
541 if (eval_parser.m_stmt_list->length () == 1
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
542 && (stmt = eval_parser.m_stmt_list->front ())
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
543 && stmt->is_expression ())
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
544 {
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
545 tree_expression *expr = stmt->expression ();
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
546
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
547 if (silent)
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
548 expr->set_print_flag (false);
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
549
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
550 retval = std::move (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
551
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
552 bool do_bind_ans = false;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
553
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
554 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
555 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
556 else
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
557 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
558
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
559 if (do_bind_ans && ! retval.empty ())
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
560 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
561
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
562 if (nargout == 0)
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
563 retval = octave_value_list ();
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
564 }
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
565 else if (nargout == 0)
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
566 eval_parser.m_stmt_list->accept (*this);
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
567 else
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
568 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
569
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
570 if (returning () || breaking () || continuing ())
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
571 break;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
572 }
26512
4d6392c879d7 avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents: 26509
diff changeset
573 else if (eval_parser.m_lexer.m_end_of_input)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
574 break;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
575 }
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
576 }
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
577 while (parse_status == 0);
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
578
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
579 return retval;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
580 }
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
581
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
582 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
583 bool silent, int& parse_status)
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
584 {
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
585 octave_value retval;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
586
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
587 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
588
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
589 if (! tmp.empty ())
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
590 retval = tmp(0);
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
591
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
592 return retval;
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
593 }
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
594
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
595 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
596 bool silent, int& parse_status,
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
597 int nargout)
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
598 {
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
599 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
600
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
601 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
602 }
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
603
27019
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
604 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
605 int nargout)
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
606 {
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
607 int parse_status = 0;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
608
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
609 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
610 }
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
611
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
612 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
613 const std::string& catch_code,
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
614 int nargout)
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
615 {
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
616 octave_value_list retval;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
617
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
618 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
619
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
620 int bem = es.buffer_error_messages ();
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
621 unwind_action act ([&es, bem] (void)
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
622 {
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
623 es.buffer_error_messages (bem);
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
624 });
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
625 es.buffer_error_messages (bem + 1);
27019
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
626
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
627 int parse_status = 0;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
628
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
629 bool execution_error = false;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
630
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
631 octave_value_list tmp;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
632
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
633 try
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
634 {
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
635 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
636 }
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
637 catch (const execution_exception&)
27019
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
638 {
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
639 interpreter::recover_from_exception ();
27019
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
640
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
641 execution_error = true;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
642 }
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
643
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
644 if (parse_status != 0 || execution_error)
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
645 {
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
646 // Set up for letting the user print any messages from
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
647 // errors that occurred in the first part of this eval().
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
648
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
649 es.buffer_error_messages (es.buffer_error_messages () - 1);
27019
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
650
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
651 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
652
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
653 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
654 }
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
655 else
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
656 {
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
657 if (nargout > 0)
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
658 retval = tmp;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
659
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
660 // 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
661 // exception occurred, not just throwing an
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
662 // execution exception.
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
663 if (execution_error)
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
664 octave_throw_execution_exception ();
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
665 }
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
666
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
667 return retval;
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
668 }
6cb675912f2b move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27018
diff changeset
669
27018
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
670 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
671 const std::string& try_code,
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
672 int nargout)
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
673 {
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
674 unwind_action act ([this] (size_t frm)
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
675 {
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
676 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
677 }, m_call_stack.current_frame ());
27018
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
678
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
679 if (context == "caller")
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
680 m_call_stack.goto_caller_frame ();
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
681 else if (context == "base")
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
682 m_call_stack.goto_base_frame ();
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
683 else
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
684 error ("evalin: CONTEXT must be \"caller\" or \"base\"");
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
685
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
686 int parse_status = 0;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
687
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
688 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
689 }
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
690
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
691 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
692 const std::string& try_code,
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
693 const std::string& catch_code,
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
694 int nargout)
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
695 {
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
696 octave_value_list retval;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
697
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
698 unwind_action act1 ([this] (size_t frm)
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
699 {
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
700 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
701 }, m_call_stack.current_frame ());
27018
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
702
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
703 if (context == "caller")
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
704 m_call_stack.goto_caller_frame ();
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
705 else if (context == "base")
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
706 m_call_stack.goto_base_frame ();
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
707 else
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
708 error ("evalin: CONTEXT must be \"caller\" or \"base\"");
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
709
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
710 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
711
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
712 int bem = es.buffer_error_messages ();
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
713 unwind_action act2 ([&es, bem] (void)
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
714 {
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
715 es.buffer_error_messages (bem);
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
716 });
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
717 es.buffer_error_messages (bem + 1);
27018
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
718
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
719 int parse_status = 0;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
720
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
721 bool execution_error = false;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
722
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
723 octave_value_list tmp;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
724
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
725 try
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
726 {
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
727 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
728 }
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
729 catch (const execution_exception&)
27018
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
730 {
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
731 interpreter::recover_from_exception ();
27018
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
732
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
733 execution_error = true;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
734 }
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
735
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
736 if (parse_status != 0 || execution_error)
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
737 {
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
738 // Set up for letting the user print any messages from
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
739 // errors that occurred in the first part of this eval().
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
740
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
741 es.buffer_error_messages (es.buffer_error_messages () - 1);
27018
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
742
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
743 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
744
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
745 retval = (nargout > 0) ? tmp : octave_value_list ();
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
746 }
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
747 else
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
748 {
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
749 if (nargout > 0)
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
750 retval = tmp;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
751
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
752 // 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
753 // exception occurred, not just throwing an
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
754 // execution exception.
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
755 if (execution_error)
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
756 octave_throw_execution_exception ();
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
757 }
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
758
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
759 return retval;
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
760 }
a20ead51515d move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27017
diff changeset
761
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
762 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
763 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
764 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
765 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
766 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
767
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
768 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
769 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
770 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
771 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
772 }
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
773
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
774 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
775 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
776 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
777 panic_impossible ();
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
778 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
779
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
780 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
781 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
782 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
783 panic_impossible ();
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
784 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
785
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
786 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
787 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
788 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
789 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
790 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
791
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
792 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
793 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
794 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
795 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
796 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
797 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
798 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
799 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
800 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
801
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
802 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
803 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
804
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
805 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
806 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
807 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
808 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
809 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
810
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
811 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
812 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
813 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
814 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
815 }
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
816
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
817 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
818 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
819 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
820 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
821 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
822 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
823 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
824 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
825 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
826
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
827 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
828 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
829
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
830 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
831 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
832 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
833
23705
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
834 bool
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
835 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
836 {
25401
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
837 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
838 || 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
839 }
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
840
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
841 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
842 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
843 {
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
844 m_debug_mode = (m_bp_table.have_breakpoints () || m_dbstep_flag != 0
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
845 || in_debug_repl ());
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
846 }
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
847
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
848 void
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
849 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
850 {
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
851 m_debug_mode = mode;
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
852 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
853
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
854 void
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
855 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
856 {
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
857 unwind_protect frame;
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
858
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
859 frame.add_fcn (command_history::ignore_entries,
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
860 command_history::ignoring_entries ());
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
861
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
862 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
863
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27100
diff changeset
864 frame.add_method (m_call_stack, &call_stack::restore_frame,
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
865 m_call_stack.current_frame ());
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
866
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
867 // 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
868 // 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
869
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
870 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
871
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
872 frame.add_method (es, &error_system::set_debug_on_error,
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
873 es.debug_on_error ());
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
874
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
875 frame.add_method (es, &error_system::set_debug_on_warning,
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
876 es.debug_on_warning ());
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
877
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
878 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
879 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
880
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
881 // 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
882
9dcbc0a449af correctly set debug_frame when using "keyboard" (bug #56625)
John W. Eaton <jwe@octave.org>
parents: 27286
diff changeset
883 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
884
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
885 // 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
886 // 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
887 //
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
888 // tree_print_code tpc (octave_stdout);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
889 // stmt.accept (tpc);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
890
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
891 Vtrack_line_num = false;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
892
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
893 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
894
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
895 m_debugger_stack.push (dbgr);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
896
27222
f5b967060442 ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents: 27212
diff changeset
897 frame.add ([this] (void)
f5b967060442 ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents: 27212
diff changeset
898 {
f5b967060442 ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents: 27212
diff changeset
899 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
900 m_debugger_stack.pop ();
f5b967060442 ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents: 27212
diff changeset
901 });
f5b967060442 ensure debuger_stack is popped when exiting a debug level (bug #56150)
John W. Eaton <jwe@octave.org>
parents: 27212
diff changeset
902
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
903 dbgr->repl (prompt);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
904 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
905
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
906 void
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
907 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
908 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
909 enter_debugger (prompt);
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
910 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
911
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
912 void
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
913 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
914 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
915 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
916 }
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
917
23481
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
918 Matrix
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
919 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
920 {
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
921 Matrix retval;
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
922
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
923 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
924
4ced2bfd737e deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents: 24270
diff changeset
925 if (! lvalues)
23482
c9937e865768 make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents: 23481
diff changeset
926 return retval;
c9937e865768 make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents: 23481
diff changeset
927
23481
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
928 octave_idx_type nbh = 0;
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
929
24349
4ced2bfd737e deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents: 24270
diff changeset
930 for (const auto& lval : *lvalues)
23481
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
931 nbh += lval.is_black_hole ();
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
932
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
933 if (nbh > 0)
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
934 {
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
935 retval.resize (1, nbh);
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
936
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
937 octave_idx_type k = 0;
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
938 octave_idx_type l = 0;
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
939
24349
4ced2bfd737e deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents: 24270
diff changeset
940 for (const auto& lval : *lvalues)
23481
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
941 {
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
942 if (lval.is_black_hole ())
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
943 retval(l++) = k+1;
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
944
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
945 k += lval.numel ();
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
946 }
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
947 }
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
948
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
949 return retval;
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
950 }
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
951
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
952 octave_value
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
953 tree_evaluator::evaluate (tree_decl_elt *elt)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
954 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
955 // Do not allow functions to return null values.
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
956
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
957 tree_identifier *id = elt->ident ();
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
958
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
959 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
960 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
961
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
962 bool
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
963 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
964 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
965 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
966
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
967 return frame.is_variable (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
968 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
969
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
970 bool
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
971 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
972 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
973 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
974
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
975 return frame.is_local_variable (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
976 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
977
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
978 bool
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
979 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
980 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
981 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
982 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
983 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
984 = 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
985
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
986 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
987 return false;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
988
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
989 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
990 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
991
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
992 return false;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
993 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
994
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
995 bool
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
996 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
997 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
998 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
999 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1000 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
1001 = 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
1002
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1003 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
1004 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1005
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1006 return false;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1007 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1008
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1009 bool
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1010 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
1011 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1012 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1013
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1014 return frame.is_variable (sym);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1015 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1016
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1017 bool
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1018 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
1019 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1020 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1021
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1022 return frame.is_defined (sym);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1023 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1024
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1025 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
1026 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1027 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1028
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1029 return frame.is_global (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1030 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1031
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1032 octave_value
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1033 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
1034 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1035 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1036
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1037 return frame.varval (sym);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1038 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1039
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1040 octave_value
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1041 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
1042 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1043 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1044
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1045 return frame.varval (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1046 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1047
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1048 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
1049 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
1050 bool global)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1051 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1052 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1053
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1054 return frame.install_variable (name, value, global);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1055 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1056
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1057 octave_value
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1058 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
1059 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1060 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
1061 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1062
27211
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1063 octave_value&
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1064 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
1065 {
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1066 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
1067 }
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1068
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1069 void
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1070 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
1071 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
1072 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1073 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
1074 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1075
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1076 octave_value
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1077 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
1078 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1079 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
1080 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1081
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1082 void
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1083 tree_evaluator::top_level_assign (const std::string& name,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1084 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
1085 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1086 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
1087 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1088
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1089 void
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1090 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
1091 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1092 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1093
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1094 frame.assign (name, val);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1095 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1096
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1097 void
27014
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1098 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
1099 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
1100 {
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1101 // FIXME: Can this be done without an unwind-protect frame, simply
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1102 // by geting a reference to the caller or base stack frame and
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1103 // calling assign on that?
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1104
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
1105 unwind_action act ([this] (size_t frm)
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
1106 {
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
1107 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
1108 }, m_call_stack.current_frame ());
27014
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1109
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1110 if (context == "caller")
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1111 m_call_stack.goto_caller_frame ();
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1112 else if (context == "base")
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1113 m_call_stack.goto_base_frame ();
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1114 else
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1115 error ("assignin: CONTEXT must be \"caller\" or \"base\"");
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1116
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1117 if (valid_identifier (name))
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1118 {
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1119 // 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
1120 // 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
1121 // already been checked.
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1122
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1123 if (iskeyword (name))
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1124 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
1125 name.c_str ());
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1126
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1127 assign (name, val);
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1128 }
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1129 else
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1130 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
1131 }
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1132
daab1b311a98 move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents: 27005
diff changeset
1133 void
27017
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1134 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
1135 const std::string& context,
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1136 bool verbose, bool require_file,
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1137 const std::string& warn_for)
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1138 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1139 // 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
1140 // 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
1141 // 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
1142 // written as
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1143 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1144 // foo1.m:
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1145 // ------
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1146 // foo2
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1147 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1148 // foo2.m:
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1149 // ------
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1150 // foo1
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1151 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1152 // and called with
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1153 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1154 // foo1
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1155 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1156 // (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
1157 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1158 // foo1.m:
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1159 // ------
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1160 // source ("foo2.m")
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1161 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1162 // foo2.m:
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1163 // ------
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1164 // source ("foo1.m")
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1165 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1166 // and called with
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1167 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1168 // source ("foo1.m")
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1169 //
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1170 // (for example).
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1171
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1172 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
1173
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1174 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
1175 = 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
1176
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1177 size_t pos
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1178 = 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
1179
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1180 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
1181
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1182 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
1183
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1184 unwind_protect frame;
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1185
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1186 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
1187 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
1188
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1189 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
1190
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1191 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
1192
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1193 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
1194 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
1195
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1196 if (! context.empty ())
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1197 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1198 frame.add_method (m_call_stack, &call_stack::restore_frame,
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1199 m_call_stack.current_frame ());
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1200
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1201 if (context == "caller")
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1202 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
1203 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
1204 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
1205 else
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1206 error ("source: context must be \"caller\" or \"base\"");
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1207 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1208
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1209 // Find symbol name that would be in symbol_table, if it were loaded.
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1210 size_t dir_end
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1211 = 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
1212 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
1213
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1214 size_t extension = file_name.find_last_of ('.');
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1215 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
1216 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
1217
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1218 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
1219 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
1220
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1221 // 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
1222 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
1223 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
1224
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1225 // 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
1226 // functions.
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1227
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1228 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
1229 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1230 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
1231
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1232 if (! code
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1233 || (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
1234 != full_name))
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1235 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1236 // 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
1237 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
1238 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1239 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1240 else
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1241 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1242 // 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
1243 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
1244 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1245
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1246 // 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
1247 // file, load.
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1248
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1249 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
1250 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1251 try
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1252 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1253 ov_code = m_interpreter.parse_fcn_file (file_full_name, file_name,
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1254 dir_name, "", "",
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1255 require_file, true, false,
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1256 false, warn_for);
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1257 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1258 catch (execution_exception& e)
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1259 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1260 error (e, "source: error sourcing file '%s'",
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1261 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
1262 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1263 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1264
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1265 // 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
1266
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1267 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
1268 return;
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1269
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1270 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
1271 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
1272
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1273 if (verbose)
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1274 {
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1275 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
1276 octave_stdout.flush ();
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1277 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1278
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1279 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
1280
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1281 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
1282
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1283 if (verbose)
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1284 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
1285 }
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1286
24b7e6326e26 move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1287 void
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1288 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
1289 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
1290 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1291 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
1292 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1293
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1294 octave_value
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1295 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
1296 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1297 return m_call_stack.get_auto_fcn_var (avt);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1298 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1299
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1300 void
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1301 tree_evaluator::define_parameter_list_from_arg_vector
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1302 (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
1303 {
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1304 int i = -1;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1305
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
1306 for (tree_decl_elt *elt : *param_list)
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1307 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1308 i++;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1309
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
1310 octave_lvalue ref = elt->lvalue (*this);
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1311
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1312 if (i < args.length ())
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1313 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1314 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
1315 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1316 if (! eval_decl_elt (elt))
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1317 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
1318 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1319 else
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1320 ref.define (args(i));
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1321 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1322 else
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1323 eval_decl_elt (elt);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1324 }
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1325 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1326
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
1327 void
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1328 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
1329 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
1330 for (tree_decl_elt *elt : *param_list)
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1331 {
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
1332 octave_lvalue ref = elt->lvalue (*this);
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1333
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1334 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
1335 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1336 }
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1337 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1338
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1339 // END is documented in op-kw-docs.
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1340 DEFCONSTMETHOD (end, interp, , ,
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1341 doc: /* -*- texinfo -*-
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1342 @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
1343 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
1344 @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
1345 @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
1346
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1347 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
1348 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
1349
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1350 Example:
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1351
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1352 @example
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1353 @group
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1354 @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
1355 @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
1356 @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
1357 @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
1358 @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
1359 @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
1360 @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
1361 @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
1362 @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
1363 @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
1364 @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
1365 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1366 octave_value retval;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1367
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1368 octave::tree_evaluator& tw = interp.get_evaluator ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1369
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1370 const octave_value *indexed_object = tw.indexed_object ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1371 int index_position = tw.index_position ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1372 int num_indices = tw.num_indices ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1373
27100
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1374 // Return invalid index value instead of throwing an error so that we
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1375 // will see an error about the object that is indexed rather than
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1376 // "end" being used incorrectly.
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1377 if (! indexed_object)
27100
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1378 return ovl (octave_NaN);
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1379
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1380 if (indexed_object->isobject ())
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1381 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1382 octave_value_list args;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1383
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1384 args(2) = num_indices;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1385 args(1) = index_position + 1;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1386 args(0) = *indexed_object;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1387
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1388 std::string class_name = indexed_object->class_name ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1389
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1390 octave::symbol_table& symtab = interp.get_symbol_table ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1391
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1392 octave_value meth = symtab.find_method ("end", class_name);
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1393
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1394 if (meth.is_defined ())
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1395 return octave::feval (meth.function_value (), args, 1);
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1396 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1397
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1398 dim_vector dv = indexed_object->dims ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1399 int ndims = dv.ndims ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1400
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1401 if (num_indices < ndims)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1402 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1403 for (int i = num_indices; i < ndims; i++)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1404 dv(num_indices-1) *= dv(i);
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1405
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1406 if (num_indices == 1)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1407 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1408 ndims = 2;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1409 dv.resize (ndims);
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1410 dv(1) = 1;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1411 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1412 else
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1413 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1414 ndims = num_indices;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1415 dv.resize (ndims);
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1416 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1417 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1418
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1419 if (index_position < ndims)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1420 retval = dv(index_position);
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1421 else
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1422 retval = 1;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1423
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1424 return retval;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1425 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1426
27100
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1427 /*
27123
dc89c9b30f3c update bug status for tests
John W. Eaton <jwe@octave.org>
parents: 27102
diff changeset
1428 %!test <*33637>
27100
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1429 %! fail ("__undef_sym__ (end)", "'__undef_sym__' undefined");
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1430 */
b453b586da16 improve error message when indexing undefined object with "end" (bug #33637)
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
1431
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1432 namespace octave
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1433 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1434 octave_value_list
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1435 tree_evaluator::convert_to_const_vector (tree_argument_list *arg_list,
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1436 const octave_value *object)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1437 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1438 // END doesn't make sense as a direct argument for a function (i.e.,
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1439 // "fcn (end)" is invalid but "fcn (array (end))" is OK). Maybe we
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1440 // need a different way of asking an octave_value object this
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1441 // question?
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1442
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1443 bool stash_object = (arg_list->includes_magic_end ()
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1444 && object
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1445 && ! (object->is_function ()
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1446 || object->is_function_handle ()));
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1447
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
1448 unwind_protect_var<const octave_value *> upv1 (m_indexed_object);
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
1449 unwind_protect_var<int> upv2 (m_index_position);
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
1450 unwind_protect_var<int> upv3 (m_num_indices);
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1451
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1452 if (stash_object)
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
1453 m_indexed_object = object;
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1454
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1455 int len = arg_list->length ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1456
27353
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1457 std::list<octave_value> 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
1458
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1459 auto p = arg_list->begin ();
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1460 for (int k = 0; k < len; k++)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1461 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1462 if (stash_object)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1463 {
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1464 m_index_position = k;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1465 m_num_indices = len;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1466 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1467
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1468 tree_expression *elt = *p++;
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1469
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1470 if (elt)
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1471 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
1472 octave_value tmp = std::move (elt->evaluate (*this));
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1473
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1474 if (tmp.is_cs_list ())
27353
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1475 {
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1476 octave_value_list tmp_ovl = tmp.list_value ();
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1477
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1478 for (octave_idx_type i = 0; i < tmp_ovl.length (); i++)
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1479 args.push_back (tmp_ovl(i));
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1480 }
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1481 else if (tmp.is_defined ())
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1482 args.push_back (tmp);
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1483 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1484 else
27353
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1485 break;
25382
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1486 }
749d9e858553 move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25381
diff changeset
1487
27353
8db55255c9d1 improve convert_to_const_vector
John W. Eaton <jwe@octave.org>
parents: 27349
diff changeset
1488 return octave_value_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
1489 }
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1490
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1491 octave_value_list
23916
85488effc0ff refactor function value return code
John W. Eaton <jwe@octave.org>
parents: 23913
diff changeset
1492 tree_evaluator::convert_return_list_to_const_vector
85488effc0ff refactor function value return code
John W. Eaton <jwe@octave.org>
parents: 23913
diff changeset
1493 (tree_parameter_list *ret_list, int nargout, const Cell& varargout)
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1494 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1495 octave_idx_type vlen = varargout.numel ();
23916
85488effc0ff refactor function value return code
John W. Eaton <jwe@octave.org>
parents: 23913
diff changeset
1496 int len = ret_list->length ();
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1497
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1498 // Special case. Will do a shallow copy.
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1499 if (len == 0)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1500 return varargout;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1501 else if (nargout <= len)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1502 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1503 octave_value_list retval (nargout);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1504
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1505 int i = 0;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1506
23916
85488effc0ff refactor function value return code
John W. Eaton <jwe@octave.org>
parents: 23913
diff changeset
1507 for (tree_decl_elt *elt : *ret_list)
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1508 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1509 if (is_defined (elt->ident ()))
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
1510 retval(i) = std::move (evaluate (elt));
23916
85488effc0ff refactor function value return code
John W. Eaton <jwe@octave.org>
parents: 23913
diff changeset
1511
85488effc0ff refactor function value return code
John W. Eaton <jwe@octave.org>
parents: 23913
diff changeset
1512 i++;
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1513 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1514
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1515 return retval;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1516 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1517 else
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1518 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1519 octave_value_list retval (len + vlen);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1520
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1521 int i = 0;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1522
23916
85488effc0ff refactor function value return code
John W. Eaton <jwe@octave.org>
parents: 23913
diff changeset
1523 for (tree_decl_elt *elt : *ret_list)
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
1524 retval(i++) = std::move (evaluate (elt));
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1525
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1526 for (octave_idx_type j = 0; j < vlen; j++)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1527 retval(i++) = varargout(j);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1528
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1529 return retval;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1530 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1531 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1532
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1533 bool
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1534 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
1535 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1536 bool retval = false;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1537
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1538 tree_identifier *id = elt->ident ();
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1539 tree_expression *expr = elt->expression ();
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1540
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1541 if (id && expr)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1542 {
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
1543 octave_lvalue ult = id->lvalue (*this);
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1544
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
1545 octave_value init_val = std::move (expr->evaluate (*this));
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1546
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1547 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
1548
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1549 retval = true;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1550 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1551
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1552 return retval;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1553 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1554
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1555 bool
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1556 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
1557 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
1558 {
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1559 tree_expression *label = expr->case_label ();
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1560
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
1561 octave_value label_value = std::move (label->evaluate (*this));
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1562
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1563 if (label_value.is_defined ())
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1564 {
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23563
diff changeset
1565 if (label_value.iscell ())
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1566 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1567 Cell cell (label_value.cell_value ());
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1568
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1569 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
1570 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1571 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
1572 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1573 bool match = val.is_equal (cell(i,j));
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1574
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1575 if (match)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1576 return true;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1577 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1578 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1579 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1580 else
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1581 return val.is_equal (label_value);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1582 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1583
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1584 return false;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1585 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
1586
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
1587 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
1588 {
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1589 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
1590 }
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1591
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1592 void tree_evaluator::push_stack_frame (octave_user_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
1593 unwind_protect *up_frame,
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1594 stack_frame *closure_frames)
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1595 {
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1596 m_call_stack.push (fcn, up_frame, closure_frames);
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1597 }
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1598
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1599 void tree_evaluator::push_stack_frame (octave_user_script *script,
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1600 unwind_protect *up_frame)
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1601 {
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1602 m_call_stack.push (script, up_frame);
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1603 }
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1604
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1605 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
1606 {
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1607 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
1608 }
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1609
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1610 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
1611 {
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1612 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
1613 }
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1614
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1615 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
1616 {
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1617 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
1618 }
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1619
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1620 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
1621 {
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1622 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
1623 }
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1624
27205
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1625 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
1626 {
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1627 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
1628 }
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1629
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1630 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
1631 {
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1632 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
1633 }
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1634
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1635 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
1636 {
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1637 stack_frame *frm = m_call_stack.current_user_frame ();
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1638
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1639 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
1640 }
6648d1ae05fe eliminate direct access to call stack in debug functions
John W. Eaton <jwe@octave.org>
parents: 27204
diff changeset
1641
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1642 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
1643 {
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1644 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
1645 }
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1646
27204
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1647 unwind_protect * tree_evaluator::curr_fcn_unwind_protect_frame (void) const
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1648 {
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1649 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
1650 }
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1651
27202
23962b243bad eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents: 27201
diff changeset
1652 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
1653 {
23962b243bad eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents: 27201
diff changeset
1654 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
1655 }
23962b243bad eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents: 27201
diff changeset
1656
27201
bd49997051ef eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents: 27200
diff changeset
1657 octave_function * tree_evaluator::current_function (void) const
bd49997051ef eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents: 27200
diff changeset
1658 {
bd49997051ef eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents: 27200
diff changeset
1659 return m_call_stack.current ();
bd49997051ef eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents: 27200
diff changeset
1660 }
bd49997051ef eliminate direct access to call stack in defun functions
John W. Eaton <jwe@octave.org>
parents: 27200
diff changeset
1661
27204
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1662 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
1663 {
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1664 return m_call_stack.caller ();
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1665 }
9a3e92d02a03 eliminate direct access to call stack in variables functions
John W. Eaton <jwe@octave.org>
parents: 27203
diff changeset
1666
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1667 bool tree_evaluator::goto_frame (size_t n, bool verbose)
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1668 {
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1669 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
1670 }
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1671
27206
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27205
diff changeset
1672 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
1673 {
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27205
diff changeset
1674 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
1675 }
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27205
diff changeset
1676
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27205
diff changeset
1677 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
1678 {
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27205
diff changeset
1679 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
1680 }
4e4a9d7b436e eliminate direct access to call stack in mex functions
John W. Eaton <jwe@octave.org>
parents: 27205
diff changeset
1681
27200
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1682 void tree_evaluator::restore_frame (size_t n)
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1683 {
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1684 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
1685 }
dc1edf932248 eliminate direct access to call_stack in input functions
John W. Eaton <jwe@octave.org>
parents: 27199
diff changeset
1686
27208
5b40cf4896f0 eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
1687 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
1688 {
5b40cf4896f0 eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
1689 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
1690 }
5b40cf4896f0 eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
1691
5b40cf4896f0 eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
1692 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
1693 {
5b40cf4896f0 eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
1694 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
1695 }
5b40cf4896f0 eliminate some direct access to call stack in classdef and inline objects
John W. Eaton <jwe@octave.org>
parents: 27206
diff changeset
1696
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
1697 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
1698 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
1699 {
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1700 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
1701 }
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1702
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1703 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
1704 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
1705 {
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1706 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
1707 }
bd684aad1821 eliminate some direct access to call stack in legacy class and function objects
John W. Eaton <jwe@octave.org>
parents: 27208
diff changeset
1708
27199
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1709 std::list<stack_frame *>
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1710 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
1711 {
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1712 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
1713 }
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1714
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1715 std::list<stack_frame *>
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1716 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
1717 {
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1718 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
1719 }
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1720
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1721 octave_map
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1722 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
1723 bool print_subfn) const
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1724 {
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1725 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
1726 }
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1727
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1728 octave_map tree_evaluator::backtrace (void)
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1729 {
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1730 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
1731 }
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1732
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1733 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
1734 {
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1735 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
1736 }
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
1737
27001
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1738 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
1739 {
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1740 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
1741
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1742 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
1743 }
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1744
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1745 void tree_evaluator::pop_scope (void)
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1746 {
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1747 m_call_stack.pop ();
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1748 }
3cea1cfb37d3 move toward limiting direct access of call stack
John W. Eaton <jwe@octave.org>
parents: 26975
diff changeset
1749
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1750 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
1751 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1752 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
1753 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1754
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1755 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
1756 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1757 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
1758 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1759
27212
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1760 void tree_evaluator::mlock (void) const
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1761 {
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1762 octave_function *fcn = m_call_stack.current ();
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1763
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1764 if (! fcn)
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1765 error ("mlock: invalid use outside a function");
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1766
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1767 fcn->lock ();
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1768 }
f84c5528e932 eliminate direct access to call stack in interpreter::mlock
John W. Eaton <jwe@octave.org>
parents: 27211
diff changeset
1769
27211
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1770 octave_value
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1771 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
1772 {
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1773 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
1774 }
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1775
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1776 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
1777 {
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1778 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
1779 }
8c27802a76c4 store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents: 27210
diff changeset
1780
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1781 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
1782 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1783 const stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1784
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1785 octave_value val = frame.varval (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1786
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1787 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
1788 return val;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1789
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1790 // 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
1791 // 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
1792 // 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
1793
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1794 octave_value fcn = frame.find_subfunction (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1795
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1796 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
1797 return fcn;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1798
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1799 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
1800
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1801 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
1802 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1803
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1804 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
1805 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1806 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1807
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1808 frame.clear_objects ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1809 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1810
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1811 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
1812 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1813 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1814
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1815 frame.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
1816 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1817
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1818 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
1819 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1820 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1821
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1822 frame.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
1823 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1824
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1825 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
1826 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1827 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1828
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1829 frame.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
1830 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1831
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1832 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
1833 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1834 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1835
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1836 frame.clear_variables ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1837 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1838
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1839 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
1840 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1841 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
1842 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1843
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1844 void
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1845 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
1846 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1847 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
1848 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1849
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1850 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
1851 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1852 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
1853 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1854
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1855 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
1856 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1857 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
1858 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1859
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1860 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
1861 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1862 // 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
1863
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1864 clear_variables ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1865 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
1866
24037
21915520ac7b use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents: 23916
diff changeset
1867 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
1868
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1869 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
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 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
1873 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1874 // 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
1875
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1876 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
1877
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1878 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
1879
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1880 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
1881 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1882
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1883 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
1884 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1885 // 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
1886
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1887 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
1888
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1889 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
1890
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1891 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
1892 }
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 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
1895 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1896 // 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
1897
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1898 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
1899
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1900 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
1901
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1902 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
1903 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1904
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1905 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
1906 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1907 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
1908 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1909
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1910 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
1911 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1912 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
1913 }
21915520ac7b use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents: 23916
diff changeset
1914
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1915 // 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
1916 // 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
1917 // current call stack.
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1918
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1919 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
1920 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
1921 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
1922 {
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1923 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
1924
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1925 if (fname.empty ())
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1926 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
1927 else
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1928 {
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1929 std::string name = fname;
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1930
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1931 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
1932 {
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1933 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
1934 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
1935 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
1936 }
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1937
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1938 size_t name_len = name.length ();
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1939
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1940 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
1941 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
1942
26065
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1943 if (name.empty ())
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1944 return nullptr;
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1945
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
1946 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
1947
26065
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1948 octave_value fcn;
26975
de826e69a5ea make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents: 26924
diff changeset
1949 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
1950
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1951 if (name[0] == '@')
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1952 {
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1953 size_t p1 = name.find (sys::file_ops::dir_sep_char (), 1);
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1954
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1955 if (p1 == std::string::npos)
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1956 return nullptr;
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1957
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1958 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
1959
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1960 p2 = name.find ('>', p1);
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1961
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1962 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
1963
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1964 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
1965 }
26975
de826e69a5ea make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents: 26924
diff changeset
1966 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
1967 {
de826e69a5ea make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents: 26924
diff changeset
1968 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
1969
de826e69a5ea make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents: 26924
diff changeset
1970 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
1971
de826e69a5ea make breakpoints in classdef methods work (bug #45404, bug #46451)
John W. Eaton <jwe@octave.org>
parents: 26924
diff changeset
1972 // 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
1973 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
1974 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
1975 }
26065
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1976 else
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1977 {
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1978 p2 = name.find ('>');
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1979
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1980 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
1981
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1982 fcn = symtab.find_function (main_fcn);
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1983 }
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1984
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1985 // List of function names sub1>sub2>...
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1986 std::string subfuns;
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1987
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1988 if (p2 != std::string::npos)
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1989 subfuns = name.substr (p2+1);
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1990
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
1991 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
1992 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
1993
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1994 if (! user_code || subfuns.empty ())
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1995 return user_code;
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1996
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1997 fcn = user_code->find_subfunction (subfuns);
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
1998
27178
e3b2d4e442c4 improve message for setting breakpoint in nonexistent function (bug #56157)
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
1999 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
2000 return nullptr;
e3b2d4e442c4 improve message for setting breakpoint in nonexistent function (bug #56157)
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2001
26065
2eb71b83d3e2 partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents: 26039
diff changeset
2002 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
2003 }
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
2004
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
2005 return user_code;
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
2006 }
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
2007
27199
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2008 std::string
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2009 tree_evaluator::current_function_name (void) const
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2010 {
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2011 octave_function *curfcn = m_call_stack.current ();
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2012
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2013 if (curfcn)
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2014 return curfcn->name ();
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2015
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2016 return "";
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2017 }
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2018
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2019 bool
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2020 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
2021 {
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2022 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
2023 }
f27002104c5b eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents: 27179
diff changeset
2024
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2025 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
2026 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
2027 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2028 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
2029 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2030 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2031 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
2032 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
2033 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2034
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2035 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
2036 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
2037
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2038 // 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
2039 // 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
2040
23469
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2041 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
2042
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2043 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
2044 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
2045 }
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2046
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2047 void
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2048 tree_evaluator::visit_decl_init_list (tree_decl_init_list& lst)
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2049 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2050 // FIXME: tree_decl_elt 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
2051 // 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
2052
23469
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2053 for (tree_decl_elt *elt : lst)
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2054 elt->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
2055 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2056
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2057 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
2058 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
2059 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
2060 tree_identifier *id = elt.ident ();
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2061
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2062 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
2063 {
23469
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2064 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
2065 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
2066 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
2067 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
2068 else
2699c5974844 handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents: 23458
diff changeset
2069 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
2070
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
2071 octave_lvalue ult = id->lvalue (*this);
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2072
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2073 if (ult.is_undefined ())
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2074 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
2075 tree_expression *expr = elt.expression ();
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2076
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2077 octave_value init_val;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2078
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2079 if (expr)
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2080 init_val = std::move (expr->evaluate (*this));
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2081 else
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2082 init_val = Matrix ();
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2083
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2084 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
2085 }
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2086 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2087 }
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24690
diff changeset
2088
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2089 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2090 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
2091 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2092 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2093
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2094 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
2095 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2096 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
2097 line++;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2098 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2099
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2100 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
2101 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
2102
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2103 // 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
2104 // and cmd.maxproc_expr ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2105
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
2106 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
2107
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2108 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
2109
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2110 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
2111
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
2112 #if defined (HAVE_LLVM)
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2113 if (tree_jit::execute (cmd, rhs))
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2114 return;
15027
741d2dbcc117 Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents: 15023
diff changeset
2115 #endif
741d2dbcc117 Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents: 15023
diff changeset
2116
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2117 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
2118 return;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2119
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2120 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
2121
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
2122 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
2123
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2124 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
2125
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2126 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
2127 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2128 Range rng = rhs.range_value ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2129
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2130 octave_idx_type steps = rng.numel ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2131
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2132 for (octave_idx_type i = 0; 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
2133 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2134 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
2135 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
2136
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2137 octave_value val (rng.elem (i));
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2138
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2139 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
2140
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2141 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
2142 loop_body->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2143
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2144 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
2145 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2146 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2147 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2148 else if (rhs.is_scalar_type ())
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2149 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2150 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
2151 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
2152
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2153 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
2154
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2155 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
2156 loop_body->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2157
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2158 // 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
2159 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
2160 }
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23563
diff changeset
2161 else if (rhs.is_matrix_type () || rhs.iscell () || rhs.is_string ()
23584
7ed6b258db91 maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents: 23577
diff changeset
2162 || 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
2163 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2164 // 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
2165 // columns.
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2166
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2167 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
2168
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2169 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
2170 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
2171
23514
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2172 octave_value arg = rhs;
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2173 if (rhs.ndims () > 2)
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2174 arg = arg.reshape (dv);
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2175
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2176 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
2177 {
23514
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2178 octave_value_list idx;
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2179 octave_idx_type iidx;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2180
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2181 // 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
2182 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
2183 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2184 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
2185 iidx = 0;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2186 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2187 else
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2188 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2189 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
2190 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
2191 iidx = 1;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2192 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2193
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2194 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
2195 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2196 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
2197 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
2198
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2199 // do_index_op expects one-based indices.
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2200 idx(iidx) = i;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2201 octave_value val = arg.do_index_op (idx);
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2202
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2203 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
2204
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2205 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
2206 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
2207
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2208 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
2209 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2210 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2211 }
23514
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2212 else
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2213 {
fd7a16594614 Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents: 23503
diff changeset
2214 // 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
2215 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
2216 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2217 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2218 else
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2219 error ("invalid type in for loop expression 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
2220 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
2221 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2222
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2223 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2224 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
2225 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2226 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2227
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2228 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
2229 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2230 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
2231 line++;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2232 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2233
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2234 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
2235 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
2236
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
2237 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
2238
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2239 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
2240
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2241 octave_value rhs = std::move (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
2242
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2243 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
2244 return;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2245
23584
7ed6b258db91 maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents: 23577
diff changeset
2246 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
2247 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
2248
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2249 // 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
2250 // 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
2251 // structure element.
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2252
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2253 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
2254
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
2255 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
2256
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2257 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
2258
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
2259 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
2260
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2261 elt = *p;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2262
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
2263 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
2264
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2265 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
2266
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2267 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
2268
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2269 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
2270
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2271 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
2272
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2273 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
2274 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2275 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
2276 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
2277
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2278 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
2279
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2280 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
2281
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2282 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
2283
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2284 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
2285
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2286 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
2287 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
2288
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2289 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
2290 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
2291
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2292 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
2293 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2294 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2295 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2296
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2297 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2298 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
2299 {
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2300 // ??
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2301 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2302 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2303
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2304 octave_value_list
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2305 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
2306 int nargout,
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2307 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
2308 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2309 octave_value_list retval;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2310
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2311 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
2312
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2313 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
2314 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
2315
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2316 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
2317
25401
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2318 if (! cmd_list)
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2319 return retval;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2320
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2321 unwind_protect frame;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2322
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2323 if (m_call_stack.size () >= static_cast<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
2324 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
2325
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2326 m_call_stack.push (&user_script, &frame);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2327
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2328 // Set pointer to the current unwind_protect frame to allow
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2329 // certain builtins register simple cleanup in a very optimized manner.
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2330 // This is *not* intended as a general-purpose on-cleanup mechanism,
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2331
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2332 frame.add_method (m_call_stack, &call_stack::pop);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2333
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2334 // Update line number even if debugging.
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2335 frame.protect_var (Vtrack_line_num);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2336 Vtrack_line_num = true;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2337
25401
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2338 frame.protect_var (m_statement_context);
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2339 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
2340
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2341 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
2342
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2343 if (echo ())
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2344 push_echo_state (frame, tree_evaluator::ECHO_SCRIPTS, file_name);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2345
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2346 cmd_list->accept (*this);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2347
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2348 if (m_returning)
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2349 m_returning = 0;
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2350
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2351 if (m_breaking)
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2352 m_breaking--;
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2353
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2354 return retval;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2355 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2356
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2357 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2358 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
2359 {
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2360 // ??
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2361 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2362 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2363
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2364 octave_value_list
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2365 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
2366 int nargout,
26825
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2367 const octave_value_list& xargs,
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2368 stack_frame *closure_frames)
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2369 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2370 octave_value_list retval;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2371
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2372 tree_statement_list *cmd_list = user_function.body ();
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2373
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2374 if (! cmd_list)
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2375 return retval;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2376
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2377 // 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
2378 // 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
2379
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2380 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
2381 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
2382
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2383 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
2384 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2385 if (args.length () > 0)
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2386 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2387 ret_args = args.slice (0, 1, true);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2388 args = args.slice (1, args.length () - 1, true);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2389 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2390 else
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2391 panic_impossible ();
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2392 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2393
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2394 #if defined (HAVE_LLVM)
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2395 if (user_function.is_special_expr ()
26004
94fecd437d9c * pt-eval.cc: Fix call to JIT evaluate function.
John W. Eaton <jwe@octave.org>
parents: 25789
diff changeset
2396 && tree_jit::execute (user_function, args, retval))
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2397 return retval;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2398 #endif
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2399
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2400 unwind_protect frame;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2401
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2402 if (m_call_stack.size () >= static_cast<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
2403 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
2404
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2405 // Save old and set current symbol table context, for
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2406 // eval_undefined_error().
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2407
26825
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2408 m_call_stack.push (&user_function, &frame, closure_frames);
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2409
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2410 frame.protect_var (Vtrack_line_num);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2411 // update source line numbers, even if debugging
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2412 Vtrack_line_num = true;
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2413
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2414 frame.add_method (m_call_stack, &call_stack::pop);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2415
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2416 bind_auto_fcn_vars (xargs.name_tags (), args.length (),
26039
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
2417 nargout, user_function.takes_varargs (),
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
2418 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
2419
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2420 if (user_function.is_anonymous_function ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2421 init_local_fcn_vars (user_function);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2422
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2423 tree_parameter_list *param_list = user_function.parameter_list ();
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2424
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2425 if (param_list && ! param_list->varargs_only ())
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2426 define_parameter_list_from_arg_vector (param_list, args);
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2427
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2428 // 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
2429 // 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
2430
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2431 tree_parameter_list *ret_list = user_function.return_list ();
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2432
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2433 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
2434 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2435 if (! ret_list)
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2436 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
2437 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
2438
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2439 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
2440 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2441
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2442 // Force parameter list to be undefined when this function exits.
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2443 // Doing so decrements the reference counts on the values of local
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2444 // variables that are also named function parameters.
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2445
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2446 // if (param_list)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2447 // frame.add_method (this, &tree_evaluator::undefine_parameter_list,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2448 // param_list);
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2449
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2450 // Force return list to be undefined when this function exits.
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2451 // Doing so decrements the reference counts on the values of local
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2452 // variables that are also named values returned by this function.
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2453
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2454 // if (ret_list)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2455 // frame.add_method (this, &tree_evaluator::undefine_parameter_list,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2456 // ret_list);
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2457
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2458 frame.add_method (&user_function,
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2459 &octave_user_function::restore_warning_states);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2460
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2461 // 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
2462
25401
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2463 frame.protect_var (m_statement_context);
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2464 m_statement_context = SC_FUNCTION;
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2465
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2466 frame.add_method (m_call_stack, &call_stack::clear_current_frame_values);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2467
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2468 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2469 profiler::enter<octave_user_function> block (m_profiler, user_function);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2470
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2471 if (echo ())
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2472 push_echo_state (frame, tree_evaluator::ECHO_FUNCTIONS,
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2473 user_function.fcn_file_name ());
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2474
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2475 if (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
2476 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2477 assert (cmd_list->length () == 1);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2478
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2479 tree_statement *stmt = cmd_list->front ();
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2480
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2481 tree_expression *expr = stmt->expression ();
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2482
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2483 if (expr)
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2484 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2485 m_call_stack.set_location (stmt->line (), stmt->column ());
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2486
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2487 retval = std::move (expr->evaluate_n (*this, nargout));
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2488 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2489 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2490 else
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2491 cmd_list->accept (*this);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2492 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2493
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2494 if (m_returning)
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2495 m_returning = 0;
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2496
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2497 if (m_breaking)
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2498 m_breaking--;
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2499
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2500 // Copy return values out.
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2501
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2502 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
2503 {
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2504 Cell varargout;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2505
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2506 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
2507 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2508 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
2509
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2510 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
2511 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
2512 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2513
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2514 retval = convert_return_list_to_const_vector (ret_list, nargout,
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2515 varargout);
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2516 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2517
26825
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2518 if (user_function.is_nested_function ()
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2519 || user_function.is_parent_function ())
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2520 {
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2521 // Copy current stack frame to handles to nested functions.
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2522
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2523 for (octave_idx_type i = 0; i < retval.length (); i++)
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2524 {
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2525 octave_value val = retval(i);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2526
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2527 if (val.is_function_handle ())
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2528 {
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2529 octave_fcn_handle *fh = val.fcn_handle_value ();
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2530
26847
8bd9fd99c12a lazily evaluate fcn handles; fix overload resolution (bug #29447, bug #31821, bug #48802)
John W. Eaton <jwe@octave.org>
parents: 26825
diff changeset
2531 if (fh)
8bd9fd99c12a lazily evaluate fcn handles; fix overload resolution (bug #29447, bug #31821, bug #48802)
John W. Eaton <jwe@octave.org>
parents: 26825
diff changeset
2532 fh->push_closure_context (*this);
26825
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2533 }
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2534 }
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2535 }
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
2536
25400
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2537 return retval;
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2538 }
d423ce60f5c8 evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents: 25399
diff changeset
2539
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2540 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2541 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
2542 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2543 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2544 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2545
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2546 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2547 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
2548 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2549 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2550 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2551
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2552 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2553 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
2554 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2555 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
2556
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2557 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
2558
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2559 if (f)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2560 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2561 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
2562
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2563 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
2564
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2565 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
2566
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2567 // 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
2568 // 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
2569
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2570 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
2571 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2572 }
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
2573
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2574 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2575 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
2576 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2577 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
2578 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2579
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2580 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2581 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
2582 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2583 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2584 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2585
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2586 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2587 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
2588 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2589 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
2590 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2591 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2592 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
2593 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
2594 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2595
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2596 // 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
2597 // 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
2598
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2599 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
2600
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2601 if (lst)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2602 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
2603 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2604
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2605 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2606 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
2607 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
2608 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
2609 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2610 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
2611
25401
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2612 if (m_statement_context == SC_FUNCTION
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2613 || m_statement_context == SC_SCRIPT)
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23532
diff changeset
2614 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
2615
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2616 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
2617 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
2618
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2619 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
2620 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2621 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
2622
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2623 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
2624 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
2625
20784
52f6921dde09 * pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20715
diff changeset
2626 break;
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2627 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2628 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2629 }
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24690
diff changeset
2630
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2631 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2632 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
2633 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2634 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
2635 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2636
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2637 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2638 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
2639 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2640 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
2641 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2642
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2643 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2644 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
2645 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2646 panic_impossible ();
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2647 }
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2648
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2649 void
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2650 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
2651 {
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2652 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
2653 }
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
2654
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2655 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2656 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
2657 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2658 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
2659 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2660 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2661 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
2662 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
2663 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2664
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2665 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
2666 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
2667 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2668
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2669 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2670 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
2671 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2672 panic_impossible ();
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2673 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2674
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2675 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2676 tree_evaluator::visit_fcn_handle (tree_fcn_handle&)
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2677 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2678 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
2679 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2680
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2681 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2682 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
2683 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2684 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2685 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2686
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2687 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2688 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
2689 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2690 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
2691 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2692
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2693 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2694 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
2695 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2696 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
2697 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2698
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2699 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2700 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
2701 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2702 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
2703 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2704 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2705 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
2706 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
2707 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2708
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2709 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
2710 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
2711
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2712 // 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
2713
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
2714 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
2715 dbcont ();
25401
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2716 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
2717 || 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
2718 || m_in_loop_command)
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2719 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
2720 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2721
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2722 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2723 tree_evaluator::visit_return_list (tree_return_list&)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2724 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2725 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2726 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2727
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2728 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2729 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
2730 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2731 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
2732 }
8662
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
2733
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2734 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2735 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
2736 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2737 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
2738 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
2739
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2740 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
2741 {
25401
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2742 if (m_statement_context == SC_FUNCTION
6f6479125d80 eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 25400
diff changeset
2743 || m_statement_context == SC_SCRIPT)
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2744 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2745 // Skip commands issued at a debug> prompt to avoid disturbing
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2746 // the state of the program we are debugging.
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2747
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2748 if (Vtrack_line_num)
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23532
diff changeset
2749 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
2750 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2751
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2752 try
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2753 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2754 if (cmd)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2755 cmd->accept (*this);
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2756 else
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2757 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2758 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
2759 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2760 size_t line = stmt.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2761 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
2762 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
2763 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2764
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2765 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
2766 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
2767
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2768 // 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
2769 // 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
2770 // 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
2771 // 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
2772
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2773 // 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
2774 // 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
2775 // 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
2776
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2777 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
2778
07876b7127bf reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents: 24563
diff changeset
2779 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
2780 {
24564
07876b7127bf reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents: 24563
diff changeset
2781 bool do_bind_ans = false;
07876b7127bf reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents: 24563
diff changeset
2782
07876b7127bf reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents: 24563
diff changeset
2783 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
2784 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
2785 else
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
2786 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
2787
07876b7127bf reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents: 24563
diff changeset
2788 if (do_bind_ans)
07876b7127bf reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents: 24563
diff changeset
2789 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
2790 && 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
2791 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2792 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2793 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2794 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
2795 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2796 // 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
2797 // 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
2798 // 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
2799 // 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
2800
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2801 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
2802 "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
2803 }
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
2804 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
2805 {
466e2aab871b stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents: 24565
diff changeset
2806 // 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
2807 // 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
2808
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2809 if (m_debug_mode)
24583
466e2aab871b stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents: 24565
diff changeset
2810 interpreter::recover_from_exception ();
466e2aab871b stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents: 24565
diff changeset
2811 else
466e2aab871b stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents: 24565
diff changeset
2812 throw;
466e2aab871b stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents: 24565
diff changeset
2813 }
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2814 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2815 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2816
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2817 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2818 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
2819 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2820 // 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
2821 // 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
2822
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25336
diff changeset
2823 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
2824
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2825 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
2826 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2827 while (true)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2828 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2829 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
2830
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2831 if (! elt)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2832 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
2833
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2834 octave_quit ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2835
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2836 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
2837
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2838 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
2839 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2840
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
2841 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
2842 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2843
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2844 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
2845 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2846 else
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2847 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2848 // 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
2849 // 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
2850 // 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
2851 // 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
2852 //
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2853 // 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
2854 // # 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
2855 //
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2856 // 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
2857 // # 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
2858 // # 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
2859 // # 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
2860
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2861 // 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
2862 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2863 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2864 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2865 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2866
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2867 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2868 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
2869 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2870 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2871 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2872
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2873 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2874 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
2875 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2876 panic_impossible ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2877 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2878
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2879 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2880 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
2881 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2882 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
2883 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2884 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2885 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
2886 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
2887 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2888
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
2889 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
2890 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
2891
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2892 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
2893
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2894 if (! expr)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2895 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
2896 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
2897
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
2898 octave_value val = std::move (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
2899
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2900 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
2901
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2902 if (lst)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2903 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
2904 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
2905 {
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
2906 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
2907 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2908 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
2909
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2910 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
2911 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
2912
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2913 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2914 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2915 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2916 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2917 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2918
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2919 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2920 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
2921 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2922 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
2923 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2924 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2925 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
2926 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
2927 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
2928
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2929 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
2930
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2931 bool execution_error = false;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2932
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
2933 {
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
2934 // unwind frame before catch block
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
2935 unwind_protect frame;
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2936
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2937 interpreter_try (frame);
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2938
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2939 // The catch code is *not* added to unwind_protect stack;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2940 // it doesn't need to be run on interrupts.
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2941
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2942 tree_statement_list *try_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
2943
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2944 if (try_code)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2945 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2946 try
20784
52f6921dde09 * pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20715
diff changeset
2947 {
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2948 int itc = es.in_try_catch ();
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
2949 unwind_action act ([&es, itc] (void)
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
2950 {
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
2951 es.in_try_catch (itc);
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
2952 });
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2953 es.in_try_catch (itc + 1);
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2954
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2955 try_code->accept (*this);
20784
52f6921dde09 * pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20715
diff changeset
2956 }
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
2957 catch (const execution_exception&)
20784
52f6921dde09 * pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20715
diff changeset
2958 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
2959 interpreter::recover_from_exception ();
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
2960
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2961 execution_error = true;
20784
52f6921dde09 * pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20715
diff changeset
2962 }
52f6921dde09 * pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20715
diff changeset
2963 }
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2964 // Unwind to let the user print any messages from
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2965 // errors that occurred in the body of the try_catch statement,
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2966 // or throw further errors.
20784
52f6921dde09 * pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20715
diff changeset
2967 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2968
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2969 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
2970 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2971 tree_statement_list *catch_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
2972 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
2973 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2974 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
2975
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2976 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
2977 {
25383
d3a035528c9a use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents: 25382
diff changeset
2978 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
2979
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2980 octave_scalar_map err;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2981
27160
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2982 err.assign ("message", es.last_error_message ());
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2983 err.assign ("identifier", es.last_error_id ());
6b0c61a5a0f0 move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents: 27123
diff changeset
2984 err.assign ("stack", es.last_error_stack ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2985
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2986 ult.assign (octave_value::op_asn_eq, err);
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2987 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2988
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2989 // perform actual "catch" block
26451
0ab258611cc5 pt-eval.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
2990 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
2991 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2992 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2993 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2994
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2995 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
2996 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
2997 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
2998 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
2999
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3000 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
3001 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
3002
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3003 // 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
3004 // backtracking.
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23532
diff changeset
3005
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3006 frame.add_method (m_call_stack, &call_stack::set_line,
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23532
diff changeset
3007 m_call_stack.current_line ());
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3008 frame.add_method (m_call_stack, &call_stack::set_column,
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23532
diff changeset
3009 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
3010
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3011 // 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
3012 // 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
3013 // 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
3014 // 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
3015
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3016 frame.protect_var (m_returning);
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3017 m_returning = 0;
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3018
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3019 frame.protect_var (m_breaking);
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3020 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
3021
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3022 try
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3023 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3024 if (list)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3025 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
3026 }
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3027 catch (const execution_exception&)
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3028 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3029 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
3030
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3031 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
3032 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
3033 else
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3034 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
3035
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3036 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
3037
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3038 throw;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3039 }
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
3040
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3041 // 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
3042 // 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
3043
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3044 // 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
3045 // 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
3046 // 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
3047 // 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
3048 // 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
3049 //
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3050 // function foo ()
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3051 // unwind_protect
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3052 // 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
3053 // break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3054 // 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
3055 // 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
3056 // 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
3057 // return;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3058 // 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
3059 // 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
3060 // endfunction
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3061 //
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3062 // 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
3063 // 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
3064 // 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
3065 // 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
3066 // 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
3067
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3068 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
3069 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
3070 else
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3071 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
3072 }
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
3073
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3074 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3075 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
3076 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3077 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
3078 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3079 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3080 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
3081 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
3082 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3083
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3084 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
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 *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
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 (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
3089 {
c34f9c182dcf Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents: 21743
diff changeset
3090 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
3091 {
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3092 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
3093 }
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3094 catch (const execution_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
3095 {
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3096 // 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
3097 // 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
3098 // 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
3099 // here?
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3100 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
3101
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3102 // 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
3103 // 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
3104 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
3105
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3106 // 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
3107 // 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
3108 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
3109 }
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3110 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
3111 {
fecca33388f7 also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents: 23219
diff changeset
3112 // The comments above apply here as well.
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
3113 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
3114 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
3115 throw;
fecca33388f7 also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents: 23219
diff changeset
3116 }
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3117
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3118 // 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
3119 // 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
3120 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
3121 }
c34f9c182dcf Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents: 21743
diff changeset
3122 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3123
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3124 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3125 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
3126 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3127 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3128
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3129 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
3130 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3131 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
3132 line++;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3133 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3134
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3135 #if defined (HAVE_LLVM)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3136 if (tree_jit::execute (cmd))
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3137 return;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3138 #endif
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9378
diff changeset
3139
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
3140 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
3141
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3142 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
3143
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3144 if (! expr)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3145 panic_impossible ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3146
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3147 for (;;)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3148 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3149 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
3150 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
3151
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
3152 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
3153 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
3154
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3155 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
3156 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3157 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
3158
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3159 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
3160 loop_body->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
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 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
3163 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3164 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3165 else
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3166 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3167 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3168 }
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
3169
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3170 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3171 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
3172 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3173 size_t line = cmd.line ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3174
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3175 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
3176 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3177 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
3178 line++;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3179 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3180
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
3181 #if defined (HAVE_LLVM)
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3182 if (tree_jit::execute (cmd))
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3183 return;
15023
75d1bc2fd6d2 Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents: 14932
diff changeset
3184 #endif
75d1bc2fd6d2 Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents: 14932
diff changeset
3185
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
3186 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
3187
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3188 tree_expression *expr = cmd.condition ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3189 int until_line = cmd.line ();
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3190 int until_column = cmd.column ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3191
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3192 if (! expr)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3193 panic_impossible ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3194
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3195 for (;;)
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3196 {
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3197 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
3198 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
3199
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3200 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
3201
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3202 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
3203 loop_body->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3204
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3205 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
3206 break;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3207
25402
ef2b9d4abf4a eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 25401
diff changeset
3208 if (m_debug_mode)
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
3209 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
3210
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23532
diff changeset
3211 m_call_stack.set_location (until_line, until_column);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3212
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3213 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
3214 break;
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3215 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3216 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3217
26686
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26662
diff changeset
3218 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3219 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
3220 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3221 panic_impossible ();
26686
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26662
diff changeset
3222 }
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26662
diff changeset
3223
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26662
diff changeset
3224 void
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3225 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
3226 {
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3227 panic_impossible ();
26686
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26662
diff changeset
3228 }
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26662
diff changeset
3229
23702
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3230 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
3231 {
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3232 static std::string ans = "ans";
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3233
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3234 if (val.is_defined ())
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3235 {
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3236 if (val.is_cs_list ())
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3237 {
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3238 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
3239
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3240 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
3241 bind_ans (lst(i), print);
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3242 }
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3243 else
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3244 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3245 assign (ans, val);
23702
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3246
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3247 if (print)
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3248 {
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3249 octave_value_list args = ovl (val);
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3250 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
3251 feval ("display", args);
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3252 }
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3253 }
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3254 }
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3255 }
d396b5fd9199 move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
3256
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3257 void
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
3258 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
3259 {
26113
8a15f3bace49 move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents: 26094
diff changeset
3260 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
3261 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
3262 }
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
3263
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3264 void
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3265 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
3266 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
3267 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3268 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
3269
25405
df2f3af2c6c5 eliminate unused octave_debug_on_interrupt_state variable
John W. Eaton <jwe@octave.org>
parents: 25404
diff changeset
3270 if (is_breakpoint)
27233
fc668ac9ce7c re-enter debugger when doing dbstep (bug #56150)
John W. Eaton <jwe@octave.org>
parents: 27222
diff changeset
3271 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
3272 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
3273 {
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3274 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
3275 {
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
3276 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
3277 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3278 // We get here if we are doing a "dbstep" or a "dbstep N" and the
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3279 // count has reached 1 so that we must stop and return to debug
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3280 // prompt. Alternatively, "dbstep N" has been used but the end
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3281 // of the frame has been reached so we stop at the last line and
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3282 // return to prompt.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3283
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3284 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
3285 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3286 else
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 // 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
3289
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
3290 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
3291 }
15574
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
3292
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3293 }
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
3294 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
3295 && 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
3296 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3297 // 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
3298
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3299 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
3300
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3301 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
3302 }
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3303 }
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
3304 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
3305 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3306 // 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
3307
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3308 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
3309
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3310 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
3311 }
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
3312 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
3313 {
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3314 // 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
3315 // 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
3316 // 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
3317 // "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
3318 // that frame.
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3319
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3320 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
3321 && 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
3322 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
3323 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3324
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3325 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
3326 {
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3327 m_dbstep_flag = 0;
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3328
27233
fc668ac9ce7c re-enter debugger when doing dbstep (bug #56150)
John W. Eaton <jwe@octave.org>
parents: 27222
diff changeset
3329 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
3330 }
22196
dd992fd74fce put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents: 22164
diff changeset
3331 }
10219
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
3332
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3333 bool
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3334 tree_evaluator::is_logically_true (tree_expression *expr,
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3335 const char *warn_for)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3336 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3337 bool expr_value = false;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3338
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3339 octave_value t1 = std::move (expr->evaluate (*this));
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3340
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3341 if (t1.is_defined ())
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3342 return t1.is_true ();
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3343 else
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3344 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
3345
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3346 return expr_value;
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23398
diff changeset
3347 }
23481
73558a835b64 eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents: 23470
diff changeset
3348
23705
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3349 octave_value
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3350 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
3351 int nargout)
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3352 {
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3353 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
3354 "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
3355 }
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3356
27203
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3357 symbol_info_list
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3358 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
3359 {
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3360 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
3361 }
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3362
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3363 symbol_info_list
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3364 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
3365 {
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3366 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
3367 }
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3368
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3369 symbol_info_list
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3370 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
3371 {
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3372 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
3373 }
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3374
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3375 symbol_info_list
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3376 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
3377 {
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3378 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
3379 }
79065f9d5553 eliminate direct access to call stack in load-save functions
John W. Eaton <jwe@octave.org>
parents: 27202
diff changeset
3380
27016
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3381 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
3382 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3383 Cell func_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
3384 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
3385
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3386 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
3387 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
3388 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3389 func_names(i) = 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
3390 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
3391
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3392 i++;
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3393 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3394
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3395 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
3396
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3397 m.assign ("function", func_names);
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3398 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
3399
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3400 return m;
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3401 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3402
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3403 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
3404 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3405 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
3406
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3407 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
3408
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3409 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
3410 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3411 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
3412
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3413 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
3414 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3415
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3416 return retval;
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3417 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3418
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3419 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
3420 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3421 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
3422
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3423 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
3424 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
3425
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3426 return names;
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3427 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3428
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3429 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
3430 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
3431 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3432 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
3433
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3434 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
3435 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
3436 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
3437
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3438 return names;
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3439 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3440
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3441 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
3442 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
3443 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3444 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
3445
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3446 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
3447 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3448
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3449 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
3450 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
3451 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3452 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
3453
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3454 // 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
3455 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
3456
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3457 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
3458
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3459 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
3460 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3461
23705
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3462 octave_value
26087
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3463 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
3464 {
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3465 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
3466 "whos_line_format");
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3467 }
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3468
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3469 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
3470 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
3471 {
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3472 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
3473 "silent_functions");
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3474 }
23706
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
3475
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3476 octave_value
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3477 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
3478 {
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3479 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
3480 "string_fill_char");
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3481 }
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3482
26094
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3483 // 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
3484 // 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
3485 // 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
3486
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3487 void tree_evaluator::final_index_error (index_exception& e,
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3488 const tree_expression *expr)
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3489 {
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3490 std::string extra_message;
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3491
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3492 symbol_scope scope = get_current_scope ();
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3493
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3494 if (is_variable (expr))
26094
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3495 {
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3496 std::string var = expr->name ();
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3497
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3498 e.set_var (var);
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3499
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3500 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
3501
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3502 octave_value fcn = symtab.find_function (var);
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3503
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3504 if (fcn.is_function ())
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3505 {
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3506 octave_function *fp = fcn.function_value ();
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3507
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3508 if (fp && fp->name () == var)
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3509 extra_message
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3510 = " (note: variable '" + var + "' shadows function)";
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3511 }
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3512 }
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3513
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3514 std::string msg = e.message () + extra_message;
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3515
26149
242aa7b2c783 Silence unnecessary warnings about security-format (bug #55046).
Rik <rik@octave.org>
parents: 26113
diff changeset
3516 error_with_id (e.err_id (), "%s", msg.c_str ());
26094
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3517 }
8fb0df0c8772 eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents: 26087
diff changeset
3518
27005
a1ea0e7aecde move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents: 27001
diff changeset
3519 octave_value
a1ea0e7aecde move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents: 27001
diff changeset
3520 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
3521 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
3522 {
a1ea0e7aecde move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents: 27001
diff changeset
3523 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
3524 }
a1ea0e7aecde move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents: 27001
diff changeset
3525
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3526 octave_value_list
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3527 tree_evaluator::make_value_list (tree_argument_list *args,
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3528 const string_vector& arg_nm,
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3529 const octave_value *object, bool rvalue)
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3530 {
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3531 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
3532
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3533 if (args)
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3534 {
27373
25627c524ad8 where possible, use new unwind-protect classes in evaluator
John W. Eaton <jwe@octave.org>
parents: 27371
diff changeset
3535 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
3536 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
3537
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3538 if (rvalue && object && args->has_magic_end ()
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3539 && object->is_undefined ())
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3540 err_invalid_inquiry_subscript ();
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3541
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3542 retval = convert_to_const_vector (args, object);
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3543 }
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3544
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3545 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
3546
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3547 if (n > 0)
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3548 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
3549
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3550 return retval;
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3551 }
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3552
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3553 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
3554 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
3555 {
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3556 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
3557
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3558 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
3559 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
3560
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3561 return retval;
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3562 }
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 27370
diff changeset
3563
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3564 void
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3565 tree_evaluator::push_echo_state (unwind_protect& frame, int type,
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3566 const std::string& file_name,
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3567 size_t pos)
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3568 {
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3569 push_echo_state_cleanup (frame);
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3570
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3571 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
3572 }
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3573
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3574 void
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3575 tree_evaluator::set_echo_state (int type, const std::string& file_name,
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3576 size_t pos)
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3577 {
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3578 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
3579 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
3580 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
3581 }
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3582
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3583 void
25653
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3584 tree_evaluator::uwp_set_echo_state (bool state, const std::string& file_name,
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3585 size_t pos)
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3586 {
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3587 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
3588 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
3589 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
3590 }
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3591
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3592 void
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3593 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
3594 {
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3595 octave_function *caller = m_call_stack.caller ();
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3596
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3597 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
3598 {
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3599 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
3600
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3601 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
3602
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3603 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
3604
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3605 size_t pos = m_call_stack.current_line ();
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3606
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3607 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
3608 }
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3609 }
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3610
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3611 void
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3612 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
3613 {
25653
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3614 frame.add_method (this, &tree_evaluator::uwp_set_echo_state,
b3d357990b52 better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents: 25483
diff changeset
3615 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
3616 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3617
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3618 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
3619 {
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3620 // 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
3621 // 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
3622 // 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
3623 // 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
3624
25399
6ca2c0d76d84 store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents: 25393
diff changeset
3625 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
3626
6ca2c0d76d84 store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents: 25393
diff changeset
3627 if (frame)
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3628 {
25399
6ca2c0d76d84 store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents: 25393
diff changeset
3629 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
3630 return true;
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3631 }
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3632
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3633 return false;
23706
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
3634 }
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3635
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3636
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3637 octave_value
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3638 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
3639 {
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3640 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
3641
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3642 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
3643
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3644 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
3645 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3646 case 0:
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3647 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
3648 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3649 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
3650 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
3651 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3652 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3653 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
3654 break;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3655
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3656 case 1:
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3657 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3658 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
3659
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3660 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
3661 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
3662 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
3663 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
3664 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3665 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3666 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
3667 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
3668
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3669 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
3670 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
3671
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3672 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
3673 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3674 // 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
3675 // 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
3676
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3677 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
3678 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3679 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3680 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3681 // 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
3682
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3683 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
3684
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3685 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
3686 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3687 // 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
3688
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3689 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
3690 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
3691 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3692 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3693 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3694 // 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
3695 // 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
3696
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3697 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
3698 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3699 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3700 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3701 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3702 break;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3703
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3704 case 2:
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3705 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3706 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
3707 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
3708
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3709 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
3710 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
3711
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3712 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
3713 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3714 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
3715 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3716 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
3717 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
3718 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3719 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3720 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3721 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
3722 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
3723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3724 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
3725 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
3726
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3727 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
3728 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
3729 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3730 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3731 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
3732 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3733 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
3734 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3735 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
3736 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
3737 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3738 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3739 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3740 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
3741 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
3742
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3743 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
3744 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
3745
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3746 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
3747 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3748 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3749 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3750 print_usage ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3751 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3752 break;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3753
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3754 default:
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3755 print_usage ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3756 break;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3757 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3758
23729
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3759 if (cleanup_pushed)
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3760 maybe_set_echo_state ();
06b3d1d54054 allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents: 23728
diff changeset
3761
23913
062ce545b21e mark octave_value from octave_value_list constructor explicit
John W. Eaton <jwe@octave.org>
parents: 23876
diff changeset
3762 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
3763 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3764
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3765 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
3766 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3767 return (m_debugger_stack.empty ()
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3768 ? 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
3769 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3770
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3771 void tree_evaluator::dbcont (void)
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3772 {
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3773 if (! m_debugger_stack.empty ())
27282
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3774 m_debugger_stack.top()->dbcont ();
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3775 }
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3776
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3777 void tree_evaluator::dbquit (bool all)
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3778 {
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3779 if (! m_debugger_stack.empty ())
49c60d16866f improve dbquit and dbcont behavior
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
3780 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
3781 }
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3782
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3783 octave_value
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3784 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
3785 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3786 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
3787 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3788
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3789 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
3790 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3791 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
3792 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3793 // 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
3794 return true;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3795 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3796
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3797 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
3798 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3799 // 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
3800 // 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
3801
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3802 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
3803
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3804 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
3805 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3806 // 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
3807 // file.
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3808
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3809 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
3810 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3811 else
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3812 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3813 // 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
3814
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3815 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
3816 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3817 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3818
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3819 return false;
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3820 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3821
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3822 void tree_evaluator::echo_code (size_t line)
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3823 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3824 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
3825
23728
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3826 octave_function *curr_fcn = m_call_stack.current ();
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3827
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3828 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
3829 {
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3830 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
3831
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3832 size_t num_lines = line - m_echo_file_pos + 1;
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3833
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3834 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
3835 = 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
3836
b40b7243a782 new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents: 23723
diff changeset
3837 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
3838 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
3839 }
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
3840 }
25360
bc5f225bc578 eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
3841
25403
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3842 // 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
3843 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
3844 {
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3845 octave_quit ();
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3846
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3847 // Maybe handle 'continue N' someday...
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3848
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3849 if (m_continuing)
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3850 m_continuing--;
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3851
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3852 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
3853
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3854 if (m_breaking)
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3855 m_breaking--;
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3856
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3857 return quit;
2b7d7a3f5f57 move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents: 25402
diff changeset
3858 }
26039
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
3859
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3860 void tree_evaluator::bind_auto_fcn_vars (const string_vector& arg_names,
26039
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
3861 int nargin, int nargout,
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
3862 bool takes_varargs,
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
3863 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
3864 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3865 set_auto_fcn_var (stack_frame::ARG_NAMES, Cell (arg_names));
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3866 set_auto_fcn_var (stack_frame::IGNORED, ignored_fcn_outputs ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3867 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
3868 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
3869 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
3870
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
3871 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
3872 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
3873 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3874
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3875 void tree_evaluator::init_local_fcn_vars (octave_user_function& user_fcn)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3876 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3877 stack_frame& frame = m_call_stack.get_current_stack_frame ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3878
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3879 const octave_user_function::local_vars_map& lviv
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3880 = user_fcn.local_var_init_vals ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3881
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3882 for (const auto& nm_ov : lviv)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3883 frame.assign (nm_ov.first, nm_ov.second);
26039
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
3884 }
27016
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3885
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3886 std::string
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3887 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
3888 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3889 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
3890 return nm;
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3891
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3892 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
3893
27037
8408acb7ca4f make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents: 27019
diff changeset
3894 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
3895
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3896 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
3897
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3898 if (fcn)
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3899 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3900 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
3901
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3902 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
3903 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3904 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
3905 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
3906
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3907 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
3908
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3909 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
3910 {
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3911 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
3912 found = true;
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3913 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3914 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3915 }
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3916
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3917 if (! found)
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3918 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
3919 "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
3920 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
3921
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27015
diff changeset
3922 return full_name;
26039
d2aae3570c81 perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents: 26004
diff changeset
3923 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3924 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3925
23705
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3926 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
3927 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
3928 @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
3929 @deftypefnx {} {@var{old_val} =} max_recursion_depth (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
3930 @deftypefnx {} {} max_recursion_depth (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
3931 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
3932 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
3933
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
3934 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
3935 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
3936
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
3937 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
3938 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
3939 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
3940
41f80b9af274 prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents: 24738
diff changeset
3941 @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
3942 @end deftypefn */)
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
3943 {
23705
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3944 octave::tree_evaluator& tw = interp.get_evaluator ();
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3945
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
3946 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
3947 }
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
3948
12833
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
3949 /*
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
3950 %!test
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
3951 %! 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
3952 %! 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
3953 %! 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
3954 %! 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
3955 %! 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
3956 %! 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
3957
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14294
diff changeset
3958 %!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
3959 */
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
3960
26087
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3961 DEFMETHOD (whos_line_format, interp, args, nargout,
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3962 doc: /* -*- texinfo -*-
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3963 @deftypefn {} {@var{val} =} whos_line_format ()
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3964 @deftypefnx {} {@var{old_val} =} whos_line_format (@var{new_val})
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3965 @deftypefnx {} {} whos_line_format (@var{new_val}, "local")
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3966 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
3967
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3968 A full format string is:
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3969 @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
3970
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3971 @smallexample
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3972 %[modifier]<command>[:width[:left-min[:balance]]];
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3973 @end smallexample
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3974
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3975 The following command sequences are available:
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3976
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3977 @table @code
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3978 @item %a
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26512
diff changeset
3979 Prints attributes of variables (g=global, p=persistent, f=formal parameter).
26087
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3980
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3981 @item %b
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3982 Prints number of bytes occupied by variables.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3983
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3984 @item %c
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3985 Prints class names of variables.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3986
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3987 @item %e
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3988 Prints elements held by variables.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3989
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3990 @item %n
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3991 Prints variable names.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3992
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3993 @item %s
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3994 Prints dimensions of variables.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3995
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3996 @item %t
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3997 Prints type names of variables.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3998 @end table
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
3999
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4000 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
4001
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4002 @table @code
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4003 @item l
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4004 Left alignment.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4005
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4006 @item r
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4007 Right alignment (default).
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4008
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4009 @item c
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4010 Column-aligned (only applicable to command %s).
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4011 @end table
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4012
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4013 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
4014 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
4015 auto-expand as required.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4016
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4017 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
4018 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
4019 @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
4020 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
4021 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
4022 the left of the specified balance column.
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4023
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4024 The default format is:
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4025
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4026 @qcode{" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;@xbackslashchar{}n"}
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4027
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4028 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
4029 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
4030 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
4031 @seealso{whos}
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4032 @end deftypefn */)
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4033 {
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4034 octave::tree_evaluator& tw = interp.get_evaluator ();
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4035
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4036 return tw.whos_line_format (args, nargout);
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4037 }
7656fcd0ff9f move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents: 26065
diff changeset
4038
23705
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
4039 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
4040 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
4041 @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
4042 @deftypefnx {} {@var{old_val} =} silent_functions (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
4043 @deftypefnx {} {} silent_functions (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
4044 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
4045 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
4046
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
4047 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
4048 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
4049 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
4050
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21922
diff changeset
4051 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
4052 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
4053 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
4054 @end deftypefn */)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4055 {
23705
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
4056 octave::tree_evaluator& tw = interp.get_evaluator ();
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
4057
4c597585ff52 move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23702
diff changeset
4058 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
4059 }
12833
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
4060
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
4061 /*
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
4062 %!test
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
4063 %! orig_val = silent_functions ();
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
4064 %! 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
4065 %! 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
4066 %! 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
4067 %! silent_functions (orig_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
4068 %! 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
4069
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14294
diff changeset
4070 %!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
4071 */
23706
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4072
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4073 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
4074 doc: /* -*- texinfo -*-
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4075 @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
4076 @deftypefnx {} {@var{old_val} =} string_fill_char (@var{new_val})
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4077 @deftypefnx {} {} string_fill_char (@var{new_val}, "local")
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4078 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
4079 matrix to the same length.
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4080
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4081 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
4082 single space). For example:
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4083
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4084 @example
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4085 @group
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4086 string_fill_char ("X");
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4087 [ "these"; "are"; "strings" ]
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4088 @result{} "theseXX"
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4089 "areXXXX"
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4090 "strings"
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4091 @end group
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4092 @end example
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4093
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4094 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
4095 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
4096 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
4097 @end deftypefn */)
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4098 {
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4099 octave::tree_evaluator& tw = interp.get_evaluator ();
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4100
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4101 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
4102 }
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4103
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4104 /*
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4105 ## 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
4106 ## 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
4107 %!shared orig_val, old_val
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4108 %! orig_val = string_fill_char ();
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4109 %! 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
4110 %!test
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4111 %! assert (orig_val, old_val);
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4112 %! assert (string_fill_char (), "X");
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4113 %! 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
4114 %! string_fill_char (orig_val);
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4115 %! 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
4116
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4117 %!assert ( [ [], {1} ], {1} )
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4118
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4119 %!error (string_fill_char (1, 2))
6683451b75b2 move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23705
diff changeset
4120 */
23723
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4121
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4122 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
4123 doc: /* -*- texinfo -*-
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4124 @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
4125 @deftypefnx {} {@var{old_val} =} PS4 (@var{new_val})
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4126 @deftypefnx {} {} PS4 (@var{new_val}, "local")
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4127 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
4128 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
4129
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4130 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
4131 @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
4132
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4133 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
4134 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
4135 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
4136 @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
4137 @end deftypefn */)
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4138 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4139 octave::tree_evaluator& tw = interp.get_evaluator ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4140
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4141 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
4142 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4143
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4144 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
4145 doc: /* -*- texinfo -*-
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4146 @deftypefn {} {} echo
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4147 @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
4148 @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
4149 @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
4150 @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
4151 @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
4152 @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
4153 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
4154
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4155 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
4156
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4157 @table @code
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4158 @item on
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4159 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
4160
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4161 @item off
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4162 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
4163
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4164 @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
4165 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
4166 functions.
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4167
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4168 @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
4169 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
4170 functions.
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 @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
4173 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
4174
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4175 @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
4176 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
4177 @end table
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4178
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4179 @noindent
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4180 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
4181
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4182 @seealso{PS4}
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4183 @end deftypefn */)
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4184 {
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4185 octave::tree_evaluator& tw = interp.get_evaluator ();
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4186
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4187 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
4188 }
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4189
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4190 /*
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4191 %!error echo ([])
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4192 %!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
4193 %!error echo ("")
ab8831d346c1 revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents: 23706
diff changeset
4194 %!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
4195 %!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
4196 %!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
4197 %!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
4198 */