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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
1 /*
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
4
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
6
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6483
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6483
diff changeset
10 option) any later version.
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
11
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
15 for more details.
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
16
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6483
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6483
diff changeset
19 <http://www.gnu.org/licenses/>.
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
20
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
21 */
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
22
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
25 #endif
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
26
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3448
diff changeset
27 #include <iostream>
6253
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
28 #include <set>
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
29
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
30 #include "defun.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
33 #include "input.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
34 #include "oct-obj.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
35 #include "oct-lvalue.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
36 #include "pager.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
37 #include "ov.h"
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents: 2980
diff changeset
38 #include "pt-arg-list.h"
3770
bf6116ca10eb [project @ 2001-02-02 02:21:40 by jwe]
jwe
parents: 3536
diff changeset
39 #include "pt-bp.h"
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
42 #include "pt-walk.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
43 #include "utils.h"
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5775
diff changeset
44 #include "variables.h"
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
45
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
46 // Simple assignment expressions.
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
51 static const char *former_built_in_variables[] =
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
52 {
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
53 "DEFAULT_EXEC_PATH",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
54 "DEFAULT_LOADPATH",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
55 "EDITOR",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
56 "EXEC_PATH",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
57 "FFTW_WISDOM_PROGRAM",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
58 "IMAGEPATH",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
59 "INFO_FILE",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
60 "INFO_PROGRAM",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
61 "LOADPATH",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
62 "MAKEINFO_PROGRAM",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
63 "PAGER",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
64 "PS1",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
65 "PS2",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
66 "PS4",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
67 "__kluge_procbuf_delay__",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
68 "automatic_replot",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
69 "beep_on_error",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
70 "completion_append_char",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
71 "crash_dumps_octave_core",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
72 "current_script_file_name",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
73 "debug_on_error",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
74 "debug_on_interrupt",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
75 "debug_on_warning",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
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
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
78 "echo_executing_commands",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
79 "fixed_point_format",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
80 "gnuplot_binary",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
81 "gnuplot_command_axes",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
82 "gnuplot_command_end",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
83 "gnuplot_command_plot",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
84 "gnuplot_command_replot",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
85 "gnuplot_command_splot",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
86 "gnuplot_command_title",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
87 "gnuplot_command_using",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
88 "gnuplot_command_with",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
89 "gnuplot_has_frames",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
90 "history_file",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
91 "history_size",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
92 "ignore_function_time_stamp",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
93 "max_recursion_depth",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
94 "octave_core_file_format",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
95 "octave_core_file_limit",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
96 "octave_core_file_name",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
97 "output_max_field_width",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
98 "output_precision",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
99 "page_output_immediately",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
100 "page_screen_output",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
101 "print_answer_id_name",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
102 "print_empty_dimensions",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
103 "print_rhs_assign_val",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
104 "save_header_format_string",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
105 "save_precision",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
106 "saving_history",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
107 "sighup_dumps_octave_core",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
108 "sigterm_dumps_octave_core",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
109 "silent_functions",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
110 "split_long_rows",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
111 "string_fill_char",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
112 "struct_levels_to_print",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
113 "suppress_verbose_help_message",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
114 "variables_can_hide_functions",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
115 "warn_assign_as_truth_value",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
116 "warn_associativity_change",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
117 "warn_divide_by_zero",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
118 "warn_empty_list_elements",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
119 "warn_fortran_indexing",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
120 "warn_function_name_clash",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
121 "warn_future_time_stamp",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
122 "warn_imag_to_real",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
123 "warn_matlab_incompatible",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
124 "warn_missing_semicolon",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
125 "warn_neg_dim_as_zero",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
126 "warn_num_to_str",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
127 "warn_precedence_change",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
128 "warn_reload_forces_clear",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
129 "warn_resize_on_range_error",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
130 "warn_separator_insert",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
131 "warn_single_quote_string",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
132 "warn_str_to_num",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
133 "warn_undefined_return_values",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
134 "warn_variable_switch_label",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
135 "whos_line_format",
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
136 0,
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
137 };
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
138
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
139 static void
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
140 maybe_warn_former_built_in_variable (const std::string& nm)
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
141 {
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
142 static bool initialized = false;
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
143
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
144 static std::set<std::string> vars;
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
145
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
146 if (! initialized)
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
147 {
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
148 const char **p = former_built_in_variables;
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
149
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
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
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
154 }
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
155
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
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
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
169 }
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
170
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
171 tree_simple_assignment::tree_simple_assignment
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
172 (tree_expression *le, tree_expression *re,
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
173 bool plhs, int l, int c, octave_value::assign_op t)
8038
aa6484781a5b fix typo in last commit
John W. Eaton <jwe@octave.org>
parents: 8037
diff changeset
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
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
176
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
177 tree_simple_assignment::~tree_simple_assignment (void)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
178 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
179 if (! preserve)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
180 delete lhs;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
181
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
182 delete rhs;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
183 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
184
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
185 octave_value_list
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
186 tree_simple_assignment::rvalue (int nargout)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
187 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
188 octave_value_list retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
189
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
190 if (nargout > 1)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
191 error ("invalid number of output arguments for expression X = RHS");
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
194
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
195 return retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
196 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
197
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
200 {
3208
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
201 octave_value retval;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
206 if (error_state)
3208
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
207 return retval;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
208
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
209 if (rhs)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
4d0d6c357bc6 [project @ 2008-01-16 08:32:13 by jwe]
jwe
parents: 7336
diff changeset
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
4d0d6c357bc6 [project @ 2008-01-16 08:32:13 by jwe]
jwe
parents: 7336
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
84c33881d0bc [project @ 1997-05-16 05:14:33 by jwe]
jwe
parents: 2982
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
259
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10230
diff changeset
260 ult.clear_index ();
3208
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
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
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
272 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
276 return retval;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
277 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
278
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
279 std::string
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
280 tree_simple_assignment::oper (void) const
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
281 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
282 return octave_value::assign_op_as_string (etype);
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
283 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
284
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
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
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
288 {
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
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
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
293
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
294 new_sa->copy_base (*this);
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
295
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
296 return new_sa;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
297 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
298
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
299 void
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
300 tree_simple_assignment::accept (tree_walker& tw)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
301 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
302 tw.visit_simple_assignment (*this);
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
303 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
304
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
305 // Multi-valued assignment expressions.
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
306
6253
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
307 tree_multi_assignment::tree_multi_assignment
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
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
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 5861
diff changeset
312
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
313 tree_multi_assignment::~tree_multi_assignment (void)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
314 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
315 if (! preserve)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
316 delete lhs;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
317
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
318 delete rhs;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
319 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
320
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
323 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
324 octave_value retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
327
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
328 if (! tmp.empty ())
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
329 retval = tmp(0);
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
330
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
331 return retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
332 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
333
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5750
diff changeset
334 // FIXME -- this works, but it would look a little better if
2984
84c33881d0bc [project @ 1997-05-16 05:14:33 by jwe]
jwe
parents: 2982
diff changeset
335 // it were broken up into a couple of separate functions.
84c33881d0bc [project @ 1997-05-16 05:14:33 by jwe]
jwe
parents: 2982
diff changeset
336
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
337 octave_value_list
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
338 tree_multi_assignment::rvalue (int)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
339 {
3208
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
340 octave_value_list retval;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
341
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
342 if (error_state)
3208
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
343 return retval;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
356 if (rhs)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
357 {
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
358 std::list<octave_lvalue> lvalue_list = lhs->lvalue_list ();
3977
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
359
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
364
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
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
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
374
3977
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
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
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
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
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
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
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5841
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
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
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
95663a3a2682 [project @ 2002-07-05 17:43:37 by jwe]
jwe
parents: 3965
diff changeset
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
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
489 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
493 return retval;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
494 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
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
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
509 std::string
3208
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
510 tree_multi_assignment::oper (void) const
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
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
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
513 }
e8a7163701be [project @ 1998-11-03 05:12:47 by jwe]
jwe
parents: 2991
diff changeset
514
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
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
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
518 {
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
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
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
523
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
524 new_ma->copy_base (*this);
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
525
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
526 return new_ma;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
527 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
528
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
529 void
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
530 tree_multi_assignment::accept (tree_walker& tw)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
531 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
532 tw.visit_multi_assignment (*this);
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
533 }