Change functions in cp-name-parser.y into methods
authorTom Tromey <tom@tromey.com>
Fri, 1 Jun 2018 17:50:01 +0000 (11:50 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 4 Jun 2018 13:15:11 +0000 (07:15 -0600)
Pedro pointed out in an earlier patch that it would be possible to
make some helper functions in cp-name-parser.y into methods on
cpname_state, cleaning up the code a bit.  This patch implements this
idea.

Doing this required moving the %union earlier in the .y file, so the
patch is somewhat bigger than you might expect.

Tested by building with both bison and byacc, and then running the
gdb.cp tests.

gdb/ChangeLog
2018-06-04  Tom Tromey  <tom@tromey.com>

* cp-name-parser.y (cpname_state): Add method declarations.
(HANDLE_QUAL): Update.
(cpname_state::d_grab, cpname_state::fill_comp)
(cpname_state::make_operator, cpname_state::make_dtor)
(cpname_state::make_builtin_type, cpname_state::make_name)
(cpname_state::d_qualify, cpname_state::d_int_type)
(cpname_state::d_unary, cpname_state::d_binary): Now methods.
(%union): Move earlier.

gdb/ChangeLog
gdb/cp-name-parser.y

index 373e667..e2f3618 100644 (file)
@@ -1,3 +1,14 @@
+2018-06-04  Tom Tromey  <tom@tromey.com>
+
+       * cp-name-parser.y (cpname_state): Add method declarations.
+       (HANDLE_QUAL): Update.
+       (cpname_state::d_grab, cpname_state::fill_comp)
+       (cpname_state::make_operator, cpname_state::make_dtor)
+       (cpname_state::make_builtin_type, cpname_state::make_name)
+       (cpname_state::d_qualify, cpname_state::d_int_type)
+       (cpname_state::d_unary, cpname_state::d_binary): Now methods.
+       (%union): Move earlier.
+
 2018-06-04  Alan Hayward  <alan.hayward@arm.com>
 
        * aarch64-tdep.c (aarch64_pseudo_read_value_1): New helper func.
index b8a3faa..72ffc8a 100644 (file)
@@ -60,12 +60,36 @@ struct demangle_info {
   struct demangle_component comps[ALLOC_CHUNK];
 };
 
+%}
+
+%union
+  {
+    struct demangle_component *comp;
+    struct nested {
+      struct demangle_component *comp;
+      struct demangle_component **last;
+    } nested;
+    struct {
+      struct demangle_component *comp, *last;
+    } nested1;
+    struct {
+      struct demangle_component *comp, **last;
+      struct nested fn;
+      struct demangle_component *start;
+      int fold_flag;
+    } abstract;
+    int lval;
+    const char *opname;
+  }
+
+%{
+
 struct cpname_state
 {
-/* LEXPTR is the current pointer into our lex buffer.  PREV_LEXPTR
-   is the start of the last token lexed, only used for diagnostics.
-   ERROR_LEXPTR is the first place an error occurred.  GLOBAL_ERRMSG
-   is the first error message encountered.  */
+  /* LEXPTR is the current pointer into our lex buffer.  PREV_LEXPTR
+     is the start of the last token lexed, only used for diagnostics.
+     ERROR_LEXPTR is the first place an error occurred.  GLOBAL_ERRMSG
+     is the first error message encountered.  */
 
   const char *lexptr, *prev_lexptr, *error_lexptr, *global_errmsg;
 
@@ -75,45 +99,63 @@ struct cpname_state
      successful parse.  */
 
   struct demangle_component *global_result;
+
+  struct demangle_component *d_grab ();
+
+  /* Helper functions.  These wrap the demangler tree interface,
+     handle allocation from our global store, and return the allocated
+     component.  */
+
+  struct demangle_component *fill_comp (enum demangle_component_type d_type,
+                                       struct demangle_component *lhs,
+                                       struct demangle_component *rhs);
+
+  struct demangle_component *make_operator (const char *name, int args);
+
+  struct demangle_component *make_dtor (enum gnu_v3_dtor_kinds kind,
+                                       struct demangle_component *name);
+
+  struct demangle_component *make_builtin_type (const char *name);
+
+  struct demangle_component *make_name (const char *name, int len);
+
+  struct demangle_component *d_qualify (struct demangle_component *lhs,
+                                       int qualifiers, int is_method);
+
+  struct demangle_component *d_int_type (int flags);
+
+  struct demangle_component *d_unary (const char *name,
+                                     struct demangle_component *lhs);
+
+  struct demangle_component *d_binary (const char *name,
+                                      struct demangle_component *lhs,
+                                      struct demangle_component *rhs);
+
+  int parse_number (const char *p, int len, int parsed_float, YYSTYPE *lvalp);
 };
 
-static struct demangle_component *
-d_grab (cpname_state *state)
+struct demangle_component *
+cpname_state::d_grab ()
 {
   struct demangle_info *more;
 
-  if (state->demangle_info->used >= ALLOC_CHUNK)
+  if (demangle_info->used >= ALLOC_CHUNK)
     {
-      if (state->demangle_info->next == NULL)
+      if (demangle_info->next == NULL)
        {
          more = XNEW (struct demangle_info);
          more->next = NULL;
-         state->demangle_info->next = more;
+         demangle_info->next = more;
        }
       else
-       more = state->demangle_info->next;
+       more = demangle_info->next;
 
       more->used = 0;
-      state->demangle_info = more;
+      demangle_info = more;
     }
-  return &state->demangle_info->comps[state->demangle_info->used++];
+  return &demangle_info->comps[demangle_info->used++];
 }
 
-/* Prototypes for helper functions used when constructing the parse
-   tree.  */
-
-static struct demangle_component *d_qualify (cpname_state *state,
-                                            struct demangle_component *, int,
-                                            int);
-
-static struct demangle_component *d_int_type (cpname_state *state, int);
-
-static struct demangle_component *d_unary (cpname_state *state, const char *,
-                                          struct demangle_component *);
-static struct demangle_component *d_binary (cpname_state *state, const char *,
-                                           struct demangle_component *,
-                                           struct demangle_component *);
-
 /* Flags passed to d_qualify.  */
 
 #define QUAL_CONST 1
@@ -138,12 +180,12 @@ static struct demangle_component *d_binary (cpname_state *state, const char *,
 /* Helper functions.  These wrap the demangler tree interface, handle
    allocation from our global store, and return the allocated component.  */
 
-static struct demangle_component *
-fill_comp (cpname_state *state,
-          enum demangle_component_type d_type, struct demangle_component *lhs,
-          struct demangle_component *rhs)
+struct demangle_component *
+cpname_state::fill_comp (enum demangle_component_type d_type,
+                        struct demangle_component *lhs,
+                        struct demangle_component *rhs)
 {
-  struct demangle_component *ret = d_grab (state);
+  struct demangle_component *ret = d_grab ();
   int i;
 
   i = cplus_demangle_fill_component (ret, d_type, lhs, rhs);
@@ -152,10 +194,10 @@ fill_comp (cpname_state *state,
   return ret;
 }
 
-static struct demangle_component *
-make_operator (cpname_state *state, const char *name, int args)
+struct demangle_component *
+cpname_state::make_operator (const char *name, int args)
 {
-  struct demangle_component *ret = d_grab (state);
+  struct demangle_component *ret = d_grab ();
   int i;
 
   i = cplus_demangle_fill_operator (ret, name, args);
@@ -164,11 +206,11 @@ make_operator (cpname_state *state, const char *name, int args)
   return ret;
 }
 
-static struct demangle_component *
-make_dtor (cpname_state *state, enum gnu_v3_dtor_kinds kind,
-          struct demangle_component *name)
+struct demangle_component *
+cpname_state::make_dtor (enum gnu_v3_dtor_kinds kind,
+                        struct demangle_component *name)
 {
-  struct demangle_component *ret = d_grab (state);
+  struct demangle_component *ret = d_grab ();
   int i;
 
   i = cplus_demangle_fill_dtor (ret, kind, name);
@@ -177,10 +219,10 @@ make_dtor (cpname_state *state, enum gnu_v3_dtor_kinds kind,
   return ret;
 }
 
-static struct demangle_component *
-make_builtin_type (cpname_state *state, const char *name)
+struct demangle_component *
+cpname_state::make_builtin_type (const char *name)
 {
-  struct demangle_component *ret = d_grab (state);
+  struct demangle_component *ret = d_grab ();
   int i;
 
   i = cplus_demangle_fill_builtin_type (ret, name);
@@ -189,10 +231,10 @@ make_builtin_type (cpname_state *state, const char *name)
   return ret;
 }
 
-static struct demangle_component *
-make_name (cpname_state *state, const char *name, int len)
+struct demangle_component *
+cpname_state::make_name (const char *name, int len)
 {
-  struct demangle_component *ret = d_grab (state);
+  struct demangle_component *ret = d_grab ();
   int i;
 
   i = cplus_demangle_fill_name (ret, name, len);
@@ -204,29 +246,6 @@ make_name (cpname_state *state, const char *name, int len)
 #define d_left(dc) (dc)->u.s_binary.left
 #define d_right(dc) (dc)->u.s_binary.right
 
-%}
-
-%union
-  {
-    struct demangle_component *comp;
-    struct nested {
-      struct demangle_component *comp;
-      struct demangle_component **last;
-    } nested;
-    struct {
-      struct demangle_component *comp, *last;
-    } nested1;
-    struct {
-      struct demangle_component *comp, **last;
-      struct nested fn;
-      struct demangle_component *start;
-      int fold_flag;
-    } abstract;
-    int lval;
-    const char *opname;
-  }
-
-%{
 static int yylex (YYSTYPE *, cpname_state *);
 static void yyerror (cpname_state *, const char *);
 %}
@@ -357,20 +376,19 @@ function
                   start_opt is used to handle "function-local" variables and
                   types.  */
                |       typespec_2 function_arglist start_opt
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME,
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME,
                                          $1, $2.comp);
                          if ($3)
-                           $$ = fill_comp (state,
-                                           DEMANGLE_COMPONENT_LOCAL_NAME,
-                                           $$, $3);
+                           $$ = state->fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME,
+                                                  $$, $3);
                        }
                |       colon_ext_only function_arglist start_opt
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp);
-                         if ($3) $$ = fill_comp (state, DEMANGLE_COMPONENT_LOCAL_NAME, $$, $3); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp);
+                         if ($3) $$ = state->fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $3); }
 
                |       conversion_op_name start_opt
                        { $$ = $1.comp;
-                         if ($2) $$ = fill_comp (state, DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2); }
+                         if ($2) $$ = state->fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2); }
                |       conversion_op_name abstract_declarator_fn
                        { if ($2.last)
                            {
@@ -382,102 +400,102 @@ function
                            }
                          /* If we have an arglist, build a function type.  */
                          if ($2.fn.comp)
-                           $$ = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME, $1.comp, $2.fn.comp);
+                           $$ = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1.comp, $2.fn.comp);
                          else
                            $$ = $1.comp;
