Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
12 KiB

  1. /*
  2. ** symbols basic types
  3. ** if the values are changed check : init'd arrays in globals.c
  4. */
  5. #define BTundef 0
  6. #define BTchar 1
  7. #define BTshort 2
  8. #define BTint 3
  9. #define BTlong 4
  10. #define BTenumuse 5
  11. #define BTfloat 6
  12. #define BTdouble 7
  13. #define BTldouble 8
  14. #define BTseg 9
  15. #define BTBASIC 9 /* used elsewhere to indicate the last basic type */
  16. #define BTvoid 10
  17. #define BTenum 11
  18. #define BTstruct 12
  19. #define BTunion 13
  20. #define BTstuse 14
  21. #define BTunuse 15
  22. #define BT_MASK 0x0f /* basic type mask */
  23. /*
  24. ** the following are also used in indirection strings as modifiers
  25. ** to the basic indirections.
  26. ** NOTE THIS DOESN'T really work for C600, but for just one case.
  27. ** if a typedef has 'near' on it, 'consolidate_types' will consider
  28. ** it to be a 'signed' bit, and remove it, thus, near never gets
  29. ** added to whatever the typedef is used on.
  30. */
  31. #define BT_UNSIGNED 0x0010 /* unsigned keyword used */
  32. #define BT_SIGNED 0x0020 /* signed keyword used */
  33. #define SU_MASK 0x0030 /* signed/unsigned mask */
  34. #define BT_NEAR 0x0040 /* near keyword used */
  35. #define BT_FAR 0x0080 /* far keyword used */
  36. #define BT_HUGE 0x00c0 /* huge keyword used */
  37. #define NFH_MASK 0x00c0 /* near/far/huge mask */
  38. #define BT_INTERRUPT 0x0100 /* interrupt seen */
  39. #define BT_SAVEREGS 0x0200 /* dynalink seen */
  40. #define BT_EXPORT 0x0400 /* export seen */
  41. #define BT_LOADDS 0x0800 /* loadds seen */
  42. #define CODEMOD_MASK 0x0f00 /* code modifiers */
  43. #define BT_CONST 0x1000 /* constant keyword used */
  44. #define BT_VOLATILE 0x2000 /* volatile keyword used */
  45. #define CV_MASK 0x3000 /* const/volatile mask */
  46. #define BT_CDECL 0x4000 /* cdecl keyword used */
  47. #define BT_FORTRAN 0x8000 /* fortran keyword used */
  48. #define BT_PASCAL 0xc000 /* pascal keyword used */
  49. #define LANGUAGE_MASK 0xc000 /* cdecl/fortran/pascal mask */
  50. #define MODIFIER_MASK (NFH_MASK | LANGUAGE_MASK | CODEMOD_MASK | CV_MASK)
  51. #define ALL_MODIFIERS (MODIFIER_MASK | SU_MASK)
  52. /*
  53. ** macros for getting/setting basic type information
  54. ** Q_* to query the flag.
  55. ** S_* to set the flag.
  56. ** the Q_near/far/huge things are defined later, and are called IS_*.
  57. */
  58. #define IS_BTBASIC(P) ((P) <= BTBASIC)
  59. #define IS_BTINTEGRAL(P) ((P) <= BTenumuse)
  60. #define IS_BTFLOAT(P) ((BTfloat <= (P)) && ((P) <= BTldouble))
  61. #define IS_BTVOID(P) ((P) == BTvoid)
  62. #define IS_BASIC(P) (IS_BTBASIC(Q_BTYPE(P)))
  63. #define IS_INTEGRAL(P) (IS_BTINTEGRAL(Q_BTYPE(P)))
  64. #define IS_FLOAT(P) (IS_BTFLOAT(Q_BTYPE(P)))
  65. #define IS_VOID(P) (IS_BTVOID(Q_BTYPE(P)))
  66. #define IS_MULTIBYTE(P) ((BTstruct <= (P)) && ((P) <= BTunuse))
  67. #define IS_UNSIGNED(P) ((P) & BT_UNSIGNED)
  68. #define IS_SIGNED(P) ((P) & BT_SIGNED)
  69. #define CLR_SIGNED(P) ((P) &= ~BT_SIGNED)
  70. #define S_UNSIGNED(P) ((P) |= BT_UNSIGNED)
  71. #define S_SIGNED(P) ((P) |= BT_SIGNED)
  72. #define S_CONST(P) ((P) |= BT_CONST)
  73. #define S_VOLATILE(P) ((P) |= BT_VOLATILE)
  74. #define S_NEAR(P) ((P) |= BT_NEAR)
  75. #define S_FAR(P) ((P) |= BT_FAR)
  76. #define S_HUGE(P) ((P) |= BT_HUGE)
  77. #define S_CDECL(P) ((P) |= BT_CDECL)
  78. #define S_FORTRAN(P) ((P) |= BT_FORTRAN)
  79. #define S_PASCAL(P) ((P) |= BT_PASCAL)
  80. #define S_INTERRUPT(P) ((P) |= BT_INTERRUPT)
  81. #define S_SAVEREGS(P) ((P) |= BT_SAVEREGS)
  82. #define Q_BTYPE(P) ((P) & ( BT_MASK ))
  83. #define S_BTYPE(P,V) ((P) = (((P) & ( ~ BT_MASK )) | V))
  84. struct s_flist { /* formal parameter list of types */
  85. ptype_t fl_type; /* type of formal */
  86. pflist_t fl_next; /* next one */
  87. };
  88. #define FL_NEXT(P) ((P)->fl_next)
  89. #define FL_TYPE(P) ((P)->fl_type)
  90. union u_ivalue {
  91. abnd_t ind_subscr; /* array subscript size */
  92. psym_t ind_formals; /* formal symbol list */
  93. pflist_t ind_flist; /* formal type list */
  94. psym_t ind_basesym; /* segment we're based on */
  95. ptype_t ind_basetype; /* type we're based on */
  96. phln_t ind_baseid; /* id we're based on */
  97. };
  98. #define PIVALUE_ISUB(P) ((P)->ind_subscr)
  99. #define PIVALUE_IFORMALS(P) ((P)->ind_formals)
  100. #define PIVALUE_IFLIST(P) ((P)->ind_flist)
  101. #define PIVALUE_BASEDSYM(P) ((P)->ind_basesym)
  102. #define PIVALUE_BASEDTYPE(P) ((P)->ind_basetype)
  103. #define PIVALUE_BASEDID(P) ((P)->ind_baseid)
  104. #define IVALUE_ISUB(P) (PIVALUE_ISUB(&(P)))
  105. #define IVALUE_IFORMALS(P) (PIVALUE_IFORMALS(&(P)))
  106. #define IVALUE_IFLIST(P) (PIVALUE_IFLIST(&(P)))
  107. #define IVALUE_BASEDSYM(P) (PIVALUE_BASEDSYM(&(P)))
  108. #define IVALUE_BASEDTYPE(P) (PIVALUE_BASEDTYPE(&(P)))
  109. #define IVALUE_BASEDID(P) (PIVALUE_BASEDID(&(P)))
  110. struct s_indir {
  111. btype_t ind_type; /* what kind ? */
  112. pindir_t ind_next; /* next one */
  113. ivalue_t ind_info; /* subscript/function's params */
  114. };
  115. #define INDIR_INEXT(P) ((P)->ind_next)
  116. #define INDIR_ITYPE(P) ((P)->ind_type)
  117. #define INDIR_INFO(P) ((P)->ind_info)
  118. #define INDIR_ISUB(P) (IVALUE_ISUB(INDIR_INFO(P)))
  119. #define INDIR_IFORMALS(P) (IVALUE_IFORMALS(INDIR_INFO(P)))
  120. #define INDIR_IFLIST(P) (IVALUE_IFLIST(INDIR_INFO(P)))
  121. #define INDIR_BASEDSYM(P) (IVALUE_BASEDSYM(INDIR_INFO(P)))
  122. #define INDIR_BASEDTYPE(P) (IVALUE_BASEDTYPE(INDIR_INFO(P)))
  123. #define INDIR_BASEDID(P) (IVALUE_BASEDID(INDIR_INFO(P)))
  124. /*
  125. ** optimal choices for these things.
  126. ** however, everyone uses macros to test them, so if i'm wrong,
  127. ** it should be easy to change the values, but think well !!!
  128. */
  129. #define IN_FUNC 0x00
  130. #define IN_PFUNC 0x01
  131. #define IN_ARRAY 0x02
  132. #define IN_PDATA 0x03
  133. #define IN_VOIDLIST 0x04
  134. #define IN_VARARGS 0x08
  135. #define IN_MASK (IN_ARRAY | IN_PDATA | IN_PFUNC | IN_FUNC)
  136. #define IN_ADDRESS (IN_ARRAY | IN_PDATA | IN_PFUNC)
  137. #define IN_DATA_ADDRESS (IN_ARRAY & IN_PDATA) /* yes, i meant '&' */
  138. #define IN_POINTER (IN_PFUNC & IN_PDATA) /* yes, i meant '&' */
  139. #if IN_DATA_ADDRESS == 0
  140. #error IN_DATA_ADDRESS is ZERO
  141. #endif
  142. #if IN_POINTER == 0
  143. #error IN_POINTER is ZERO
  144. #endif
  145. #define IS_ARRAY(I) (((I) & IN_MASK) == IN_ARRAY)
  146. #define IS_PDATA(I) (((I) & IN_MASK) == IN_PDATA)
  147. #define IS_PFUNC(I) (((I) & IN_MASK) == IN_PFUNC)
  148. #define IS_FUNC(I) (((I) & IN_MASK) == IN_FUNC)
  149. #define IS_EXTRACT(I) ((I) & IN_POINTER)
  150. #define IS_DATA_ADDRESS(I) ((I) & IN_DATA_ADDRESS)
  151. #define IS_ADDRESS(I) ((I) & IN_ADDRESS)
  152. #define IS_INDIR(I) ((I) & IN_MASK)
  153. #define MASK_INDIR(I) ((I) & IN_MASK)
  154. #define IS_VOIDLIST(I) ((I) & IN_VOIDLIST)
  155. #define IS_VARARGS(I) ((I) & IN_VARARGS)
  156. #define IS_NFH(I) ((I) & NFH_MASK)
  157. #define IS_NEARNFH(I) ((I) == BT_NEAR)
  158. #define IS_FARNFH(I) ((I) == BT_FAR)
  159. #define IS_HUGENFH(I) ((I) == BT_HUGE)
  160. #define IS_BASEDNFH(I) ((I) >= BT_BASED)
  161. #define IS_BASEDSELFNFH(I) ((I) == BT_BASEDSELF)
  162. #define IS_BASEDIDNFH(I) ((I) == BT_BASEDID)
  163. #define IS_BASEDSYMNFH(I) ((I) == BT_BASEDSYM)
  164. #define IS_BASEDTYPENFH(I) ((I) == BT_BASEDTYPE)
  165. #define IS_NEAR(I) (IS_NEARNFH(IS_NFH(I)))
  166. #define IS_FAR(I) (IS_FARNFH(IS_NFH(I)))
  167. #define IS_HUGE(I) (IS_HUGENFH(IS_NFH(I)))
  168. #define IS_BASED(I) (IS_BASEDNFH(IS_NFH(I)))
  169. #define IS_BASEDSELF(I) (IS_BASEDSELFNFH(IS_NFH(I)))
  170. #define IS_BASEDID(I) (IS_BASEDIDNFH(IS_NFH(I)))
  171. #define IS_BASEDSYM(I) (IS_BASEDSYMNFH(IS_NFH(I)))
  172. #define IS_BASEDTYPE(I) (IS_BASEDTYPENFH(IS_NFH(I)))
  173. #define IS_INTERRUPT(I) ((I) & BT_INTERRUPT)
  174. #define IS_SAVEREGS(I) ((I) & BT_SAVEREGS)
  175. #define IS_EXPORT(I) ((I) & BT_EXPORT)
  176. #define IS_LOADDS(I) ((I) & BT_LOADDS)
  177. #define IS_CODEMOD(I) ((I) & CODEMOD_MASK)
  178. #define IS_CONST(I) ((I) & BT_CONST)
  179. #define IS_VOLATILE(I) ((I) & BT_VOLATILE)
  180. #define IS_MODIFIED(I) ((I) & (MODIFIER_MASK))
  181. #define ANY_MODIFIER(I) ((I) & (ALL_MODIFIERS))
  182. #define INTERF(I) (MASK_INDIR(I) + (((I) & NFH_MASK) > 4))
  183. #define S_ITYPE(I,V) ((I) = ((I) & ( ~ IN_MASK )) | (V))
  184. #define S_INFH(I,V) ((I) = ((I) & ( ~ NFH_MASK )) | (V))
  185. /*
  186. ** type info for symbols
  187. */
  188. struct s_type {
  189. btype_t ty_bt; /* base type specifiers */
  190. pindir_t ty_indir; /* indirection string */
  191. p1key_t ty_dtype; /* derived type */
  192. psym_t ty_esu; /* enum/structure/union/static defining type */
  193. USHORT ty_index; /* unique index of type for debugger */
  194. };
  195. /*
  196. ** help getting type info. P is pointer to TYPE (struct s_type).
  197. ** TYPE contains the basic type, adjectives and an optional pointer
  198. ** to a symbol which is an enumeration, structure, union which is the type
  199. ** of this TYPE.
  200. */
  201. #define TY_BTYPE(P) ((P)->ty_bt) /* basic type */
  202. #define TY_DTYPE(P) ((P)->ty_dtype) /* derived type */
  203. #define TY_ESU(P) ((P)->ty_esu) /* ptr to parent enum/struct/union */
  204. #define TY_INDIR(P) ((P)->ty_indir) /* indirection string */
  205. #define TY_TINDEX(P) ((P)->ty_index) /* type index */
  206. #define TY_INEXT(P) (INDIR_INEXT(TY_INDIR(P)))
  207. #define TY_ITYPE(P) (INDIR_ITYPE(TY_INDIR(P)))
  208. #define TY_ISUB(P) (INDIR_ISUB(TY_INDIR(P)))
  209. #define TY_IFORMALS(P) (INDIR_IFORMALS(TY_INDIR(P)))
  210. #define TY_IFLIST(P) (INDIR_IFLIST(TY_INDIR(P)))
  211. typedef struct s_indir_entry indir_entry_t;
  212. typedef struct s_type_entry type_entry_t;
  213. struct s_indir_entry {
  214. indir_entry_t *ind_next;
  215. indir_t ind_type;
  216. };
  217. struct s_type_entry {
  218. type_entry_t *te_next;
  219. type_t te_type;
  220. };
  221. #define TYPE_TABLE_SIZE 0x100
  222. #define INDIR_TABLE_SIZE 0x040
  223. /*
  224. ** HASH_MASK : is a value which consists of the bits in common
  225. ** between upper and lower case. we mask each char we read with this
  226. ** to sum them for a hash value. we do this so that all names consisting
  227. ** of the same chars (case insensitive), will hash to the same location.
  228. */
  229. #define HASH_MASK 0x5f
  230. #define DATASEGMENT 0
  231. #define TEXTSEGMENT 1
  232.