cp-demangle.h revision 169695
1207753Smm/* Internal demangler interface for g++ V3 ABI.
2207753Smm   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3207753Smm   Written by Ian Lance Taylor <ian@wasabisystems.com>.
4207753Smm
5207753Smm   This file is part of the libiberty library, which is part of GCC.
6207753Smm
7207753Smm   This file is free software; you can redistribute it and/or modify
8207753Smm   it under the terms of the GNU General Public License as published by
9207753Smm   the Free Software Foundation; either version 2 of the License, or
10207753Smm   (at your option) any later version.
11207753Smm
12207753Smm   In addition to the permissions in the GNU General Public License, the
13207753Smm   Free Software Foundation gives you unlimited permission to link the
14207753Smm   compiled version of this file into combinations with other programs,
15207753Smm   and to distribute those combinations without any restriction coming
16207753Smm   from the use of this file.  (The General Public License restrictions
17207753Smm   do apply in other respects; for example, they cover modification of
18207753Smm   the file, and distribution when not linked into a combined
19207753Smm   executable.)
20207753Smm
21207753Smm   This program is distributed in the hope that it will be useful,
22207753Smm   but WITHOUT ANY WARRANTY; without even the implied warranty of
23207753Smm   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24207753Smm   GNU General Public License for more details.
25207753Smm
26207753Smm   You should have received a copy of the GNU General Public License
27207753Smm   along with this program; if not, write to the Free Software
28207753Smm   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
29207753Smm*/
30207753Smm
31207753Smm/* This file provides some definitions shared by cp-demangle.c and
32207753Smm   cp-demint.c.  It should not be included by any other files.  */
33207753Smm
34207753Smm/* Information we keep for operators.  */
35207753Smm
36207753Smmstruct demangle_operator_info
37207753Smm{
38207753Smm  /* Mangled name.  */
39207753Smm  const char *code;
40207753Smm  /* Real name.  */
41207753Smm  const char *name;
42207753Smm  /* Length of real name.  */
43207753Smm  int len;
44207753Smm  /* Number of arguments.  */
45207753Smm  int args;
46207753Smm};
47207753Smm
48207753Smm/* How to print the value of a builtin type.  */
49207753Smm
50207753Smmenum d_builtin_type_print
51207753Smm{
52207753Smm  /* Print as (type)val.  */
53207753Smm  D_PRINT_DEFAULT,
54207753Smm  /* Print as integer.  */
55207753Smm  D_PRINT_INT,
56207753Smm  /* Print as unsigned integer, with trailing "u".  */
57207753Smm  D_PRINT_UNSIGNED,
58207753Smm  /* Print as long, with trailing "l".  */
59207753Smm  D_PRINT_LONG,
60207753Smm  /* Print as unsigned long, with trailing "ul".  */
61207753Smm  D_PRINT_UNSIGNED_LONG,
62207753Smm  /* Print as long long, with trailing "ll".  */
63207753Smm  D_PRINT_LONG_LONG,
64207753Smm  /* Print as unsigned long long, with trailing "ull".  */
65207753Smm  D_PRINT_UNSIGNED_LONG_LONG,
66207753Smm  /* Print as bool.  */
67207753Smm  D_PRINT_BOOL,
68207753Smm  /* Print as float--put value in square brackets.  */
69207753Smm  D_PRINT_FLOAT,
70207753Smm  /* Print in usual way, but here to detect void.  */
71207753Smm  D_PRINT_VOID
72207753Smm};
73207753Smm
74207753Smm/* Information we keep for a builtin type.  */
75207753Smm
76207753Smmstruct demangle_builtin_type_info
77207753Smm{
78207753Smm  /* Type name.  */
79207753Smm  const char *name;
80207753Smm  /* Length of type name.  */
81207753Smm  int len;
82207753Smm  /* Type name when using Java.  */
83207753Smm  const char *java_name;
84207753Smm  /* Length of java name.  */
85207753Smm  int java_len;
86207753Smm  /* How to print a value of this type.  */
87207753Smm  enum d_builtin_type_print print;
88207753Smm};
89207753Smm
90207753Smm/* The information structure we pass around.  */
91207753Smm
92207753Smmstruct d_info
93207753Smm{
94207753Smm  /* The string we are demangling.  */
95207753Smm  const char *s;
96207753Smm  /* The end of the string we are demangling.  */
97207753Smm  const char *send;
98207753Smm  /* The options passed to the demangler.  */
99207753Smm  int options;
100207753Smm  /* The next character in the string to consider.  */
101207753Smm  const char *n;
102207753Smm  /* The array of components.  */
103207753Smm  struct demangle_component *comps;
104207753Smm  /* The index of the next available component.  */
105207753Smm  int next_comp;
106207753Smm  /* The number of available component structures.  */
107207753Smm  int num_comps;
108207753Smm  /* The array of substitutions.  */
109207753Smm  struct demangle_component **subs;
110207753Smm  /* The index of the next substitution.  */
111207753Smm  int next_sub;
112207753Smm  /* The number of available entries in the subs array.  */
113207753Smm  int num_subs;
114207753Smm  /* The number of substitutions which we actually made from the subs
115207753Smm     array, plus the number of template parameter references we
116207753Smm     saw.  */
117207753Smm  int did_subs;
118207753Smm  /* The last name we saw, for constructors and destructors.  */
119207753Smm  struct demangle_component *last_name;
120207753Smm  /* A running total of the length of large expansions from the
121207753Smm     mangled name to the demangled name, such as standard
122207753Smm     substitutions and builtin types.  */
123207753Smm  int expansion;
124207753Smm};
125207753Smm
126207753Smm#define d_peek_char(di) (*((di)->n))
127207753Smm#define d_peek_next_char(di) ((di)->n[1])
128207753Smm#define d_advance(di, i) ((di)->n += (i))
129207753Smm#define d_next_char(di) (*((di)->n++))
130207753Smm#define d_str(di) ((di)->n)
131207753Smm
132207753Smm/* Functions and arrays in cp-demangle.c which are referenced by
133207753Smm   functions in cp-demint.c.  */
134207753Smm#ifdef IN_GLIBCPP_V3
135207753Smm#define CP_STATIC_IF_GLIBCPP_V3 static
136207753Smm#else
137207753Smm#define CP_STATIC_IF_GLIBCPP_V3 extern
138207753Smm#endif
139207753Smm
140207753SmmCP_STATIC_IF_GLIBCPP_V3
141207753Smmconst struct demangle_operator_info cplus_demangle_operators[];
142207753Smm
143207753Smm#define D_BUILTIN_TYPE_COUNT (26)
144207753Smm
145207753SmmCP_STATIC_IF_GLIBCPP_V3
146207753Smmconst struct demangle_builtin_type_info
147207753Smmcplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT];
148207753Smm
149207753SmmCP_STATIC_IF_GLIBCPP_V3
150207753Smmstruct demangle_component *
151207753Smmcplus_demangle_mangled_name (struct d_info *, int);
152207753Smm
153207753SmmCP_STATIC_IF_GLIBCPP_V3
154207753Smmstruct demangle_component *
155207753Smmcplus_demangle_type (struct d_info *);
156207753Smm
157207753Smmextern void
158207753Smmcplus_demangle_init_info (const char *, int, size_t, struct d_info *);
159207753Smm
160207753Smm/* cp-demangle.c needs to define this a little differently */
161207753Smm#undef CP_STATIC_IF_GLIBCPP_V3
162207753Smm