-                         if ($2.start) $$ = fill_comp (state, DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2.start);
+                         if ($2.start) $$ = state->fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2.start);
                        }
                ;
 
 demangler_special
                :       DEMANGLER_SPECIAL start
-                       { $$ = fill_comp (state, (enum demangle_component_type) $1, $2, NULL); }
+                       { $$ = state->fill_comp ((enum demangle_component_type) $1, $2, NULL); }
                |       CONSTRUCTION_VTABLE start CONSTRUCTION_IN start
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, $2, $4); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, $2, $4); }
                ;
 
 oper   :       OPERATOR NEW
                        {
                          /* Match the whitespacing of cplus_demangle_operators.
                             It would abort on unrecognized string otherwise.  */
-                         $$ = make_operator (state, "new", 3);
+                         $$ = state->make_operator ("new", 3);
                        }
                |       OPERATOR DELETE
                        {
                          /* Match the whitespacing of cplus_demangle_operators.
                             It would abort on unrecognized string otherwise.  */
-                         $$ = make_operator (state, "delete ", 1);
+                         $$ = state->make_operator ("delete ", 1);
                        }
                |       OPERATOR NEW '[' ']'
                        {
                          /* Match the whitespacing of cplus_demangle_operators.
                             It would abort on unrecognized string otherwise.  */
-                         $$ = make_operator (state, "new[]", 3);
+                         $$ = state->make_operator ("new[]", 3);
                        }
                |       OPERATOR DELETE '[' ']'
                        {
                          /* Match the whitespacing of cplus_demangle_operators.
                             It would abort on unrecognized string otherwise.  */
-                         $$ = make_operator (state, "delete[] ", 1);
+                         $$ = state->make_operator ("delete[] ", 1);
                        }
                |       OPERATOR '+'
