diff libinterp/parse-tree/pt-id.h @ 24352:bff8e3884a88

restructure global variable handling in symbol table * symrec.h, symrec.cc (symbol_record::symbol_record_rep::xglobal_varref, symbol_record::symbol_record_rep::xglobal_varval): Delete. (symbol_record::find): Don't treat globals specially. (symbol_record::symbol_record_rep::varref, (symbol_record::symbol_record_rep::varval): Handle globals like other variables, but with context always equal to 0. (symbol_record::symbol_record_rep::clear): For globals, unbind forward rep instead of calling unmark_global. (symbol_record::symbol_record_rep::unmark_global): Delete. (symbol_record::symbol_record_rep::mark_global): Don't forward. (symbol_record::symbol_record_rep::bind_fwd_rep, symbol_record::symbol_record_rep::unbind_fwd_rep): Do forward. (symbol_record::varref, symbol_record::unmark_global): Delete. * symscope.h, symscope.cc (symbol_scope::clear_global_pattern, symbol_scope::clear_global, symbol_scope::varref): Delete. * symtab.h, symtab.cc (symbol_table::find_global_symbol, symbol_table::clear_global_pattern, symbol_table::clear_global): New functions. (symbol_table::erase_global, symbol_table::global_varref): Delete. (symbol_table::clear_all): Call clear_variables for the global scope instead of clear_global_pattern for the current scope. (symbol_table::m_global_symbols): Delete variable and all uses. * variables.cc (do_clear_globals): Call clear_variable for the symbols in the current scope that are linked to global symbols and symtab::clear_global for the actual global symbols. * pt-eval.cc (tree_evaluator::visit_tree_decl_elt): Find global symbol and link ID to it instead of calling mark_global for ID. * pt-id.h, pt-id.cc (tree_identifier::link_to_global): New function. (tree_identifier::mark_global): Delete.
author John W. Eaton <jwe@octave.org>
date Thu, 30 Nov 2017 15:10:12 -0500
parents bc3819b7cca1
children 8b14ba8296af
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-id.h	Thu Nov 30 08:00:40 2017 -0500
+++ b/libinterp/parse-tree/pt-id.h	Thu Nov 30 15:10:12 2017 -0500
@@ -36,7 +36,7 @@
 #include "pt-bp.h"
 #include "pt-exp.h"
 #include "pt-walk.h"
-#include "symtab.h"
+#include "symscope.h"
 
 namespace octave
 {
@@ -69,8 +69,6 @@
 
     bool is_identifier (void) const { return true; }
 
-    // The name doesn't change with scope, so use sym instead of
-    // accessing it through sym so that this function may remain const.
     std::string name (void) const { return sym.name (); }
 
     bool is_defined (void) { return sym.is_defined (); }
@@ -100,7 +98,7 @@
       return sym.find (args);
     }
 
-    void mark_global (void) { sym.mark_global (); }
+    void link_to_global (const symbol_record& global_sym);
 
     void mark_persistent (void) { sym.init_persistent (); }