# HG changeset patch # User Jaroslav Hajek # Date 1219169364 14400 # Node ID 1695e4627d2b2c5ba56dfee02d05f923d104263d # Parent c51deec2faf19fcbc10a64053b8ae7c4e3e5beee check for obsolete built-in variable assignment at first execution rather than parse time diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,15 @@ 2008-08-19 Jaroslav Hajek + * 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. diff --git a/src/pt-assign.cc b/src/pt-assign.cc --- 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; @@ -258,6 +261,8 @@ eval_error (); } + first_execution = false; + return retval; } @@ -303,15 +308,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) { @@ -345,6 +342,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 lvalue_list = lhs->lvalue_list (); @@ -486,6 +494,8 @@ else eval_error (); + first_execution = false; + return retval; } diff --git a/src/pt-assign.h b/src/pt-assign.h --- a/src/pt-assign.h +++ b/src/pt-assign.h @@ -46,7 +46,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, @@ -162,6 +167,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&);