bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03-muscle-obstack.patch


From: Akim Demaille
Subject: 03-muscle-obstack.patch
Date: Fri, 14 Jun 2002 19:28:33 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/files.c (action_obstack): Remove, unused.
        (output_obstack): Remove it, and all its dependencies, as it is no
        longer needed.
        * src/reader.c (epilogue_set): Build the epilogue in the
        muscle_obstack.
        * src/output.h, src/output.c (muscle_obstack): Move to...
        * src/muscle_tab.h, src/muscle_tab.h: here.
        (muscle_init): Initialize muscle_obstack.
        (muscle_free): New.
        * src/main.c (main): Call it.
        
        
Index: src/files.c
--- src/files.c Thu, 02 May 2002 19:30:29 +0200 akim
+++ src/files.c Fri, 14 Jun 2002 18:19:53 +0200 akim
@@ -1,5 +1,5 @@
 /* Open and close files for bison,
-   Copyright 1984, 1986, 1989, 1992, 2000, 2001, 2002
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
@@ -32,8 +32,6 @@
 
 FILE *finput = NULL;
 
-struct obstack action_obstack;
-struct obstack output_obstack;
 struct obstack pre_prologue_obstack;
 struct obstack post_prologue_obstack;
 
Index: src/files.h
--- src/files.h Wed, 08 May 2002 11:29:49 +0200 akim
+++ src/files.h Fri, 14 Jun 2002 18:19:53 +0200 akim
@@ -46,15 +46,9 @@
 extern FILE *finput;
 
 
-/* Output all the action code; precise form depends on which parser. */
-extern struct obstack action_obstack;
-
 /* If semantic parser, output a .h file that defines YYSTYPE... */
 extern struct obstack pre_prologue_obstack;
 extern struct obstack post_prologue_obstack;
-
-/* The verbose output. */
-extern struct obstack output_obstack;
 
 extern char *infile;
 
Index: src/main.c
--- src/main.c Tue, 11 Jun 2002 21:16:20 +0200 akim
+++ src/main.c Fri, 14 Jun 2002 18:27:44 +0200 akim
@@ -110,7 +110,7 @@
   free_nullable ();
   free_derives ();
   grammar_free ();
-
+  muscle_free ();
   /* If using alloca.c, flush the alloca'ed memory for the benefit of
      people running Bison as a library in IDEs.  */
 #if C_ALLOCA
Index: src/muscle_tab.c
--- src/muscle_tab.c Tue, 11 Jun 2002 17:17:43 +0200 akim
+++ src/muscle_tab.c Fri, 14 Jun 2002 18:10:27 +0200 akim
@@ -24,6 +24,10 @@
 #include "muscle_tab.h"
 #include "getargs.h"
 
+
+/* An obstack used to create some entries.  */
+struct obstack muscle_obstack;
+
 /* Initial capacity of muscles hash table.  */
 #define HT_INITIAL_CAPACITY 257
 
@@ -44,16 +48,24 @@
   return hash_string (m->key, tablesize);
 }
 
+/*-----------------------------------------------------------------.
+| Create the MUSCLE_TABLE, and initialize it with default values.  |
+| Also set up the MUSCLE_OBSTACK.                                  |
+`-----------------------------------------------------------------*/
+
 void
 muscle_init (void)
 {
   muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
-                                 hash_compare_muscles, NULL);
+                                 hash_compare_muscles, free);
 
   /* Version and input file.  */
   muscle_insert ("version", VERSION);
   muscle_insert ("filename", infile);
 
+  /* FIXME: there should probably be no default here, only in the
+     skeletons.  */
+
   /* Types.  */
   muscle_insert ("ltype", "yyltype");
 
@@ -66,7 +78,24 @@
 
   /* C++ macros.  */
   muscle_insert ("name", "Parser");
+
+  /* Initialize the muscle obstack.  */
+  obstack_init (&muscle_obstack);
 }
+
+
+/*------------------------------------------------------------.
+| Free all the memory consumed by the muscle machinery only.  |
+`------------------------------------------------------------*/
+
+void
+muscle_free (void)
+{
+  hash_free (muscle_table);
+  obstack_free (&muscle_obstack, NULL);
+}
+
+
 
 void
 muscle_insert (const char *key, const char *value)