-                       { $$ = make_operator (state, "+", 2); }
+                       { $$ = state->make_operator ("+", 2); }
                |       OPERATOR '-'
-                       { $$ = make_operator (state, "-", 2); }
+                       { $$ = state->make_operator ("-", 2); }
                |       OPERATOR '*'
-                       { $$ = make_operator (state, "*", 2); }
+                       { $$ = state->make_operator ("*", 2); }
                |       OPERATOR '/'
-                       { $$ = make_operator (state, "/", 2); }
+                       { $$ = state->make_operator ("/", 2); }
                |       OPERATOR '%'
-                       { $$ = make_operator (state, "%", 2); }
+                       { $$ = state->make_operator ("%", 2); }
                |       OPERATOR '^'
-                       { $$ = make_operator (state, "^", 2); }
+                       { $$ = state->make_operator ("^", 2); }
                |       OPERATOR '&'
-                       { $$ = make_operator (state, "&", 2); }
+                       { $$ = state->make_operator ("&", 2); }
                |       OPERATOR '|'
-                       { $$ = make_operator (state, "|", 2); }
+                       { $$ = state->make_operator ("|", 2); }
                |       OPERATOR '~'
-                       { $$ = make_operator (state, "~", 1); }
+                       { $$ = state->make_operator ("~", 1); }
                |       OPERATOR '!'
-                       { $$ = make_operator (state, "!", 1); }
+                       { $$ = state->make_operator ("!", 1); }
                |       OPERATOR '='
-                       { $$ = make_operator (state, "=", 2); }
+                       { $$ = state->make_operator ("=", 2); }
                |       OPERATOR '<'
-                       { $$ = make_operator (state, "<", 2); }
+                       { $$ = state->make_operator ("<", 2); }
                |       OPERATOR '>'
-                       { $$ = make_operator (state, ">", 2); }
+                       { $$ = state->make_operator (">", 2); }
                |       OPERATOR ASSIGN_MODIFY
-                       { $$ = make_operator (state, $2, 2); }
+                       { $$ = state->make_operator ($2, 2); }
                |       OPERATOR LSH
-                       { $$ = make_operator (state, "<<", 2); }
+                       { $$ = state->make_operator ("<<", 2); }
                |       OPERATOR RSH
-                       { $$ = make_operator (state, ">>", 2); }
+                       { $$ = state->make_operator (">>", 2); }
                |       OPERATOR EQUAL
-                       { $$ = make_operator (state, "==", 2); }
+                       { $$ = state->make_operator ("==", 2); }
                |       OPERATOR NOTEQUAL
-                       { $$ = make_operator (state, "!=", 2); }
+                       { $$ = state->make_operator ("!=", 2); }
                |       OPERATOR LEQ
-                       { $$ = make_operator (state, "<=", 2); }
+                       { $$ = state->make_operator ("<=", 2); }
                |       OPERATOR GEQ
-                       { $$ = make_operator (state, ">=", 2); }
+                       { $$ = state->make_operator (">=", 2); }
                |       OPERATOR ANDAND
-                       { $$ = make_operator (state, "&&", 2); }
+                       { $$ = state->make_operator ("&&", 2); }
                |       OPERATOR OROR
-                       { $$ = make_operator (state, "||", 2); }
+                       { $$ = state->make_operator ("||", 2); }
                |       OPERATOR INCREMENT
-                       { $$ = make_operator (state, "++", 1); }
+                       { $$ = state->make_operator ("++", 1); }
                |       OPERATOR DECREMENT
-                       { $$ = make_operator (state, "--", 1); }
+                       { $$ = state->make_operator ("--", 1); }
                |       OPERATOR ','
-                       { $$ = make_operator (state, ",", 2); }
+                       { $$ = state->make_operator (",", 2); }
                |       OPERATOR ARROW '*'
-                       { $$ = make_operator (state, "->*", 2); }
+                       { $$ = state->make_operator ("->*", 2); }
                |       OPERATOR ARROW
-                       { $$ = make_operator (state, "->", 2); }
+                       { $$ = state->make_operator ("->", 2); }
                |       OPERATOR '(' ')'
-                       { $$ = make_operator (state, "()", 2); }
+                       { $$ = state->make_operator ("()", 2); }
                |       OPERATOR '[' ']'
-                       { $$ = make_operator (state, "[]", 2); }
+                       { $$ = state->make_operator ("[]", 2); }
                ;
 
                /* Conversion operators.  We don't try to handle some of
@@ -485,7 +503,7 @@ oper        :       OPERATOR NEW
                   since it's not clear that it's parseable.  */
 conversion_op
                :       OPERATOR typespec_2
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_CONVERSION, $2, NULL); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_CONVERSION, $2, NULL); }
                ;
 
 conversion_op_name
@@ -513,9 +531,9 @@ conversion_op_name
 /* This accepts certain invalid placements of '~'.  */
 unqualified_name:      oper
                |       oper '<' template_params '>'
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_TEMPLATE, $1, $3.comp); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_TEMPLATE, $1, $3.comp); }
                |       '~' NAME
