type.hh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* $Header$ */
  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. char par_kind; /* kind of parameter ('p', 'i', or 'v') */
  19. };
  20. typedef struct type {
  21. short ty_class;
  22. #define T_SUBRANGE 1
  23. #define T_ARRAY 2
  24. #define T_STRUCT 3
  25. #define T_UNION 4
  26. #define T_ENUM 5
  27. #define T_POINTER 6
  28. #define T_FILE 7
  29. #define T_PROCEDURE 8
  30. #define T_SET 9
  31. #define T_REAL 10
  32. #define T_INTEGER 11
  33. #define T_VOID 12
  34. #define T_UNSIGNED 13
  35. #define T_STRING 14 /* only for string constants ... */
  36. #define T_INCOMPLETE 100
  37. short ty_flags;
  38. #define T_CROSS 0x0001
  39. long ty_size;
  40. union {
  41. /* cross references */
  42. char *typ_tag;
  43. #define ty_tag ty_v.typ_tag
  44. /* procedures/functions: */
  45. struct {
  46. int typ_nparams;
  47. struct type *typ_retval;
  48. struct param *typ_params;
  49. long typ_nbparams;
  50. } ty_proc;
  51. #define ty_nparams ty_v.ty_proc.typ_nparams
  52. #define ty_retval ty_v.ty_proc.typ_retval
  53. #define ty_params ty_v.ty_proc.typ_params
  54. #define ty_nbparams ty_v.ty_proc.typ_nbparams
  55. /* pointers, files: */
  56. struct type *typ_ptrto;
  57. #define ty_ptrto ty_v.typ_ptrto
  58. #define ty_fileof ty_v.typ_ptrto
  59. /* arrays: */
  60. struct {
  61. struct type *typ_index;
  62. struct type *typ_elements;
  63. } ty_array;
  64. #define ty_index ty_v.ty_array.typ_index
  65. #define ty_elements ty_v.ty_array.typ_elements
  66. /* subranges: */
  67. struct {
  68. long typ_low, typ_up;
  69. int typ_A;
  70. struct type *typ_base;
  71. } ty_subrange;
  72. #define ty_A ty_v.ty_subrange.typ_A
  73. #define ty_low ty_v.ty_subrange.typ_low
  74. #define ty_up ty_v.ty_subrange.typ_up
  75. #define ty_base ty_v.ty_subrange.typ_base
  76. /* structures/unions: */
  77. struct {
  78. unsigned typ_nfields; /* number of field structures */
  79. struct fields *typ_fields;
  80. } ty_struct;
  81. #define ty_nfields ty_v.ty_struct.typ_nfields
  82. #define ty_fields ty_v.ty_struct.typ_fields
  83. /* enumerations: */
  84. struct {
  85. unsigned typ_nenums; /* number of enumeration literals */
  86. struct literal *typ_literals;
  87. } ty_enum;
  88. #define ty_nenums ty_v.ty_enum.typ_nenums
  89. #define ty_literals ty_v.ty_enum.typ_literals
  90. /* bit sets: */
  91. struct {
  92. struct type *typ_setbase; /* base type of set elements */
  93. long typ_setlow; /* low bound */
  94. } ty_set;
  95. #define ty_setbase ty_v.ty_set.typ_setbase
  96. #define ty_setlow ty_v.ty_set.typ_setlow
  97. } ty_v;
  98. } t_type, *p_type;
  99. /* ALLOCDEF "type" 50 */
  100. extern p_type
  101. subrange_type(),
  102. array_type(),
  103. *tp_lookup();
  104. extern long
  105. param_size(),
  106. compute_size();
  107. extern p_type char_type, uchar_type,
  108. long_type, double_type, string_type;
  109. extern p_type void_type, incomplete_type;