type.hh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* $Id$ */
  2. /* internal type representation */
  3. /* structure for struct/union elements */
  4. struct fields {
  5. long fld_pos; /* position of field */
  6. long fld_bitsize; /* size in bits */
  7. struct type *fld_type; /* type of field */
  8. char *fld_name; /* name of field */
  9. };
  10. /* structure for enumeration literals */
  11. struct literal {
  12. long lit_val; /* value of literal */
  13. char *lit_name; /* name of literal */
  14. };
  15. /* structure for parameters */
  16. struct param {
  17. struct type *par_type; /* type of parameter */
  18. long par_off; /* offset of parameter */
  19. char par_kind; /* kind of parameter ('p', 'i', or 'v') */
  20. };
  21. typedef struct type {
  22. short ty_class;
  23. #define T_SUBRANGE 1
  24. #define T_ARRAY 2
  25. #define T_STRUCT 3
  26. #define T_UNION 4
  27. #define T_ENUM 5
  28. #define T_POINTER 6
  29. #define T_FILE 7
  30. #define T_PROCEDURE 8
  31. #define T_SET 9
  32. #define T_REAL 10
  33. #define T_INTEGER 11
  34. #define T_VOID 12
  35. #define T_UNSIGNED 13
  36. #define T_STRING 14 /* only for string constants ... */
  37. #define T_CROSS 15 /* cross reference to type */
  38. #define T_INCOMPLETE 100
  39. long ty_size;
  40. struct symbol *ty_sym;
  41. union {
  42. /* cross references */
  43. struct type *typ_cross;
  44. #define ty_cross ty_v.typ_cross
  45. /* procedures/functions: */
  46. struct {
  47. int typ_nparams;
  48. struct type *typ_retval;
  49. struct param *typ_params;
  50. long typ_nbparams;
  51. } ty_proc;
  52. #define ty_nparams ty_v.ty_proc.typ_nparams
  53. #define ty_retval ty_v.ty_proc.typ_retval
  54. #define ty_params ty_v.ty_proc.typ_params
  55. #define ty_nbparams ty_v.ty_proc.typ_nbparams
  56. /* pointers, files: */
  57. struct type *typ_ptrto;
  58. #define ty_ptrto ty_v.typ_ptrto
  59. #define ty_fileof ty_v.typ_ptrto
  60. /* arrays: */
  61. struct {
  62. long typ_lb, typ_hb;
  63. struct type *typ_index;
  64. struct type *typ_elements;
  65. } ty_array;
  66. #define ty_lb ty_v.ty_array.typ_lb
  67. #define ty_hb ty_v.ty_array.typ_hb
  68. #define ty_index ty_v.ty_array.typ_index
  69. #define ty_elements ty_v.ty_array.typ_elements
  70. /* subranges: */
  71. struct {
  72. long typ_low, typ_up;
  73. int typ_A;
  74. struct type *typ_base;
  75. } ty_subrange;
  76. #define ty_A ty_v.ty_subrange.typ_A
  77. #define ty_low ty_v.ty_subrange.typ_low
  78. #define ty_up ty_v.ty_subrange.typ_up
  79. #define ty_base ty_v.ty_subrange.typ_base
  80. /* structures/unions: */
  81. struct {
  82. unsigned typ_nfields; /* number of field structures */
  83. struct fields *typ_fields;
  84. } ty_struct;
  85. #define ty_nfields ty_v.ty_struct.typ_nfields
  86. #define ty_fields ty_v.ty_struct.typ_fields
  87. /* enumerations: */
  88. struct {
  89. unsigned typ_nenums; /* number of enumeration literals */
  90. struct literal *typ_literals;
  91. } ty_enum;
  92. #define ty_nenums ty_v.ty_enum.typ_nenums
  93. #define ty_literals ty_v.ty_enum.typ_literals
  94. /* bit sets: */
  95. struct {
  96. struct type *typ_setbase; /* base type of set elements */
  97. long typ_setlow; /* low bound */
  98. } ty_set;
  99. #define ty_setbase ty_v.ty_set.typ_setbase
  100. #define ty_setlow ty_v.ty_set.typ_setlow
  101. } ty_v;
  102. } t_type, *p_type;
  103. /* ALLOCDEF "type" 50 */
  104. extern p_type
  105. subrange_type(),
  106. array_type(),
  107. *tp_lookup();
  108. extern long
  109. param_size(),
  110. compute_size();
  111. extern p_type char_type, uchar_type, bool_type, int_type,
  112. long_type, double_type, string_type, address_type;
  113. extern p_type void_type;
  114. extern long int_size, short_size, pointer_size, long_size,
  115. float_size, double_size;