-                       { $$ = make_dtor (state, gnu_v3_complete_object_dtor, $2); }
+                       { $$ = state->make_dtor (gnu_v3_complete_object_dtor, $2); }
                ;
 
 /* This rule is used in name and nested_name, and expanded inline there
@@ -556,21 +574,21 @@ ext_only_name     :       nested_name unqualified_name
                ;
 
 nested_name    :       NAME COLONCOLON
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_QUAL_NAME, $1, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $1, NULL);
                          $$.last = $$.comp;
                        }
                |       nested_name NAME COLONCOLON
                        { $$.comp = $1.comp;
-                         d_right ($1.last) = fill_comp (state, DEMANGLE_COMPONENT_QUAL_NAME, $2, NULL);
+                         d_right ($1.last) = state->fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $2, NULL);
                          $$.last = d_right ($1.last);
                        }
                |       templ COLONCOLON
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_QUAL_NAME, $1, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $1, NULL);
                          $$.last = $$.comp;
                        }
                |       nested_name templ COLONCOLON
                        { $$.comp = $1.comp;
-                         d_right ($1.last) = fill_comp (state, DEMANGLE_COMPONENT_QUAL_NAME, $2, NULL);
+                         d_right ($1.last) = state->fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $2, NULL);
                          $$.last = d_right ($1.last);
                        }
                ;
@@ -578,15 +596,15 @@ nested_name       :       NAME COLONCOLON
 /* DEMANGLE_COMPONENT_TEMPLATE */
 /* DEMANGLE_COMPONENT_TEMPLATE_ARGLIST */
 templ  :       NAME '<' template_params '>'
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_TEMPLATE, $1, $3.comp); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_TEMPLATE, $1, $3.comp); }
                ;
 
 template_params        :       template_arg
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, $1, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, $1, NULL);
                        $$.last = &d_right ($$.comp); }
                |       template_params ',' template_arg
                        { $$.comp = $1.comp;
-                         *$1.last = fill_comp (state, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, $3, NULL);
+                         *$1.last = state->fill_comp (DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, $3, NULL);
                          $$.last = &d_right (*$1.last);
                        }
                ;
@@ -601,36 +619,36 @@ template_arg      :       typespec_2
                          *$2.last = $1;
                        }
                |       '&' start
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY, make_operator (state, "&", 1), $2); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY, state->make_operator ("&", 1), $2); }
                |       '&' '(' start ')'
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY, make_operator (state, "&", 1), $3); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY, state->make_operator ("&", 1), $3); }
                |       exp
                ;
 
 function_args  :       typespec_2
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_ARGLIST, $1, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_ARGLIST, $1, NULL);
                          $$.last = &d_right ($$.comp);
                        }
                |       typespec_2 abstract_declarator
                        { *$2.last = $1;
-                         $$.comp = fill_comp (state, DEMANGLE_COMPONENT_ARGLIST, $2.comp, NULL);
+                         $$.comp = state->fill_comp (DEMANGLE_COMPONENT_ARGLIST, $2.comp, NULL);
                          $$.last = &d_right ($$.comp);
                        }
                |       function_args ',' typespec_2
-                       { *$1.last = fill_comp (state, DEMANGLE_COMPONENT_ARGLIST, $3, NULL);
+                       { *$1.last = state->fill_comp (DEMANGLE_COMPONENT_ARGLIST, $3, NULL);
                          $$.comp = $1.comp;
                          $$.last = &d_right (*$1.last);
                        }
                |       function_args ',' typespec_2 abstract_declarator
                        { *$4.last = $3;
-                         *$1.last = fill_comp (state, DEMANGLE_COMPONENT_ARGLIST, $4.comp, NULL);
+                         *$1.last = state->fill_comp (DEMANGLE_COMPONENT_ARGLIST, $4.comp, NULL);
                          $$.comp = $1.comp;
                          $$.last = &d_right (*$1.last);
                        }
                |       function_args ',' ELLIPSIS
                        { *$1.last
-                           = fill_comp (state, DEMANGLE_COMPONENT_ARGLIST,
-                                          make_builtin_type (state, "..."),
+                           = state->fill_comp (DEMANGLE_COMPONENT_ARGLIST,
+                                          state->make_builtin_type ("..."),
                                           NULL);
                          $$.comp = $1.comp;
                          $$.last = &d_right (*$1.last);
@@ -638,17 +656,17 @@ function_args     :       typespec_2
                ;
 
 function_arglist:      '(' function_args ')' qualifiers_opt %prec NAME
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, $2.comp);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, $2.comp);
                          $$.last = &d_left ($$.comp);
-                         $$.comp = d_qualify (state, $$.comp, $4, 1); }
+                         $$.comp = state->d_qualify ($$.comp, $4, 1); }
                |       '(' VOID ')' qualifiers_opt
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, NULL);
                          $$.last = &d_left ($$.comp);
-                         $$.comp = d_qualify (state, $$.comp, $4, 1); }
+                         $$.comp = state->d_qualify ($$.comp, $4, 1); }
                |       '(' ')' qualifiers_opt
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, NULL);
                          $$.last = &d_left ($$.comp);
-                         $$.comp = d_qualify (state, $$.comp, $3, 1); }
+                         $$.comp = state->d_qualify ($$.comp, $3, 1); }
                ;
 
 /* Should do something about DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL */
@@ -693,50 +711,50 @@ int_seq           :       int_part
                ;
 
 builtin_type   :       int_seq
-                       { $$ = d_int_type (state, $1); }
+                       { $$ = state->d_int_type ($1); }
                |       FLOAT_KEYWORD
-                       { $$ = make_builtin_type (state, "float"); }
+                       { $$ = state->make_builtin_type ("float"); }
                |       DOUBLE_KEYWORD
-                       { $$ = make_builtin_type (state, "double"); }
+                       { $$ = state->make_builtin_type ("double"); }
                |       LONG DOUBLE_KEYWORD
-                       { $$ = make_builtin_type (state, "long double"); }
+                       { $$ = state->make_builtin_type ("long double"); }
                |       BOOL
-                       { $$ = make_builtin_type (state, "bool"); }
+                       { $$ = state->make_builtin_type ("bool"); }
                |       WCHAR_T
