Mercurial > hg > octave-nkf
changeset 16277:8cb65fd72164
eliminate obsolete concepts of "pending local" and "forced" variables
* symtab.h, lexh, lex.ll, oct-parse.in.yy, toplev.cc, input.cc:
Delete unused functions and data for handling pending local and forced
variables in the parser and lexer.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 11 Mar 2013 15:01:32 -0400 |
parents | dd7de0345124 |
children | ea78011f66bf 8c17cd370477 |
files | libinterp/interpfcn/input.cc libinterp/interpfcn/symtab.h libinterp/interpfcn/toplev.cc libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.in.yy |
diffstat | 6 files changed, 8 insertions(+), 133 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interpfcn/input.cc +++ b/libinterp/interpfcn/input.cc @@ -517,11 +517,6 @@ curr_parser.reset (); - // Do this with an unwind-protect cleanup function so that the - // forced variables will be unmarked in the event of an interrupt. - symbol_table::scope_id scope = symbol_table::top_scope (); - middle_frame.add_fcn (symbol_table::unmark_forced_variables, scope); - int retval = curr_parser.run (); if (retval == 0 && curr_parser.stmt_list)
--- a/libinterp/interpfcn/symtab.h +++ b/libinterp/interpfcn/symtab.h @@ -196,12 +196,9 @@ // not cleared at function exit static const unsigned int persistent = 64; - // temporary variables forced into symbol table for parsing - static const unsigned int forced = 128; - // this symbol may NOT become a variable. // (symbol added to a static workspace) - static const unsigned int added_static = 256; + static const unsigned int added_static = 128; private: @@ -218,17 +215,6 @@ value_stack.push_back (v); } - void force_variable (context_id context = xdefault_context) - { - if (context == xdefault_context) - context = active_context (); - - octave_value& val = varref (context); - - if (! val.is_defined ()) - mark_forced (); - } - octave_value& varref (context_id context = xdefault_context) { if (is_global ()) @@ -341,7 +327,7 @@ if (context == xdefault_context) context = active_context (); - return (! is_local () || is_defined (context) || is_forced ()); + return (! is_local () || is_defined (context)); } bool is_local (void) const { return storage_class & local; } @@ -351,7 +337,6 @@ bool is_inherited (void) const { return storage_class & inherited; } bool is_global (void) const { return storage_class & global; } bool is_persistent (void) const { return storage_class & persistent; } - bool is_forced (void) const { return storage_class & forced; } bool is_added_static (void) const {return storage_class & added_static; } void mark_local (void) { storage_class |= local; } @@ -373,7 +358,6 @@ else storage_class |= persistent; } - void mark_forced (void) { storage_class |= forced; } void mark_added_static (void) { storage_class |= added_static; } void unmark_local (void) { storage_class &= ~local; } @@ -383,7 +367,6 @@ void unmark_inherited (void) { storage_class &= ~inherited; } void unmark_global (void) { storage_class &= ~global; } void unmark_persistent (void) { storage_class &= ~persistent; } - void unmark_forced (void) { storage_class &= ~forced; } void unmark_added_static (void) { storage_class &= ~added_static; } void init_persistent (void) @@ -496,11 +479,6 @@ octave_value find (const octave_value_list& args = octave_value_list ()) const; - void force_variable (context_id context = xdefault_context) - { - rep->force_variable (context); - } - octave_value& varref (context_id context = xdefault_context) { return rep->varref (context); @@ -541,7 +519,6 @@ bool is_hidden (void) const { return rep->is_hidden (); } bool is_inherited (void) const { return rep->is_inherited (); } bool is_persistent (void) const { return rep->is_persistent (); } - bool is_forced (void) const { return rep->is_forced (); } bool is_added_static (void) const { return rep->is_added_static (); } void mark_local (void) { rep->mark_local (); } @@ -551,7 +528,6 @@ void mark_inherited (void) { rep->mark_inherited (); } void mark_global (void) { rep->mark_global (); } void mark_persistent (void) { rep->mark_persistent (); } - void mark_forced (void) { rep->mark_forced (); } void mark_added_static (void) { rep->mark_added_static (); } void unmark_local (void) { rep->unmark_local (); } @@ -561,7 +537,6 @@ void unmark_inherited (void) { rep->unmark_inherited (); } void unmark_global (void) { rep->unmark_global (); } void unmark_persistent (void) { rep->unmark_persistent (); } - void unmark_forced (void) { rep->unmark_forced (); } void unmark_added_static (void) { rep->unmark_added_static (); } void init_persistent (void) { rep->init_persistent (); } @@ -1205,16 +1180,6 @@ return inst ? inst->do_insert (name) : foobar; } - static void force_variable (const std::string& name, - scope_id scope = xcurrent_scope, - context_id context = xdefault_context) - { - symbol_table *inst = get_instance (scope); - - if (inst) - inst->do_force_variable (name, context); - } - static octave_value& varref (const std::string& name, scope_id scope = xcurrent_scope, context_id context = xdefault_context, @@ -1495,14 +1460,6 @@ inst->do_clear_objects (); } - static void unmark_forced_variables (scope_id scope = xcurrent_scope) - { - symbol_table *inst = get_instance (scope); - - if (inst) - inst->do_unmark_forced_variables (); - } - static void clear_functions (void) { for (fcn_table_iterator p = fcn_table.begin (); p != fcn_table.end (); p++) @@ -2326,20 +2283,6 @@ return p->second; } - void do_force_variable (const std::string& name, context_id context) - { - table_iterator p = table.find (name); - - if (p == table.end ()) - { - symbol_record& sr = do_insert (name); - - sr.force_variable (context); - } - else - p->second.force_variable (context); - } - octave_value& do_varref (const std::string& name, context_id context, bool force_add) { table_iterator p = table.find (name); @@ -2434,12 +2377,6 @@ } } - void do_unmark_forced_variables (void) - { - for (table_iterator p = table.begin (); p != table.end (); p++) - p->second.unmark_forced (); - } - void do_clear_global (const std::string& name) { table_iterator p = table.find (name);
--- a/libinterp/interpfcn/toplev.cc +++ b/libinterp/interpfcn/toplev.cc @@ -578,12 +578,6 @@ if (symbol_table::at_top_level ()) tree_evaluator::reset_debug_state (); - // Do this with an unwind-protect cleanup function so that - // the forced variables will be unmarked in the event of an - // interrupt. - symbol_table::scope_id scope = symbol_table::top_scope (); - inner_frame.add_fcn (symbol_table::unmark_forced_variables, scope); - retval = curr_parser.run (); if (retval == 0)
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -496,8 +496,6 @@ int is_keyword_token (const std::string& s); - bool is_variable (const std::string& name); - bool whitespace_is_significant (void); void handle_number (void);
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -1483,8 +1483,6 @@ while (! parsed_function_name.empty ()) parsed_function_name.pop (); - pending_local_variables.clear (); - nesting_level.reset (); tokens.clear (); @@ -2054,14 +2052,6 @@ } bool -octave_lexer::is_variable (const std::string& name) -{ - return (symbol_table::is_variable (name) - || (pending_local_variables.find (name) - != pending_local_variables.end ())); -} - -bool octave_lexer::whitespace_is_significant (void) { return (nesting_level.is_bracket ()
--- a/libinterp/parse-tree/oct-parse.in.yy +++ b/libinterp/parse-tree/oct-parse.in.yy @@ -427,25 +427,13 @@ ; matrix : '[' ']' - { - $$ = new tree_constant (octave_null_matrix::instance); - curr_lexer->pending_local_variables.clear (); - } + { $$ = new tree_constant (octave_null_matrix::instance); } | '[' ';' ']' - { - $$ = new tree_constant (octave_null_matrix::instance); - curr_lexer->pending_local_variables.clear (); - } + { $$ = new tree_constant (octave_null_matrix::instance); } | '[' ',' ']' - { - $$ = new tree_constant (octave_null_matrix::instance); - curr_lexer->pending_local_variables.clear (); - } + { $$ = new tree_constant (octave_null_matrix::instance); } | '[' matrix_rows ']' - { - $$ = curr_parser.finish_matrix ($2); - curr_lexer->pending_local_variables.clear (); - } + { $$ = curr_parser.finish_matrix ($2); } ; matrix_rows : matrix_rows1 @@ -672,14 +660,10 @@ $$ = curr_parser.validate_matrix_for_assignment ($1); if ($$) - { - curr_lexer->looking_at_matrix_or_assign_lhs = false; - curr_lexer->pending_local_variables.clear (); - } + { curr_lexer->looking_at_matrix_or_assign_lhs = false; } else { - // validate_matrix_for_assignment deleted $1 - // for us. + // validate_matrix_for_assignment deleted $1. ABORT_PARSE; } } @@ -2581,11 +2565,6 @@ script->stash_fcn_file_time (now); primary_fcn_ptr = script; - - // Unmark any symbols that may have been tagged as local variables - // while parsing (for example, by force_local_variable in lex.l). - - symbol_table::unmark_forced_variables (); } // Begin defining a function. @@ -2786,12 +2765,6 @@ retval = new tree_function_def (fcn); } - - // Unmark any symbols that may have been tagged as local - // variables while parsing (for example, by force_local_variable - // in lex.l). - - symbol_table::unmark_forced_variables (fcn->scope ()); } return retval; @@ -3237,12 +3210,6 @@ curr_parser.autoloading = autoload; curr_parser.fcn_file_from_relative_lookup = relative_lookup; - // Do this with an unwind-protect cleanup function so that - // the forced variables will be unmarked in the event of an - // interrupt. - symbol_table::scope_id scope = symbol_table::top_scope (); - frame.add_fcn (symbol_table::unmark_forced_variables, scope); - curr_parser.curr_lexer->force_script = force_script; curr_parser.curr_lexer->prep_for_file (); curr_parser.curr_lexer->parsing_class_method = ! dispatch_type.empty (); @@ -3939,12 +3906,6 @@ { curr_parser.reset (); - // Do this with an unwind-protect cleanup function so that the - // forced variables will be unmarked in the event of an - // interrupt. - symbol_table::scope_id scope = symbol_table::top_scope (); - frame.add_fcn (symbol_table::unmark_forced_variables, scope); - parse_status = curr_parser.run (); // Unmark forced variables.