Mercurial > hg > octave-lyh
changeset 14294:9e3983c8963c
deprecate the static keyword
* octave.gperf: Use PERSISTENT as the token for "static" and
"persistent" but use separate static_kw and persistent_kw values so we
can distinguish them.
* lex.ll (is_keyword_token): Handle static_kw and persistent_kw
separately. Generate deprecated keyword warning for static_kw.
* oct-parse.cc: Use PERSISTENT token instead of STATIC.
* pt-decl.h, pt-decl.cc (tree_persistent_command): Rename from
tree_static_command. Change all uses.
* pt-walk.h (tree_walker::visit_persistent_command):
Rename from visit_static_command. Change all derived classes.
* NEWS: note that static has been deprecated.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 30 Jan 2012 23:42:41 -0500 |
parents | 71a198cca35b |
children | 21572e9bd365 |
files | NEWS src/lex.ll src/oct-parse.yy src/octave.gperf src/pt-bp.cc src/pt-bp.h src/pt-check.cc src/pt-check.h src/pt-decl.cc src/pt-decl.h src/pt-eval.cc src/pt-eval.h src/pt-pr-code.cc src/pt-pr-code.h src/pt-walk.h |
diffstat | 15 files changed, 57 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS +++ b/NEWS @@ -22,6 +22,13 @@ be removed from Octave 3.12 (or whatever version is the second major release after 3.8): + <none yet> + + The following keywords have been deprecated in Octave 3.8 and will + be removed from Octave 3.12 (or whatever version is the second major + release after 3.8): + + static Summary of important user-visible changes for version 3.6:
--- a/src/lex.ll +++ b/src/lex.ll @@ -1497,10 +1497,26 @@ lexer_flags.at_beginning_of_statement = true; break; + case static_kw: + if ((reading_fcn_file || reading_script_file + || reading_classdef_file) + && ! curr_fcn_file_full_name.empty ()) + warning_with_id ("Octave:deprecated-keyword", + "the `static' keyword is obsolete and will be removed from a future version of Octave; please use `persistent' instead; near line %d of file `%s'", + input_line_number, + curr_fcn_file_full_name.c_str ()); + else + warning_with_id ("Octave:deprecated-keyword", + "the `static' keyword is obsolete and will be removed from a future version of Octave; please use `persistent' instead; near line %d", + input_line_number); + // fall through ... + + case persistent_kw: + break; + case case_kw: case elseif_kw: case global_kw: - case static_kw: case until_kw: break; @@ -3694,7 +3710,7 @@ case TRY: std::cerr << "TRY\n"; break; case CATCH: std::cerr << "CATCH\n"; break; case GLOBAL: std::cerr << "GLOBAL\n"; break; - case STATIC: std::cerr << "STATIC\n"; break; + case PERSISTENT: std::cerr << "PERSISTENT\n"; break; case FCN_HANDLE: std::cerr << "FCN_HANDLE\n"; break; case END_OF_INPUT: std::cerr << "END_OF_INPUT\n\n"; break; case LEXICAL_ERROR: std::cerr << "LEXICAL_ERROR\n\n"; break;
--- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -446,7 +446,7 @@ %token <tok_val> BREAK CONTINUE FUNC_RET %token <tok_val> UNWIND CLEANUP %token <tok_val> TRY CATCH -%token <tok_val> GLOBAL STATIC +%token <tok_val> GLOBAL PERSISTENT %token <tok_val> FCN_HANDLE %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION %token <tok_val> METAQUERY @@ -997,9 +997,9 @@ $$ = make_decl_command (GLOBAL, $1, $3); lexer_flags.looking_at_decl_list = false; } - | STATIC parsing_decl_list decl1 + | PERSISTENT parsing_decl_list decl1 { - $$ = make_decl_command (STATIC, $1, $3); + $$ = make_decl_command (PERSISTENT, $1, $3); lexer_flags.looking_at_decl_list = false; } ; @@ -3091,9 +3091,9 @@ retval = new tree_global_command (lst, l, c); break; - case STATIC: + case PERSISTENT: if (current_function_depth > 0) - retval = new tree_static_command (lst, l, c); + retval = new tree_persistent_command (lst, l, c); else { if (reading_script_file)
--- a/src/octave.gperf +++ b/src/octave.gperf @@ -60,6 +60,7 @@ methods_kw, otherwise_kw, parfor_kw, + persistent_kw, properties_kw, return_kw, set_kw, @@ -106,11 +107,11 @@ methods, METHODS, methods_kw otherwise, OTHERWISE, otherwise_kw parfor, PARFOR, parfor_kw -persistent, STATIC, static_kw +persistent, PERSISTENT, persistent_kw properties, PROPERTIES, properties_kw return, FUNC_RET, return_kw set, SET, set_kw -static, STATIC, static_kw +static, PERSISTENT, static_kw switch, SWITCH, switch_kw try, TRY, try_kw until, UNTIL, until_kw
--- a/src/pt-bp.cc +++ b/src/pt-bp.cc @@ -111,7 +111,7 @@ } void -tree_breakpoint::visit_static_command (tree_static_command& cmd) +tree_breakpoint::visit_persistent_command (tree_persistent_command& cmd) { do_decl_command (cmd); }
--- a/src/pt-bp.h +++ b/src/pt-bp.h @@ -58,7 +58,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-check.cc +++ b/src/pt-check.cc @@ -105,7 +105,7 @@ } void -tree_checker::visit_static_command (tree_static_command& cmd) +tree_checker::visit_persistent_command (tree_persistent_command& cmd) { do_decl_command (cmd); }
--- a/src/pt-check.h +++ b/src/pt-check.h @@ -51,7 +51,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-decl.cc +++ b/src/pt-decl.cc @@ -132,16 +132,16 @@ // Static. tree_command * -tree_static_command::dup (symbol_table::scope_id scope, +tree_persistent_command::dup (symbol_table::scope_id scope, symbol_table::context_id context) const { return - new tree_static_command (init_list ? init_list->dup (scope, context) : 0, - line (), column ()); + new tree_persistent_command (init_list ? init_list->dup (scope, context) : 0, + line (), column ()); } void -tree_static_command::accept (tree_walker& tw) +tree_persistent_command::accept (tree_walker& tw) { - tw.visit_static_command (*this); + tw.visit_persistent_command (*this); }
--- a/src/pt-decl.h +++ b/src/pt-decl.h @@ -207,20 +207,20 @@ tree_global_command& operator = (const tree_global_command&); }; -// Static. +// Persistent. class -tree_static_command : public tree_decl_command +tree_persistent_command : public tree_decl_command { public: - tree_static_command (int l = -1, int c = -1) - : tree_decl_command ("static", l, c) { } + tree_persistent_command (int l = -1, int c = -1) + : tree_decl_command ("persistent", l, c) { } - tree_static_command (tree_decl_init_list *t, int l = -1, int c = -1) - : tree_decl_command ("static", t, l, c) { } + tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1) + : tree_decl_command ("persistent", t, l, c) { } - ~tree_static_command (void) { } + ~tree_persistent_command (void) { } tree_command *dup (symbol_table::scope_id scope, symbol_table::context_id context) const; @@ -233,9 +233,9 @@ // No copying! - tree_static_command (const tree_static_command&); + tree_persistent_command (const tree_persistent_command&); - tree_static_command& operator = (const tree_static_command&); + tree_persistent_command& operator = (const tree_persistent_command&); }; #endif
--- a/src/pt-eval.cc +++ b/src/pt-eval.cc @@ -215,7 +215,7 @@ } void -tree_evaluator::visit_static_command (tree_static_command& cmd) +tree_evaluator::visit_persistent_command (tree_persistent_command& cmd) { if (debug_mode) do_breakpoint (cmd.is_breakpoint ());
--- a/src/pt-eval.h +++ b/src/pt-eval.h @@ -60,7 +60,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-pr-code.cc +++ b/src/pt-pr-code.cc @@ -165,7 +165,7 @@ } void -tree_print_code::visit_static_command (tree_static_command& cmd) +tree_print_code::visit_persistent_command (tree_persistent_command& cmd) { do_decl_command (cmd); }
--- a/src/pt-pr-code.h +++ b/src/pt-pr-code.h @@ -67,7 +67,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-walk.h +++ b/src/pt-walk.h @@ -30,7 +30,7 @@ class tree_colon_expression; class tree_continue_command; class tree_global_command; -class tree_static_command; +class tree_persistent_command; class tree_decl_elt; class tree_decl_init_list; class tree_simple_for_command; @@ -92,7 +92,7 @@ visit_global_command (tree_global_command&) = 0; virtual void - visit_static_command (tree_static_command&) = 0; + visit_persistent_command (tree_persistent_command&) = 0; virtual void visit_decl_elt (tree_decl_elt&) = 0;