-                       { $$ = make_builtin_type (state, "wchar_t"); }
+                       { $$ = state->make_builtin_type ("wchar_t"); }
                |       VOID
-                       { $$ = make_builtin_type (state, "void"); }
+                       { $$ = state->make_builtin_type ("void"); }
                ;
 
 ptr_operator   :       '*' qualifiers_opt
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_POINTER, NULL, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_POINTER, NULL, NULL);
                          $$.last = &d_left ($$.comp);
-                         $$.comp = d_qualify (state, $$.comp, $2, 0); }
+                         $$.comp = state->d_qualify ($$.comp, $2, 0); }
                /* g++ seems to allow qualifiers after the reference?  */
                |       '&'
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_REFERENCE, NULL, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_REFERENCE, NULL, NULL);
                          $$.last = &d_left ($$.comp); }
                |       ANDAND
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_RVALUE_REFERENCE, NULL, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_RVALUE_REFERENCE, NULL, NULL);
                          $$.last = &d_left ($$.comp); }
                |       nested_name '*' qualifiers_opt
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_PTRMEM_TYPE, $1.comp, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_PTRMEM_TYPE, $1.comp, NULL);
                          /* Convert the innermost DEMANGLE_COMPONENT_QUAL_NAME to a DEMANGLE_COMPONENT_NAME.  */
                          *$1.last = *d_left ($1.last);
                          $$.last = &d_right ($$.comp);
-                         $$.comp = d_qualify (state, $$.comp, $3, 0); }
+                         $$.comp = state->d_qualify ($$.comp, $3, 0); }
                |       COLONCOLON nested_name '*' qualifiers_opt
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_PTRMEM_TYPE, $2.comp, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_PTRMEM_TYPE, $2.comp, NULL);
                          /* Convert the innermost DEMANGLE_COMPONENT_QUAL_NAME to a DEMANGLE_COMPONENT_NAME.  */
                          *$2.last = *d_left ($2.last);
                          $$.last = &d_right ($$.comp);
-                         $$.comp = d_qualify (state, $$.comp, $4, 0); }
+                         $$.comp = state->d_qualify ($$.comp, $4, 0); }
                ;
 
 array_indicator        :       '[' ']'
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_ARRAY_TYPE, NULL, NULL); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_ARRAY_TYPE, NULL, NULL); }
                |       '[' INT ']'
-                       { $$ = fill_comp (state, DEMANGLE_COMPONENT_ARRAY_TYPE, $2, NULL); }
+                       { $$ = state->fill_comp (DEMANGLE_COMPONENT_ARRAY_TYPE, $2, NULL); }
                ;
 
 /* Details of this approach inspired by the G++ < 3.4 parser.  */
@@ -750,29 +768,29 @@ typespec  :       builtin_type
 */
 
 typespec_2     :       builtin_type qualifiers
-                       { $$ = d_qualify (state, $1, $2, 0); }
+                       { $$ = state->d_qualify ($1, $2, 0); }
                |       builtin_type
                |       qualifiers builtin_type qualifiers
-                       { $$ = d_qualify (state, $2, $1 | $3, 0); }
+                       { $$ = state->d_qualify ($2, $1 | $3, 0); }
                |       qualifiers builtin_type
-                       { $$ = d_qualify (state, $2, $1, 0); }
+                       { $$ = state->d_qualify ($2, $1, 0); }
 
                |       name qualifiers
-                       { $$ = d_qualify (state, $1, $2, 0); }
+                       { $$ = state->d_qualify ($1, $2, 0); }
                |       name
                |       qualifiers name qualifiers
-                       { $$ = d_qualify (state, $2, $1 | $3, 0); }
+                       { $$ = state->d_qualify ($2, $1 | $3, 0); }
                |       qualifiers name
-                       { $$ = d_qualify (state, $2, $1, 0); }
+                       { $$ = state->d_qualify ($2, $1, 0); }
 
                |       COLONCOLON name qualifiers
-                       { $$ = d_qualify (state, $2, $3, 0); }
+                       { $$ = state->d_qualify ($2, $3, 0); }
                |       COLONCOLON name
                        { $$ = $2; }
                |       qualifiers COLONCOLON name qualifiers
-                       { $$ = d_qualify (state, $3, $1 | $4, 0); }
+                       { $$ = state->d_qualify ($3, $1 | $4, 0); }
                |       qualifiers COLONCOLON name
-                       { $$ = d_qualify (state, $3, $1, 0); }
+                       { $$ = state->d_qualify ($3, $1, 0); }
                ;
 
 abstract_declarator
@@ -889,7 +907,7 @@ direct_declarator
                          $$.last = &d_right ($2);
                        }
                |       colon_ext_name
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME, $1, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, NULL);
                          $$.last = &d_right ($$.comp);
                        }
                ;
@@ -905,7 +923,7 @@ declarator_1        :       ptr_operator declarator_1
                          $$.last = $1.last;
                          *$2.last = $1.comp; }
                |       colon_ext_name
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME, $1, NULL);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, NULL);
                          $$.last = &d_right ($$.comp);
                        }
                |       direct_declarator_1
@@ -917,15 +935,15 @@ declarator_1      :       ptr_operator declarator_1
                           members will not be mangled.  If they are hopefully
                           they'll end up to the right of the ::.  */
                |       colon_ext_name function_arglist COLONCOLON start
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp);
                          $$.last = $2.last;
-                         $$.comp = fill_comp (state, DEMANGLE_COMPONENT_LOCAL_NAME, $$.comp, $4);
+                         $$.comp = state->fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$.comp, $4);
                        }
                |       direct_declarator_1 function_arglist COLONCOLON start
                        { $$.comp = $1.comp;
                          *$1.last = $2.comp;
                          $$.last = $2.last;
-                         $$.comp = fill_comp (state, DEMANGLE_COMPONENT_LOCAL_NAME, $$.comp, $4);
+                         $$.comp = state->fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$.comp, $4);
                        }
                ;
 
@@ -945,11 +963,11 @@ direct_declarator_1
                          $$.last = &d_right ($2);
                        }
                |       colon_ext_name function_arglist
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp);
                          $$.last = $2.last;
                        }
                |       colon_ext_name array_indicator
