Mercurial > hg > octave-lojdl
changeset 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 | 854683691d7a |
children | aa6484781a5b |
files | src/ChangeLog src/pt-assign.cc src/pt-assign.h |
diffstat | 3 files changed, 43 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,15 @@ 2008-08-19 Jaroslav Hajek <highegg@gmail.com> + * pt-assign.h (tree_simple_assignment::first_execution): New + member field. + (tree_simple_assignment::first_execution): Dtto. + * pt-assign.cc (tree_simple_assignment::tree_simple_assignment): + Initialize first_execution. + (tree_multi_assignment::tree_multi_assignment): Dtto. + (tree_simple_assignment::rvalue): Check for obsolete built-in + variables only at first execution. + (tree_multi_assignment::rvalue): Dtto. + * DLD-FUNCTIONS/__glpk__.cc (F__glpk__): Checks whether LB and UB are of proper size.
--- 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; }
--- a/src/pt-assign.h +++ b/src/pt-assign.h @@ -47,7 +47,8 @@ tree_simple_assignment (bool plhs = false, int l = -1, int c = -1, octave_value::assign_op t = octave_value::op_asn_eq) - : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype (t) { } + : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype (t), + first_execution (true) { } tree_simple_assignment (tree_expression *le, tree_expression *re, bool plhs = false, int l = -1, int c = -1, @@ -100,6 +101,9 @@ // The type of the expression. octave_value::assign_op etype; + // true only on first rvalue() call. + bool first_execution; + // No copying! tree_simple_assignment (const tree_simple_assignment&); @@ -116,7 +120,8 @@ tree_multi_assignment (bool plhs = false, int l = -1, int c = -1, octave_value::assign_op t = octave_value::op_asn_eq) - : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype(t) { } + : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype(t), + first_execution (true) { } tree_multi_assignment (tree_argument_list *lst, tree_expression *r, bool plhs = false, int l = -1, int c = -1, @@ -161,6 +166,9 @@ // The type of the expression. octave_value::assign_op etype; + // true only on first rvalue() call. + bool first_execution; + // No copying! tree_multi_assignment (const tree_multi_assignment&);