type.H 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* T Y P E D E S C R I P T O R S T R U C T U R E */
  2. #include "dbsymtab.h"
  3. struct paramlist { /* structure for parameterlist of a PROCEDURE */
  4. struct paramlist *next;
  5. struct def *par_def; /* "df" of parameter */
  6. #define IsVarParam(xpar) ((xpar)->par_def->df_flags & D_VARPAR)
  7. #define TypeOfParam(xpar) ((xpar)->par_def->df_type)
  8. };
  9. /* ALLOCDEF "paramlist" 50 */
  10. struct enume {
  11. struct def *en_enums;
  12. unsigned int en_ncst; /* number of constants */
  13. label en_rck; /* label of range check descriptor */
  14. #define enm_enums tp_value.tp_enum.en_enums
  15. #define enm_ncst tp_value.tp_enum.en_ncst
  16. #define enm_rck tp_value.tp_enum.en_rck
  17. };
  18. struct subrange {
  19. arith su_lb, su_ub; /* lower bound and upper bound */
  20. label su_rck; /* label of range check descriptor */
  21. #define sub_lb tp_value.tp_subrange.su_lb
  22. #define sub_ub tp_value.tp_subrange.su_ub
  23. #define sub_rck tp_value.tp_subrange.su_rck
  24. };
  25. struct array {
  26. struct type *ar_elem; /* type of elements */
  27. union {
  28. struct { /* normal array */
  29. arith ar_elsize; /* size of elements */
  30. label ar_descr; /* label of array descriptor */
  31. } norm_arr;
  32. struct { /* conformant array */
  33. int cf_sclevel; /* scope level of declaration */
  34. arith cf_descr; /* offset array descriptor */
  35. } conf_arr;
  36. } ar_type;
  37. #define arr_elem tp_value.tp_arr.ar_elem
  38. #define arr_elsize tp_value.tp_arr.ar_type.norm_arr.ar_elsize
  39. #define arr_ardescr tp_value.tp_arr.ar_type.norm_arr.ar_descr
  40. #define arr_cfdescr tp_value.tp_arr.ar_type.conf_arr.cf_descr
  41. #define arr_sclevel tp_value.tp_arr.ar_type.conf_arr.cf_sclevel
  42. };
  43. struct selector {
  44. struct type *sel_type; /* type of the selector of a variant */
  45. arith sel_ncst; /* number of values of selector type */
  46. arith sel_lb; /* lower bound of selector type */
  47. struct selector **sel_ptrs; /* tagvalue table with pointers to
  48. nested variant-selectors */
  49. };
  50. struct record {
  51. struct scope *rc_scope; /* scope of this record */
  52. /* members are in the symbol table */
  53. struct selector *rc_selector; /* selector of variant (if present) */
  54. #define rec_scope tp_value.tp_record.rc_scope
  55. #define rec_sel tp_value.tp_record.rc_selector
  56. };
  57. struct proc {
  58. struct paramlist *pr_params;
  59. arith pr_nbpar;
  60. #define prc_params tp_value.tp_proc.pr_params
  61. #define prc_nbpar tp_value.tp_proc.pr_nbpar
  62. };
  63. struct type {
  64. struct type *next; /* used with ARRAY, PROCEDURE, FILE, SET,
  65. POINTER, SUBRANGE */
  66. int tp_fund; /* fundamental type or constructor */
  67. #define T_ENUMERATION 0x0001
  68. #define T_INTEGER 0x0002
  69. #define T_REAL 0x0004
  70. #define T_CHAR 0x0008
  71. #define T_PROCEDURE 0x0010
  72. #define T_FUNCTION 0x0020
  73. #define T_FILE 0x0040
  74. #define T_STRINGCONST 0x0080
  75. #define T_SUBRANGE 0x0100
  76. #define T_SET 0x0200
  77. #define T_ARRAY 0x0400
  78. #define T_RECORD 0x0800
  79. #define T_POINTER 0x1000
  80. #define T_LONG 0x2000
  81. #define T_STRING 0x4000
  82. #define T_ERROR 0x8000 /* bad type */
  83. #define T_NUMERIC (T_INTEGER | T_REAL | T_LONG)
  84. #define T_INDEX (T_SUBRANGE | T_ENUMERATION | T_CHAR | T_INTEGER )
  85. #define T_ORDINAL (T_INDEX | T_LONG)
  86. #define T_CONSTRUCTED (T_ARRAY | T_SET | T_RECORD | T_FILE | T_STRINGCONST)
  87. #define T_ROUTINE (T_FUNCTION | T_PROCEDURE)
  88. unsigned short tp_flags;
  89. #define T_HASFILE 0x1 /* set if type has a filecomponent */
  90. #define T_PACKED 0x2 /* set if type is packed */
  91. #define T_CHECKED 0x4 /* set if array has been checked */
  92. #ifdef DBSYMTAB
  93. short tp_dbindex; /* index in debugger symbol table */
  94. #endif
  95. int tp_align; /* alignment requirement of this type */
  96. int tp_palign; /* in packed structures */
  97. arith tp_size; /* size of this type */
  98. arith tp_psize; /* in packed structures */
  99. union {
  100. struct enume tp_enum;
  101. struct subrange tp_subrange;
  102. struct array tp_arr;
  103. struct record tp_record;
  104. struct proc tp_proc;
  105. } tp_value;
  106. };
  107. /* ALLOCDEF "type" 50 */
  108. extern struct type
  109. *bool_type,
  110. *char_type,
  111. *int_type,
  112. *long_type,
  113. *real_type,
  114. *string_type,
  115. *std_type,
  116. *text_type,
  117. *nil_type,
  118. *emptyset_type,
  119. *void_type,
  120. *error_type; /* All from type.c */
  121. #include "nocross.h"
  122. #ifdef NOCROSS
  123. #include "target_sizes.h"
  124. #define word_align (AL_WORD)
  125. #define int_align (AL_INT)
  126. #define long_align (AL_LONG)
  127. #define pointer_align (AL_POINTER)
  128. #define real_align (AL_REAL)
  129. #define struct_align (AL_STRUCT)
  130. #define word_size (SZ_WORD)
  131. #define int_size (SZ_INT)
  132. #define long_size (SZ_LONG)
  133. #define pointer_size (SZ_POINTER)
  134. #define real_size (SZ_REAL)
  135. #else /* NOCROSS */
  136. extern int
  137. word_align,
  138. int_align,
  139. long_align,
  140. pointer_align,
  141. real_align,
  142. struct_align; /* All from type.c */
  143. extern arith
  144. word_size,
  145. int_size,
  146. long_size,
  147. pointer_size,
  148. real_size; /* All from type.c */
  149. #endif /* NOCROSS */
  150. extern arith
  151. align();
  152. struct type
  153. *construct_type(),
  154. *standard_type(),
  155. *proc_type(),
  156. *func_type(),
  157. *set_type(),
  158. *subr_type(); /* All from type.c */
  159. #define NULLTYPE ((struct type *) 0)
  160. #define bounded(tpx) ((tpx)->tp_fund & T_INDEX)
  161. #define WA(sz) (align(sz, (int) word_size))
  162. #define ResultType(tpx) (assert((tpx)->tp_fund & T_ROUTINE),(tpx)->next)
  163. #define ElementType(tpx) (assert((tpx)->tp_fund & T_SET), (tpx)->next)
  164. #define BaseType(tpx) ((tpx)->tp_fund & T_SUBRANGE ? (tpx)->next :\
  165. (tpx))
  166. #define IndexType(tpx) (assert((tpx)->tp_fund == T_ARRAY), (tpx)->next)
  167. #define IsConstructed(tpx) ((tpx)->tp_fund & T_CONSTRUCTED)
  168. #define IsConformantArray(tpx) ((tpx)->tp_fund & T_ARRAY &&\
  169. (tpx)->tp_size == 0)
  170. #define IsPacked(tpx) ((tpx)->tp_flags & T_PACKED)
  171. #define PointedtoType(tpx) (assert((tpx)->tp_fund == T_POINTER ||\
  172. (tpx)->tp_fund == T_FILE), (tpx)->next)
  173. #define ParamList(tpx) (assert((tpx)->tp_fund & T_ROUTINE),\
  174. (tpx)->prc_params)
  175. extern long full_mask[];
  176. #define ufit(n, i) (((n) & ~full_mask[(i)]) == 0)