1 /* Support routines for manipulating internal types for GDB.
2 Copyright (C) 1992 Free Software Foundation, Inc.
3 Contributed by Cygnus Support, using pieces from other GDB modules.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #include "expression.h"
33 /* Alloc a new type structure and fill it with some defaults. If
34 OBJFILE is non-NULL, then allocate the space for the type structure
35 in that objfile's type_obstack. */
39 struct objfile
*objfile
;
41 register struct type
*type
;
43 /* Alloc the structure and start off with all fields zeroed. */
47 type
= (struct type
*) xmalloc (sizeof (struct type
));
51 type
= (struct type
*) obstack_alloc (&objfile
-> type_obstack
,
52 sizeof (struct type
));
54 (void) memset ((char *)type
, 0, sizeof (struct type
));
56 /* Initialize the fields that might not be zero. */
58 TYPE_CODE (type
) = TYPE_CODE_UNDEF
;
59 TYPE_OBJFILE (type
) = objfile
;
60 TYPE_VPTR_FIELDNO (type
) = -1;
65 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
66 to a pointer to memory where the pointer type should be stored.
67 If *TYPEPTR is zero, update it to point to the pointer type we return.
68 We allocate new memory if needed. */
71 make_pointer_type (type
, typeptr
)
73 struct type
**typeptr
;
75 register struct type
*ntype
; /* New type */
76 struct objfile
*objfile
;
78 ntype
= TYPE_POINTER_TYPE (type
);
82 return ntype
; /* Don't care about alloc, and have new type. */
83 else if (*typeptr
== 0)
85 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
89 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
91 ntype
= alloc_type (TYPE_OBJFILE (type
));
95 else /* We have storage, but need to reset it. */
98 objfile
= TYPE_OBJFILE (ntype
);
99 memset ((char *)ntype
, 0, sizeof (struct type
));
100 TYPE_OBJFILE (ntype
) = objfile
;
103 TYPE_TARGET_TYPE (ntype
) = type
;
104 TYPE_POINTER_TYPE (type
) = ntype
;
106 /* FIXME! Assume the machine has only one representation for pointers! */
108 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
109 TYPE_CODE (ntype
) = TYPE_CODE_PTR
;
111 /* pointers are unsigned */
112 TYPE_FLAGS (ntype
) |= TYPE_FLAG_UNSIGNED
;
114 if (!TYPE_POINTER_TYPE (type
)) /* Remember it, if don't have one. */
115 TYPE_POINTER_TYPE (type
) = ntype
;
120 /* Given a type TYPE, return a type of pointers to that type.
121 May need to construct such a type if this is the first use. */
124 lookup_pointer_type (type
)
127 return make_pointer_type (type
, (struct type
**)0);
130 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
131 to a pointer to memory where the reference type should be stored.
132 If *TYPEPTR is zero, update it to point to the reference type we return.
133 We allocate new memory if needed. */
136 make_reference_type (type
, typeptr
)
138 struct type
**typeptr
;
140 register struct type
*ntype
; /* New type */
141 struct objfile
*objfile
;
143 ntype
= TYPE_REFERENCE_TYPE (type
);
147 return ntype
; /* Don't care about alloc, and have new type. */
148 else if (*typeptr
== 0)
150 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
154 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
156 ntype
= alloc_type (TYPE_OBJFILE (type
));
160 else /* We have storage, but need to reset it. */
163 objfile
= TYPE_OBJFILE (ntype
);
164 memset ((char *)ntype
, 0, sizeof (struct type
));
165 TYPE_OBJFILE (ntype
) = objfile
;
168 TYPE_TARGET_TYPE (ntype
) = type
;
169 TYPE_REFERENCE_TYPE (type
) = ntype
;
171 /* FIXME! Assume the machine has only one representation for references,
172 and that it matches the (only) representation for pointers! */
174 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
175 TYPE_CODE (ntype
) = TYPE_CODE_REF
;
177 if (!TYPE_REFERENCE_TYPE (type
)) /* Remember it, if don't have one. */
178 TYPE_REFERENCE_TYPE (type
) = ntype
;
183 /* Same as above, but caller doesn't care about memory allocation details. */
186 lookup_reference_type (type
)
189 return make_reference_type (type
, (struct type
**)0);
192 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
193 to a pointer to memory where the function type should be stored.
194 If *TYPEPTR is zero, update it to point to the function type we return.
195 We allocate new memory if needed. */
198 make_function_type (type
, typeptr
)
200 struct type
**typeptr
;
202 register struct type
*ntype
; /* New type */
203 struct objfile
*objfile
;
205 ntype
= TYPE_FUNCTION_TYPE (type
);
209 return ntype
; /* Don't care about alloc, and have new type. */
210 else if (*typeptr
== 0)
212 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
216 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
218 ntype
= alloc_type (TYPE_OBJFILE (type
));
222 else /* We have storage, but need to reset it. */
225 objfile
= TYPE_OBJFILE (ntype
);
226 memset ((char *)ntype
, 0, sizeof (struct type
));
227 TYPE_OBJFILE (ntype
) = objfile
;
230 TYPE_TARGET_TYPE (ntype
) = type
;
231 TYPE_FUNCTION_TYPE (type
) = ntype
;
233 TYPE_LENGTH (ntype
) = 1;
234 TYPE_CODE (ntype
) = TYPE_CODE_FUNC
;
236 if (!TYPE_FUNCTION_TYPE (type
)) /* Remember it, if don't have one. */
237 TYPE_FUNCTION_TYPE (type
) = ntype
;
243 /* Given a type TYPE, return a type of functions that return that type.
244 May need to construct such a type if this is the first use. */
247 lookup_function_type (type
)
250 return make_function_type (type
, (struct type
**)0);
253 /* Implement direct support for MEMBER_TYPE in GNU C++.
254 May need to construct such a type if this is the first use.
255 The TYPE is the type of the member. The DOMAIN is the type
256 of the aggregate that the member belongs to. */
259 lookup_member_type (type
, domain
)
263 register struct type
*mtype
;
265 mtype
= alloc_type (TYPE_OBJFILE (type
));
266 smash_to_member_type (mtype
, domain
, type
);
270 /* Allocate a stub method whose return type is TYPE.
271 This apparently happens for speed of symbol reading, since parsing
272 out the arguments to the method is cpu-intensive, the way we are doing
273 it. So, we will fill in arguments later.
274 This always returns a fresh type. */
277 allocate_stub_method (type
)
282 mtype
= alloc_type (TYPE_OBJFILE (type
));
283 TYPE_TARGET_TYPE (mtype
) = type
;
284 /* _DOMAIN_TYPE (mtype) = unknown yet */
285 /* _ARG_TYPES (mtype) = unknown yet */
286 TYPE_FLAGS (mtype
) = TYPE_FLAG_STUB
;
287 TYPE_CODE (mtype
) = TYPE_CODE_METHOD
;
288 TYPE_LENGTH (mtype
) = 1;
292 /* Create an array type. Elements will be of type TYPE, and there will
295 Eventually this should be extended to take two more arguments which
296 specify the bounds of the array and the type of the index.
297 It should also be changed to be a "lookup" function, with the
298 appropriate data structures added to the type field.
299 Then read array type should call here. */
302 create_array_type (element_type
, number
)
303 struct type
*element_type
;
306 struct type
*result_type
;
307 struct type
*range_type
;
309 result_type
= alloc_type (TYPE_OBJFILE (element_type
));
311 TYPE_CODE (result_type
) = TYPE_CODE_ARRAY
;
312 TYPE_TARGET_TYPE (result_type
) = element_type
;
313 TYPE_LENGTH (result_type
) = number
* TYPE_LENGTH (element_type
);
314 TYPE_NFIELDS (result_type
) = 1;
315 TYPE_FIELDS (result_type
) = (struct field
*)
316 obstack_alloc (&TYPE_OBJFILE (result_type
) -> type_obstack
,
317 sizeof (struct field
));
320 /* Create range type. */
321 range_type
= alloc_type (TYPE_OBJFILE (result_type
));
322 TYPE_CODE (range_type
) = TYPE_CODE_RANGE
;
323 TYPE_TARGET_TYPE (range_type
) = builtin_type_int
; /* FIXME */
325 /* This should never be needed. */
326 TYPE_LENGTH (range_type
) = sizeof (int);
328 TYPE_NFIELDS (range_type
) = 2;
329 TYPE_FIELDS (range_type
) = (struct field
*)
330 obstack_alloc (&TYPE_OBJFILE (range_type
) -> type_obstack
,
331 2 * sizeof (struct field
));
332 TYPE_FIELD_BITPOS (range_type
, 0) = 0; /* FIXME */
333 TYPE_FIELD_BITPOS (range_type
, 1) = number
-1; /* FIXME */
334 TYPE_FIELD_TYPE (range_type
, 0) = builtin_type_int
; /* FIXME */
335 TYPE_FIELD_TYPE (range_type
, 1) = builtin_type_int
; /* FIXME */
337 TYPE_FIELD_TYPE(result_type
,0)=range_type
;
338 TYPE_VPTR_FIELDNO (result_type
) = -1;
340 return (result_type
);
344 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
345 A MEMBER is a wierd thing -- it amounts to a typed offset into
346 a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
347 include the offset (that's the value of the MEMBER itself), but does
348 include the structure type into which it points (for some reason).
350 When "smashing" the type, we preserve the objfile that the
351 old type pointed to, since we aren't changing where the type is actually
355 smash_to_member_type (type
, domain
, to_type
)
358 struct type
*to_type
;
360 struct objfile
*objfile
;
362 objfile
= TYPE_OBJFILE (type
);
364 (void) memset ((char *)type
, 0, sizeof (struct type
));
365 TYPE_OBJFILE (type
) = objfile
;
366 TYPE_TARGET_TYPE (type
) = to_type
;
367 TYPE_DOMAIN_TYPE (type
) = domain
;
368 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
369 TYPE_CODE (type
) = TYPE_CODE_MEMBER
;
372 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
373 METHOD just means `function that gets an extra "this" argument'.
375 When "smashing" the type, we preserve the objfile that the
376 old type pointed to, since we aren't changing where the type is actually
380 smash_to_method_type (type
, domain
, to_type
, args
)
383 struct type
*to_type
;
386 struct objfile
*objfile
;
388 objfile
= TYPE_OBJFILE (type
);
390 (void) memset ((char *)type
, 0, sizeof (struct type
));
391 TYPE_OBJFILE (type
) = objfile
;
392 TYPE_TARGET_TYPE (type
) = to_type
;
393 TYPE_DOMAIN_TYPE (type
) = domain
;
394 TYPE_ARG_TYPES (type
) = args
;
395 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
396 TYPE_CODE (type
) = TYPE_CODE_METHOD
;
399 /* Return a typename for a struct/union/enum type
400 without the tag qualifier. If the type has a NULL name,
404 type_name_no_tag (type
)
405 register const struct type
*type
;
409 if ((name
= TYPE_NAME (type
)) != NULL
)
411 switch (TYPE_CODE (type
))
413 case TYPE_CODE_STRUCT
:
414 if(!strncmp (name
, "struct ", 7))
419 case TYPE_CODE_UNION
:
420 if(!strncmp (name
, "union ", 6))
426 if(!strncmp (name
, "enum ", 5))
431 default: /* To avoid -Wall warnings */
438 /* Lookup a primitive type named NAME.
439 Return zero if NAME is not a primitive type.*/
442 lookup_primitive_typename (name
)
445 struct type
** const *p
;
447 for (p
= current_language
-> la_builtin_type_vector
; *p
!= NULL
; p
++)
449 if (!strcmp ((**p
) -> name
, name
))
457 /* Lookup a typedef or primitive type named NAME,
458 visible in lexical block BLOCK.
459 If NOERR is nonzero, return zero if NAME is not suitably defined. */
462 lookup_typename (name
, block
, noerr
)
467 register struct symbol
*sym
;
468 register struct type
*tmp
;
470 sym
= lookup_symbol (name
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
471 if (sym
== NULL
|| SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
473 tmp
= lookup_primitive_typename (name
);
478 else if (!tmp
&& noerr
)
484 error ("No type named %s.", name
);
487 return (SYMBOL_TYPE (sym
));
491 lookup_unsigned_typename (name
)
494 char *uns
= alloca (strlen (name
) + 10);
496 strcpy (uns
, "unsigned ");
497 strcpy (uns
+ 9, name
);
498 return (lookup_typename (uns
, (struct block
*) NULL
, 0));
501 /* Lookup a structure type named "struct NAME",
502 visible in lexical block BLOCK. */
505 lookup_struct (name
, block
)
509 register struct symbol
*sym
;
511 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
512 (struct symtab
**) NULL
);
516 error ("No struct type named %s.", name
);
518 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
520 error ("This context has class, union or enum %s, not a struct.", name
);
522 return (SYMBOL_TYPE (sym
));
525 /* Lookup a union type named "union NAME",
526 visible in lexical block BLOCK. */
529 lookup_union (name
, block
)
533 register struct symbol
*sym
;
535 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
536 (struct symtab
**) NULL
);
540 error ("No union type named %s.", name
);
542 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_UNION
)
544 error ("This context has class, struct or enum %s, not a union.", name
);
546 return (SYMBOL_TYPE (sym
));
549 /* Lookup an enum type named "enum NAME",
550 visible in lexical block BLOCK. */
553 lookup_enum (name
, block
)
557 register struct symbol
*sym
;
559 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
560 (struct symtab
**) NULL
);
563 error ("No enum type named %s.", name
);
565 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_ENUM
)
567 error ("This context has class, struct or union %s, not an enum.", name
);
569 return (SYMBOL_TYPE (sym
));
572 /* Lookup a template type named "template NAME<TYPE>",
573 visible in lexical block BLOCK. */
576 lookup_template_type (name
, type
, block
)
582 char *nam
= (char*) alloca(strlen(name
) + strlen(type
->name
) + 4);
585 strcat (nam
, type
->name
);
586 strcat (nam
, " >"); /* FIXME, extra space still introduced in gcc? */
588 sym
= lookup_symbol (nam
, block
, VAR_NAMESPACE
, 0, (struct symtab
**)NULL
);
592 error ("No template type named %s.", name
);
594 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
596 error ("This context has class, union or enum %s, not a struct.", name
);
598 return (SYMBOL_TYPE (sym
));
601 /* Given a type TYPE, lookup the type of the component of type named
603 If NOERR is nonzero, return zero if NAME is not suitably defined. */
606 lookup_struct_elt_type (type
, name
, noerr
)
613 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
&&
614 TYPE_CODE (type
) != TYPE_CODE_UNION
)
616 target_terminal_ours ();
618 fprintf (stderr
, "Type ");
619 type_print (type
, "", stderr
, -1);
620 error (" is not a structure or union type.");
623 check_stub_type (type
);
625 for (i
= TYPE_NFIELDS (type
) - 1; i
>= TYPE_N_BASECLASSES (type
); i
--)
627 char *t_field_name
= TYPE_FIELD_NAME (type
, i
);
629 if (t_field_name
&& !strcmp (t_field_name
, name
))
631 return TYPE_FIELD_TYPE (type
, i
);
635 /* OK, it's not in this class. Recursively check the baseclasses. */
636 for (i
= TYPE_N_BASECLASSES (type
) - 1; i
>= 0; i
--)
640 t
= lookup_struct_elt_type (TYPE_BASECLASS (type
, i
), name
, 0);
652 target_terminal_ours ();
654 fprintf (stderr
, "Type ");
655 type_print (type
, "", stderr
, -1);
656 fprintf (stderr
, " has no component named ");
657 fputs_filtered (name
, stderr
);
659 return (struct type
*)-1; /* For lint */
662 /* This function is really horrible, but to avoid it, there would need
663 to be more filling in of forward references. */
666 fill_in_vptr_fieldno (type
)
669 if (TYPE_VPTR_FIELDNO (type
) < 0)
672 for (i
= 1; i
< TYPE_N_BASECLASSES (type
); i
++)
674 fill_in_vptr_fieldno (TYPE_BASECLASS (type
, i
));
675 if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
)) >= 0)
677 TYPE_VPTR_FIELDNO (type
)
678 = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
));
679 TYPE_VPTR_BASETYPE (type
)
680 = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type
, i
));
687 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
689 If this is a stubbed struct (i.e. declared as struct foo *), see if
690 we can find a full definition in some other file. If so, copy this
691 definition, so we can use it in future. If not, set a flag so we
692 don't waste too much time in future. (FIXME, this doesn't seem
695 This used to be coded as a macro, but I don't think it is called
696 often enough to merit such treatment.
699 struct complaint stub_noname_complaint
=
700 {"stub type has NULL name", 0, 0};
703 check_stub_type (type
)
706 if (TYPE_FLAGS(type
) & TYPE_FLAG_STUB
)
708 char* name
= type_name_no_tag (type
);
712 complain (&stub_noname_complaint
, 0);
715 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0,
716 (struct symtab
**) NULL
);
719 memcpy ((char *)type
, (char *)SYMBOL_TYPE(sym
), sizeof (struct type
));
724 /* Ugly hack to convert method stubs into method types.
726 He ain't kiddin'. This demangles the name of the method into a string
727 including argument types, parses out each argument type, generates
728 a string casting a zero to that type, evaluates the string, and stuffs
729 the resulting type into an argtype vector!!! Then it knows the type
730 of the whole function (including argument types for overloading),
731 which info used to be in the stab's but was removed to hack back
732 the space required for them. */
735 check_stub_method (type
, i
, j
)
741 char *mangled_name
= gdb_mangle_name (type
, i
, j
);
742 char *demangled_name
= cplus_demangle (mangled_name
, 0);
743 char *argtypetext
, *p
;
744 int depth
= 0, argcount
= 1;
745 struct type
**argtypes
;
748 if (demangled_name
== NULL
)
750 error ("Internal: Cannot demangle mangled name `%s'.", mangled_name
);
753 /* Now, read in the parameters that define this type. */
754 argtypetext
= strchr (demangled_name
, '(') + 1;
766 else if (*p
== ',' && depth
== 0)
774 /* We need two more slots: one for the THIS pointer, and one for the
775 NULL [...] or void [end of arglist]. */
777 argtypes
= (struct type
**)
778 obstack_alloc (&TYPE_OBJFILE (type
) -> type_obstack
,
779 (argcount
+2) * sizeof (struct type
*));
781 argtypes
[0] = lookup_pointer_type (type
);
784 if (*p
!= ')') /* () means no args, skip while */
789 if (depth
<= 0 && (*p
== ',' || *p
== ')'))
792 parse_and_eval_type (argtypetext
, p
- argtypetext
);
810 if (p
[-2] != '.') /* ... */
812 argtypes
[argcount
] = builtin_type_void
; /* Ellist terminator */
816 argtypes
[argcount
] = NULL
; /* List terminator */
819 free (demangled_name
);
821 f
= TYPE_FN_FIELDLIST1 (type
, i
);
822 TYPE_FN_FIELD_PHYSNAME (f
, j
) = mangled_name
;
824 /* Now update the old "stub" type into a real type. */
825 mtype
= TYPE_FN_FIELD_TYPE (f
, j
);
826 TYPE_DOMAIN_TYPE (mtype
) = type
;
827 TYPE_ARG_TYPES (mtype
) = argtypes
;
828 TYPE_FLAGS (mtype
) &= ~TYPE_FLAG_STUB
;
829 TYPE_FN_FIELD_STUB (f
, j
) = 0;
832 const struct cplus_struct_type cplus_struct_default
;
835 allocate_cplus_struct_type (type
)
838 if (!HAVE_CPLUS_STRUCT (type
))
840 TYPE_CPLUS_SPECIFIC (type
) = (struct cplus_struct_type
*)
841 obstack_alloc (¤t_objfile
-> type_obstack
,
842 sizeof (struct cplus_struct_type
));
843 *(TYPE_CPLUS_SPECIFIC(type
)) = cplus_struct_default
;
847 /* Helper function to initialize the standard scalar types. */
850 init_type (code
, length
, flags
, name
, objfile
)
855 struct objfile
*objfile
;
857 register struct type
*type
;
859 type
= alloc_type (objfile
);
860 TYPE_CODE (type
) = code
;
861 TYPE_LENGTH (type
) = length
;
862 TYPE_FLAGS (type
) |= flags
;
863 TYPE_NAME (type
) = name
;
867 if (code
== TYPE_CODE_STRUCT
|| code
== TYPE_CODE_UNION
)
869 INIT_CPLUS_SPECIFIC (type
);
874 /* Look up a fundamental type for the specified objfile.
875 May need to construct such a type if this is the first use.
877 Some object file formats (ELF, COFF, etc) do not define fundamental
878 types such as "int" or "double". Others (stabs for example), do
879 define fundamental types.
881 For the formats which don't provide fundamental types, gdb can create
882 such types, using defaults reasonable for the current target machine. */
885 lookup_fundamental_type (objfile
, typeid)
886 struct objfile
*objfile
;
889 register struct type
*type
= NULL
;
890 register struct type
**typep
;
893 if (typeid < 0 || typeid >= FT_NUM_MEMBERS
)
895 error ("internal error - invalid fundamental type id %d", typeid);
899 /* If this is the first time we */
900 if (objfile
-> fundamental_types
== NULL
)
902 nbytes
= FT_NUM_MEMBERS
* sizeof (struct type
*);
903 objfile
-> fundamental_types
= (struct type
**)
904 obstack_alloc (&objfile
-> type_obstack
, nbytes
);
905 (void) memset ((char *)objfile
-> fundamental_types
, 0, nbytes
);
907 typep
= objfile
-> fundamental_types
+ typeid;
908 if ((type
= *typep
) == NULL
)
913 error ("internal error: unhandled type id %d", typeid);
916 type
= init_type (TYPE_CODE_VOID
,
917 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
922 type
= init_type (TYPE_CODE_INT
,
923 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
928 type
= init_type (TYPE_CODE_PASCAL_ARRAY
,
929 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
934 type
= init_type (TYPE_CODE_INT
,
935 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
940 type
= init_type (TYPE_CODE_INT
,
941 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
943 "signed char", objfile
);
945 case FT_UNSIGNED_CHAR
:
946 type
= init_type (TYPE_CODE_INT
,
947 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
949 "unsigned char", objfile
);
952 type
= init_type (TYPE_CODE_INT
,
953 TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
957 case FT_SIGNED_SHORT
:
958 type
= init_type (TYPE_CODE_INT
,
959 TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
961 "signed short", objfile
);
963 case FT_UNSIGNED_SHORT
:
964 type
= init_type (TYPE_CODE_INT
,
965 TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
967 "unsigned short", objfile
);
970 type
= init_type (TYPE_CODE_INT
,
971 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
975 case FT_SIGNED_INTEGER
:
976 type
= init_type (TYPE_CODE_INT
,
977 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
979 "signed int", objfile
);
981 case FT_UNSIGNED_INTEGER
:
982 type
= init_type (TYPE_CODE_INT
,
983 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
985 "unsigned int", objfile
);
987 case FT_FIXED_DECIMAL
:
988 type
= init_type (TYPE_CODE_INT
,
989 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
991 "fixed decimal", objfile
);
994 type
= init_type (TYPE_CODE_INT
,
995 TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
1000 type
= init_type (TYPE_CODE_INT
,
1001 TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
1003 "signed long", objfile
);
1005 case FT_UNSIGNED_LONG
:
1006 type
= init_type (TYPE_CODE_INT
,
1007 TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
1009 "unsigned long", objfile
);
1012 type
= init_type (TYPE_CODE_INT
,
1013 TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
1015 "long long", objfile
);
1017 case FT_SIGNED_LONG_LONG
:
1018 type
= init_type (TYPE_CODE_INT
,
1019 TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
1021 "signed long long", objfile
);
1023 case FT_UNSIGNED_LONG_LONG
:
1024 type
= init_type (TYPE_CODE_INT
,
1025 TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
1027 "unsigned long long", objfile
);
1030 type
= init_type (TYPE_CODE_FLT
,
1031 TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
1035 case FT_DBL_PREC_FLOAT
:
1036 type
= init_type (TYPE_CODE_FLT
,
1037 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
1041 case FT_FLOAT_DECIMAL
:
1042 type
= init_type (TYPE_CODE_FLT
,
1043 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
1045 "floating decimal", objfile
);
1047 case FT_EXT_PREC_FLOAT
:
1048 type
= init_type (TYPE_CODE_FLT
,
1049 TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
1051 "long double", objfile
);
1054 type
= init_type (TYPE_CODE_FLT
,
1055 TARGET_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
1057 "complex", objfile
);
1059 case FT_DBL_PREC_COMPLEX
:
1060 type
= init_type (TYPE_CODE_FLT
,
1061 TARGET_DOUBLE_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
1063 "double complex", objfile
);
1065 case FT_EXT_PREC_COMPLEX
:
1066 type
= init_type (TYPE_CODE_FLT
,
1067 TARGET_DOUBLE_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
1069 "long double complex", objfile
);
1072 /* Install the newly created type in the objfile's fundamental_types