changeset 11557:e9d72a3caa46

mark automatic variables as automatic
author John W. Eaton <jwe@octave.org>
date Mon, 17 Jan 2011 13:36:59 -0500
parents e582adc89d55
children 1e4dfc7a9487
files src/ChangeLog src/ov-usr-fcn.cc src/symtab.h
diffstat 3 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2011-01-17  John W. Eaton  <jwe@octave.org>
+
+	* ov-usr-fcn.cc (bind_automatic_vars): Mark variables created
+	here as automatic.
+
+	* symtab.h (symbol_table::mark_automatic): New function.
+	(symbol_table::do_mark_automatic): New function.
+
 2011-01-17  Michael Godfrey <godfrey@isl.stanford.edu>
 
 	* variables.cc (Fwhos): Describe a and f attributes in help text.
--- a/src/ov-usr-fcn.cc
+++ b/src/ov-usr-fcn.cc
@@ -543,7 +543,11 @@
    const octave_value_list& va_args, const std::list<octave_lvalue> *lvalue_list)
 {
   if (! arg_names.empty ())
-    symbol_table::varref ("argn") = arg_names;
+    {
+      symbol_table::varref ("argn") = arg_names;
+
+      symbol_table::mark_automatic ("argn");
+    }
 
   symbol_table::varref (".nargin.") = nargin;
   symbol_table::varref (".nargout.") = nargout;
@@ -551,6 +555,9 @@
   symbol_table::mark_hidden (".nargin.");
   symbol_table::mark_hidden (".nargout.");
 
+  symbol_table::mark_automatic (".nargin.");
+  symbol_table::mark_automatic (".nargout.");
+
   if (takes_varargs ())
     symbol_table::varref ("varargin") = va_args.cell_value ();
   
@@ -575,7 +582,9 @@
             }
 
           symbol_table::varref (".ignored.") = bh;
+
           symbol_table::mark_hidden (".ignored.");
+          symbol_table::mark_automatic (".ignored.");
         }
     }
 }
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -1578,6 +1578,14 @@
   // For unwind_protect.
   static void pop_context (void *) { pop_context (); }
 
+  static void mark_automatic (const std::string& name)
+  {
+    symbol_table *inst = get_instance (xcurrent_scope);
+
+    if (inst)
+      inst->do_mark_automatic (name);
+  }
+
   static void mark_hidden (const std::string& name)
   {
     symbol_table *inst = get_instance (xcurrent_scope);
@@ -2267,6 +2275,11 @@
       }
   }
 
+  void do_mark_automatic (const std::string& name)
+  {
+    do_insert (name).mark_automatic ();
+  }
+
   void do_mark_hidden (const std::string& name)
   {
     do_insert (name).mark_hidden ();