-                       { $$.comp = fill_comp (state, DEMANGLE_COMPONENT_TYPED_NAME, $1, $2);
+                       { $$.comp = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, $2);
                          $$.last = &d_right ($2);
                        }
                ;
@@ -964,29 +982,29 @@ exp1      :       exp
        ;
 
 exp1   :       exp '>' exp
-               { $$ = d_binary (state, ">", $1, $3); }
+               { $$ = state->d_binary (">", $1, $3); }
        ;
 
 /* References.  Not allowed everywhere in template parameters, only
    at the top level, but treat them as expressions in case they are wrapped
    in parentheses.  */
 exp1   :       '&' start
-               { $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY, make_operator (state, "&", 1), $2); }
+               { $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY, state->make_operator ("&", 1), $2); }
        |       '&' '(' start ')'
-               { $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY, make_operator (state, "&", 1), $3); }
+               { $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY, state->make_operator ("&", 1), $3); }
        ;
 
 /* Expressions, not including the comma operator.  */
 exp    :       '-' exp    %prec UNARY
-               { $$ = d_unary (state, "-", $2); }
+               { $$ = state->d_unary ("-", $2); }
        ;
 
 exp    :       '!' exp    %prec UNARY
-               { $$ = d_unary (state, "!", $2); }
+               { $$ = state->d_unary ("!", $2); }
        ;
 
 exp    :       '~' exp    %prec UNARY
-               { $$ = d_unary (state, "~", $2); }
+               { $$ = state->d_unary ("~", $2); }
        ;
 
 /* Casts.  First your normal C-style cast.  If exp is a LITERAL, just change
@@ -1000,8 +1018,8 @@ exp       :       '(' type ')' exp  %prec UNARY
                      d_left ($4) = $2;
                    }
                  else
-                   $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY,
-                                     fill_comp (state, DEMANGLE_COMPONENT_CAST, $2, NULL),
+                   $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY,
+                                     state->fill_comp (DEMANGLE_COMPONENT_CAST, $2, NULL),
                                      $4);
                }
        ;
@@ -1009,22 +1027,22 @@ exp     :       '(' type ')' exp  %prec UNARY
 /* Mangling does not differentiate between these, so we don't need to
    either.  */
 exp    :       STATIC_CAST '<' type '>' '(' exp1 ')' %prec UNARY
-               { $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY,
-                                   fill_comp (state, DEMANGLE_COMPONENT_CAST, $3, NULL),
+               { $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY,
+                                   state->fill_comp (DEMANGLE_COMPONENT_CAST, $3, NULL),
                                    $6);
                }
        ;
 
 exp    :       DYNAMIC_CAST '<' type '>' '(' exp1 ')' %prec UNARY
-               { $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY,
-                                   fill_comp (state, DEMANGLE_COMPONENT_CAST, $3, NULL),
+               { $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY,
+                                   state->fill_comp (DEMANGLE_COMPONENT_CAST, $3, NULL),
                                    $6);
                }
        ;
 
 exp    :       REINTERPRET_CAST '<' type '>' '(' exp1 ')' %prec UNARY
