diff libinterp/parse-tree/pt-fcn-handle.cc @ 23602:214cb58ccc1c

use pointer to scope instead of scope id Eliminate symbol table scope ID and the global list of all scopes indexed by numeric ID. Function scope data is now only accessible from the function itself, or by asking a scope for its parent scope (if it exists). The top-level and global scopes are now regular data members of the symbol table class instead of being static. Symbol table scopes are now created in the lexer when parsing a function begins and stored in the function object when finishing the construction of function object. If an error occurs while parsing a function, the list of any pending scopes is deleted.
author John W. Eaton <jwe@octave.org>
date Wed, 14 Jun 2017 11:53:34 -0400
parents db947ba52118
children 91c8f006ed8b
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-fcn-handle.cc	Sun Jun 11 16:57:00 2017 -0400
+++ b/libinterp/parse-tree/pt-fcn-handle.cc	Wed Jun 14 11:53:34 2017 -0400
@@ -54,8 +54,7 @@
   }
 
   tree_expression *
-  tree_fcn_handle::dup (symbol_table::scope_id,
-                        symbol_table::context_id) const
+  tree_fcn_handle::dup (symbol_table::scope&) const
   {
     tree_fcn_handle *new_fh = new tree_fcn_handle (nm, line (), column ());
 
@@ -71,27 +70,26 @@
   }
 
   tree_expression *
-  tree_anon_fcn_handle::dup (symbol_table::scope_id,
-                             symbol_table::context_id) const
+  tree_anon_fcn_handle::dup (symbol_table::scope&) const
   {
     tree_parameter_list *param_list = parameter_list ();
     tree_expression *expr = expression ();
 
-    symbol_table::scope_id af_sid = scope ();
-    symbol_table::scope_id af_parent_sid = parent_scope ();
+    symbol_table::scope *af_scope = m_scope;
+    symbol_table::scope *af_parent_scope = m_parent_scope;
 
     symbol_table& symtab
       = octave::__get_symbol_table__ ("tree_anon_fcn_handle::dup");
 
-    symbol_table::scope_id new_scope = symtab.dup_scope (af_sid);
+    symbol_table::scope *new_scope = af_scope ? af_scope->dup () : 0;
 
-    if (new_scope > 0)
+    if (new_scope)
       symtab.inherit (new_scope);
 
     tree_anon_fcn_handle *new_afh = new
-      tree_anon_fcn_handle (param_list ? param_list->dup (new_scope, 0) : 0,
-                            expr ? expr->dup (new_scope, 0) : 0,
-                            new_scope, af_parent_sid, line (), column ());
+      tree_anon_fcn_handle (param_list ? param_list->dup (*new_scope) : 0,
+                            expr ? expr->dup (*new_scope) : 0,
+                            new_scope, af_parent_scope, line (), column ());
 
     new_afh->copy_base (*this);