Mercurial > octave
annotate libinterp/parse-tree/pt-eval.cc @ 24564:07876b7127bf
reorganize binding to ans in evaluator for clarity
* pt-eval.cc (tree_evaluator::visit_statement):
Evaluate expression first, then decide whether to bind to ans.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 08 Jan 2018 15:51:52 -0500 |
parents | 8f2c479eb125 |
children | dbec1e04f499 |
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 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2009-2017 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> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <fstream> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <typeinfo> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
34 #include "cmd-edit.h" |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
35 #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
|
36 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
37 #include "bp-table.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
38 #include "call-stack.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "defun.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #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
|
41 #include "errwarn.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "input.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
43 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
44 #include "interpreter.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "ov-fcn-handle.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "ov-usr-fcn.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
47 #include "ov-re-sparse.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
48 #include "ov-cx-sparse.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
49 #include "profiler.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "pt-all.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 #include "pt-eval.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
52 #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
|
53 #include "symtab.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 #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
|
55 #include "utils.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
56 #include "variables.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 |
14899 | 58 //FIXME: This should be part of tree_evaluator |
59 #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
|
60 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
61 namespace octave |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
63 int tree_evaluator::dbstep_flag = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
64 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
65 size_t tree_evaluator::current_frame = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
66 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
67 bool tree_evaluator::debug_mode = false; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
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 bool tree_evaluator::quiet_breakpoint_flag = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
70 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
71 tree_evaluator::stmt_list_type tree_evaluator::statement_context |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
72 = tree_evaluator::other; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
73 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
74 bool tree_evaluator::in_loop_command = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
75 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
76 // Normal evaluator. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
78 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
79 tree_evaluator::reset (void) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
80 { |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
81 m_result_type = RT_UNDEFINED; |
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
82 m_expr_result_value = octave_value (); |
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
83 m_expr_result_value_list = octave_value_list (); |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
84 m_lvalue_list_stack.clear (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
85 m_nargout_stack.clear (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
86 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
87 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
88 void |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
89 tree_evaluator::visit_anon_fcn_handle (tree_anon_fcn_handle& anon_fh) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
90 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
91 // FIXME: should CMD_LIST be limited to a single expression? |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
92 // I think that is what Matlab does. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
93 |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
94 tree_parameter_list *param_list = anon_fh.parameter_list (); |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
95 tree_expression *expr = anon_fh.expression (); |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
96 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
97 symbol_scope af_scope = anon_fh.scope (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
98 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
99 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
|
100 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
101 symbol_scope af_parent_scope; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
102 if (anon_fh.has_parent_scope ()) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
103 af_parent_scope = symtab.current_scope (); |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
104 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
105 symbol_scope new_scope; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
106 if (af_scope) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
107 new_scope = af_scope.dup (); |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
108 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
109 if (new_scope && af_parent_scope) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
110 new_scope.inherit (af_parent_scope); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
111 |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
112 tree_parameter_list *param_list_dup |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
113 = param_list ? param_list->dup (new_scope) : nullptr; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
114 |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
115 tree_parameter_list *ret_list = nullptr; |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
116 |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
117 tree_statement_list *stmt_list = nullptr; |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
118 |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
119 if (expr) |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
120 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
121 tree_expression *expr_dup = expr->dup (new_scope); |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
122 tree_statement *stmt = new tree_statement (expr_dup, nullptr); |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
123 stmt_list = new tree_statement_list (stmt); |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
124 } |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
125 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
126 octave_user_function *af |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
127 = new octave_user_function (new_scope, param_list_dup, ret_list, |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
128 stmt_list); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
129 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
130 new_scope.set_parent (af_parent_scope); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
131 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
132 octave_function *curr_fcn = m_call_stack.current (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
133 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
134 if (curr_fcn) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
135 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
136 // FIXME: maybe it would be better to just stash curr_fcn |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
137 // instead of individual bits of info about it? |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
138 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
139 af->stash_parent_fcn_name (curr_fcn->name ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
140 af->stash_dir_name (curr_fcn->dir_name ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
141 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
142 if (curr_fcn->is_class_method () || curr_fcn->is_class_constructor ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
143 af->stash_dispatch_class (curr_fcn->dispatch_class ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
144 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
145 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
146 af->mark_as_anonymous_function (); |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
147 |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
148 // FIXME: these should probably come from ANON_FH. |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
149 // af->stash_fcn_file_name (expr.file_name ()); |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
150 // af->stash_fcn_location (expr.line (), expr.column ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
151 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
152 octave_value ov_fcn (af); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
153 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
154 octave_value fh (octave_fcn_binder::maybe_binder (ov_fcn, this)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
155 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
156 push_result (fh); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
157 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
159 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
160 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
|
161 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
162 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
163 } |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
164 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
165 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
166 tree_evaluator::visit_binary_expression (tree_binary_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
167 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
168 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
169 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
170 tree_expression *op_lhs = expr.lhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
171 tree_expression *op_rhs = expr.rhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
172 octave_value::binary_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
173 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
174 if (expr.is_eligible_for_braindead_shortcircuit ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
175 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
176 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
177 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
178 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
179 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
180 if (a.ndims () == 2 && a.rows () == 1 && a.columns () == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
181 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
182 bool result = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
183 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
184 bool a_true = a.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
185 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
186 if (a_true) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
187 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
188 if (etype == octave_value::op_el_or) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
189 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
190 expr.matlab_style_short_circuit_warning ("|"); |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
191 push_result (octave_value (true)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
192 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
193 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
194 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
195 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
196 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
197 if (etype == octave_value::op_el_and) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
198 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
199 expr.matlab_style_short_circuit_warning ("&"); |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
200 push_result (octave_value (false)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
201 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
202 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
203 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
204 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
205 if (op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
206 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
207 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
208 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
209 result = b.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
210 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
211 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
212 push_result (octave_value (result)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
213 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
214 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
215 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
216 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
217 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
218 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
219 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
220 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
221 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
222 if (a.is_defined () && op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
223 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
224 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
225 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
226 if (b.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
227 { |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
228 profiler::enter<tree_binary_expression> |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
229 block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
230 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
231 // Note: The profiler does not catch the braindead |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
232 // short-circuit evaluation code above, but that should be |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
233 // ok. The evaluation of operands and the operator itself |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
234 // is entangled and it's not clear where to start/stop |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
235 // timing the operator to make it reasonable. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
236 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
237 val = ::do_binary_op (etype, a, b); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
238 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
239 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
240 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
241 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
242 push_result (val); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
243 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
244 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
245 void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
246 tree_evaluator::visit_boolean_expression (tree_boolean_expression& expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
247 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
248 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
249 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
250 bool result = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
251 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
252 // This evaluation is not caught by the profiler, since we can't find |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
253 // a reasonable place where to time. Note that we don't want to |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
254 // include evaluation of LHS or RHS into the timing, but this is |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
255 // entangled together with short-circuit evaluation here. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
256 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
257 tree_expression *op_lhs = expr.lhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
258 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
259 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
260 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
261 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
262 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
263 bool a_true = a.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
264 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
265 tree_boolean_expression::type etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
266 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
267 if (a_true) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
268 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
269 if (etype == tree_boolean_expression::bool_or) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
270 { |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
271 push_result (octave_value (true)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
272 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
273 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
274 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
275 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
276 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
277 if (etype == tree_boolean_expression::bool_and) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
278 { |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
279 push_result (octave_value (false)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
280 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
281 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
282 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
283 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
284 tree_expression *op_rhs = expr.rhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
285 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
286 if (op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
287 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
288 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
289 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
290 result = b.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
291 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
292 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
293 val = octave_value (result); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
294 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
295 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
296 push_result (val); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
297 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
298 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
299 void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
300 tree_evaluator::visit_compound_binary_expression (tree_compound_binary_expression& expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
301 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
302 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
303 |
23523
d2748870db4e
undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
23522
diff
changeset
|
304 tree_expression *op_lhs = expr.clhs (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
305 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
306 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
307 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
308 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
309 |
23523
d2748870db4e
undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
23522
diff
changeset
|
310 tree_expression *op_rhs = expr.crhs (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
311 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
312 if (a.is_defined () && op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
313 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
314 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
315 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
316 if (b.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
317 { |
23522
d2e300f7700c
fix compound binary op error introduced in c452180ab672
John W. Eaton <jwe@octave.org>
parents:
23521
diff
changeset
|
318 octave_value::compound_binary_op etype = expr.cop_type (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
319 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
320 val = ::do_binary_op (etype, a, b); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
321 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
322 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
323 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
324 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
325 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
326 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
328 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
329 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
|
330 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
331 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
|
332 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
333 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
|
334 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
|
335 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
|
336 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
337 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
338 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
339 do_breakpoint (cmd.is_breakpoint (true)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 |
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
|
341 if (in_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
|
342 tree_break_command::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
|
343 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
|
344 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
|
345 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
346 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
347 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
348 tree_evaluator::visit_colon_expression (tree_colon_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
349 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
350 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
351 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
352 tree_expression *op_base = expr.base (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
353 tree_expression *op_limit = expr.limit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
354 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
355 if (! op_base || ! op_limit) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
356 { |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
357 push_result (octave_value (val)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
358 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
359 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
360 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
361 octave_value ov_base = evaluate (op_base); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
362 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
363 octave_value ov_limit = evaluate (op_limit); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
364 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
365 tree_expression *op_increment = expr.increment (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
366 |
23587
0c468af9dc00
maint: Deprecate is_object and replace with isobject.
Rik <rik@octave.org>
parents:
23584
diff
changeset
|
367 if (ov_base.isobject () || ov_limit.isobject ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
368 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
369 octave_value_list tmp1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
370 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
371 if (op_increment) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
372 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
373 octave_value ov_increment = evaluate (op_increment); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
374 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
375 tmp1(2) = ov_limit; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
376 tmp1(1) = ov_increment; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
377 tmp1(0) = ov_base; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
378 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
379 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
380 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
381 tmp1(1) = ov_limit; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
382 tmp1(0) = ov_base; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
383 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
384 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
385 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
|
386 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
387 octave_value fcn = symtab.find_function ("colon", tmp1); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
388 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
389 if (! fcn.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
390 error ("can not find overloaded colon function"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
391 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
392 octave_value_list tmp2 = feval (fcn, tmp1, 1); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
393 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
394 val = tmp2 (0); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
395 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
396 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
397 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
398 octave_value ov_increment = 1.0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
399 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
400 if (op_increment) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
401 ov_increment = evaluate (op_increment); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
402 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
403 val = do_colon_op (ov_base, ov_increment, ov_limit, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
404 expr.is_for_cmd_expr ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
405 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
406 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
407 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
408 } |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
409 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
410 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
411 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
|
412 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
413 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
|
414 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
415 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
|
416 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
|
417 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
|
418 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
419 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
420 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
421 do_breakpoint (cmd.is_breakpoint (true)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
422 |
22703
d43094e91ba7
Ignore continue statement when used outside of a loop (bug #48665)
Mike Miller <mtmiller@octave.org>
parents:
22407
diff
changeset
|
423 if (in_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
|
424 tree_continue_command::continuing = 1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
425 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
427 bool |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
428 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
|
429 { |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
430 return ! (m_silent_functions && (statement_context == function |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
431 || statement_context == script)); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
432 } |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
433 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
434 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
435 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
|
436 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
437 debug_mode = bp_table::have_breakpoints () || Vdebugging; |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
438 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
439 dbstep_flag = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
440 } |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
441 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
442 Matrix |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
443 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
|
444 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
445 Matrix retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
446 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
447 const std::list<octave_lvalue> *lvalues = lvalue_list (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
448 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
449 if (! lvalues) |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
450 return retval; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
451 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
452 octave_idx_type nbh = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
453 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
454 for (const auto& lval : *lvalues) |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
455 nbh += lval.is_black_hole (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
456 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
457 if (nbh > 0) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
458 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
459 retval.resize (1, nbh); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
460 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
461 octave_idx_type k = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
462 octave_idx_type l = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
463 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
464 for (const auto& lval : *lvalues) |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
465 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
466 if (lval.is_black_hole ()) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
467 retval(l++) = k+1; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
468 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
469 k += lval.numel (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
470 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
471 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
472 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
473 return retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
474 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
475 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
476 bool |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
477 tree_evaluator::isargout (int nargout, int iout) const |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
478 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
479 const std::list<octave_lvalue> *lvalues = lvalue_list (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
480 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
481 if (iout >= std::max (nargout, 1)) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
482 return false; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
483 else if (lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
484 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
485 int k = 0; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
486 for (const auto& lval : *lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
487 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
488 if (k == iout) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
489 return ! lval.is_black_hole (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
490 k += lval.numel (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
491 if (k > iout) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
492 break; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
493 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
494 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
495 return true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
496 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
497 else |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
498 return true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
499 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
500 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
501 void |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
502 tree_evaluator::isargout (int nargout, int nout, bool *isargout) const |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
503 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
504 const std::list<octave_lvalue> *lvalues = lvalue_list (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
505 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
506 if (lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
507 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
508 int k = 0; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
509 for (const auto& lval : *lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
510 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
511 if (lval.is_black_hole ()) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
512 isargout[k++] = false; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
513 else |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
514 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
515 int l = std::min (k + lval.numel (), |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
516 static_cast<octave_idx_type> (nout)); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
517 while (k < l) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
518 isargout[k++] = true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
519 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
520 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
521 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
522 else |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
523 for (int i = 0; i < nout; i++) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
524 isargout[i] = true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
525 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
526 for (int i = std::max (nargout, 1); i < nout; i++) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
527 isargout[i] = false; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
528 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
529 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
530 octave_value |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
531 tree_evaluator::evaluate (tree_decl_elt *elt) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
532 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
533 // Do not allow functions to return null values. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
534 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
535 tree_identifier *id = elt->ident (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
536 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
537 return id ? evaluate (id).storable_value () : octave_value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
538 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
539 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
540 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
541 tree_evaluator::define_parameter_list_from_arg_vector |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
542 (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
|
543 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
544 int i = -1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
545 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
546 for (tree_decl_elt *elt : *param_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
547 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
548 i++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
549 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
550 octave_lvalue ref = elt->lvalue (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
551 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
552 if (i < args.length ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
553 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
554 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
|
555 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
556 if (! eval_decl_elt (elt)) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
557 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
|
558 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
559 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
560 ref.define (args(i)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
561 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
562 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
563 eval_decl_elt (elt); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
564 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
565 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
567 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
568 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
|
569 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
570 for (tree_decl_elt *elt : *param_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
571 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
572 octave_lvalue ref = elt->lvalue (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
573 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
574 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
|
575 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
576 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
577 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
578 octave_value_list |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
579 tree_evaluator::convert_return_list_to_const_vector |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
580 (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
|
581 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
582 octave_idx_type vlen = varargout.numel (); |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
583 int len = ret_list->length (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
584 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
585 // Special case. Will do a shallow copy. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
586 if (len == 0) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
587 return varargout; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
588 else if (nargout <= len) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
589 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
590 symbol_scope scope = get_current_scope (); |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
591 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
592 symbol_record::context_id context = scope.current_context (); |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
593 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
594 octave_value_list retval (nargout); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
595 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
596 int i = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
597 |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
598 for (tree_decl_elt *elt : *ret_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
599 { |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
600 if (elt->is_defined (context)) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
601 { |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
602 octave_value tmp = evaluate (elt); |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
603 retval(i) = tmp; |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
604 } |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
605 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
606 i++; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
607 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
608 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
609 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
610 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
611 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
612 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
613 octave_value_list retval (len + vlen); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
614 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
615 int i = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
616 |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
617 for (tree_decl_elt *elt : *ret_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
618 retval(i++) = evaluate (elt); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
619 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
620 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
|
621 retval(i++) = varargout(j); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
622 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
623 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
624 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
625 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
626 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
627 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
628 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
|
629 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
630 bool retval = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
631 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
632 tree_identifier *id = elt->ident (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
633 tree_expression *expr = elt->expression (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
634 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
635 if (id && expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
636 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
637 octave_lvalue ult = id->lvalue (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
638 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
639 octave_value init_val = evaluate (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
640 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
641 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
|
642 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
643 retval = true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
644 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
645 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
646 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
647 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
648 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
649 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
650 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
|
651 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
|
652 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
653 tree_expression *label = expr->case_label (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
654 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
655 octave_value label_value = evaluate (label); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
656 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
657 if (label_value.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
658 { |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23563
diff
changeset
|
659 if (label_value.iscell ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
660 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
661 Cell cell (label_value.cell_value ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
662 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
663 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
|
664 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
665 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
|
666 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
667 bool match = val.is_equal (cell(i,j)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
668 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
669 if (match) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
670 return true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
671 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
672 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
673 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
674 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
675 return val.is_equal (label_value); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
676 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
677 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
678 return false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
679 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
680 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
681 symbol_scope |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
682 tree_evaluator::get_current_scope (void) |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
683 { |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
684 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
|
685 |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
686 return symtab.current_scope (); |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
687 } |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
688 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
689 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
|
690 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
|
691 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
692 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
|
693 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
694 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
|
695 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
|
696 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
|
697 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
698 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
699 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
700 do_breakpoint (cmd.is_breakpoint (true)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
701 |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
702 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
|
703 |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
704 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
|
705 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
|
706 } |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
707 |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
708 void |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
709 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
|
710 { |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
711 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
|
712 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
|
713 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
714 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
715 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
|
716 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
|
717 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
718 tree_identifier *id = elt.ident (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
719 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
720 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
|
721 { |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
722 if (elt.is_global ()) |
24352
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24349
diff
changeset
|
723 { |
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24349
diff
changeset
|
724 symbol_table& symtab = m_interpreter.get_symbol_table (); |
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24349
diff
changeset
|
725 |
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24349
diff
changeset
|
726 symbol_record global_sym = symtab.find_global_symbol (id->name ()); |
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24349
diff
changeset
|
727 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
728 id->link_to_global (symtab.global_scope (), global_sym); |
24352
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24349
diff
changeset
|
729 } |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
730 else if (elt.is_persistent ()) |
23470
a41fdb801db6
use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents:
23469
diff
changeset
|
731 id->mark_persistent (); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
732 else |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
733 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
|
734 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
735 octave_lvalue ult = id->lvalue (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
736 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
737 if (ult.is_undefined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
738 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
739 tree_expression *expr = elt.expression (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
740 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
741 octave_value init_val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
742 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
743 if (expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
744 init_val = evaluate (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
745 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
746 init_val = Matrix (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
747 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
748 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
|
749 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
750 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
751 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
753 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
754 // Decide if it's time to quit a for or while loop. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 static inline bool |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
756 quit_loop_now (void) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
757 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
758 octave_quit (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
759 |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
760 // Maybe handle 'continue N' someday... |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 |
23369
2a6246cc4a68
* pt-eval.cc (quit_loop_now): Avoid deprecated variable warnings.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
762 if (octave::tree_continue_command::continuing) |
2a6246cc4a68
* pt-eval.cc (quit_loop_now): Avoid deprecated variable warnings.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
763 octave::tree_continue_command::continuing--; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
764 |
23369
2a6246cc4a68
* pt-eval.cc (quit_loop_now): Avoid deprecated variable warnings.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
765 bool quit = (octave::tree_return_command::returning |
2a6246cc4a68
* pt-eval.cc (quit_loop_now): Avoid deprecated variable warnings.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
766 || octave::tree_break_command::breaking |
2a6246cc4a68
* pt-eval.cc (quit_loop_now): Avoid deprecated variable warnings.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
767 || octave::tree_continue_command::continuing); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
768 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23369
diff
changeset
|
769 if (octave::tree_break_command::breaking) |
23369
2a6246cc4a68
* pt-eval.cc (quit_loop_now): Avoid deprecated variable warnings.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
770 octave::tree_break_command::breaking--; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
771 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
772 return quit; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
773 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
774 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
775 namespace octave |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
776 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
777 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
778 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
|
779 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
780 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
|
781 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
782 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
|
783 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
784 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
|
785 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
786 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
787 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
788 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
789 do_breakpoint (cmd.is_breakpoint (true)); |
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
|
790 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
791 // 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
|
792 // and cmd.maxproc_expr (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
793 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
794 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
795 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
796 frame.protect_var (in_loop_command); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
797 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
798 in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
799 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
800 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
|
801 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
802 octave_value rhs = evaluate (expr); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
803 |
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
|
804 #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
|
805 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
|
806 return; |
15027
741d2dbcc117
Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents:
15023
diff
changeset
|
807 #endif |
741d2dbcc117
Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents:
15023
diff
changeset
|
808 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
809 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
|
810 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
811 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
812 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
|
813 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
814 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
|
815 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
816 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
|
817 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
818 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
|
819 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
820 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
|
821 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
822 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
|
823 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
824 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
|
825 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
826 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
|
827 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
|
828 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
829 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
|
830 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
831 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
|
832 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
833 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
|
834 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
835 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
836 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
|
837 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
838 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
839 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
840 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
|
841 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
842 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
|
843 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
|
844 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
845 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
|
846 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
847 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
|
848 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
849 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
850 // 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
|
851 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
|
852 } |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23563
diff
changeset
|
853 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
|
854 || 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
|
855 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
856 // 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
|
857 // columns. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
858 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
859 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
|
860 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
861 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
|
862 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
|
863 |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
864 octave_value arg = rhs; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
865 if (rhs.ndims () > 2) |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
866 arg = arg.reshape (dv); |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
867 |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
868 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
|
869 { |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
870 octave_value_list idx; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
871 octave_idx_type iidx; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
872 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
873 // 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
|
874 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
|
875 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
876 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
|
877 iidx = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
878 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
879 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
880 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
881 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
|
882 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
|
883 iidx = 1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
884 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
885 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
886 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
|
887 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
888 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
|
889 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
|
890 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
891 // 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
|
892 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
|
893 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
|
894 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
895 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
|
896 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
897 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
|
898 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
|
899 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
900 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
|
901 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
902 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
903 } |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
904 else |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
905 { |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
906 // 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
|
907 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
|
908 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
909 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
910 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
911 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
|
912 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
|
913 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
914 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
915 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
916 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
|
917 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
918 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
|
919 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
920 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
|
921 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
922 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
|
923 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
924 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
925 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
926 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
927 do_breakpoint (cmd.is_breakpoint (true)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
928 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
929 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
|
930 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
931 frame.protect_var (in_loop_command); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
932 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
933 in_loop_command = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
934 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
935 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
|
936 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
937 octave_value rhs = evaluate (expr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
938 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
939 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
|
940 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
941 |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
942 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
|
943 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
|
944 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
945 // 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
|
946 // 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
|
947 // structure element. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
948 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
949 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
|
950 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
951 tree_argument_list::iterator p = lhs->begin (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
952 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
953 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
|
954 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
955 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
|
956 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
957 elt = *p; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
958 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
959 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
|
960 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
961 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
|
962 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
963 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
|
964 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
965 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
|
966 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
967 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
|
968 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
969 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
|
970 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
971 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
|
972 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
|
973 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
974 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
|
975 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
976 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
|
977 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
978 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
|
979 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
980 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
|
981 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
982 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
|
983 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
|
984 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
985 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
|
986 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
|
987 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
988 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
|
989 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
990 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
991 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
992 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
993 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
994 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
|
995 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
996 // ?? |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
997 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
998 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
999 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1000 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1001 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
|
1002 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1003 // ?? |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1004 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1005 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1006 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1007 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1008 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
|
1009 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1010 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1011 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1012 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1013 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1014 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
|
1015 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1016 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1017 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1018 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1019 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1020 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
|
1021 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1022 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
|
1023 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1024 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
|
1025 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1026 if (f) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1027 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1028 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
|
1029 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1030 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
|
1031 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1032 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
|
1033 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1034 // 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
|
1035 // 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
|
1036 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1037 symbol_scope scope = symtab.current_scope (); |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
1038 |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
1039 if (scope) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1040 scope.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
|
1041 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1042 } |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
1043 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1044 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1045 tree_evaluator::visit_identifier (tree_identifier& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1046 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1047 octave_value_list retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1048 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1049 symbol_scope scope = get_current_scope (); |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1050 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1051 symbol_record::context_id context = scope.current_context (); |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1052 |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
24075
diff
changeset
|
1053 symbol_record sym = expr.symbol (); |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1054 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1055 octave_value val = sym.find (context); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1056 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1057 if (val.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1058 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1059 // GAGME -- this would be cleaner if we required |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1060 // parens to indicate function calls. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1061 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1062 // If this identifier refers to a function, we need to know |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1063 // whether it is indexed so that we can do the same thing |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1064 // for 'f' and 'f()'. If the index is present and the function |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1065 // object declares it can handle it, return the function object |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1066 // and let tree_index_expression::rvalue handle indexing. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1067 // Otherwise, arrange to call the function here, so that we don't |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1068 // return the function definition as a value. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1069 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
1070 octave_function *fcn = nullptr; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1071 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1072 if (val.is_function ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1073 fcn = val.function_value (true); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1074 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1075 int nargout = m_nargout_stack.top (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1076 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1077 if (fcn && ! (expr.is_postfix_indexed () |
23503
6a2fed2d39ac
improve some function names
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
1078 && fcn->accepts_postfix_index (expr.postfix_index ()))) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1079 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23523
diff
changeset
|
1080 retval = fcn->call (*this, nargout); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1081 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1082 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1083 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1084 if (expr.print_result () && nargout == 0 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1085 && statement_printing_enabled ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1086 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1087 octave_value_list args = ovl (val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1088 args.stash_name_tags (string_vector (expr.name ())); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1089 feval ("display", args); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1090 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1091 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1092 push_result (val); |
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1093 return; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1094 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1095 } |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1096 else if (sym.is_added_static ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1097 expr.static_workspace_error (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1098 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1099 expr.eval_undefined_error (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1100 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1101 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1102 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1103 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1104 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1105 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
|
1106 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1107 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1108 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1109 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1110 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1111 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
|
1112 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1113 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
|
1114 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1115 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
|
1116 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
|
1117 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
|
1118 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1119 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1120 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
|
1121 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1122 if (lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1123 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
|
1124 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1125 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1126 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1127 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
|
1128 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
1129 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
|
1130 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1131 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
|
1132 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1133 if (statement_context == function || statement_context == script) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
1134 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
|
1135 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1136 if (debug_mode && ! tic->is_else_clause ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1137 do_breakpoint (tic->is_breakpoint (true)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1138 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1139 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
|
1140 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1141 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
|
1142 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1143 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
|
1144 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
|
1145 |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
1146 break; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1147 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1148 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1149 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1150 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1151 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1152 // Final step of processing an indexing error. Add the name of the |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1153 // variable being indexed, if any, then issue an error. (Will this also |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1154 // be needed by pt-lvalue, which calls subsref?) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1155 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1156 static void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1157 final_index_error (octave::index_exception& e, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1158 const octave::tree_expression *expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1159 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1160 std::string extra_message; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1161 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1162 // FIXME: make this a member function for direct access to symbol |
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1163 // table and scope? |
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1164 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1165 octave::symbol_scope scope |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1166 = octave::__require_current_scope__ ("final_index_error"); |
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1167 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1168 octave::symbol_record::context_id context = scope.current_context (); |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1169 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1170 if (expr->is_identifier () |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1171 && dynamic_cast<const octave::tree_identifier *> (expr)->is_variable (context)) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1172 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1173 std::string var = expr->name (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1174 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1175 e.set_var (var); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1176 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23684
diff
changeset
|
1177 octave::symbol_table& symtab = octave::__get_symbol_table__ ("final_index_error"); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1178 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1179 octave_value fcn = symtab.find_function (var); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1180 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1181 if (fcn.is_function ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1182 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1183 octave_function *fp = fcn.function_value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1184 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1185 if (fp && fp->name () == var) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1186 extra_message = " (note: variable '" + var + "' shadows function)"; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1187 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1188 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1189 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1190 std::string msg = e.message () + extra_message; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1191 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1192 error_with_id (e.err_id (), msg.c_str ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1193 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1194 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1195 namespace octave |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1196 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1197 // Unlike Matlab, which does not allow the result of a function call |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1198 // or array indexing expression to be further indexed, Octave attempts |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1199 // to handle arbitrary index expressions. For example, Octave allows |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1200 // expressions like |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1201 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1202 // svd (rand (10))(1:5) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1203 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1204 // Although octave_value objects may contain function objects, no |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1205 // indexing operation or function call is supposed to return them |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1206 // directly. Instead, the language is supposed to only allow function |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1207 // objects to be stored as function handles (named or anonymous) or as |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1208 // inline functions. The only place a function object should appear |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1209 // directly is if the symbol stored in a tree_identifier object |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1210 // resolves to a function. This means that the only place we need to |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1211 // look for functions is in the first element of the index |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1212 // expression. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1213 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1214 // Steps: |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1215 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1216 // * Obtain the initial value from the expression component of the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1217 // tree_index_expression object. If it is a tree_identifier object |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1218 // indexed by '(args)' and the identifier is not a variable, then |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1219 // peform a function call. Use the (optional) arguments to perform |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1220 // the function lookup so we choose the correct function or class |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1221 // method to call. Otherwise, evaluate the first expression |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1222 // without any additional arguments. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1223 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1224 // * Iterate over the remaining elements of the index expression and |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1225 // call the octave_value::subsref method. If indexing a class or |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1226 // classdef object, build up a list of indices for a call to the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1227 // subsref method for the object. Otherwise, use the result of |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1228 // each temporary evaluation for the next index element. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1229 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1230 // * If not indexing a class or classdef object and any partial |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1231 // expression evaluation produces a class or classdef object, then |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1232 // build up a complete argument list from that point on for a final |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1233 // subsref call for that object. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1234 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1235 // Multiple partial evaluations may be required. For example, |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1236 // given a class or classdef object X, then for the expression |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1237 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1238 // x.a{end}(2:end).b |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1239 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1240 // we must evaluate x.a to obtain the size for the first {end} |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1241 // expression, then we must evaluate x.a{end} to obtain the size |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1242 // for the second (2:end) expression. Finally, the complete |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1243 // expression may be evaluated. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1244 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1245 // If X is a cell array in the above expression, and none of the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1246 // intermediate evaluations produces a class or classdef object, |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1247 // then the evaluation is performed as the following series of |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1248 // steps |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1249 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1250 // tmp = x.a |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1251 // tmp = tmp{end} |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1252 // tmp = tmp(2:end) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1253 // result = tmp.b |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1254 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1255 // If any of the partial evaluations produces a class or classdef |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1256 // object, then the subsref method for that object is called as |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1257 // described above. For example, suppose x.a produces a classdef |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1258 // object. Then the evaluation is performed as the following |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1259 // series of steps |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1260 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1261 // base_expr = tmp = x.a |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1262 // tmp = base_expr{end} |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1263 // base_expr{end}(2:end).b |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1264 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1265 // In the last two steps, the partial value computed in the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1266 // previous step is used to determine the value of END. |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1267 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1268 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1269 tree_evaluator::visit_index_expression (tree_index_expression& idx_expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1270 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1271 octave_value_list retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1272 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1273 int nargout = m_nargout_stack.top (); |
23458
0f4ed33886de
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
1274 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1275 std::string type = idx_expr.type_tags (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1276 std::list<tree_argument_list *> args = idx_expr.arg_lists (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1277 std::list<string_vector> arg_nm = idx_expr.arg_names (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1278 std::list<tree_expression *> dyn_field = idx_expr.dyn_fields (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1279 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1280 assert (! args.empty ()); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1281 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1282 std::list<tree_argument_list *>::iterator p_args = args.begin (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1283 std::list<string_vector>::iterator p_arg_nm = arg_nm.begin (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1284 std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1285 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1286 int n = args.size (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1287 int beg = 0; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1288 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1289 octave_value base_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1290 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1291 tree_expression *expr = idx_expr.expression (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1292 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1293 if (expr->is_identifier () && type[beg] == '(') |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1294 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1295 tree_identifier *id = dynamic_cast<tree_identifier *> (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1296 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1297 symbol_scope scope = get_current_scope (); |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1298 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
1299 symbol_record::context_id context = scope.current_context (); |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1300 |
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1301 if (! id->is_variable (context)) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1302 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1303 octave_value_list first_args; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1304 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1305 tree_argument_list *al = *p_args; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1306 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1307 if (al && al->length () > 0) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1308 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1309 // Function calls inside an argument list can't have |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1310 // ignored output arguments. |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1311 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1312 unwind_protect frame; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1313 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
1314 m_lvalue_list_stack.push (nullptr); |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1315 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1316 frame.add_method (m_lvalue_list_stack, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1317 &value_stack<const std::list<octave_lvalue>*>::pop); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1318 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1319 string_vector anm = *p_arg_nm; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1320 first_args = al->convert_to_const_vector (this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1321 first_args.stash_name_tags (anm); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1322 } |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1323 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1324 octave_function *fcn = nullptr; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1325 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
1326 octave_value val = id->do_lookup (context, first_args); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1327 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1328 if (val.is_function ()) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1329 fcn = val.function_value (true); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1330 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1331 if (fcn) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1332 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1333 try |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1334 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23523
diff
changeset
|
1335 retval = fcn->call (*this, nargout, first_args); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1336 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1337 catch (index_exception& e) |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1338 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1339 final_index_error (e, expr); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1340 } |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1341 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1342 beg++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1343 p_args++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1344 p_arg_nm++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1345 p_dyn_field++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1346 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1347 if (n > beg) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1348 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1349 // More indices to follow. Silently ignore |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1350 // extra output values. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1351 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1352 if (retval.length () == 0) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1353 error ("indexing undefined value"); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1354 else |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1355 base_expr_val = retval(0); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1356 } |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1357 else |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1358 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1359 // No more indices, so we are done. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1360 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1361 push_result (retval); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1362 return; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1363 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1364 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1365 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1366 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1367 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1368 if (base_expr_val.is_undefined ()) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1369 base_expr_val = evaluate (expr); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1370 |
23781
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1371 // If we are indexing an object or looking at something like |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1372 // |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1373 // classname.static_function (args, ...); |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1374 // |
23844
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
1375 // then we'll just build a complete index list for one big subsref |
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
1376 // call. If the expression we are indexing is a classname then |
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
1377 // base_expr_val will be an octave_classdef_meta object. If we have |
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
1378 // files in a +packagename folder, they will also be an |
23838
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
1379 // octave_classdef_meta object, but we don't want to index them. |
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
1380 |
23844
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
1381 bool indexing_object = (base_expr_val.isobject () |
23838
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
1382 || base_expr_val.isjava () |
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
1383 || (base_expr_val.is_classdef_meta () |
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
1384 && ! base_expr_val.is_package ())); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1385 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1386 std::list<octave_value_list> idx; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1387 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1388 octave_value partial_expr_val = base_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1389 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1390 for (int i = beg; i < n; i++) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1391 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1392 if (i > beg) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1393 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1394 tree_argument_list *al = *p_args; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1395 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1396 if (! indexing_object || (al && al->has_magic_end ())) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1397 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1398 // Evaluate what we have so far to find the value to |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1399 // pass to the END function. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1400 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1401 try |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1402 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1403 // Silently ignore extra output values. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1404 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1405 octave_value_list tmp_list |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1406 = base_expr_val.subsref (type.substr (beg, i-beg), |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1407 idx, nargout); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1408 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1409 partial_expr_val |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1410 = tmp_list.length () ? tmp_list(0) : octave_value (); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1411 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1412 if (! indexing_object) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1413 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1414 base_expr_val = partial_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1415 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1416 if (partial_expr_val.is_cs_list ()) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1417 err_indexed_cs_list (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1418 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1419 retval = partial_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1420 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1421 beg = i; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1422 idx.clear (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1423 |
23781
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1424 if (partial_expr_val.isobject () |
24075
3645139bd28f
allow meta.class.fromName to work again (bug #51935)
Piotr Held <pjheld@gmail.com>
parents:
24037
diff
changeset
|
1425 || partial_expr_val.isjava () |
3645139bd28f
allow meta.class.fromName to work again (bug #51935)
Piotr Held <pjheld@gmail.com>
parents:
24037
diff
changeset
|
1426 || (partial_expr_val.is_classdef_meta () |
3645139bd28f
allow meta.class.fromName to work again (bug #51935)
Piotr Held <pjheld@gmail.com>
parents:
24037
diff
changeset
|
1427 && ! partial_expr_val.is_package ())) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1428 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1429 // Found an object, so now we'll build up |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1430 // complete index list for one big subsref |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1431 // call from this point on. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1432 |
23781
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1433 // FIXME: is is also possible to have a |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1434 // static method call buried somewhere in |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1435 // the depths of a complex indexing |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1436 // expression so that we would also need to |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1437 // check for an octave_classdef_meta object |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1438 // here? |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
1439 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1440 indexing_object = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1441 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1442 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1443 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1444 catch (index_exception& e) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1445 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1446 final_index_error (e, expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1447 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1448 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1449 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1450 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1451 switch (type[i]) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1452 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1453 case '(': |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1454 idx.push_back (make_value_list (*p_args, *p_arg_nm, &partial_expr_val)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1455 break; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1456 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1457 case '{': |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1458 idx.push_back (make_value_list (*p_args, *p_arg_nm, &partial_expr_val)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1459 break; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1460 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1461 case '.': |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1462 idx.push_back (octave_value |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1463 (idx_expr.get_struct_index (this, p_arg_nm, p_dyn_field))); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1464 break; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1465 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1466 default: |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1467 panic_impossible (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1468 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1469 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1470 p_args++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1471 p_arg_nm++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1472 p_dyn_field++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1473 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1474 |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1475 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1476 // If ! idx.empty () that means we still have stuff to index otherwise |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1477 // they would have been dealt with and idx would have been emptied. |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1478 if (! idx.empty ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1479 { |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1480 // This is for +package and other classdef_meta objects |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1481 if (! base_expr_val.is_function () |
23844
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
1482 || base_expr_val.is_classdef_meta ()) |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1483 { |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1484 try |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1485 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1486 retval = base_expr_val.subsref (type.substr (beg, n-beg), |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1487 idx, nargout); |
23871
5352f632859b
Fix (once more) pkg.fcn with no arguments (bug #51715).
Piotr Held <pjheld@gmail.com>
parents:
23865
diff
changeset
|
1488 beg = n; |
5352f632859b
Fix (once more) pkg.fcn with no arguments (bug #51715).
Piotr Held <pjheld@gmail.com>
parents:
23865
diff
changeset
|
1489 idx.clear (); |
23876
b6e756d8f485
maint: eliminate TAB characters from source files
John W. Eaton <jwe@octave.org>
parents:
23872
diff
changeset
|
1490 } |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1491 catch (octave::index_exception& e) |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1492 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1493 final_index_error (e, expr); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1494 } |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1495 } |
23872
9b39ec2e0952
revert unintended change to pt-eval.cc made in d56c18dc1373
John W. Eaton <jwe@octave.org>
parents:
23871
diff
changeset
|
1496 else |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1497 { |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1498 // FIXME: we want this to only be a superclass constructor |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1499 // call Should we actually make a check for this or are all |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1500 // other types of calls already dealt with? |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1501 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1502 octave_function *fcn = base_expr_val.function_value (); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1503 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1504 if (fcn) |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1505 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1506 try |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1507 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1508 retval = fcn->call (*this, nargout, idx); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1509 } |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1510 catch (octave::index_exception& e) |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1511 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1512 final_index_error (e, expr); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1513 } |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1514 } |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
1515 } |
23435
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 |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1518 // FIXME: when can the following happen? In what case does indexing |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1519 // result in a value that is a function? Classdef method calls? |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
1520 // Something else? |
23683
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1521 |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1522 octave_value val = (retval.length () ? retval(0) : octave_value ()); |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1523 |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1524 if (val.is_function ()) |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1525 { |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1526 octave_function *fcn = val.function_value (true); |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1527 |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1528 if (fcn) |
23684
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1529 { |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1530 octave_value_list final_args; |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1531 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1532 if (! idx.empty ()) |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1533 { |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1534 if (n - beg != 1) |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1535 error ("unexpected extra index at end of expression"); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1536 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1537 if (type[beg] != '(') |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1538 error ("invalid index type '%c' for function call", |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1539 type[beg]); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1540 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1541 final_args = idx.front (); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1542 } |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1543 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1544 retval = fcn->call (*this, nargout, final_args); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
1545 } |
23683
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1546 } |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
1547 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1548 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1549 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1550 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1551 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1552 tree_evaluator::visit_matrix (tree_matrix& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1553 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1554 octave_value retval = Matrix (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1555 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1556 bool all_strings_p = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1557 bool all_sq_strings_p = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1558 bool all_dq_strings_p = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1559 bool all_empty_p = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1560 bool all_real_p = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1561 bool any_sparse_p = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1562 bool any_class_p = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1563 bool frc_str_conv = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1564 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1565 tm_const tmp (expr, this); |
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 if (tmp && ! tmp.empty ()) |
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 dim_vector dv = tmp.dims (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1570 all_strings_p = tmp.all_strings_p (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1571 all_sq_strings_p = tmp.all_sq_strings_p (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1572 all_dq_strings_p = tmp.all_dq_strings_p (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1573 all_empty_p = tmp.all_empty_p (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1574 all_real_p = tmp.all_real_p (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1575 any_sparse_p = tmp.any_sparse_p (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1576 any_class_p = tmp.any_class_p (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1577 frc_str_conv = tmp.some_strings_p (); |
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 // Try to speed up the common cases. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1580 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1581 std::string result_type = tmp.class_name (); |
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 if (any_class_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1584 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1585 retval = do_class_concat (tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1586 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1587 else if (result_type == "double") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1588 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1589 if (any_sparse_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1590 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1591 if (all_real_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1592 retval = do_single_type_concat<SparseMatrix> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1593 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1594 retval = do_single_type_concat<SparseComplexMatrix> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1595 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1596 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1597 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1598 if (all_real_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1599 retval = do_single_type_concat<NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1600 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1601 retval = do_single_type_concat<ComplexNDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1602 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1603 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1604 else if (result_type == "single") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1605 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1606 if (all_real_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1607 retval = do_single_type_concat<FloatNDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1608 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1609 retval = do_single_type_concat<FloatComplexNDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1610 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1611 else if (result_type == "char") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1612 { |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
1613 char type = (all_dq_strings_p ? '"' : '\''); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1614 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1615 if (! all_strings_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1616 warn_implicit_conversion ("Octave:num-to-str", |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1617 "numeric", result_type); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1618 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1619 maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1620 |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
1621 charNDArray result (dv, m_string_fill_char); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1622 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1623 single_type_concat<charNDArray> (result, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1624 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1625 retval = octave_value (result, type); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1626 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1627 else if (result_type == "logical") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1628 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1629 if (any_sparse_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1630 retval = do_single_type_concat<SparseBoolMatrix> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1631 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1632 retval = do_single_type_concat<boolNDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1633 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1634 else if (result_type == "int8") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1635 retval = do_single_type_concat<int8NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1636 else if (result_type == "int16") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1637 retval = do_single_type_concat<int16NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1638 else if (result_type == "int32") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1639 retval = do_single_type_concat<int32NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1640 else if (result_type == "int64") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1641 retval = do_single_type_concat<int64NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1642 else if (result_type == "uint8") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1643 retval = do_single_type_concat<uint8NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1644 else if (result_type == "uint16") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1645 retval = do_single_type_concat<uint16NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1646 else if (result_type == "uint32") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1647 retval = do_single_type_concat<uint32NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1648 else if (result_type == "uint64") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1649 retval = do_single_type_concat<uint64NDArray> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1650 else if (result_type == "cell") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1651 retval = do_single_type_concat<Cell> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1652 else if (result_type == "struct") |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1653 retval = do_single_type_concat<octave_map> (dv, tmp); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1654 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1655 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1656 // The line below might seem crazy, since we take a copy of |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1657 // the first argument, resize it to be empty and then resize |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1658 // it to be full. This is done since it means that there is |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1659 // no recopying of data, as would happen if we used a single |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1660 // resize. It should be noted that resize operation is also |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1661 // significantly slower than the do_cat_op function, so it |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1662 // makes sense to have an empty matrix and copy all data. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1663 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1664 // We might also start with a empty octave_value using |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1665 // |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1666 // ctmp = octave::type_info::lookup_type |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1667 // (tmp.begin() -> begin() -> type_name()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1668 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1669 // and then directly resize. However, for some types there |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1670 // might be some additional setup needed, and so this should |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1671 // be avoided. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1672 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1673 octave_value ctmp; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1674 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1675 // Find the first non-empty object |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1676 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1677 if (any_sparse_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1678 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1679 // Start with sparse matrix to avoid issues memory issues |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1680 // with things like [ones(1,4),sprandn(1e8,4,1e-4)] |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1681 if (all_real_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1682 ctmp = octave_sparse_matrix ().resize (dv); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1683 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1684 ctmp = octave_sparse_complex_matrix ().resize (dv); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1685 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1686 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1687 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1688 for (tm_row_const& row : tmp) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1689 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1690 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1691 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1692 for (auto& elt : row) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1693 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1694 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1695 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1696 ctmp = elt; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1697 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1698 if (! ctmp.all_zero_dims ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1699 goto found_non_empty; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1700 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1701 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1702 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1703 ctmp = (*(tmp.begin () -> begin ())); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1704 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1705 found_non_empty: |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1706 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1707 if (! all_empty_p) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1708 ctmp = ctmp.resize (dim_vector (0,0)).resize (dv); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1709 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1710 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1711 // Now, extract the values from the individual elements and |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1712 // insert them in the result matrix. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1713 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1714 int dv_len = dv.ndims (); |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
1715 octave_idx_type ntmp = (dv_len > 1 ? dv_len : 2); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1716 Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1717 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1718 for (tm_row_const& row : tmp) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1719 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1720 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1721 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1722 for (auto& elt : row) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1723 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1724 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1725 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
1726 if (elt.isempty ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1727 continue; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1728 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1729 ctmp = do_cat_op (ctmp, elt, ra_idx); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1730 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1731 ra_idx (1) += elt.columns (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1732 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1733 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1734 ra_idx (0) += row.rows (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1735 ra_idx (1) = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1736 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1737 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1738 retval = ctmp; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1739 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1740 if (frc_str_conv && ! retval.is_string ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1741 retval = retval.convert_to_str (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1742 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1743 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1744 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1745 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1746 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1747 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1748 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1749 tree_evaluator::visit_cell (tree_cell& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1750 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1751 octave_value retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1752 |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1753 // Function calls inside an argument list can't have ignored |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1754 // output arguments. |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1755 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1756 unwind_protect frame; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1757 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
1758 m_lvalue_list_stack.push (nullptr); |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1759 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1760 frame.add_method (m_lvalue_list_stack, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1761 &value_stack<const std::list<octave_lvalue>*>::pop); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1762 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1763 octave_idx_type nr = expr.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1764 octave_idx_type nc = -1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1765 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1766 Cell val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1767 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1768 octave_idx_type i = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1769 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
1770 for (tree_argument_list *elt : expr) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1771 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1772 octave_value_list row = elt->convert_to_const_vector (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1773 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1774 if (nr == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1775 // Optimize the single row case. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1776 val = row.cell_value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1777 else if (nc < 0) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1778 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1779 nc = row.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1780 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1781 val = Cell (nr, nc); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1782 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1783 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1784 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1785 octave_idx_type this_nc = row.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1786 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1787 if (this_nc != nc) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1788 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1789 if (this_nc == 0) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1790 continue; // blank line |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1791 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1792 error ("number of columns must match"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1793 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1794 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1795 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1796 for (octave_idx_type j = 0; j < nc; j++) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1797 val(i,j) = row(j); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1798 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1799 i++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1800 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1801 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1802 if (i < nr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1803 val.resize (dim_vector (i, nc)); // there were blank rows |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1804 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1805 retval = val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1806 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1807 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1808 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1809 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1810 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1811 tree_evaluator::visit_multi_assignment (tree_multi_assignment& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1812 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1813 octave_value_list val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1814 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1815 tree_expression *rhs = expr.right_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1816 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1817 if (rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1818 { |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1819 unwind_protect frame; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1820 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1821 tree_argument_list *lhs = expr.left_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1822 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1823 std::list<octave_lvalue> lvalue_list = make_lvalue_list (lhs); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1824 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1825 m_lvalue_list_stack.push (&lvalue_list); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1826 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1827 frame.add_method (m_lvalue_list_stack, |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1828 &value_stack<const std::list<octave_lvalue>*>::pop); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1829 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1830 octave_idx_type n_out = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1831 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1832 for (const auto& lval : lvalue_list) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1833 n_out += lval.numel (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1834 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1835 // The following trick is used to keep rhs_val constant. |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
1836 const octave_value_list rhs_val1 = evaluate_n (rhs, n_out); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1837 const octave_value_list rhs_val = (rhs_val1.length () == 1 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1838 && rhs_val1(0).is_cs_list () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1839 ? rhs_val1(0).list_value () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1840 : rhs_val1); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1841 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1842 octave_idx_type k = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1843 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1844 octave_idx_type n = rhs_val.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1845 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1846 // To avoid copying per elements and possible optimizations, we |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1847 // postpone joining the final values. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1848 std::list<octave_value_list> retval_list; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1849 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1850 tree_argument_list::iterator q = lhs->begin (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1851 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1852 for (octave_lvalue ult : lvalue_list) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1853 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1854 tree_expression *lhs_elt = *q++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1855 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1856 octave_idx_type nel = ult.numel (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1857 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1858 if (nel != 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1859 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1860 // Huge kluge so that wrapper scripts with lines like |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1861 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1862 // [varargout{1:nargout}] = fcn (args); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1863 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1864 // Will work the same as calling fcn directly when nargout |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1865 // is 0 and fcn produces more than one output even when |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1866 // nargout is 0. This only works if varargout has not yet |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1867 // been defined. See also bug #43813. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1868 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1869 if (lvalue_list.size () == 1 && nel == 0 && n > 0 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1870 && ! ult.is_black_hole () && ult.is_undefined () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1871 && ult.index_type () == "{" && ult.index_is_empty ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1872 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1873 // Convert undefined lvalue with empty index to a cell |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1874 // array with a single value and indexed by 1 to |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1875 // handle a single output. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1876 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1877 nel = 1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1878 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1879 ult.define (Cell (1, 1)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1880 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1881 ult.clear_index (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1882 std::list<octave_value_list> idx; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1883 idx.push_back (octave_value_list (octave_value (1))); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1884 ult.set_index ("{", idx); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1885 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1886 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1887 if (k + nel > n) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1888 error ("some elements undefined in return list"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1889 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1890 // This element of the return list expects a |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1891 // comma-separated list of values. Slicing avoids |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1892 // copying. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1893 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1894 octave_value_list ovl = rhs_val.slice (k, nel); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1895 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1896 ult.assign (octave_value::op_asn_eq, octave_value (ovl)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1897 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1898 retval_list.push_back (ovl); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1899 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1900 k += nel; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1901 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1902 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1903 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1904 if (k < n) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1905 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1906 if (ult.is_black_hole ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1907 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1908 k++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1909 continue; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1910 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1911 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1912 { |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1913 octave_value tmp = rhs_val(k); |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1914 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1915 if (tmp.is_undefined ()) |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1916 error ("element number %d undefined in return list", |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1917 k+1); |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1918 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1919 ult.assign (octave_value::op_asn_eq, tmp); |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1920 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1921 retval_list.push_back (tmp); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1922 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1923 k++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1924 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1925 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1926 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1927 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1928 // This can happen for a function like |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1929 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1930 // function varargout = f () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1931 // varargout{1} = nargout; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1932 // endfunction |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1933 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1934 // called with |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1935 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1936 // [a, ~] = f (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1937 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1938 // Then the list of of RHS values will contain one |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1939 // element but we are iterating over the list of all |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1940 // RHS values. We shouldn't complain that a value we |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1941 // don't need is missing from the list. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1942 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1943 if (! ult.is_black_hole ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1944 error ("element number %d undefined in return list", k+1); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1945 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1946 k++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1947 continue; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1948 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1949 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1950 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1951 if (expr.print_result () && statement_printing_enabled ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1952 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1953 // We clear any index here so that we can get |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1954 // the new value of the referenced object below, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1955 // instead of the indexed value (which should be |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1956 // the same as the right hand side value). |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1957 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1958 ult.clear_index (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1959 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1960 octave_value lhs_val = ult.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1961 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1962 octave_value_list args = ovl (lhs_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1963 args.stash_name_tags (string_vector (lhs_elt->name ())); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1964 feval ("display", args); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1965 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1966 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1967 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1968 // Concatenate return values. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1969 val = retval_list; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1970 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1971 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1972 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1973 } |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
1974 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1975 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1976 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
|
1977 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1978 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
|
1979 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1980 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
|
1981 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
|
1982 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
|
1983 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1984 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1985 if (debug_mode && cmd.is_end_of_fcn_or_script ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1986 do_breakpoint (cmd.is_breakpoint (true), true); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1987 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1988 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1989 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1990 tree_evaluator::visit_constant (tree_constant& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1991 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1992 int nargout = m_nargout_stack.top (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1993 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1994 if (nargout > 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1995 error ("invalid number of output arguments for constant expression"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1996 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
1997 push_result (expr.value ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1998 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1999 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2000 void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2001 tree_evaluator::visit_fcn_handle (tree_fcn_handle& expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2002 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2003 std::string nm = expr.name (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2004 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2005 octave_value fh = make_fcn_handle (nm); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2006 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2007 push_result (fh); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2008 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2009 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2010 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2011 tree_evaluator::visit_funcall (tree_funcall& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2012 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2013 octave_value_list retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2014 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2015 octave_value fcn = expr.function (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2016 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2017 octave_value_list args = expr.arguments (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2018 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2019 int nargout = m_nargout_stack.top (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2020 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2021 retval = feval (fcn.function_value (), args, nargout); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2022 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2023 if (retval.length () == 1 && retval(0).is_function ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2024 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2025 // The return object is a function. We may need to re-index it |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2026 // using the same logic as for identifier. This is primarily |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2027 // used for superclass references in classdef. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2028 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2029 octave_value val = retval(0); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2030 octave_function *f = val.function_value (true); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2031 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2032 if (f && ! (expr.is_postfix_indexed () |
23503
6a2fed2d39ac
improve some function names
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
2033 && f->accepts_postfix_index (expr.postfix_index ()))) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2034 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23523
diff
changeset
|
2035 retval = f->call (*this, nargout); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2036 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2037 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2038 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2039 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2040 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2041 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2042 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2043 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
|
2044 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2045 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2046 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2047 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2048 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2049 tree_evaluator::visit_postfix_expression (tree_postfix_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2050 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2051 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2052 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2053 tree_expression *op = expr.operand (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2054 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2055 if (op) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2056 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2057 octave_value::unary_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2058 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2059 if (etype == octave_value::op_incr || etype == octave_value::op_decr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2060 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2061 octave_lvalue ref = op->lvalue (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2062 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2063 val = ref.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2064 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2065 profiler::enter<tree_postfix_expression> block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2066 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2067 ref.do_unary_op (etype); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2068 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2069 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2070 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2071 octave_value op_val = evaluate (op); |
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 (op_val.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2074 { |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2075 profiler::enter<tree_postfix_expression> |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2076 block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2077 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2078 val = ::do_unary_op (etype, op_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2079 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2080 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2081 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2082 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2083 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2084 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2085 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2086 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2087 tree_evaluator::visit_prefix_expression (tree_prefix_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2088 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2089 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2090 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2091 tree_expression *op = expr.operand (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2092 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2093 if (op) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2094 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2095 octave_value::unary_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2096 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2097 if (etype == octave_value::op_incr || etype == octave_value::op_decr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2098 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2099 octave_lvalue op_ref = op->lvalue (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2100 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2101 profiler::enter<tree_prefix_expression> block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2102 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2103 op_ref.do_unary_op (etype); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2104 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2105 val = op_ref.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2106 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2107 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2108 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2109 octave_value op_val = evaluate (op); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2110 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2111 if (op_val.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2112 { |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2113 profiler::enter<tree_prefix_expression> |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2114 block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2115 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2116 // Attempt to do the operation in-place if it is unshared |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2117 // (a temporary expression). |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2118 if (op_val.get_count () == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2119 val = op_val.do_non_const_unary_op (etype); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2120 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2121 val = ::do_unary_op (etype, op_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2122 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2123 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2124 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2125 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2126 push_result (val); |
22196
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2129 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2130 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
|
2131 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2132 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
|
2133 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2134 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
|
2135 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
|
2136 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
|
2137 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2138 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2139 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2140 do_breakpoint (cmd.is_breakpoint (true)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2141 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2142 // 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
|
2143 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2144 if (Vdebugging && m_call_stack.current_frame () == 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
|
2145 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2146 Vdebugging = false; |
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 reset_debug_state (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2149 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2150 else if (statement_context == function || statement_context == script |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2151 || in_loop_command) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2152 tree_return_command::returning = 1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2153 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2154 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2155 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2156 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
|
2157 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2158 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2159 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2160 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2161 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2162 tree_evaluator::visit_simple_assignment (tree_simple_assignment& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2163 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2164 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2165 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2166 tree_expression *rhs = expr.right_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2167 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2168 if (rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2169 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2170 octave_value rhs_val = evaluate (rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2171 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2172 if (rhs_val.is_undefined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2173 error ("value on right hand side of assignment is undefined"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2174 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2175 if (rhs_val.is_cs_list ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2176 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2177 const octave_value_list lst = rhs_val.list_value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2178 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2179 if (lst.empty ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2180 error ("invalid number of elements on RHS of assignment"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2181 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2182 rhs_val = lst(0); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2183 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2184 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2185 tree_expression *lhs = expr.left_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2186 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2187 try |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2188 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2189 unwind_protect frame; |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2190 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2191 octave_lvalue ult = lhs->lvalue (this); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2192 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2193 std::list<octave_lvalue> lvalue_list; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2194 lvalue_list.push_back (ult); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2195 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2196 m_lvalue_list_stack.push (&lvalue_list); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2197 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2198 frame.add_method (m_lvalue_list_stack, |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2199 &value_stack<const std::list<octave_lvalue>*>::pop); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2200 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2201 if (ult.numel () != 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2202 err_nonbraced_cs_list_assignment (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2203 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2204 octave_value::assign_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2205 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2206 ult.assign (etype, rhs_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2207 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2208 if (etype == octave_value::op_asn_eq) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2209 val = rhs_val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2210 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2211 val = ult.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2212 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2213 if (expr.print_result () && statement_printing_enabled ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2214 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2215 // We clear any index here so that we can |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2216 // get the new value of the referenced |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2217 // object below, instead of the indexed |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2218 // value (which should be the same as the |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2219 // right hand side value). |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2220 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2221 ult.clear_index (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2222 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2223 octave_value lhs_val = ult.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2224 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2225 octave_value_list args = ovl (lhs_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2226 args.stash_name_tags (string_vector (lhs->name ())); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2227 feval ("display", args); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2228 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2229 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2230 catch (index_exception& e) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2231 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2232 e.set_var (lhs->name ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2233 std::string msg = e.message (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2234 error_with_id (e.err_id (), msg.c_str ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2235 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2236 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2237 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2238 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2239 } |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
2240 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2241 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2242 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
|
2243 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2244 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
|
2245 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
|
2246 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2247 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
|
2248 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2249 if (statement_context == function || statement_context == script) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2250 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2251 // 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
|
2252 // 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
|
2253 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2254 if (Vtrack_line_num) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2255 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
|
2256 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2257 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2258 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2259 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2260 if (cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2261 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
|
2262 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2263 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2264 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
|
2265 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2266 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
|
2267 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
|
2268 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
|
2269 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2270 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2271 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2272 do_breakpoint (expr->is_breakpoint (true)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2273 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2274 // 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
|
2275 // 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
|
2276 // 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
|
2277 // 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
|
2278 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2279 // 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
|
2280 // 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
|
2281 // 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
|
2282 |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2283 octave_value tmp_result = evaluate (expr, 0); |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2284 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2285 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
|
2286 { |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2287 bool do_bind_ans = false; |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2288 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2289 if (expr->is_identifier ()) |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2290 { |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2291 symbol_scope scope = get_current_scope (); |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2292 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2293 symbol_record::context_id context |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2294 = scope.current_context (); |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2295 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2296 tree_identifier *id |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2297 = dynamic_cast<tree_identifier *> (expr); |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2298 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2299 do_bind_ans = (! id->is_variable (context)); |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2300 } |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2301 else |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2302 do_bind_ans = (! expr->is_assignment_expression ()); |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2303 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2304 if (do_bind_ans) |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2305 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
|
2306 && 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
|
2307 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2308 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2309 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2310 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
|
2311 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2312 // 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
|
2313 // 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
|
2314 // 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
|
2315 // 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
|
2316 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2317 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
|
2318 "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
|
2319 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2320 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2321 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2322 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2323 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2324 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
|
2325 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2326 // 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
|
2327 // 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
|
2328 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2329 tree_statement_list::iterator p = lst.begin (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2330 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2331 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
|
2332 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2333 while (true) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2334 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2335 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
|
2336 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2337 if (! elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2338 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
|
2339 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2340 octave_quit (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2341 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2342 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
|
2343 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2344 if (tree_break_command::breaking |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2345 || tree_continue_command::continuing) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2346 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2347 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2348 if (tree_return_command::returning) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2349 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2350 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2351 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
|
2352 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2353 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2354 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2355 // 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
|
2356 // 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
|
2357 // 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
|
2358 // 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
|
2359 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2360 // 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
|
2361 // # 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
|
2362 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2363 // 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
|
2364 // # 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
|
2365 // # 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
|
2366 // # 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
|
2367 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2368 // 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
|
2369 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2370 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2371 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2372 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2373 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2374 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2375 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
|
2376 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2377 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2378 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2379 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2380 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2381 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
|
2382 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2383 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2384 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2385 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2386 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2387 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
|
2388 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2389 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
|
2390 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2391 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
|
2392 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
|
2393 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
|
2394 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2395 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2396 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2397 do_breakpoint (cmd.is_breakpoint (true)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2398 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2399 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
|
2400 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2401 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2402 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
|
2403 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
|
2404 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2405 octave_value val = evaluate (expr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2406 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2407 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
|
2408 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2409 if (lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2410 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
2411 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
|
2412 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2413 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
|
2414 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2415 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
|
2416 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2417 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
|
2418 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
|
2419 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2420 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2421 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2422 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2423 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2424 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2425 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2426 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2427 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
|
2428 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2429 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
|
2430 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2431 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
|
2432 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
|
2433 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
|
2434 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2435 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2436 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
|
2437 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
2438 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
2439 // 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
|
2440 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
|
2441 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2442 frame.protect_var (buffer_error_messages); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2443 frame.protect_var (Vdebug_on_error); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2444 frame.protect_var (Vdebug_on_warning); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2445 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2446 buffer_error_messages++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2447 Vdebug_on_error = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2448 Vdebug_on_warning = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2449 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2450 // 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
|
2451 // 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
|
2452 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2453 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
|
2454 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2455 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
|
2456 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2457 try |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
2458 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2459 in_try_catch++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2460 try_code->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2461 in_try_catch--; |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
2462 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2463 catch (const execution_exception&) |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
2464 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2465 interpreter::recover_from_exception (); |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
2466 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2467 in_try_catch--; // must be restored before "catch" block |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2468 execution_error = true; |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
2469 } |
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
2470 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2471 // 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
|
2472 // 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
|
2473 // or throw further errors. |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
2474 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2475 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2476 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
|
2477 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2478 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
|
2479 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
|
2480 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2481 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
|
2482 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2483 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
|
2484 { |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
2485 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
|
2486 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2487 octave_scalar_map err; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2488 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2489 err.assign ("message", last_error_message ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2490 err.assign ("identifier", last_error_id ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2491 err.assign ("stack", last_error_stack ()); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2492 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2493 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
|
2494 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2495 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2496 // perform actual "catch" block |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2497 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
|
2498 catch_code->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2499 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2500 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2501 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2502 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2503 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2504 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
|
2505 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2506 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
|
2507 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2508 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
|
2509 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
|
2510 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2511 // 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
|
2512 // backtracking. |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2513 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2514 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
|
2515 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
|
2516 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
|
2517 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
|
2518 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2519 // 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
|
2520 // 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
|
2521 // 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
|
2522 // 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
|
2523 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2524 frame.protect_var (tree_return_command::returning); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2525 tree_return_command::returning = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2526 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2527 frame.protect_var (tree_break_command::breaking); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2528 tree_break_command::breaking = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2529 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2530 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2531 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2532 if (list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2533 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
|
2534 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2535 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
|
2536 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2537 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
|
2538 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2539 if (tree_break_command::breaking || tree_return_command::returning) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2540 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
|
2541 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2542 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
|
2543 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2544 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
|
2545 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2546 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2547 } |
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
|
2548 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2549 // 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
|
2550 // 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
|
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 // 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
|
2553 // 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
|
2554 // 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
|
2555 // 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
|
2556 // 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
|
2557 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2558 // function foo () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2559 // unwind_protect |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2560 // 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
|
2561 // break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2562 // 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
|
2563 // 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
|
2564 // 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
|
2565 // return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2566 // 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
|
2567 // 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
|
2568 // endfunction |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2569 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2570 // 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
|
2571 // 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
|
2572 // 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
|
2573 // 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
|
2574 // 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
|
2575 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2576 if (tree_break_command::breaking || tree_return_command::returning) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2577 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
|
2578 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2579 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
|
2580 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
2581 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2582 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2583 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
|
2584 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2585 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
|
2586 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2587 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
|
2588 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
|
2589 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
|
2590 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2591 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2592 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
|
2593 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2594 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
|
2595 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2596 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
|
2597 { |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
2598 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
|
2599 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2600 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
|
2601 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2602 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
|
2603 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2604 // 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
|
2605 // 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
|
2606 // 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
|
2607 // here? |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2608 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
|
2609 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2610 // 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
|
2611 // 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
|
2612 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
|
2613 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2614 // 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
|
2615 // 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
|
2616 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
|
2617 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2618 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
|
2619 { |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
2620 // 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
|
2621 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
|
2622 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
|
2623 throw; |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
2624 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2625 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2626 // 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
|
2627 // 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
|
2628 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
|
2629 } |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
2630 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2631 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2632 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2633 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
|
2634 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2635 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
|
2636 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2637 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
|
2638 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2639 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
|
2640 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2641 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2642 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2643 #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
|
2644 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
|
2645 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2646 #endif |
9383 | 2647 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2648 unwind_protect frame; |
10210
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
2649 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2650 frame.protect_var (in_loop_command); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2651 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2652 in_loop_command = true; |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
2653 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2654 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
|
2655 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2656 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2657 panic_impossible (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2658 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2659 for (;;) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2660 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2661 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
|
2662 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
|
2663 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2664 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2665 do_breakpoint (cmd.is_breakpoint (true)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2666 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2667 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
|
2668 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2669 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
|
2670 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2671 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
|
2672 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2673 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2674 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
|
2675 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2676 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2677 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2678 break; |
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 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
2681 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2682 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2683 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
|
2684 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2685 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
|
2686 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2687 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
|
2688 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2689 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
|
2690 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2691 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2692 |
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
|
2693 #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
|
2694 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
|
2695 return; |
15023
75d1bc2fd6d2
Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents:
14932
diff
changeset
|
2696 #endif |
75d1bc2fd6d2
Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents:
14932
diff
changeset
|
2697 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2698 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2699 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2700 frame.protect_var (in_loop_command); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2701 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2702 in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2703 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2704 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
|
2705 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
|
2706 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
|
2707 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2708 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2709 panic_impossible (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2710 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2711 for (;;) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2712 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2713 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
|
2714 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
|
2715 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2716 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
|
2717 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2718 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
|
2719 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2720 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2721 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
|
2722 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2723 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2724 if (debug_mode) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2725 do_breakpoint (cmd.is_breakpoint (true)); |
18325
2a8243d8327a
jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents:
18270
diff
changeset
|
2726 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2727 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
|
2728 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2729 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
|
2730 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2731 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2732 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2733 |
23702
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2734 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
|
2735 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2736 static std::string ans = "ans"; |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2737 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2738 if (val.is_defined ()) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2739 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2740 if (val.is_cs_list ()) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2741 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2742 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
|
2743 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2744 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
|
2745 bind_ans (lst(i), print); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2746 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2747 else |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2748 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2749 symbol_scope scope = get_current_scope (); |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2750 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2751 scope.force_assign (ans, val); |
23702
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2752 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2753 if (print) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2754 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2755 octave_value_list args = ovl (val); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2756 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
|
2757 feval ("display", args); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2758 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2759 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2760 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2761 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
2762 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2763 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2764 tree_evaluator::do_breakpoint (tree_statement& stmt) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2765 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2766 do_breakpoint (stmt.is_breakpoint (true), stmt.is_end_of_fcn_or_script ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2767 } |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
2768 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2769 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2770 tree_evaluator::do_breakpoint (bool is_breakpoint, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2771 bool is_end_of_fcn_or_script) const |
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 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
|
2774 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2775 if (octave_debug_on_interrupt_state) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2776 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2777 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
|
2778 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2779 octave_debug_on_interrupt_state = false; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2780 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2781 current_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
|
2782 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2783 else if (is_breakpoint) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2784 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2785 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
|
2786 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2787 dbstep_flag = 0; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2788 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2789 current_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
|
2790 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2791 else if (dbstep_flag > 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2792 { |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2793 if (m_call_stack.current_frame () == 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
|
2794 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2795 if (dbstep_flag == 1 || is_end_of_fcn_or_script) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2796 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2797 // 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
|
2798 // 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
|
2799 // 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
|
2800 // 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
|
2801 // return to prompt. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2802 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2803 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
|
2804 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2805 dbstep_flag = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2806 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2807 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2808 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2809 // 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
|
2810 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2811 dbstep_flag--; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2812 } |
15574
d20cbfec6df7
Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents:
15469
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 else if (dbstep_flag == 1 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2816 && m_call_stack.current_frame () < 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
|
2817 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2818 // 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
|
2819 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2820 current_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
|
2821 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2822 break_on_this_statement = true; |
15574
d20cbfec6df7
Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
2823 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2824 dbstep_flag = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2825 } |
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 else if (dbstep_flag == -1) |
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 // 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
|
2830 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2831 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
|
2832 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2833 dbstep_flag = 0; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2834 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2835 current_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
|
2836 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2837 else if (dbstep_flag == -2) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2838 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2839 // 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
|
2840 // 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
|
2841 // 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
|
2842 // "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
|
2843 // that frame. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2844 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2845 if (is_end_of_fcn_or_script |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2846 && m_call_stack.current_frame () == 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
|
2847 dbstep_flag = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2848 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2849 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2850 if (break_on_this_statement) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2851 do_keyboard (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2852 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2853 } |
10219
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
2854 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2855 // ARGS is currently unused, but since the do_keyboard function in |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2856 // input.cc accepts an argument list, we preserve it here so that the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2857 // interface won't have to change if we decide to use it in the future. |
10219
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
2858 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2859 octave_value |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2860 tree_evaluator::do_keyboard (const octave_value_list& args) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2861 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2862 return ::do_keyboard (args); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2863 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2864 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2865 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2866 tree_evaluator::is_logically_true (tree_expression *expr, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2867 const char *warn_for) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2868 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2869 bool expr_value = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2870 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2871 octave_value t1 = evaluate (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2872 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2873 if (t1.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2874 return t1.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2875 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2876 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
|
2877 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2878 return expr_value; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2879 } |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2880 |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2881 octave_value_list |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2882 tree_evaluator::make_value_list (tree_argument_list *args, |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2883 const string_vector& arg_nm, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2884 const octave_value *object, bool rvalue) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2885 { |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2886 octave_value_list retval; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2887 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2888 if (args) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2889 { |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2890 // Function calls inside an argument list can't have ignored |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2891 // output arguments. |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2892 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2893 unwind_protect frame; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2894 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
2895 m_lvalue_list_stack.push (nullptr); |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2896 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2897 frame.add_method (m_lvalue_list_stack, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2898 &value_stack<const std::list<octave_lvalue>*>::pop); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2899 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2900 if (rvalue && object && args->has_magic_end () |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2901 && object->is_undefined ()) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2902 err_invalid_inquiry_subscript (); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2903 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2904 retval = args->convert_to_const_vector (this, object); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2905 } |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2906 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2907 octave_idx_type n = retval.length (); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2908 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2909 if (n > 0) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2910 retval.stash_name_tags (arg_nm); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2911 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2912 return retval; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2913 } |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2914 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2915 std::list<octave_lvalue> |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2916 tree_evaluator::make_lvalue_list (tree_argument_list *lhs) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2917 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2918 std::list<octave_lvalue> retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2919 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2920 for (tree_expression *elt : *lhs) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2921 retval.push_back (elt->lvalue (this)); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2922 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2923 return retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2924 } |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2925 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2926 octave_value |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2927 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
|
2928 int nargout) |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2929 { |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2930 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
|
2931 "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
|
2932 } |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2933 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2934 octave_value |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2935 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
|
2936 { |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2937 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
|
2938 "silent_functions"); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2939 } |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
2940 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2941 octave_value |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2942 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
|
2943 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2944 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
|
2945 "string_fill_char"); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2946 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2947 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2948 void |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2949 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
|
2950 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
|
2951 size_t pos) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2952 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2953 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
|
2954 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2955 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
|
2956 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2957 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2958 void |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2959 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
|
2960 size_t pos) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2961 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2962 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
|
2963 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
|
2964 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
|
2965 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2966 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2967 void |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2968 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
|
2969 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2970 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
|
2971 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2972 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
|
2973 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2974 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
|
2975 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2976 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
|
2977 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2978 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
|
2979 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2980 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
|
2981 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2982 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
|
2983 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2984 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2985 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2986 void |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2987 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
|
2988 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2989 frame.add_method (*this, &tree_evaluator::set_echo_state, |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2990 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
|
2991 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2992 frame.add_method (*this, &tree_evaluator::set_echo_file_name, |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2993 m_echo_file_name); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2994 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2995 frame.add_method (*this, &tree_evaluator::set_echo_file_pos, |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2996 m_echo_file_pos); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2997 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2998 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
2999 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
|
3000 { |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3001 // 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
|
3002 // the top of the call stack. If the caller of ECHO is a |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3003 // user-defined fucntion or script, then set up unwind-protect |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3004 // 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
|
3005 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3006 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
|
3007 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3008 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
|
3009 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3010 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
|
3011 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3012 unwind_protect *frame = fcn->unwind_protect_frame (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3013 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3014 if (frame) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3015 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3016 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
|
3017 return true; |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3018 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3019 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3020 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3021 return false; |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3022 } |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3023 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3024 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3025 octave_value |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3026 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
|
3027 { |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3028 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
|
3029 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3030 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
|
3031 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3032 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
|
3033 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3034 case 0: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3035 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
|
3036 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3037 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
|
3038 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
|
3039 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3040 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3041 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
|
3042 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3043 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3044 case 1: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3045 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3046 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
|
3047 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3048 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
|
3049 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
|
3050 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
|
3051 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
|
3052 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3053 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3054 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
|
3055 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
|
3056 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3057 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
|
3058 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
|
3059 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3060 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
|
3061 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3062 // 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
|
3063 // 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
|
3064 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3065 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
|
3066 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3067 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3068 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3069 // 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
|
3070 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3071 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
|
3072 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3073 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
|
3074 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3075 // 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
|
3076 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3077 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
|
3078 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
|
3079 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3080 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3081 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3082 // 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
|
3083 // 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
|
3084 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3085 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
|
3086 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3087 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3088 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3089 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3090 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3091 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3092 case 2: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3093 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3094 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
|
3095 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
|
3096 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3097 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
|
3098 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
|
3099 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3100 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
|
3101 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3102 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
|
3103 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3104 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
|
3105 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
|
3106 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3107 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3108 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3109 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
|
3110 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
|
3111 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3112 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
|
3113 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
|
3114 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3115 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
|
3116 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
|
3117 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3118 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3119 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
|
3120 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3121 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
|
3122 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3123 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
|
3124 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
|
3125 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3126 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3127 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3128 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
|
3129 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
|
3130 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3131 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
|
3132 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
|
3133 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3134 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
|
3135 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3136 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3137 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3138 print_usage (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3139 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3140 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3141 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3142 default: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3143 print_usage (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3144 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3145 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3146 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3147 if (cleanup_pushed) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3148 maybe_set_echo_state (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3149 |
23913
062ce545b21e
mark octave_value from octave_value_list constructor explicit
John W. Eaton <jwe@octave.org>
parents:
23876
diff
changeset
|
3150 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
|
3151 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3152 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3153 octave_value |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3154 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
|
3155 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3156 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
|
3157 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3158 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3159 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
|
3160 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3161 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
|
3162 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3163 // 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
|
3164 return true; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3165 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3166 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3167 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
|
3168 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3169 // 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
|
3170 // 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
|
3171 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3172 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
|
3173 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3174 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
|
3175 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3176 // 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
|
3177 // file. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3178 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3179 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
|
3180 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3181 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3182 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3183 // 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
|
3184 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3185 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
|
3186 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3187 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3188 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3189 return false; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3190 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3191 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3192 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
|
3193 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3194 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
|
3195 |
23728
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3196 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
|
3197 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3198 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
|
3199 { |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3200 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
|
3201 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3202 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
|
3203 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3204 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
|
3205 = 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
|
3206 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3207 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
|
3208 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
|
3209 } |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3210 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3211 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3212 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3213 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
|
3214 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
|
3215 @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
|
3216 @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
|
3217 @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
|
3218 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
|
3219 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
|
3220 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3221 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
|
3222 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
|
3223 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3224 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
|
3225 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
|
3226 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
|
3227 @end deftypefn */) |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
3228 { |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3229 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
|
3230 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3231 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
|
3232 } |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
3233 |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3234 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3235 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3236 %! 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
|
3237 %! 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
|
3238 %! 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
|
3239 %! 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
|
3240 %! 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
|
3241 %! 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
|
3242 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
3243 %!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
|
3244 */ |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3245 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3246 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
|
3247 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
|
3248 @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
|
3249 @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
|
3250 @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
|
3251 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
|
3252 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
|
3253 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3254 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
|
3255 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
|
3256 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
|
3257 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3258 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
|
3259 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
|
3260 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
|
3261 @end deftypefn */) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3262 { |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3263 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
|
3264 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3265 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
|
3266 } |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3267 |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3268 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3269 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3270 %! orig_val = silent_functions (); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3271 %! 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
|
3272 %! 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
|
3273 %! 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
|
3274 %! silent_functions (orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3275 %! 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
|
3276 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
3277 %!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
|
3278 */ |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3279 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3280 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
|
3281 doc: /* -*- texinfo -*- |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3282 @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
|
3283 @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
|
3284 @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
|
3285 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
|
3286 matrix to the same length. |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3287 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3288 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
|
3289 single space). For example: |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3290 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3291 @example |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3292 @group |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3293 string_fill_char ("X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3294 [ "these"; "are"; "strings" ] |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3295 @result{} "theseXX" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3296 "areXXXX" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3297 "strings" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3298 @end group |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3299 @end example |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3300 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3301 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
|
3302 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
|
3303 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
|
3304 @end deftypefn */) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3305 { |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3306 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
|
3307 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3308 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
|
3309 } |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3310 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3311 /* |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3312 ## 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
|
3313 ## 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
|
3314 %!shared orig_val, old_val |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3315 %! orig_val = string_fill_char (); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3316 %! 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
|
3317 %!test |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3318 %! assert (orig_val, old_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3319 %! assert (string_fill_char (), "X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3320 %! 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
|
3321 %! string_fill_char (orig_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3322 %! 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
|
3323 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3324 %!assert ( [ [], {1} ], {1} ) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3325 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3326 %!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
|
3327 */ |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3328 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3329 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
|
3330 doc: /* -*- texinfo -*- |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3331 @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
|
3332 @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
|
3333 @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
|
3334 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
|
3335 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
|
3336 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3337 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
|
3338 @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
|
3339 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3340 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
|
3341 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
|
3342 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
|
3343 @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
|
3344 @end deftypefn */) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3345 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3346 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
|
3347 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3348 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
|
3349 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3350 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3351 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
|
3352 doc: /* -*- texinfo -*- |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3353 @deftypefn {} {} echo |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3354 @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
|
3355 @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
|
3356 @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
|
3357 @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
|
3358 @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
|
3359 @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
|
3360 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
|
3361 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3362 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
|
3363 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3364 @table @code |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3365 @item on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3366 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
|
3367 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3368 @item off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3369 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
|
3370 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3371 @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
|
3372 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
|
3373 functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3374 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3375 @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
|
3376 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
|
3377 functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3378 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3379 @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
|
3380 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
|
3381 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3382 @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
|
3383 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
|
3384 @end table |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3385 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3386 @noindent |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3387 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
|
3388 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3389 @seealso{PS4} |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3390 @end deftypefn */) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3391 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3392 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
|
3393 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3394 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
|
3395 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3396 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3397 /* |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3398 %!error echo ([]) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3399 %!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
|
3400 %!error echo ("") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3401 %!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
|
3402 %!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
|
3403 %!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
|
3404 %!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
|
3405 */ |