2004-07-28 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / gdbtypes.h
index e7d755a1746fd7a3f2b9c2b0521356094060dee9..6a724071c632ecf7f04c1cbff8d20116839716d2 100644 (file)
@@ -1,7 +1,7 @@
 /* Internal type definitions for GDB.
 
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
@@ -134,8 +134,9 @@ enum type_code
 
     TYPE_CODE_TYPEDEF,
     TYPE_CODE_TEMPLATE,                /* C++ template */
-    TYPE_CODE_TEMPLATE_ARG     /* C++ template arg */
+    TYPE_CODE_TEMPLATE_ARG,    /* C++ template arg */
 
+    TYPE_CODE_NAMESPACE                /* C++ namespace.  */
   };
 
 /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
@@ -272,11 +273,31 @@ enum type_code
 #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
                                   & TYPE_FLAG_ADDRESS_CLASS_ALL)
 
+/*  Array bound type.  */
+enum array_bound_type
+{
+  BOUND_SIMPLE = 0,
+  BOUND_BY_VALUE_IN_REG,
+  BOUND_BY_REF_IN_REG,
+  BOUND_BY_VALUE_ON_STACK,
+  BOUND_BY_REF_ON_STACK,
+  BOUND_CANNOT_BE_DETERMINED
+};
+
+/* This structure is space-critical.
+   Its layout has been tweaked to reduce the space used.  */
+
 struct main_type
 {
   /* Code for kind of type */
 
-  enum type_code code;
+  ENUM_BITFIELD(type_code) code : 8;
+
+  /* Array bounds.  These fields appear at this location because
+     they pack nicely here.  */
+
+  ENUM_BITFIELD(array_bound_type) upper_bound_type : 4;
+  ENUM_BITFIELD(array_bound_type) lower_bound_type : 4;
 
   /* Name of this type, or NULL if none.
 
@@ -298,19 +319,8 @@ struct main_type
 
   char *tag_name;
 
-  /* FIXME, these should probably be restricted to a Fortran-specific
-     field in some fashion.  */
-#define BOUND_CANNOT_BE_DETERMINED   5
-#define BOUND_BY_REF_ON_STACK        4
-#define BOUND_BY_VALUE_ON_STACK      3
-#define BOUND_BY_REF_IN_REG          2
-#define BOUND_BY_VALUE_IN_REG        1
-#define BOUND_SIMPLE                 0
-  int upper_bound_type;
-  int lower_bound_type;
-
   /* Every type is now associated with a particular objfile, and the
-     type is allocated on the type_obstack for that objfile.  One problem
+     type is allocated on the objfile_obstack for that objfile.  One problem
      however, is that there are times when gdb allocates new types while
      it is not in the process of reading symbols from a particular objfile.
      Fortunately, these happen when the type being created is a derived
@@ -340,6 +350,15 @@ struct main_type
 
   short nfields;
 
+  /* Field number of the virtual function table pointer in
+     VPTR_BASETYPE.  If -1, we were unable to find the virtual
+     function table pointer in initial symbol reading, and
+     fill_in_vptr_fieldno should be called to find it if possible.
+
+     Unused if this type does not have virtual functions.  */
+
+  short vptr_fieldno;
+
   /* For structure and union types, a description of each field.
      For set and pascal array types, there is one "field",
      whose type is the domain type of the set or array.
@@ -421,15 +440,6 @@ struct main_type
 
   struct type *vptr_basetype;
 
-  /* Field number of the virtual function table pointer in
-     VPTR_BASETYPE.  If -1, we were unable to find the virtual
-     function table pointer in initial symbol reading, and
-     fill_in_vptr_fieldno should be called to find it if possible.
-
-     Unused if this type does not have virtual functions.  */
-
-  int vptr_fieldno;
-
   /* Slot to point to additional language-specific fields of this type.  */
 
   union type_specific
@@ -913,7 +923,77 @@ extern void allocate_cplus_struct_type (struct type *);
                                   (TYPE_NFIELDS (thistype) == 0)                     && \
                                   (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)))
 
