diff libinterp/parse-tree/oct-parse.in.yy @ 16177:a7669b4d27f6

eliminate global global_command variable * toplev.h, toplev.cc (global_command): Delete. * parse.h, oct-parse.in.yy (octave_parser::stmt_list): New member variable. (octave_parser::octave_parser): Initialize it to zero. (octave_parser:~octave_parser): Delete it. (octave_parser::reset): Delete it and set it to zero. * toplev.cc (main_loop): Use curr_parser->stmt_list instead of global_command. * input.cc (get_debug_input): Likewise. * oct-parse.in.yy (eval_string, parse_fcn_file): Likewise. (ABORT_PARSE): Don't set global_command to zero. (input): Set curr_parser->stmt_list instead of global_command.
author John W. Eaton <jwe@octave.org>
date Sat, 02 Mar 2013 19:31:26 -0500 (2013-03-03)
parents 39096b290a2f
children 490625211945
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy
+++ b/libinterp/parse-tree/oct-parse.in.yy
@@ -132,7 +132,6 @@
 #define ABORT_PARSE \
   do \
     { \
-      global_command = 0; \
       yyerrok; \
       if (! parser_symtab_context.empty ()) \
         parser_symtab_context.pop (); \
@@ -326,7 +325,7 @@
 
 input           : input1
                   {
-                    global_command = $1;
+                    curr_parser->stmt_list = $1;
                     promptflag = 1;
                     YYACCEPT;
                   }
@@ -1486,7 +1485,9 @@
   yypstate_delete (static_cast<yypstate *> (parser_state));
 #endif
 
-delete curr_lexer;
+  delete stmt_list;
+
+  delete curr_lexer;
 }
 void octave_parser::init (void)
 {
@@ -1497,6 +1498,16 @@
   CURR_LEXER = curr_lexer;
 }
 
+void
+octave_parser::reset (void)
+{
+  delete stmt_list;
+
+  stmt_list = 0;
+
+  curr_lexer->reset ();
+}
+
 int
 octave_parser::run (void)
 {
@@ -3467,18 +3478,8 @@
 
           curr_parser->curr_lexer->parsing_class_method = ! dispatch_type.empty ();
 
-          frame.protect_var (global_command);
-
-          global_command = 0;
-
           int status = curr_parser->run ();
 
-          // Use an unwind-protect cleanup function so that the
-          // global_command list will be deleted in the event of an
-          // interrupt.
-
-          frame.add_fcn (cleanup_statement_list, &global_command);
-
           fcn_ptr = curr_parser->primary_fcn_ptr;
 
           if (status != 0)
@@ -4212,10 +4213,6 @@
     {
       curr_parser->reset ();
 
-      frame.protect_var (global_command);
-
-      global_command = 0;
-
       // Do this with an unwind-protect cleanup function so that the
       // forced variables will be unmarked in the event of an
       // interrupt.
@@ -4224,28 +4221,17 @@
 
       parse_status = curr_parser->run ();
 
-      tree_statement_list *command_list = global_command;
-
       // Unmark forced variables.
-      // Restore previous value of global_command.
-      frame.run (2);
+      frame.run (1);
 
       if (parse_status == 0)
         {
-          if (command_list)
+          if (curr_parser->stmt_list)
             {
-              unwind_protect inner_frame;
-
-              // Use an unwind-protect cleanup function so that the
-              // global_command list will be deleted in the event of an
-              // interrupt.
-
-              inner_frame.add_fcn (cleanup_statement_list, &command_list);
-
               tree_statement *stmt = 0;
 
-              if (command_list->length () == 1
-                  && (stmt = command_list->front ())
+              if (curr_parser->stmt_list->length () == 1
+                  && (stmt = curr_parser->stmt_list->front ())
                   && stmt->is_expression ())
                 {
                   tree_expression *expr = stmt->expression ();
@@ -4274,7 +4260,7 @@
                     retval = octave_value_list ();
                 }
               else if (nargout == 0)
-                command_list->accept (*current_evaluator);
+                curr_parser->stmt_list->accept (*current_evaluator);
               else
                 error ("eval: invalid use of statement list");