-               { $$ = fill_comp (state, DEMANGLE_COMPONENT_UNARY,
-                                   fill_comp (state, DEMANGLE_COMPONENT_CAST, $3, NULL),
+               { $$ = state->fill_comp (DEMANGLE_COMPONENT_UNARY,
+                                   state->fill_comp (DEMANGLE_COMPONENT_CAST, $3, NULL),
                                    $6);
                }
        ;
@@ -1042,86 +1060,86 @@ exp     :       REINTERPRET_CAST '<' type '>' '(' exp1 ')' %prec UNARY
 /* Binary operators in order of decreasing precedence.  */
 
 exp    :       exp '*' exp
-               { $$ = d_binary (state, "*", $1, $3); }
+               { $$ = state->d_binary ("*", $1, $3); }
        ;
 
 exp    :       exp '/' exp
-               { $$ = d_binary (state, "/", $1, $3); }
+               { $$ = state->d_binary ("/", $1, $3); }
        ;
 
 exp    :       exp '%' exp
-               { $$ = d_binary (state, "%", $1, $3); }
+               { $$ = state->d_binary ("%", $1, $3); }
        ;
 
 exp    :       exp '+' exp
-               { $$ = d_binary (state, "+", $1, $3); }
+               { $$ = state->d_binary ("+", $1, $3); }
        ;
 
 exp    :       exp '-' exp
-               { $$ = d_binary (state, "-", $1, $3); }
+               { $$ = state->d_binary ("-", $1, $3); }
        ;
 
 exp    :       exp LSH exp
-               { $$ = d_binary (state, "<<", $1, $3); }
+               { $$ = state->d_binary ("<<", $1, $3); }
        ;
 
 exp    :       exp RSH exp
-               { $$ = d_binary (state, ">>", $1, $3); }
+               { $$ = state->d_binary (">>", $1, $3); }
        ;
 
 exp    :       exp EQUAL exp
-               { $$ = d_binary (state, "==", $1, $3); }
+               { $$ = state->d_binary ("==", $1, $3); }
        ;
 
 exp    :       exp NOTEQUAL exp
-               { $$ = d_binary (state, "!=", $1, $3); }
+               { $$ = state->d_binary ("!=", $1, $3); }
        ;
 
 exp    :       exp LEQ exp
-               { $$ = d_binary (state, "<=", $1, $3); }
+               { $$ = state->d_binary ("<=", $1, $3); }
        ;
 
 exp    :       exp GEQ exp
-               { $$ = d_binary (state, ">=", $1, $3); }
+               { $$ = state->d_binary (">=", $1, $3); }
        ;
 
 exp    :       exp '<' exp
-               { $$ = d_binary (state, "<", $1, $3); }
+               { $$ = state->d_binary ("<", $1, $3); }
        ;
 
 exp    :       exp '&' exp
-               { $$ = d_binary (state, "&", $1, $3); }
+               { $$ = state->d_binary ("&", $1, $3); }
        ;
 
 exp    :       exp '^' exp
-               { $$ = d_binary (state, "^", $1, $3); }
+               { $$ = state->d_binary ("^", $1, $3); }
        ;
 
 exp    :       exp '|' exp
-               { $$ = d_binary (state, "|", $1, $3); }
+               { $$ = state->d_binary ("|", $1, $3); }
        ;
 
 exp    :       exp ANDAND exp
-               { $$ = d_binary (state, "&&", $1, $3); }
+               { $$ = state->d_binary ("&&", $1, $3); }
        ;
 
 exp    :       exp OROR exp
-               { $$ = d_binary (state, "||", $1, $3); }
+               { $$ = state->d_binary ("||", $1, $3); }
        ;
 
 /* Not 100% sure these are necessary, but they're harmless.  */
 exp    :       exp ARROW NAME
-               { $$ = d_binary (state, "->", $1, $3); }
+               { $$ = state->d_binary ("->", $1, $3); }
        ;
 
 exp    :       exp '.' NAME
-               { $$ = d_binary (state, ".", $1, $3); }
+               { $$ = state->d_binary (".", $1, $3); }
        ;
 
 exp    :       exp '?' exp ':' exp     %prec '?'
-               { $$ = fill_comp (state, DEMANGLE_COMPONENT_TRINARY, make_operator (state, "?", 3),
-                                   fill_comp (state, DEMANGLE_COMPONENT_TRINARY_ARG1, $1,
-                                                fill_comp (state, DEMANGLE_COMPONENT_TRINARY_ARG2, $3, $5)));
+               { $$ = state->fill_comp (DEMANGLE_COMPONENT_TRINARY, state->make_operator ("?", 3),
+                                   state->fill_comp (DEMANGLE_COMPONENT_TRINARY_ARG1, $1,
+                                                state->fill_comp (DEMANGLE_COMPONENT_TRINARY_ARG2, $3, $5)));
                }
        ;
                          
@@ -1136,25 +1154,25 @@ exp     :       SIZEOF '(' type ')'     %prec UNARY
                {
                  /* Match the whitespacing of cplus_demangle_operators.
                     It would abort on unrecognized string otherwise.  */
-                 $$ = d_unary (state, "sizeof ", $3);
+                 $$ = state->d_unary ("sizeof ", $3);
                }
        ;
 
 /* C++.  */
 exp     :       TRUEKEYWORD    
                { struct demangle_component *i;
-                 i = make_name (state, "1", 1);
-                 $$ = fill_comp (state, DEMANGLE_COMPONENT_LITERAL,
-                                   make_builtin_type (state, "bool"),
+                 i = state->make_name ("1", 1);
+                 $$ = state->fill_comp (DEMANGLE_COMPONENT_LITERAL,
+                                   state->make_builtin_type ( "bool"),
                                    i);
                }
        ;
 
 exp     :       FALSEKEYWORD   
                { struct demangle_component *i;
-                 i = make_name (state, "0", 1);
-                 $$ = fill_comp (state, DEMANGLE_COMPONENT_LITERAL,
-                                   make_builtin_type (state, "bool"),
+                 i = state->make_name ("0", 1);
+                 $$ = state->fill_comp (DEMANGLE_COMPONENT_LITERAL,
+                                   state->make_builtin_type ("bool"),
                                    i);
                }
        ;
@@ -1169,8 +1187,8 @@ exp     :       FALSEKEYWORD
    may already be qualified; duplicate qualifiers are not created.  */
 
 struct demangle_component *
-d_qualify (cpname_state *state, struct demangle_component *lhs, int qualifiers,
-          int is_method)
+cpname_state::d_qualify (struct demangle_component *lhs, int qualifiers,
+                        int is_method)
 {
   struct demangle_component **inner_p;
   enum demangle_component_type type;
@@ -1180,8 +1198,8 @@ d_qualify (cpname_state *state, struct demangle_component *lhs, int qualifiers,
 #define HANDLE_QUAL(TYPE, MTYPE, QUAL)                         \
   if ((qualifiers & QUAL) && (type != TYPE) && (type != MTYPE))        \
     {                                                          \
-      *inner_p = fill_comp (state, is_method ? MTYPE : TYPE,   \
-                             *inner_p, NULL);                  \
+      *inner_p = fill_comp (is_method ? MTYPE : TYPE,          \
+                           *inner_p, NULL);                    \
       inner_p = &d_left (*inner_p);                            \
       type = (*inner_p)->type;                                 \
     }                                                          \
@@ -1204,8 +1222,8 @@ d_qualify (cpname_state *state, struct demangle_component *lhs, int qualifiers,
 
 /* Return a builtin type corresponding to FLAGS.  */
 
-static struct demangle_component *
-d_int_type (cpname_state *state, int flags)
+struct demangle_component *
+cpname_state::d_int_type (int flags)
 {
   const char *name;
 
@@ -1252,25 +1270,25 @@ d_int_type (cpname_state *state, int flags)
       return NULL;
     }
 
-  return make_builtin_type (state, name);
+  return make_builtin_type (name);
 }
 
 /* Wrapper to create a unary operation.  */
 
-static struct demangle_component *
-d_unary (cpname_state *state, const char *name, struct demangle_component *lhs)
+struct demangle_component *
+cpname_state::d_unary (const char *name, struct demangle_component *lhs)
 {
-  return fill_comp (state, DEMANGLE_COMPONENT_UNARY, make_operator (state, name, 1), lhs);
+  return fill_comp (DEMANGLE_COMPONENT_UNARY, make_operator (name, 1), lhs);
 }
 
 /* Wrapper to create a binary operation.  */
 
-static struct demangle_component *
-d_binary (cpname_state *state, const char *name, struct demangle_component *lhs,
-         struct demangle_component *rhs)
+struct demangle_component *
+cpname_state::d_binary (const char *name, struct demangle_component *lhs,
+                       struct demangle_component *rhs)
 {
-  return fill_comp (state, DEMANGLE_COMPONENT_BINARY, make_operator (state, name, 2),
-                     fill_comp (state, DEMANGLE_COMPONENT_BINARY_ARGS, lhs, rhs));
+  return fill_comp (DEMANGLE_COMPONENT_BINARY, make_operator (name, 2),
+                   fill_comp (DEMANGLE_COMPONENT_BINARY_ARGS, lhs, rhs));
 }
 
 /* Find the end of a symbol name starting at LEXPTR.  */
@@ -1290,9 +1308,9 @@ symbol_end (const char *lexptr)
    The number starts at P and contains LEN characters.  Store the result in
    YYLVAL.  */
 
-static int
-parse_number (cpname_state *state, const char *p, int len, int parsed_float,
-             YYSTYPE *lvalp)
+int
+cpname_state::parse_number (const char *p, int len, int parsed_float,
+                           YYSTYPE *lvalp)
 {
   int unsigned_p = 0;
 
@@ -1329,20 +1347,20 @@ parse_number (cpname_state *state, const char *p, int len, int parsed_float,
       if (c == 'f')
        {
          len--;
-         type = make_builtin_type (state, "float");
+         type = make_builtin_type ("float");
        }
       else if (c == 'l')
        {
          len--;
-         type = make_builtin_type (state, "long double");
+         type = make_builtin_type ("long double");
        }
       else if (ISDIGIT (c) || c == '.')
-       type = make_builtin_type (state, "double");
+       type = make_builtin_type ("double");
       else
        return ERROR;
 
-      name = make_name (state, p, len);
-      lvalp->comp = fill_comp (state, literal_type, type, name);
+      name = make_name (p, len);
+      lvalp->comp = fill_comp (literal_type, type, name);
 
       return FLOAT;
     }
@@ -1371,18 +1389,18 @@ parse_number (cpname_state *state, const char *p, int len, int parsed_float,
 
   if (long_p == 0)
     {
-      unsigned_type = make_builtin_type (state, "unsigned int");
-      signed_type = make_builtin_type (state, "int");
+      unsigned_type = make_builtin_type ("unsigned int");
+      signed_type = make_builtin_type ("int");
     }
   else if (long_p == 1)
     {
-      unsigned_type = make_builtin_type (state, "unsigned long");
-      signed_type = make_builtin_type (state, "long");
+      unsigned_type = make_builtin_type ("unsigned long");
+      signed_type = make_builtin_type ("long");
     }
   else
     {
-      unsigned_type = make_builtin_type (state, "unsigned long long");
-      signed_type = make_builtin_type (state, "long long");
+      unsigned_type = make_builtin_type ("unsigned long long");
+      signed_type = make_builtin_type ("long long");
     }
 
    if (unsigned_p)
@@ -1390,8 +1408,8 @@ parse_number (cpname_state *state, const char *p, int len, int parsed_float,
    else
      type = signed_type;
 
-   name = make_name (state, p, len);
-   lvalp->comp = fill_comp (state, literal_type, type, name);
+   name = make_name (p, len);
+   lvalp->comp = fill_comp (literal_type, type, name);
 
    return INT;
 }
@@ -1565,9 +1583,11 @@ yylex (YYSTYPE *lvalp, cpname_state *state)
         presumably the same one that appears in manglings - the decimal
         representation.  But if that isn't in our input then we have to
         allocate memory for it somewhere.  */
-      lvalp->comp = fill_comp (state, DEMANGLE_COMPONENT_LITERAL,
-                                make_builtin_type (state, "char"),
-                                make_name (state, tokstart, state->lexptr - tokstart));
+      lvalp->comp
+       = state->fill_comp (DEMANGLE_COMPONENT_LITERAL,
+                           state->make_builtin_type ("char"),
+                           state->make_name (tokstart,
+                                             state->lexptr - tokstart));
 
       return INT;
 
@@ -1575,8 +1595,8 @@ yylex (YYSTYPE *lvalp, cpname_state *state)
       if (strncmp (tokstart, "(anonymous namespace)", 21) == 0)
        {
          state->lexptr += 21;
-         lvalp->comp = make_name (state, "(anonymous namespace)",
-                                    sizeof "(anonymous namespace)" - 1);
+         lvalp->comp = state->make_name ("(anonymous namespace)",
+                                         sizeof "(anonymous namespace)" - 1);
          return NAME;
        }
        /* FALL THROUGH */
@@ -1674,8 +1694,8 @@ yylex (YYSTYPE *lvalp, cpname_state *state)
            else if (! ISALNUM (*p))
              break;
          }
-       toktype = parse_number (state, tokstart, p - tokstart, got_dot|got_e,
-                               lvalp);
+       toktype = state->parse_number (tokstart, p - tokstart, got_dot|got_e,
+                                      lvalp);
         if (toktype == ERROR)
          {
            char *err_copy = (char *) alloca (p - tokstart + 1);
@@ -1831,7 +1851,7 @@ yylex (YYSTYPE *lvalp, cpname_state *state)
          lvalp->lval = DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS;
          /* Find the end of the symbol.  */
          p = symbol_end (state->lexptr);
-         lvalp->comp = make_name (state, state->lexptr, p - state->lexptr);
+         lvalp->comp = state->make_name (state->lexptr, p - state->lexptr);
          state->lexptr = p;
          return DEMANGLER_SPECIAL;
        }
@@ -1842,7 +1862,7 @@ yylex (YYSTYPE *lvalp, cpname_state *state)
          lvalp->lval = DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS;
          /* Find the end of the symbol.  */
          p = symbol_end (state->lexptr);
-         lvalp->comp = make_name (state, state->lexptr, p - state->lexptr);
+         lvalp->comp = state->make_name (state->lexptr, p - state->lexptr);
          state->lexptr = p;
          return DEMANGLER_SPECIAL;
        }
@@ -1900,7 +1920,7 @@ yylex (YYSTYPE *lvalp, cpname_state *state)
       break;
     }
 
-  lvalp->comp = make_name (state, tokstart, namelen);
+  lvalp->comp = state->make_name (tokstart, namelen);
   return NAME;
 }