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.

172 lines
6.1 KiB

  1. /*
  2. ** Tree types
  3. */
  4. #define TTfree 0x0
  5. #define TTconstant 0x01
  6. #define TTsymbol 0x02
  7. #define TTunary 0x04
  8. #define TTleaf 0x08
  9. #define TTbinary 0x10
  10. #define TThybrid 0x20
  11. #define TTBasicShape (TTfree|TTconstant|TTsymbol|TTunary|TTbinary|TThybrid)
  12. #define TTzero 0x40
  13. typedef USHORT p2type_t;
  14. typedef p2type_t *pp2type_t;
  15. typedef struct tree_200 {
  16. ptree_t tr_left; /* left child */
  17. ptree_t tr_right; /* right child */
  18. } tree_200_st;
  19. typedef struct tree_190 {
  20. ptree_t tr_uchild; /* unary child */
  21. } tree_190_st;
  22. typedef struct tree_180 {
  23. psym_t tr_symbol; /* symbol */
  24. } tree_180_st;
  25. typedef struct tree_170 {
  26. value_t tr_value; /* value of the tree */
  27. } tree_170_st;
  28. typedef union tree_100 {
  29. tree_200_st t200;
  30. tree_190_st t190;
  31. tree_180_st t180;
  32. tree_170_st t170;
  33. } tree_100_st;
  34. struct s_tree {
  35. token_t tr_token; /* tree's token */
  36. shape_t tr_shape; /* tree shape */
  37. ptype_t tr_p1type; /* p1's view of the type */
  38. p2type_t tr_p2type; /* p1's view of the type p2 should have */
  39. tree_100_st t100;
  40. };
  41. #define TR_SHAPE(P) ((P)->tr_shape)
  42. #define BASIC_SHAPE(S) ((S) & TTBasicShape)
  43. #define TR_TOKEN(P) ((P)->tr_token)
  44. #define TR_P1TYPE(P) ((P)->tr_p1type) /* resultant type */
  45. #define TR_P2TYPE(P) ((P)->tr_p2type) /* resultant type */
  46. #define TR_ISZERO(P) (TR_SHAPE(P) & TTzero)
  47. #define TR_LEFT(P) ((P)->t100.t200.tr_left) /* left child */
  48. #define TR_RIGHT(P) ((P)->t100.t200.tr_right) /* right child */
  49. #define TR_UCHILD(P) ((P)->t100.t190.tr_uchild) /* unary's child */
  50. #define TR_SVALUE(P) ((P)->t100.t180.tr_symbol) /* ptr to the symbol */
  51. #define TR_VALUE(P) ((P)->t100.t170.tr_value) /* value of tree */
  52. #define TR_RCON(P) (TR_VALUE(P).v_rcon) /* real constant */
  53. #define TR_DVALUE(P) (TR_RCON(P)->rcon_real) /* double value */
  54. #define TR_LVALUE(P) (TR_VALUE(P).v_long) /* long value */
  55. #define TR_STRING(P) (TR_VALUE(P).v_string) /* string value */
  56. #define TR_CVALUE(P) (TR_STRING(P).str_ptr) /* ptr to string */
  57. #define TR_CLEN(P) (TR_STRING(P).str_len) /* length of string */
  58. #define TR_BTYPE(P) (TY_BTYPE(TR_P1TYPE(P)))/* base type */
  59. #define TR_ESU(P) (TY_ESU(TR_P1TYPE(P))) /* parent enum/struct/union */
  60. #define TR_INDIR(P) (TY_INDIR(TR_P1TYPE(P)))
  61. #define TR_INEXT(P) (INDIR_INEXT(TR_INDIR(P)))
  62. #define TR_ITYPE(P) (INDIR_ITYPE(TR_INDIR(P)))
  63. #define TR_ISUB(P) (INDIR_ISUB(TR_INDIR(P)))
  64. #define TR_IFORMALS(P) (INDIR_IFORMALS(TR_INDIR(P)))
  65. /*
  66. ** for cases
  67. */
  68. struct s_case {
  69. case_t *c_next; /* next in list */
  70. long c_expr; /* value of constant expression */
  71. p1key_t c_label; /* label to which to jump if expr */
  72. };
  73. #define NEXT_CASE(p) ((p)->c_next)
  74. #define CASE_EXPR(p) ((p)->c_expr)
  75. #define CASE_LABEL(p) ((p)->c_label)
  76. /*
  77. ** loop inversion structs
  78. ** for( init; test; incr ) { ... }
  79. ** we handle : sym | const relop sym | const; sym op sym | const
  80. */
  81. typedef struct s_loopia loopia_t, *loopiap_t;
  82. typedef struct s_liarray liarray_t, *liarrayp_t;
  83. struct s_loopia {
  84. token_t lia_token;
  85. union {
  86. psym_t lia_sym;
  87. long lia_value;
  88. liarrayp_t lia_array;
  89. } lia_union;
  90. };
  91. #define LIA_TOKEN(p) ((p)->lia_token)
  92. #define LIA_SYM(p) ((p)->lia_union.lia_sym)
  93. #define LIA_VALUE(p) ((p)->lia_union.lia_value)
  94. #define LIA_ARRAY(p) ((p)->lia_union.lia_array)
  95. typedef struct s_liarray {
  96. loopia_t liar_left;
  97. loopia_t liar_right;
  98. } liarray;
  99. #define LIAR_LEFT(p) (&((p)->liar_left))
  100. #define LIAR_RIGHT(p) (&((p)->liar_right))
  101. typedef struct s_loopi {
  102. int li_relop;
  103. int li_incop;
  104. loopia_t li_w;
  105. loopia_t li_x;
  106. loopia_t li_y;
  107. loopia_t li_z;
  108. } loopi_t, *loopip_t;
  109. #define LOOP_RELOP(p) ((p)->li_relop)
  110. #define LOOP_INCOP(p) ((p)->li_incop)
  111. #define LOOP_W(p) (&((p)->li_w))
  112. #define LOOP_X(p) (&((p)->li_x))
  113. #define LOOP_Y(p) (&((p)->li_y))
  114. #define LOOP_Z(p) (&((p)->li_z))
  115. #define LOOP_W_TOKEN(p) LIA_TOKEN(LOOP_W(p))
  116. #define LOOP_X_TOKEN(p) LIA_TOKEN(LOOP_X(p))
  117. #define LOOP_Y_TOKEN(p) LIA_TOKEN(LOOP_Y(p))
  118. #define LOOP_Z_TOKEN(p) LIA_TOKEN(LOOP_Z(p))
  119. #define LOOP_W_SYM(p) LIA_SYM(LOOP_W(p))
  120. #define LOOP_X_SYM(p) LIA_SYM(LOOP_X(p))
  121. #define LOOP_Y_SYM(p) LIA_SYM(LOOP_Y(p))
  122. #define LOOP_Z_SYM(p) LIA_SYM(LOOP_Z(p))
  123. #define LOOP_W_VALUE(p) LIA_VALUE(LOOP_W(p))
  124. #define LOOP_X_VALUE(p) LIA_VALUE(LOOP_X(p))
  125. #define LOOP_Y_VALUE(p) LIA_VALUE(LOOP_Y(p))
  126. #define LOOP_Z_VALUE(p) LIA_VALUE(LOOP_Z(p))
  127. /*
  128. ** stack structure for saving items which must be stacked at various places
  129. */
  130. struct s_stack {
  131. stack_t *stk_next;
  132. union {
  133. ptree_t sv_tree;
  134. psym_t sv_sym;
  135. int sv_int;
  136. loopip_t sv_loopi;
  137. } stk_value;
  138. };
  139. #define TEST_LAB (Test->stk_value.sv_tree)
  140. #define START_LAB (Start->stk_value.sv_tree)
  141. #define CONTINUE_LAB (Continue->stk_value.sv_tree)
  142. #define BREAK_LAB (Break->stk_value.sv_tree)
  143. #define CA_LAB (Case->stk_value.sv_tree)
  144. #define DEFAULT_LAB (Default->stk_value.sv_tree)
  145. #define LOOPI(p) ((p)->stk_value.sv_loopi)