+struct builtin_type
+{
+  /* Address/pointer types.  */
+
+  /* `pointer to data' type.  Some target platforms use an implicitly
+     {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA.  */
+  struct type *builtin_data_ptr;
+
+  /* `pointer to function (returning void)' type.  Harvard
+     architectures mean that ABI function and code pointers are not
+     interconvertible.  Similarly, since ANSI, C standards have
+     explicitly said that pointers to functions and pointers to data
+     are not interconvertible --- that is, you can't cast a function
+     pointer to void * and back, and expect to get the same value.
+     However, all function pointer types are interconvertible, so void
+     (*) () can server as a generic function pointer.  */
+  struct type *builtin_func_ptr;
+
+  /* The target CPU's address type.  This is the ISA address size.  */
+  struct type *builtin_core_addr;
+
+  /* Integral types.  */
+
+  /* Explicit sizes.  These are assumed to be 2's complement and in
+     the architecture's byte order.  The "int0" is for when an ISA
+     needs to describe a register that has no size.  The naming schema
+     is based on C9X <intypes.h>.  */
+  /* FIXME: cagney/2004-07-26: As with floating-point, there should be
+     explicit big, little and little-byte-big-word endian types that
+     exist outside of the architecture vector.  */
+  struct type *builtin_int0;
+  struct type *builtin_int8;
+  struct type *builtin_uint8;
+  struct type *builtin_int16;
+  struct type *builtin_uint16;
+  struct type *builtin_int32;
+  struct type *builtin_uint32;
+  struct type *builtin_int64;
+  struct type *builtin_uint64;
+  struct type *builtin_int128;
+  struct type *builtin_uint128;
+
+  /* We use this for the '/c' print format, because c_char is just a
+     one-byte integral type, which languages less laid back than C
+     will print as ... well, a one-byte integral type.  */
+  struct type *builtin_true_char;
+
+  /* Implicit size/sign (based on the the architecture's ABI).  */
+  struct type *builtin_void;
+  struct type *builtin_char;
+  struct type *builtin_short;
+  struct type *builtin_int;
+  struct type *builtin_long;
+  struct type *builtin_signed_char;
+  struct type *builtin_unsigned_char;
+  struct type *builtin_unsigned_short;
+  struct type *builtin_unsigned_int;
+  struct type *builtin_unsigned_long;
+  struct type *builtin_float;
+  struct type *builtin_double;
+  struct type *builtin_long_double;
+  struct type *builtin_complex;
+  struct type *builtin_double_complex;
+  struct type *builtin_string;
+  struct type *builtin_bool;
+  struct type *builtin_long_long;
+  struct type *builtin_unsigned_long_long;
+};
 
+/* Return the type table for the specified architecture.  */
+extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
 
 /* Implicit sizes */
 extern struct type *builtin_type_void;
@@ -1059,15 +1139,15 @@ extern struct type *builtin_type_f_void;
 /* Allocate space for storing data associated with a particular type.
    We ensure that the space is allocated using the same mechanism that
    was used to allocate the space for the type structure itself.  I.E.
-   if the type is on an objfile's type_obstack, then the space for data
-   associated with that type will also be allocated on the type_obstack.
+   if the type is on an objfile's objfile_obstack, then the space for data
+   associated with that type will also be allocated on the objfile_obstack.
    If the type is not associated with any particular objfile (such as
    builtin types), then the data space will be allocated with xmalloc,
    the same as for the type structure. */
 
 #define TYPE_ALLOC(t,size)  \
    (TYPE_OBJFILE (t) != NULL  \
-    ? obstack_alloc (&TYPE_OBJFILE (t) -> type_obstack, size) \
+    ? obstack_alloc (&TYPE_OBJFILE (t) -> objfile_obstack, size) \
     : xmalloc (size))
 
 extern struct type *alloc_type (struct objfile *);
@@ -1147,8 +1227,6 @@ extern struct type *lookup_primitive_typename (char *);
 
 extern char *gdb_mangle_name (struct type *, int, int);
 
-extern struct type *builtin_type (char **);
-
 extern struct type *lookup_typename (char *, struct block *, int);
 
 extern struct type *lookup_template_type (char *, struct type *,
This page took 0.026999 seconds and 4 git commands to generate.