Mercurial > hg > octave-nkf
comparison src/pt-assign.cc @ 6253:f1676652d808
[project @ 2007-01-24 20:43:36 by jwe]
author | jwe |
---|---|
date | Wed, 24 Jan 2007 20:43:37 +0000 |
parents | 2a6cb4ed8f1e |
children | d00da2148c53 |
comparison
equal
deleted
inserted
replaced
6252:738c97e101eb | 6253:f1676652d808 |
---|---|
24 #ifdef HAVE_CONFIG_H | 24 #ifdef HAVE_CONFIG_H |
25 #include <config.h> | 25 #include <config.h> |
26 #endif | 26 #endif |
27 | 27 |
28 #include <iostream> | 28 #include <iostream> |
29 #include <set> | |
29 | 30 |
30 #include "defun.h" | 31 #include "defun.h" |
31 #include "error.h" | 32 #include "error.h" |
32 #include "input.h" | 33 #include "input.h" |
33 #include "oct-obj.h" | 34 #include "oct-obj.h" |
41 #include "utils.h" | 42 #include "utils.h" |
42 #include "variables.h" | 43 #include "variables.h" |
43 | 44 |
44 // Simple assignment expressions. | 45 // Simple assignment expressions. |
45 | 46 |
47 static const char *former_built_in_variables[] = | |
48 { | |
49 "DEFAULT_EXEC_PATH", | |
50 "DEFAULT_LOADPATH", | |
51 "EDITOR", | |
52 "EXEC_PATH", | |
53 "FFTW_WISDOM_PROGRAM", | |
54 "IMAGEPATH", | |
55 "INFO_FILE", | |
56 "INFO_PROGRAM", | |
57 "LOADPATH", | |
58 "MAKEINFO_PROGRAM", | |
59 "PAGER", | |
60 "PS1", | |
61 "PS2", | |
62 "PS4", | |
63 "__kluge_procbuf_delay__", | |
64 "ans", | |
65 "automatic_replot", | |
66 "beep_on_error", | |
67 "completion_append_char", | |
68 "crash_dumps_octave_core", | |
69 "current_script_file_name", | |
70 "debug_on_error", | |
71 "debug_on_interrupt", | |
72 "debug_on_warning", | |
73 "debug_symtab_lookups", | |
74 "default_save_format", | |
75 "echo_executing_commands", | |
76 "fixed_point_format", | |
77 "gnuplot_binary", | |
78 "gnuplot_command_axes", | |
79 "gnuplot_command_end", | |
80 "gnuplot_command_plot", | |
81 "gnuplot_command_replot", | |
82 "gnuplot_command_splot", | |
83 "gnuplot_command_title", | |
84 "gnuplot_command_using", | |
85 "gnuplot_command_with", | |
86 "gnuplot_has_frames", | |
87 "history_file", | |
88 "history_size", | |
89 "ignore_function_time_stamp", | |
90 "max_recursion_depth", | |
91 "octave_core_file_format", | |
92 "octave_core_file_limit", | |
93 "octave_core_file_name", | |
94 "output_max_field_width", | |
95 "output_precision", | |
96 "page_output_immediately", | |
97 "page_screen_output", | |
98 "print_answer_id_name", | |
99 "print_empty_dimensions", | |
100 "print_rhs_assign_val", | |
101 "save_header_format_string", | |
102 "save_precision", | |
103 "saving_history", | |
104 "sighup_dumps_octave_core", | |
105 "sigterm_dumps_octave_core", | |
106 "silent_functions", | |
107 "split_long_rows", | |
108 "string_fill_char", | |
109 "struct_levels_to_print", | |
110 "suppress_verbose_help_message", | |
111 "variables_can_hide_functions", | |
112 "warn_assign_as_truth_value", | |
113 "warn_associativity_change", | |
114 "warn_divide_by_zero", | |
115 "warn_empty_list_elements", | |
116 "warn_fortran_indexing", | |
117 "warn_function_name_clash", | |
118 "warn_future_time_stamp", | |
119 "warn_imag_to_real", | |
120 "warn_matlab_incompatible", | |
121 "warn_missing_semicolon", | |
122 "warn_neg_dim_as_zero", | |
123 "warn_num_to_str", | |
124 "warn_precedence_change", | |
125 "warn_reload_forces_clear", | |
126 "warn_resize_on_range_error", | |
127 "warn_separator_insert", | |
128 "warn_single_quote_string", | |
129 "warn_str_to_num", | |
130 "warn_undefined_return_values", | |
131 "warn_variable_switch_label", | |
132 "whos_line_format", | |
133 0, | |
134 }; | |
135 | |
136 static void | |
137 maybe_warn_former_built_in_variable (const std::string& nm) | |
138 { | |
139 static bool initialized = false; | |
140 | |
141 static std::set<std::string> vars; | |
142 | |
143 if (! initialized) | |
144 { | |
145 const char **p = former_built_in_variables; | |
146 | |
147 while (*p) | |
148 vars.insert (*p++); | |
149 } | |
150 | |
151 if (vars.find (nm) != vars.end ()) | |
152 warning_with_id ("Octave:built-in-variable-assignment", | |
153 "%s is no longer a built-in variable; please read the NEWS file or type `news' for details", | |
154 nm.c_str ()); | |
155 } | |
156 | |
157 tree_simple_assignment::tree_simple_assignment | |
158 (tree_expression *le, tree_expression *re, | |
159 bool plhs, int l, int c, octave_value::assign_op t) | |
160 : tree_expression (l, c), lhs (le), rhs (re), preserve (plhs), etype (t) | |
161 { | |
162 if (lhs) | |
163 maybe_warn_former_built_in_variable (lhs->name ()); | |
164 } | |
165 | |
46 tree_simple_assignment::~tree_simple_assignment (void) | 166 tree_simple_assignment::~tree_simple_assignment (void) |
47 { | 167 { |
48 if (! preserve) | 168 if (! preserve) |
49 delete lhs; | 169 delete lhs; |
50 | 170 |
176 { | 296 { |
177 tw.visit_simple_assignment (*this); | 297 tw.visit_simple_assignment (*this); |
178 } | 298 } |
179 | 299 |
180 // Multi-valued assignment expressions. | 300 // Multi-valued assignment expressions. |
301 | |
302 tree_multi_assignment::tree_multi_assignment | |
303 (tree_argument_list *lst, tree_expression *r, | |
304 bool plhs, int l, int c, octave_value::assign_op t) | |
305 : tree_expression (l, c), lhs (lst), rhs (r), preserve (plhs), etype (t) | |
306 { | |
307 for (tree_argument_list::iterator p = lhs->begin (); p != lhs->end (); p++) | |
308 { | |
309 tree_expression *lhs = *p; | |
310 | |
311 if (lhs) | |
312 maybe_warn_former_built_in_variable (lhs->name ()); | |
313 } | |
314 } | |
181 | 315 |
182 tree_multi_assignment::~tree_multi_assignment (void) | 316 tree_multi_assignment::~tree_multi_assignment (void) |
183 { | 317 { |
184 if (! preserve) | 318 if (! preserve) |
185 delete lhs; | 319 delete lhs; |