If a source directory doesn't exist, use the install root instead.
[wine/multimedia.git] / tools / winedump / msmangle.c
blob44d6a8715786a302b5db272860bcdc2bc169ab87
1 /*
2 * Demangle VC++ symbols into C function prototypes
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include "winedump.h"
26 /* Type for parsing mangled types */
27 typedef struct _compound_type
29 char dest_type;
30 int flags;
31 int have_qualifiers;
32 char *expression;
33 } compound_type;
36 /* Initialise a compound type structure */
37 #define INIT_CT(ct) do { memset (&ct, 0, sizeof (ct)); } while (0)
39 /* free the memory used by a compound structure */
40 #define FREE_CT(ct) do { if (ct.expression) free (ct.expression); } while (0)
42 /* Flags for data types */
43 #define DATA_VTABLE 0x1
45 /* Internal functions */
46 static char *demangle_datatype (char **str, compound_type *ct,
47 parsed_symbol* sym);
49 static char *get_constraints_convention_1 (char **str, compound_type *ct);
51 static char *get_constraints_convention_2 (char **str, compound_type *ct);
53 static char *get_type_string (const char c, const int constraints);
55 static int get_type_constant (const char c, const int constraints);
57 static char *get_pointer_type_string (compound_type *ct,
58 const char *expression);
61 /*******************************************************************
62 * demangle_symbol
64 * Demangle a C++ linker symbol into a C prototype
66 int symbol_demangle (parsed_symbol *sym)
68 compound_type ct;
69 int is_static = 0, is_const = 0;
70 char *function_name = NULL;
71 char *class_name = NULL;
72 char *name;
73 const char *const_status;
74 static unsigned int hash = 0; /* In case of overloaded functions */
75 unsigned int data_flags = 0;
77 assert (globals.do_code);
78 assert (sym && sym->symbol);
80 hash++;
82 /* MS mangled names always begin with '?' */
83 name = sym->symbol;
84 if (*name++ != '?')
85 return -1;
87 if (VERBOSE)
88 puts ("Attempting to demangle symbol");
90 /* Then function name or operator code */
91 if (*name == '?')
93 /* C++ operator code (one character, or two if the first is '_') */
94 switch (*++name)
96 case '0': function_name = strdup ("ctor"); break;
97 case '1': function_name = strdup ("dtor"); break;
98 case '2': function_name = strdup ("operator_new"); break;
99 case '3': function_name = strdup ("operator_delete"); break;
100 case '4': function_name = strdup ("operator_equals"); break;
101 case '5': function_name = strdup ("operator_shiftright"); break;
102 case '6': function_name = strdup ("operator_shiftleft"); break;
103 case '7': function_name = strdup ("operator_not"); break;
104 case '8': function_name = strdup ("operator_equalsequals"); break;
105 case '9': function_name = strdup ("operator_notequals"); break;
106 case 'A': function_name = strdup ("operator_array"); break;
107 case 'C': function_name = strdup ("operator_dereference"); break;
108 case 'D': function_name = strdup ("operator_multiply"); break;
109 case 'E': function_name = strdup ("operator_plusplus"); break;
110 case 'F': function_name = strdup ("operator_minusminus"); break;
111 case 'G': function_name = strdup ("operator_minus"); break;
112 case 'H': function_name = strdup ("operator_plus"); break;
113 case 'I': function_name = strdup ("operator_address"); break;
114 case 'J': function_name = strdup ("operator_dereferencememberptr"); break;
115 case 'K': function_name = strdup ("operator_divide"); break;
116 case 'L': function_name = strdup ("operator_modulo"); break;
117 case 'M': function_name = strdup ("operator_lessthan"); break;
118 case 'N': function_name = strdup ("operator_lessthanequal"); break;
119 case 'O': function_name = strdup ("operator_greaterthan"); break;
120 case 'P': function_name = strdup ("operator_greaterthanequal"); break;
121 case 'Q': function_name = strdup ("operator_comma"); break;
122 case 'R': function_name = strdup ("operator_functioncall"); break;
123 case 'S': function_name = strdup ("operator_complement"); break;
124 case 'T': function_name = strdup ("operator_xor"); break;
125 case 'U': function_name = strdup ("operator_logicalor"); break;
126 case 'V': function_name = strdup ("operator_logicaland"); break;
127 case 'W': function_name = strdup ("operator_or"); break;
128 case 'X': function_name = strdup ("operator_multiplyequals"); break;
129 case 'Y': function_name = strdup ("operator_plusequals"); break;
130 case 'Z': function_name = strdup ("operator_minusequals"); break;
131 case '_':
132 switch (*++name)
134 case '0': function_name = strdup ("operator_divideequals"); break;
135 case '1': function_name = strdup ("operator_moduloequals"); break;
136 case '2': function_name = strdup ("operator_shiftrightequals"); break;
137 case '3': function_name = strdup ("operator_shiftleftequals"); break;
138 case '4': function_name = strdup ("operator_andequals"); break;
139 case '5': function_name = strdup ("operator_orequals"); break;
140 case '6': function_name = strdup ("operator_xorequals"); break;
141 case '7': function_name = strdup ("vftable"); data_flags = DATA_VTABLE; break;
142 case '8': function_name = strdup ("vbtable"); data_flags = DATA_VTABLE; break;
143 case '9': function_name = strdup ("vcall"); data_flags = DATA_VTABLE; break;
144 case 'A': function_name = strdup ("typeof"); data_flags = DATA_VTABLE; break;
145 case 'B': function_name = strdup ("local_static_guard"); data_flags = DATA_VTABLE; break;
146 case 'C': function_name = strdup ("string"); data_flags = DATA_VTABLE; break;
147 case 'D': function_name = strdup ("vbase_dtor"); data_flags = DATA_VTABLE; break;
148 case 'E': function_name = strdup ("vector_dtor"); break;
149 case 'G': function_name = strdup ("scalar_dtor"); break;
150 case 'H': function_name = strdup ("vector_ctor_iter"); break;
151 case 'I': function_name = strdup ("vector_dtor_iter"); break;
152 case 'J': function_name = strdup ("vector_vbase_ctor_iter"); break;
153 case 'L': function_name = strdup ("eh_vector_ctor_iter"); break;
154 case 'M': function_name = strdup ("eh_vector_dtor_iter"); break;
155 case 'N': function_name = strdup ("eh_vector_vbase_ctor_iter"); break;
156 case 'O': function_name = strdup ("copy_ctor_closure"); break;
157 case 'S': function_name = strdup ("local_vftable"); data_flags = DATA_VTABLE; break;
158 case 'T': function_name = strdup ("local_vftable_ctor_closure"); break;
159 case 'U': function_name = strdup ("operator_new_vector"); break;
160 case 'V': function_name = strdup ("operator_delete_vector"); break;
161 case 'X': function_name = strdup ("placement_new_closure"); break;
162 case 'Y': function_name = strdup ("placement_delete_closure"); break;
163 default:
164 return -1;
166 break;
167 default:
168 /* FIXME: Other operators */
169 return -1;
171 name++;
173 else
175 /* Type or function name terminated by '@' */
176 function_name = name;
177 while (*name && *name++ != '@') ;
178 if (!*name)
179 return -1;
180 function_name = str_substring (function_name, name - 1);
183 /* Either a class name, or '@' if the symbol is not a class member */
184 if (*name == '@')
186 class_name = strdup ("global"); /* Non member function (or a datatype) */
187 name++;
189 else
191 /* Class the function is associated with, terminated by '@@' */
192 class_name = name;
193 while (*name && *name++ != '@') ;
194 if (*name++ != '@')
195 return -1;
196 class_name = str_substring (class_name, name - 2);
199 /* Function/Data type and access level */
200 /* FIXME: why 2 possible letters for each option? */
201 switch(*name++)
203 /* Data */
205 case '0' : /* private static */
206 case '1' : /* protected static */
207 case '2' : /* public static */
208 is_static = 1;
209 /* Fall through */
210 case '3' : /* non static */
211 case '4' : /* non static */
212 /* Data members need to be implemented: report */
213 INIT_CT (ct);
214 if (!demangle_datatype (&name, &ct, sym))
216 if (VERBOSE)
217 printf ("/*FIXME: %s: unknown data*/\n", sym->symbol);
218 return -1;
220 sym->flags |= SYM_DATA;
221 sym->argc = 1;
222 sym->arg_name[0] = str_create (5, OUTPUT_UC_DLL_NAME, "_", class_name,
223 is_static ? "static_" : "_", function_name);
224 sym->arg_text[0] = str_create (3, ct.expression, " ", sym->arg_name[0]);
225 FREE_CT (ct);
226 return 0;
227 break;
229 case '6' : /* compiler generated static */
230 case '7' : /* compiler generated static */
231 if (data_flags & DATA_VTABLE)
233 sym->flags |= SYM_DATA;
234 sym->argc = 1;
235 sym->arg_name[0] = str_create (5, OUTPUT_UC_DLL_NAME, "_", class_name,
236 "_", function_name);
237 sym->arg_text[0] = str_create (2, "void *", sym->arg_name[0]);
239 if (VERBOSE)
240 puts ("Demangled symbol OK [vtable]");
241 return 0;
243 return -1;
244 break;
246 /* Functions */
248 case 'E' : /* private virtual */
249 case 'F' : /* private virtual */
250 case 'M' : /* protected virtual */
251 case 'N' : /* protected virtual */
252 case 'U' : /* public virtual */
253 case 'V' : /* public virtual */
254 /* Virtual functions need to be added to the exported vtable: report */
255 if (VERBOSE)
256 printf ("/*FIXME %s: %s::%s is virtual-add to vftable*/\n", sym->symbol,
257 class_name, function_name);
258 /* Fall through */
259 case 'A' : /* private */
260 case 'B' : /* private */
261 case 'I' : /* protected */
262 case 'J' : /* protected */
263 case 'Q' : /* public */
264 case 'R' : /* public */
265 /* Implicit 'this' pointer */
266 sym->arg_text [sym->argc] = str_create (3, "struct ", class_name, " *");
267 sym->arg_type [sym->argc] = ARG_POINTER;
268 sym->arg_flag [sym->argc] = 0;
269 sym->arg_name [sym->argc++] = strdup ("_this");
270 /* New struct definitions can be 'grep'ed out for making a fixup header */
271 if (VERBOSE)
272 printf ("struct %s { void **vtable; /*FIXME: class definition */ };\n", class_name);
273 break;
274 case 'C' : /* private: static */
275 case 'D' : /* private: static */
276 case 'K' : /* protected: static */
277 case 'L' : /* protected: static */
278 case 'S' : /* public: static */
279 case 'T' : /* public: static */
280 is_static = 1; /* No implicit this pointer */
281 break;
282 case 'Y' :
283 case 'Z' :
284 break;
285 /* FIXME: G,H / O,P / W,X are private / protected / public thunks */
286 default:
287 return -1;
290 /* If there is an implicit this pointer, const status follows */
291 if (sym->argc)
293 switch (*name++)
295 case 'A': break; /* non-const */
296 case 'B': is_const = CT_CONST; break;
297 case 'C': is_const = CT_VOLATILE; break;
298 case 'D': is_const = (CT_CONST | CT_VOLATILE); break;
299 default:
300 return -1;
304 /* Next is the calling convention */
305 switch (*name++)
307 case 'A': /* __cdecl */
308 case 'B': /* __cdecl __declspec(dllexport) */
309 if (!sym->argc)
311 sym->flags |= SYM_CDECL;
312 break;
314 /* Else fall through */
315 case 'C': /* __pascal */
316 case 'D': /* __pascal __declspec(dllexport) */
317 case 'E': /* __thiscall */
318 case 'F': /* __thiscall __declspec(dllexport) */
319 case 'G': /* __stdcall */
320 case 'H': /* __stdcall __declspec(dllexport) */
321 case 'I': /* __fastcall */
322 case 'J': /* __fastcall __declspec(dllexport)*/
323 case 'K': /* default (none given) */
324 if (sym->argc)
325 sym->flags |= SYM_THISCALL;
326 else
327 sym->flags |= SYM_STDCALL;
328 break;
329 default:
330 return -1;
333 /* Return type, or @ if 'void' */
334 if (*name == '@')
336 sym->return_text = strdup ("void");
337 sym->return_type = ARG_VOID;
338 name++;
340 else
342 INIT_CT (ct);
343 if (!demangle_datatype (&name, &ct, sym))
344 return -1;
345 sym->return_text = ct.expression;
346 sym->return_type = get_type_constant(ct.dest_type, ct.flags);
347 ct.expression = NULL;
348 FREE_CT (ct);
351 /* Now come the function arguments */
352 while (*name && *name != 'Z')
354 /* Decode each data type and append it to the argument list */
355 if (*name != '@')
357 INIT_CT (ct);
358 if (!demangle_datatype(&name, &ct, sym))
359 return -1;
361 if (strcmp (ct.expression, "void"))
363 sym->arg_text [sym->argc] = ct.expression;
364 ct.expression = NULL;
365 sym->arg_type [sym->argc] = get_type_constant (ct.dest_type, ct.flags);
366 sym->arg_flag [sym->argc] = ct.flags;
367 sym->arg_name[sym->argc] = str_create_num (1, sym->argc, "arg");
368 sym->argc++;
370 else
371 break; /* 'void' terminates an argument list */
372 FREE_CT (ct);
374 else
375 name++;
378 while (*name == '@')
379 name++;
381 /* Functions are always terminated by 'Z'. If we made it this far and
382 * Don't find it, we have incorrectly identified a data type.
384 if (*name != 'Z')
385 return -1;
387 /* Note: '()' after 'Z' means 'throws', but we don't care here */
389 /* Create the function name. Include a unique number because otherwise
390 * overloaded functions could have the same c signature.
392 switch (is_const)
394 case (CT_CONST | CT_VOLATILE): const_status = "_const_volatile"; break;
395 case CT_CONST: const_status = "_const"; break;
396 case CT_VOLATILE: const_status = "_volatile"; break;
397 default: const_status = "_"; break;
399 sym->function_name = str_create_num (4, hash, class_name, "_",
400 function_name, is_static ? "_static" : const_status);
402 assert (sym->return_text);
403 assert (sym->flags);
404 assert (sym->function_name);
406 free (class_name);
407 free (function_name);
409 if (VERBOSE)
410 puts ("Demangled symbol OK");
412 return 0;
416 /*******************************************************************
417 * demangle_datatype
419 * Attempt to demangle a C++ data type, which may be compound.
420 * a compound type is made up of a number of simple types. e.g:
421 * char** = (pointer to (pointer to (char)))
423 * Uses a simple recursive descent algorithm that is broken
424 * and/or incomplete, without a doubt ;-)
426 static char *demangle_datatype (char **str, compound_type *ct,
427 parsed_symbol* sym)
429 char *iter;
431 assert (str && *str);
432 assert (ct);
434 iter = *str;
436 if (!get_constraints_convention_1 (&iter, ct))
437 return NULL;
439 if (*iter == '_')
441 /* MS type: __int8,__int16 etc */
442 ct->flags |= CT_EXTENDED;
443 iter++;
446 switch (*iter)
448 case 'C': case 'D': case 'E': case 'F': case 'G':
449 case 'H': case 'I': case 'J': case 'K': case 'M':
450 case 'N': case 'O': case 'X': case 'Z':
451 /* Simple data types */
452 ct->dest_type = *iter++;
453 if (!get_constraints_convention_2 (&iter, ct))
454 return NULL;
455 ct->expression = get_type_string (ct->dest_type, ct->flags);
456 break;
457 case 'U':
458 case 'V':
459 /* Class/struct/union */
460 ct->dest_type = *iter++;
461 if (*iter == '0' || *iter == '1')
463 /* Referring to class type (implicit 'this') */
464 char *stripped;
465 if (!sym->argc)
466 return NULL;
468 iter++;
469 /* Apply our constraints to the base type (struct xxx *) */
470 stripped = strdup (sym->arg_text [0]);
471 if (!stripped)
472 fatal ("Out of Memory");
474 /* If we're a reference, re-use the pointer already in the type */
475 if (!(ct->flags & CT_BY_REFERENCE))
476 stripped[ strlen (stripped) - 2] = '\0'; /* otherwise, strip it */
478 ct->expression = str_create (2, ct->flags & CT_CONST ? "const " :
479 ct->flags & CT_VOLATILE ? "volatile " : "", stripped);
480 free (stripped);
482 else if (*iter != '@')
484 /* The name of the class/struct, followed by '@@' */
485 char *struct_name = iter;
486 while (*iter && *iter++ != '@') ;
487 if (*iter++ != '@')
488 return NULL;
489 struct_name = str_substring (struct_name, iter - 2);
490 ct->expression = str_create (4, ct->flags & CT_CONST ? "const " :
491 ct->flags & CT_VOLATILE ? "volatile " : "", "struct ",
492 struct_name, ct->flags & CT_BY_REFERENCE ? " *" : "");
493 free (struct_name);
495 break;
496 case 'Q': /* FIXME: Array Just treated as pointer currently */
497 case 'P': /* Pointer */
499 compound_type sub_ct;
500 INIT_CT (sub_ct);
502 ct->dest_type = *iter++;
503 if (!get_constraints_convention_2 (&iter, ct))
504 return NULL;
506 /* FIXME: P6 = Function pointer, others who knows.. */
507 if (isdigit (*iter))
509 if (*iter == '6')
511 int sub_expressions = 0;
512 /* FIXME: there are a tons of memory leaks here */
513 /* FIXME: this is still broken in some cases and it has to be
514 * merged with the function prototype parsing above...
516 iter += iter[1] == 'A' ? 2 : 3; /* FIXME */
517 if (!demangle_datatype (&iter, &sub_ct, sym))
518 return NULL;
519 ct->expression = str_create(2, sub_ct.expression, " (*)(");
520 if (*iter != '@')
522 while (*iter != 'Z')
524 FREE_CT (sub_ct);
525 INIT_CT (sub_ct);
526 if (!demangle_datatype (&iter, &sub_ct, sym))
527 return NULL;
528 if (sub_expressions)
529 ct->expression = str_create(3, ct->expression, ", ", sub_ct.expression);
530 else
531 ct->expression = str_create(2, ct->expression, sub_ct.expression);
532 while (*iter == '@') iter++;
533 sub_expressions++;
535 } else while (*iter == '@') iter++;
536 iter++;
537 ct->expression = str_create(2, ct->expression, ")");
539 else
540 return NULL;
542 else
544 /* Recurse to get the pointed-to type */
545 if (!demangle_datatype (&iter, &sub_ct, sym))
546 return NULL;
548 ct->expression = get_pointer_type_string (ct, sub_ct.expression);
551 FREE_CT (sub_ct);
553 break;
554 case '0': case '1': case '2': case '3': case '4':
555 case '5': case '6': case '7': case '8': case '9':
556 /* Referring back to previously parsed type */
557 if (sym->argc >= (size_t)('0' - *iter))
558 return NULL;
559 ct->dest_type = sym->arg_type ['0' - *iter];
560 ct->expression = strdup (sym->arg_text ['0' - *iter]);
561 iter++;
562 break;
563 default :
564 return NULL;
566 if (!ct->expression)
567 return NULL;
569 return (char *)(*str = iter);
573 /* Constraints:
574 * There are two conventions for specifying data type constaints. I
575 * don't know how the compiler chooses between them, but I suspect it
576 * is based on ensuring that linker names are unique.
577 * Convention 1. The data type modifier is given first, followed
578 * by the data type it operates on. '?' means passed by value,
579 * 'A' means passed by reference. Note neither of these characters
580 * is a valid base data type. This is then followed by a character
581 * specifying constness or volatilty.
582 * Convention 2. The base data type (which is never '?' or 'A') is
583 * given first. The character modifier is optionally given after
584 * the base type character. If a valid character mofifier is present,
585 * then it only applies to the current data type if the character
586 * after that is not 'A' 'B' or 'C' (Because this makes a convention 1
587 * constraint for the next data type).
589 * The conventions are usually mixed within the same symbol.
590 * Since 'C' is both a qualifier and a data type, I suspect that
591 * convention 1 allows specifying e.g. 'volatile signed char*'. In
592 * convention 2 this would be 'CC' which is ambigious (i.e. Is it two
593 * pointers, or a single pointer + modifier?). In convention 1 it
594 * is encoded as '?CC' which is not ambigious. This probably
595 * holds true for some other types as well.
598 /*******************************************************************
599 * get_constraints_convention_1
601 * Get type constraint information for a data type
603 static char *get_constraints_convention_1 (char **str, compound_type *ct)
605 char *iter = *str, **retval = str;
607 if (ct->have_qualifiers)
608 return (char *)*str; /* Previously got constraints for this type */
610 if (*iter == '?' || *iter == 'A')
612 ct->have_qualifiers = 1;
613 ct->flags |= (*iter++ == '?' ? 0 : CT_BY_REFERENCE);
615 switch (*iter++)
617 case 'A' :
618 break; /* non-const, non-volatile */
619 case 'B' :
620 ct->flags |= CT_CONST;
621 break;
622 case 'C' :
623 ct->flags |= CT_VOLATILE;
624 break;
625 default :
626 return NULL;
630 return (char *)(*retval = iter);
634 /*******************************************************************
635 * get_constraints_convention_2
637 * Get type constraint information for a data type
639 static char *get_constraints_convention_2 (char **str, compound_type *ct)
641 char *iter = *str, **retval = str;
643 /* FIXME: Why do arrays have both convention 1 & 2 constraints? */
644 if (ct->have_qualifiers && ct->dest_type != 'Q')
645 return (char *)*str; /* Previously got constraints for this type */
647 ct->have_qualifiers = 1; /* Even if none, we've got all we're getting */
649 switch (*iter)
651 case 'A' :
652 if (iter[1] != 'A' && iter[1] != 'B' && iter[1] != 'C')
653 iter++;
654 break;
655 case 'B' :
656 ct->flags |= CT_CONST;
657 iter++;
658 break;
659 case 'C' :
660 /* See note above, if we find 'C' it is _not_ a signed char */
661 ct->flags |= CT_VOLATILE;
662 iter++;
663 break;
666 return (char *)(*retval = iter);
670 /*******************************************************************
671 * get_type_string
673 * Return a string containing the name of a data type
675 static char *get_type_string (const char c, const int constraints)
677 const char *type_string;
679 if (constraints & CT_EXTENDED)
681 switch (c)
683 case 'D': type_string = "__int8"; break;
684 case 'E': type_string = "unsigned __int8"; break;
685 case 'F': type_string = "__int16"; break;
686 case 'G': type_string = "unsigned __int16"; break;
687 case 'H': type_string = "__int32"; break;
688 case 'I': type_string = "unsigned __int32"; break;
689 case 'J': type_string = "__int64"; break;
690 case 'K': type_string = "unsigned __int64"; break;
691 case 'L': type_string = "__int128"; break;
692 case 'M': type_string = "unsigned __int128"; break;
693 case 'N': type_string = "int"; break; /* bool */
694 case 'W': type_string = "WCHAR"; break; /* wchar_t */
695 default:
696 return NULL;
699 else
701 switch (c)
703 case 'C': /* Signed char, fall through */
704 case 'D': type_string = "char"; break;
705 case 'E': type_string = "unsigned char"; break;
706 case 'F': type_string = "short int"; break;
707 case 'G': type_string = "unsigned short int"; break;
708 case 'H': type_string = "int"; break;
709 case 'I': type_string = "unsigned int"; break;
710 case 'J': type_string = "long"; break;
711 case 'K': type_string = "unsigned long"; break;
712 case 'M': type_string = "float"; break;
713 case 'N': type_string = "double"; break;
714 case 'O': type_string = "long double"; break;
715 /* FIXME: T = union */
716 case 'U':
717 case 'V': type_string = "struct"; break;
718 case 'X': return strdup ("void");
719 case 'Z': return strdup ("...");
720 default:
721 return NULL;
725 return str_create (3, constraints & CT_CONST ? "const " :
726 constraints & CT_VOLATILE ? "volatile " : "", type_string,
727 constraints & CT_BY_REFERENCE ? " *" : "");
731 /*******************************************************************
732 * get_type_constant
734 * Get the ARG_* constant for this data type
736 static int get_type_constant (const char c, const int constraints)
738 /* Any reference type is really a pointer */
739 if (constraints & CT_BY_REFERENCE)
740 return ARG_POINTER;
742 switch (c)
744 case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I':
745 case 'J': case 'K':
746 return ARG_LONG;
747 case 'M':
748 return ARG_FLOAT;
749 case 'N': case 'O':
750 return ARG_DOUBLE;
751 case 'P': case 'Q':
752 return ARG_POINTER;
753 case 'U': case 'V':
754 return ARG_STRUCT;
755 case 'X':
756 return ARG_VOID;
757 case 'Z':
758 default:
759 return -1;
764 /*******************************************************************
765 * get_pointer_type_string
767 * Return a string containing 'pointer to expression'
769 static char *get_pointer_type_string (compound_type *ct,
770 const char *expression)
772 /* FIXME: set a compound flag for bracketing expression if needed */
773 return str_create (3, ct->flags & CT_CONST ? "const " :
774 ct->flags & CT_VOLATILE ? "volatile " : "", expression,
775 ct->flags & CT_BY_REFERENCE ? " **" : " *");