Mercurial > hg > octave-lyh
diff src/pt-assign.cc @ 8037:0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 19 Aug 2008 14:09:24 -0400 |
parents | 3100283874d7 |
children | aa6484781a5b |
line wrap: on
line diff
--- a/src/pt-assign.cc +++ b/src/pt-assign.cc @@ -44,6 +44,9 @@ // Simple assignment expressions. +// FIXME -- the following variable and the function that uses it +// should be removed from some future version of Octave. + static const char *former_built_in_variables[] = { "DEFAULT_EXEC_PATH", @@ -158,10 +161,7 @@ (tree_expression *le, tree_expression *re, bool plhs, int l, int c, octave_value::assign_op t) : tree_expression (l, c), lhs (le), rhs (re), preserve (plhs), etype (t) -{ - if (lhs) - maybe_warn_former_built_in_variable (lhs->name ()); -} + first_execution (true) { } tree_simple_assignment::~tree_simple_assignment (void) { @@ -194,6 +194,9 @@ { octave_value retval; + if (first_execution && lhs) + maybe_warn_former_built_in_variable (lhs->name ()); + if (error_state) return retval; @@ -260,6 +263,8 @@ } } + first_execution = false; + return retval; } @@ -295,15 +300,7 @@ (tree_argument_list *lst, tree_expression *r, bool plhs, int l, int c, octave_value::assign_op t) : tree_expression (l, c), lhs (lst), rhs (r), preserve (plhs), etype (t) -{ - for (tree_argument_list::iterator p = lhs->begin (); p != lhs->end (); p++) - { - tree_expression *lhs_expr = *p; - - if (lhs_expr) - maybe_warn_former_built_in_variable (lhs_expr->name ()); - } -} + first_execution (true) { } tree_multi_assignment::~tree_multi_assignment (void) { @@ -337,6 +334,17 @@ if (error_state) return retval; + if (first_execution) + { + for (tree_argument_list::iterator p = lhs->begin (); p != lhs->end (); p++) + { + tree_expression *lhs_expr = *p; + + if (lhs_expr) + maybe_warn_former_built_in_variable (lhs_expr->name ()); + } + } + if (rhs) { std::list<octave_lvalue> lvalue_list = lhs->lvalue_list (); @@ -471,6 +479,8 @@ } } + first_execution = false; + return retval; }