Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-assign.cc @ 15606:fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
* pt-assign.cc (tree_simple_assignment::rvalue1, tree_multi_assignment::rvalue):
Check tree_evaluator::statement_printing_enabled.
* pt-eval.cc (tree_evaluator::statement_printing_enabled): New function.
(tree_evaluator::visit_statement): Do not modify parse tree and check
tree_evaluator::statement_printing_enabled.
* pt-eval.h (tree_evaluator::statement_printing_enabled): New declaration.
* pt-exp.h (tree_expression::print_result): Added comment.
* pt-id.cc (tree_identifier::rvalue): Check
tree_evaluator::statement_printing_enabled.
author | Max Brister <max@2bass.com> |
---|---|
date | Fri, 09 Nov 2012 20:29:21 -0700 |
parents | 2fc554ffbc28 |
children | b04ae15530fc |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14048
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2980 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2980 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2980 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
3503 | 27 #include <iostream> |
6253 | 28 #include <set> |
2980 | 29 |
30 #include "defun.h" | |
31 #include "error.h" | |
10030
83bb2a78c07d
improve simple assignments error checks and messages
Jaroslav Hajek <highegg@gmail.com>
parents:
9782
diff
changeset
|
32 #include "gripes.h" |
2980 | 33 #include "input.h" |
34 #include "oct-obj.h" | |
35 #include "oct-lvalue.h" | |
36 #include "pager.h" | |
37 #include "ov.h" | |
2982 | 38 #include "pt-arg-list.h" |
3770 | 39 #include "pt-bp.h" |
2980 | 40 #include "pt-assign.h" |
15606
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
41 #include "pt-eval.h" |
2980 | 42 #include "pt-walk.h" |
43 #include "utils.h" | |
5794 | 44 #include "variables.h" |
2980 | 45 |
46 // Simple assignment expressions. | |
47 | |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
48 // FIXME -- the following variable and the function that uses it |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
49 // should be removed from some future version of Octave. |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
50 |
6253 | 51 static const char *former_built_in_variables[] = |
52 { | |
53 "DEFAULT_EXEC_PATH", | |
54 "DEFAULT_LOADPATH", | |
55 "EDITOR", | |
56 "EXEC_PATH", | |
57 "FFTW_WISDOM_PROGRAM", | |
58 "IMAGEPATH", | |
59 "INFO_FILE", | |
60 "INFO_PROGRAM", | |
61 "LOADPATH", | |
62 "MAKEINFO_PROGRAM", | |
63 "PAGER", | |
64 "PS1", | |
65 "PS2", | |
66 "PS4", | |
67 "__kluge_procbuf_delay__", | |
68 "automatic_replot", | |
69 "beep_on_error", | |
70 "completion_append_char", | |
71 "crash_dumps_octave_core", | |
72 "current_script_file_name", | |
73 "debug_on_error", | |
74 "debug_on_interrupt", | |
75 "debug_on_warning", | |
76 "debug_symtab_lookups", | |
14048
fafd2f45bfa5
Change "default_save_format" to "default_save_options" in former_built_in_variables list.
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
13867
diff
changeset
|
77 "default_save_options", |
6253 | 78 "echo_executing_commands", |
79 "fixed_point_format", | |
80 "gnuplot_binary", | |
81 "gnuplot_command_axes", | |
82 "gnuplot_command_end", | |
83 "gnuplot_command_plot", | |
84 "gnuplot_command_replot", | |
85 "gnuplot_command_splot", | |
86 "gnuplot_command_title", | |
87 "gnuplot_command_using", | |
88 "gnuplot_command_with", | |
89 "gnuplot_has_frames", | |
90 "history_file", | |
91 "history_size", | |
92 "ignore_function_time_stamp", | |
93 "max_recursion_depth", | |
94 "octave_core_file_format", | |
95 "octave_core_file_limit", | |
96 "octave_core_file_name", | |
97 "output_max_field_width", | |
98 "output_precision", | |
99 "page_output_immediately", | |
100 "page_screen_output", | |
101 "print_answer_id_name", | |
102 "print_empty_dimensions", | |
103 "print_rhs_assign_val", | |
104 "save_header_format_string", | |
105 "save_precision", | |
106 "saving_history", | |
107 "sighup_dumps_octave_core", | |
108 "sigterm_dumps_octave_core", | |
109 "silent_functions", | |
110 "split_long_rows", | |
111 "string_fill_char", | |
112 "struct_levels_to_print", | |
113 "suppress_verbose_help_message", | |
114 "variables_can_hide_functions", | |
115 "warn_assign_as_truth_value", | |
116 "warn_associativity_change", | |
117 "warn_divide_by_zero", | |
118 "warn_empty_list_elements", | |
119 "warn_fortran_indexing", | |
120 "warn_function_name_clash", | |
121 "warn_future_time_stamp", | |
122 "warn_imag_to_real", | |
123 "warn_matlab_incompatible", | |
124 "warn_missing_semicolon", | |
125 "warn_neg_dim_as_zero", | |
126 "warn_num_to_str", | |
127 "warn_precedence_change", | |
128 "warn_reload_forces_clear", | |
129 "warn_resize_on_range_error", | |
130 "warn_separator_insert", | |
131 "warn_single_quote_string", | |
132 "warn_str_to_num", | |
133 "warn_undefined_return_values", | |
134 "warn_variable_switch_label", | |
135 "whos_line_format", | |
136 0, | |
137 }; | |
138 | |
139 static void | |
140 maybe_warn_former_built_in_variable (const std::string& nm) | |
141 { | |
142 static bool initialized = false; | |
143 | |
144 static std::set<std::string> vars; | |
145 | |
146 if (! initialized) | |
147 { | |
148 const char **p = former_built_in_variables; | |
149 | |
150 while (*p) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
151 vars.insert (*p++); |
9224
a6422d81bee7
pt-assign.cc (maybe_warn_former_built_in_variable): set initialized to true on first call
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
152 |
a6422d81bee7
pt-assign.cc (maybe_warn_former_built_in_variable): set initialized to true on first call
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
153 initialized = true; |
6253 | 154 } |
155 | |
156 if (vars.find (nm) != vars.end ()) | |
9421
86eb5ff921d0
pt-assign.cc (maybe_warn_former_built_in_variable): improve message
John W. Eaton <jwe@octave.org>
parents:
9387
diff
changeset
|
157 { |
86eb5ff921d0
pt-assign.cc (maybe_warn_former_built_in_variable): improve message
John W. Eaton <jwe@octave.org>
parents:
9387
diff
changeset
|
158 const char *nm_c_str = nm.c_str (); |
86eb5ff921d0
pt-assign.cc (maybe_warn_former_built_in_variable): improve message
John W. Eaton <jwe@octave.org>
parents:
9387
diff
changeset
|
159 |
86eb5ff921d0
pt-assign.cc (maybe_warn_former_built_in_variable): improve message
John W. Eaton <jwe@octave.org>
parents:
9387
diff
changeset
|
160 warning_with_id ("Octave:built-in-variable-assignment", |
13867
922bfdd80413
Clean up help about old flags for debug variables
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
11523
diff
changeset
|
161 "\ |
922bfdd80413
Clean up help about old flags for debug variables
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
11523
diff
changeset
|
162 In recent versions of Octave, %s is a function instead\n\ |
922bfdd80413
Clean up help about old flags for debug variables
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
11523
diff
changeset
|
163 of a built-in variable.\n\n\ |
922bfdd80413
Clean up help about old flags for debug variables
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
11523
diff
changeset
|
164 By assigning to %s, you have created a variable that hides\n\ |
922bfdd80413
Clean up help about old flags for debug variables
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
11523
diff
changeset
|
165 the function %s. To remove the variable and restore the \n\ |
922bfdd80413
Clean up help about old flags for debug variables
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
11523
diff
changeset
|
166 function, type \"clear %s\"\n", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
167 nm_c_str, nm_c_str, nm_c_str, nm_c_str); |
9421
86eb5ff921d0
pt-assign.cc (maybe_warn_former_built_in_variable): improve message
John W. Eaton <jwe@octave.org>
parents:
9387
diff
changeset
|
168 } |
6253 | 169 } |
170 | |
171 tree_simple_assignment::tree_simple_assignment | |
172 (tree_expression *le, tree_expression *re, | |
173 bool plhs, int l, int c, octave_value::assign_op t) | |
8038 | 174 : tree_expression (l, c), lhs (le), rhs (re), preserve (plhs), etype (t), |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
175 first_execution (true) { } |
6253 | 176 |
2980 | 177 tree_simple_assignment::~tree_simple_assignment (void) |
178 { | |
179 if (! preserve) | |
180 delete lhs; | |
181 | |
182 delete rhs; | |
183 } | |
184 | |
185 octave_value_list | |
186 tree_simple_assignment::rvalue (int nargout) | |
187 { | |
188 octave_value_list retval; | |
189 | |
190 if (nargout > 1) | |
191 error ("invalid number of output arguments for expression X = RHS"); | |
192 else | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
193 retval = rvalue1 (nargout); |
2980 | 194 |
195 return retval; | |
196 } | |
197 | |
198 octave_value | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
199 tree_simple_assignment::rvalue1 (int) |
2980 | 200 { |
3208 | 201 octave_value retval; |
2980 | 202 |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
203 if (first_execution && lhs) |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
204 maybe_warn_former_built_in_variable (lhs->name ()); |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
205 |
2980 | 206 if (error_state) |
3208 | 207 return retval; |
2980 | 208 |
209 if (rhs) | |
210 { | |
8905
24dd61b36591
assign rvalue1 result to octave_value object, not octave_value_list object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
211 octave_value rhs_val = rhs->rvalue1 (); |
2980 | 212 |
8905
24dd61b36591
assign rvalue1 result to octave_value object, not octave_value_list object
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
213 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
214 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
215 if (rhs_val.is_undefined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
216 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
217 error ("value on right hand side of assignment is undefined"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
218 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
219 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
220 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
221 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
222 if (rhs_val.is_cs_list ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
223 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
224 const octave_value_list lst = rhs_val.list_value (); |
7389 | 225 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
226 if (! lst.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
227 rhs_val = lst(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
228 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
229 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
230 error ("invalid number of elements on RHS of assignment"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
231 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
232 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
233 } |
7389 | 234 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
235 octave_lvalue ult = lhs->lvalue (); |
2980 | 236 |
10030
83bb2a78c07d
improve simple assignments error checks and messages
Jaroslav Hajek <highegg@gmail.com>
parents:
9782
diff
changeset
|
237 if (ult.numel () != 1) |
83bb2a78c07d
improve simple assignments error checks and messages
Jaroslav Hajek <highegg@gmail.com>
parents:
9782
diff
changeset
|
238 gripe_nonbraced_cs_list_assignment (); |
83bb2a78c07d
improve simple assignments error checks and messages
Jaroslav Hajek <highegg@gmail.com>
parents:
9782
diff
changeset
|
239 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
240 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
241 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
242 ult.assign (etype, rhs_val); |
2980 | 243 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
244 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
245 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
246 if (etype == octave_value::op_asn_eq) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
247 retval = rhs_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
248 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
249 retval = ult.value (); |
2984 | 250 |
15606
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
251 if (print_result () |
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
252 && tree_evaluator::statement_printing_enabled ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
253 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
254 // We clear any index here so that we can |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
255 // get the new value of the referenced |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
256 // object below, instead of the indexed |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
257 // value (which should be the same as the |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
258 // right hand side value). |
2980 | 259 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
260 ult.clear_index (); |
3208 | 261 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
262 octave_value lhs_val = ult.value (); |
3208 | 263 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
264 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
265 lhs_val.print_with_name (octave_stdout, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
266 lhs->name ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
267 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
268 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
269 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
270 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
271 } |
2980 | 272 } |
273 | |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
274 first_execution = false; |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
275 |
3208 | 276 return retval; |
2980 | 277 } |
278 | |
3536 | 279 std::string |
2980 | 280 tree_simple_assignment::oper (void) const |
281 { | |
282 return octave_value::assign_op_as_string (etype); | |
283 } | |
284 | |
5861 | 285 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7389
diff
changeset
|
286 tree_simple_assignment::dup (symbol_table::scope_id scope, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
287 symbol_table::context_id context) const |
5861 | 288 { |
289 tree_simple_assignment *new_sa | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7389
diff
changeset
|
290 = new tree_simple_assignment (lhs ? lhs->dup (scope, context) : 0, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
291 rhs ? rhs->dup (scope, context) : 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
292 preserve, etype); |
5861 | 293 |
294 new_sa->copy_base (*this); | |
295 | |
296 return new_sa; | |
297 } | |
298 | |
2980 | 299 void |
300 tree_simple_assignment::accept (tree_walker& tw) | |
301 { | |
302 tw.visit_simple_assignment (*this); | |
303 } | |
304 | |
305 // Multi-valued assignment expressions. | |
306 | |
6253 | 307 tree_multi_assignment::tree_multi_assignment |
308 (tree_argument_list *lst, tree_expression *r, | |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
309 bool plhs, int l, int c) |
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
310 : tree_expression (l, c), lhs (lst), rhs (r), preserve (plhs), |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
311 first_execution (true) { } |
6253 | 312 |
2980 | 313 tree_multi_assignment::~tree_multi_assignment (void) |
314 { | |
315 if (! preserve) | |
316 delete lhs; | |
317 | |
318 delete rhs; | |
319 } | |
320 | |
321 octave_value | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
322 tree_multi_assignment::rvalue1 (int nargout) |
2980 | 323 { |
324 octave_value retval; | |
325 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
326 const octave_value_list tmp = rvalue (nargout); |
2980 | 327 |
328 if (! tmp.empty ()) | |
329 retval = tmp(0); | |
330 | |
331 return retval; | |
332 } | |
333 | |
5775 | 334 // FIXME -- this works, but it would look a little better if |
2984 | 335 // it were broken up into a couple of separate functions. |
336 | |
2980 | 337 octave_value_list |
338 tree_multi_assignment::rvalue (int) | |
339 { | |
3208 | 340 octave_value_list retval; |
2980 | 341 |
342 if (error_state) | |
3208 | 343 return retval; |
2980 | 344 |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
345 if (first_execution) |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
346 { |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
347 for (tree_argument_list::iterator p = lhs->begin (); p != lhs->end (); p++) |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
348 { |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
349 tree_expression *lhs_expr = *p; |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
350 |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
351 if (lhs_expr) |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
352 maybe_warn_former_built_in_variable (lhs_expr->name ()); |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
353 } |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
354 } |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
355 |
2980 | 356 if (rhs) |
357 { | |
5846 | 358 std::list<octave_lvalue> lvalue_list = lhs->lvalue_list (); |
3977 | 359 |
360 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
361 return retval; |
2980 | 362 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
363 octave_idx_type n_out = 0; |
5846 | 364 |
365 for (std::list<octave_lvalue>::const_iterator p = lvalue_list.begin (); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
366 p != lvalue_list.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
367 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
368 n_out += p->numel (); |
5846 | 369 |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8313
diff
changeset
|
370 // The following trick is used to keep rhs_val constant. |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
371 const octave_value_list rhs_val1 = rhs->rvalue (n_out, &lvalue_list); |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8313
diff
changeset
|
372 const octave_value_list rhs_val = (rhs_val1.length () == 1 && rhs_val1(0).is_cs_list () |
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8313
diff
changeset
|
373 ? rhs_val1(0).list_value () : rhs_val1); |
2980 | 374 |
3977 | 375 if (error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
376 return retval; |
2980 | 377 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
378 octave_idx_type k = 0; |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
379 |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
380 octave_idx_type n = rhs_val.length (); |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
381 |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
382 // To avoid copying per elements and possible optimizations, we |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
383 // postpone joining the final values. |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
384 std::list<octave_value_list> retval_list; |
2980 | 385 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
386 tree_argument_list::iterator q = lhs->begin (); |
2980 | 387 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
388 for (std::list<octave_lvalue>::iterator p = lvalue_list.begin (); |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
389 p != lvalue_list.end (); |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
390 p++) |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
391 { |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
392 tree_expression *lhs_elt = *q++; |
5846 | 393 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
394 octave_lvalue ult = *p; |
5846 | 395 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
396 octave_idx_type nel = ult.numel (); |
3977 | 397 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
398 if (nel != 1) |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
399 { |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
400 if (k + nel <= n) |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
401 { |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
402 // This won't do a copy. |
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
403 octave_value_list ovl = rhs_val.slice (k, nel); |
5846 | 404 |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
405 ult.assign (octave_value::op_asn_eq, octave_value (ovl, true)); |
2980 | 406 |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
407 if (! error_state) |
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
408 { |
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
409 retval_list.push_back (ovl); |
5846 | 410 |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
411 k += nel; |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
412 } |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
413 } |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
414 else |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
415 error ("some elements undefined in return list"); |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
416 } |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
417 else |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
418 { |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
419 if (k < n) |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
420 { |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
421 ult.assign (octave_value::op_asn_eq, rhs_val(k)); |
3977 | 422 |
10227
d3fc22c3071c
omit ~ values from multi-assignment return lists
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
423 if (ult.is_black_hole ()) |
d3fc22c3071c
omit ~ values from multi-assignment return lists
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
424 { |
d3fc22c3071c
omit ~ values from multi-assignment return lists
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
425 k++; |
d3fc22c3071c
omit ~ values from multi-assignment return lists
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
426 continue; |
d3fc22c3071c
omit ~ values from multi-assignment return lists
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
427 } |
d3fc22c3071c
omit ~ values from multi-assignment return lists
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
428 else if (! error_state) |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
429 { |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
430 retval_list.push_back (rhs_val(k)); |
5846 | 431 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
432 k++; |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
433 } |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
434 } |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
435 else |
14572
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
436 { |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
437 // This can happen for a function like |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
438 // |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
439 // function varargout = f () |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
440 // varargout{1} = nargout; |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
441 // endfunction |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
442 // |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
443 // called with |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
444 // |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
445 // [a, ~] = f (); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
446 // |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
447 // Then the list of of RHS values will contain one |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
448 // element but we are iterating over the list of all |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
449 // RHS values. We shouldn't complain that a value we |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
450 // don't need is missing from the list. |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
451 |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
452 if (ult.is_black_hole ()) |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
453 { |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
454 k++; |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
455 continue; |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
456 } |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
457 else |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
458 error ("element number %d undefined in return list", k+1); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
459 } |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
460 } |
2980 | 461 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
462 if (error_state) |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
463 break; |
15606
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
464 else if (print_result () |
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
465 && tree_evaluator::statement_printing_enabled ()) |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
466 { |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
467 // We clear any index here so that we can get |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
468 // the new value of the referenced object below, |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
469 // instead of the indexed value (which should be |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
470 // the same as the right hand side value). |
3977 | 471 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
472 ult.clear_index (); |
3208 | 473 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
474 octave_value lhs_val = ult.value (); |
3977 | 475 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
476 if (! error_state) |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
477 lhs_val.print_with_name (octave_stdout, |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
478 lhs_elt->name ()); |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
479 } |
3977 | 480 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
481 if (error_state) |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
482 break; |
3977 | 483 |
9782
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
484 } |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
485 |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
486 // Concatenate return values. |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
487 retval = retval_list; |
eead00a7df05
don't skip empty multi-assignments to allow side effects
Jaroslav Hajek <highegg@gmail.com>
parents:
9421
diff
changeset
|
488 |
2980 | 489 } |
490 | |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
491 first_execution = false; |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
492 |
3208 | 493 return retval; |
2980 | 494 } |
495 | |
14572
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
496 /* |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
497 %!function varargout = f () |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
498 %! varargout{1} = nargout; |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
499 %!endfunction |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
500 %! |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
501 %!test |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
502 %! [a, ~] = f (); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
503 %! assert (a, 2); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
504 %!test |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
505 %! [a, ~, ~, ~, ~] = f (); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
506 %! assert (a, 5); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
507 */ |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
508 |
3536 | 509 std::string |
3208 | 510 tree_multi_assignment::oper (void) const |
511 { | |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
512 return octave_value::assign_op_as_string (op_type ()); |
3208 | 513 } |
514 | |
5861 | 515 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7389
diff
changeset
|
516 tree_multi_assignment::dup (symbol_table::scope_id scope, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
517 symbol_table::context_id context) const |
5861 | 518 { |
519 tree_multi_assignment *new_ma | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7389
diff
changeset
|
520 = new tree_multi_assignment (lhs ? lhs->dup (scope, context) : 0, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
521 rhs ? rhs->dup (scope, context) : 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10230
diff
changeset
|
522 preserve); |
5861 | 523 |
524 new_ma->copy_base (*this); | |
525 | |
526 return new_ma; | |
527 } | |
528 | |
2980 | 529 void |
530 tree_multi_assignment::accept (tree_walker& tw) | |
531 { | |
532 tw.visit_multi_assignment (*this); | |
533 } |