Index: src/muscle_tab.h
--- src/muscle_tab.h Sun, 07 Apr 2002 17:21:28 +0200 akim
+++ src/muscle_tab.h Fri, 14 Jun 2002 18:08:40 +0200 akim
@@ -32,6 +32,11 @@
 void muscle_init PARAMS ((void));
 void muscle_insert PARAMS ((const char *key, const char *value));
 const char *muscle_find PARAMS ((const char *key));
+void muscle_free PARAMS ((void));
+
+
+/* An obstack dedicated to receive muscle keys and values.  */
+extern struct obstack muscle_obstack;
 
 #define MUSCLE_INSERT_INT(Key, Value)                          \
 {                                                              \
Index: src/output.c
--- src/output.c Tue, 11 Jun 2002 17:25:43 +0200 akim
+++ src/output.c Fri, 14 Jun 2002 18:14:53 +0200 akim
@@ -132,7 +132,6 @@
 static int lowzero;
 static int high;
 
-struct obstack muscle_obstack;
 static struct obstack format_obstack;
 
 int error_verbose = 0;
@@ -1087,9 +1086,7 @@
   /* Process the selected skeleton file.  */
   output_skeleton ();
 
-  obstack_free (&muscle_obstack, NULL);
   obstack_free (&format_obstack, NULL);
-  obstack_free (&action_obstack, NULL);
   obstack_free (&pre_prologue_obstack, NULL);
   obstack_free (&post_prologue_obstack, NULL);
 }
Index: src/output.h
--- src/output.h Thu, 02 May 2002 19:30:29 +0200 akim
+++ src/output.h Fri, 14 Jun 2002 18:08:34 +0200 akim
@@ -29,6 +29,4 @@
 void actions_output PARAMS ((FILE *out));
 void token_definitions_output PARAMS ((FILE *out));
 
-extern struct obstack muscle_obstack;
-
 #endif /* !OUTPUT_H_ */
Index: src/print.c
--- src/print.c Thu, 06 Jun 2002 20:45:16 +0200 akim
+++ src/print.c Fri, 14 Jun 2002 18:19:45 +0200 akim
@@ -503,13 +503,6 @@
      that conflicts with Posix.  */
   FILE *out = xfopen (spec_verbose_file, "w");
 
-  size_t size = obstack_object_size (&output_obstack);
-  fwrite (obstack_finish (&output_obstack), 1, size, out);
-  obstack_free (&output_obstack, NULL);
-
-  if (size)
-    fputs ("\n\n", out);
-
   reduce_output (out);
   conflicts_output (out);
 
Index: src/reader.c
--- src/reader.c Fri, 14 Jun 2002 17:55:27 +0200 akim
+++ src/reader.c Fri, 14 Jun 2002 18:18:51 +0200 akim
@@ -138,19 +138,16 @@
 void
 epilogue_set (const char *epilogue, location_t location)
 {
-  struct obstack el_obstack;
-  obstack_init (&el_obstack);
-
   if (!no_lines_flag)
     {
-      obstack_fgrow2 (&el_obstack, muscle_find ("linef"),
+      obstack_fgrow2 (&muscle_obstack, muscle_find ("linef"),
                      location.first_line,
                      quotearg_style (c_quoting_style,
                                      muscle_find ("filename")));
     }
-  obstack_sgrow (&el_obstack, epilogue);
-  obstack_1grow (&el_obstack, 0);
-  muscle_insert ("epilogue", obstack_finish (&el_obstack));
+  obstack_sgrow (&muscle_obstack, epilogue);
+  obstack_1grow (&muscle_obstack, 0);
+  muscle_insert ("epilogue", obstack_finish (&muscle_obstack));
 }
 
 
@@ -450,9 +447,6 @@
   gram_control_t gram_control;
   lineno = 1;
 
-  /* Initialize the muscle obstack.  */
-  obstack_init (&muscle_obstack);
-
   /* Initialize the symbol table.  */
   symbols_new ();
 
@@ -473,8 +467,6 @@
   undeftoken->number = ntokens++;
 
   /* Initialize the obstacks. */
-  obstack_init (&action_obstack);
-  obstack_init (&output_obstack);
   obstack_init (&pre_prologue_obstack);
   obstack_init (&post_prologue_obstack);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]