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.

333 lines
7.9 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. walkctxt.hxx
  5. Abstract:
  6. types for walking the whole typegraph
  7. Notes:
  8. Author:
  9. GregJen Oct-27-1993 Created.
  10. Notes:
  11. ----------------------------------------------------------------------------*/
  12. #ifndef __WALKCTXT_HXX__
  13. #define __WALKCTXT_HXX__
  14. /****************************************************************************
  15. * include files
  16. ***************************************************************************/
  17. #include "listhndl.hxx"
  18. #include "midlnode.hxx"
  19. #include "attrlist.hxx"
  20. #include "nodeskl.hxx"
  21. #include "attrnode.hxx"
  22. #include "fldattr.hxx"
  23. #include "ndrtypes.h"
  24. /****************************************************************************
  25. * local data
  26. ***************************************************************************/
  27. /****************************************************************************
  28. * externs
  29. ***************************************************************************/
  30. /****************************************************************************
  31. * definitions
  32. ***************************************************************************/
  33. class node_interface;
  34. class type_node_list;
  35. class ATTRLIST;
  36. //
  37. // the special iterator for attribute lists during context walks
  38. //
  39. class ATTR_ITERATOR
  40. {
  41. private:
  42. ATTR_SUMMARY Summary;
  43. ATTR_POINTER_VECTOR AllAttrs;
  44. gplistmgr RedundantAttrExtras[ REDUNDANT_ATTR_END + 1 ];
  45. public:
  46. ATTR_ITERATOR()
  47. {
  48. CLEAR_ATTR( Summary );
  49. memset( AllAttrs, 0, sizeof( ATTR_POINTER_VECTOR ) );
  50. }
  51. void ExtractFieldAttributes( FIELD_ATTR_INFO * );
  52. node_base_attr * ExtractAttribute( ATTR_T );
  53. node_base_attr * GetAttribute( ATTR_T );
  54. BOOL FInSummary( ATTR_T Attr )
  55. {
  56. return (NULL != AllAttrs[ Attr ]);
  57. }
  58. void Add( node_base_attr * pAttr )
  59. {
  60. ATTR_T Attr = pAttr->GetAttrID();
  61. if ( !AllAttrs[ Attr ] )
  62. AllAttrs[ Attr ] = pAttr;
  63. else
  64. AddRedundantAttr( pAttr );
  65. SET_ATTR( Summary, Attr );
  66. }
  67. void ClearAttributes()
  68. {
  69. CLEAR_ATTR( Summary );
  70. memset( AllAttrs, 0, sizeof( ATTR_POINTER_VECTOR ) );
  71. memset( RedundantAttrExtras, 0, sizeof( RedundantAttrExtras ) );
  72. }
  73. BOOL HasAttributes()
  74. {
  75. return !IS_CLEAR_ATTR( Summary );
  76. }
  77. ATTR_VECTOR * GetSummary()
  78. {
  79. return &Summary;
  80. }
  81. private:
  82. void AddRedundantAttr( node_base_attr * pAttr )
  83. {
  84. ATTR_T Attr = pAttr->GetAttrID();
  85. RedundantAttrExtras[ Attr ].Insert( pAttr );
  86. }
  87. };
  88. //
  89. // the tree walk context base class
  90. //
  91. class WALK_CTXT;
  92. class WALK_CTXT
  93. {
  94. protected:
  95. node_skl * pParent;
  96. WALK_CTXT * pParentCtxt;
  97. WALK_CTXT * pIntfCtxt;
  98. ATTR_ITERATOR * pDownAttrList;
  99. BOOL GotImportantPosn;
  100. public:
  101. // use this to make one without a parent context
  102. WALK_CTXT( node_skl * pPar = NULL)
  103. {
  104. pParent = pPar;
  105. pParentCtxt = NULL;
  106. pIntfCtxt = NULL;
  107. GotImportantPosn = FALSE;
  108. // allocate the topmost attributes structure
  109. pDownAttrList = new ATTR_ITERATOR;
  110. // attribute stuff goes here...
  111. if ( pPar && pPar->HasAttributes() )
  112. {
  113. AddAttributes( (named_node *) pPar );
  114. }
  115. }
  116. // use this to make one with info from a parent context
  117. WALK_CTXT( node_skl * pPar, WALK_CTXT * pCtxt)
  118. {
  119. pParent = pPar;
  120. pParentCtxt = pCtxt;
  121. pIntfCtxt = pCtxt->pIntfCtxt;
  122. GotImportantPosn = pCtxt->GotImportantPosn;
  123. pDownAttrList = pCtxt->pDownAttrList;
  124. // attribute stuff goes here...
  125. if ( pPar && pPar->HasAttributes() )
  126. {
  127. AddAttributes( (named_node *) pPar );
  128. }
  129. }
  130. // use this to make one with info from a parent context
  131. // that also corresponds to this node
  132. WALK_CTXT( WALK_CTXT * pCtxt)
  133. {
  134. pParent = pCtxt->GetParent();
  135. pParentCtxt = pCtxt;
  136. pIntfCtxt = pCtxt->pIntfCtxt;
  137. GotImportantPosn = pCtxt->GotImportantPosn;
  138. pDownAttrList = pCtxt->pDownAttrList;
  139. }
  140. // Get and Set functions
  141. node_skl * GetParent()
  142. {
  143. return pParent;
  144. }
  145. node_skl * SetParent( node_skl * pPar )
  146. {
  147. return ( pParent = pPar );
  148. }
  149. WALK_CTXT * GetParentContext()
  150. {
  151. return pParentCtxt;
  152. }
  153. WALK_CTXT * SetParentContext( WALK_CTXT * pParCtxt )
  154. {
  155. return ( pParentCtxt = pParCtxt );
  156. }
  157. WALK_CTXT * GetInterfaceContext()
  158. {
  159. return pIntfCtxt;
  160. }
  161. node_interface * GetInterfaceNode()
  162. {
  163. return (node_interface *) pIntfCtxt->pParent;
  164. }
  165. void MarkImportantPosition()
  166. {
  167. GotImportantPosn = TRUE;
  168. }
  169. void UnMarkImportantPosition()
  170. {
  171. GotImportantPosn = FALSE;
  172. }
  173. BOOL IsImportantPosition()
  174. {
  175. return GotImportantPosn;
  176. }
  177. void FindImportantPosition(tracked_node & Posn);
  178. // establish a new interface context for this node; new clean attr list
  179. WALK_CTXT * SetInterfaceContext( WALK_CTXT * pCtxt )
  180. {
  181. pDownAttrList = new ATTR_ITERATOR();
  182. return ( pIntfCtxt = pCtxt );
  183. }
  184. // find the first ancestor context of the designated kind
  185. WALK_CTXT * FindAncestorContext( NODE_T Kind );
  186. // find the first non typedef ancestor context
  187. WALK_CTXT * FindNonDefAncestorContext();
  188. // find an ancestor context containing myself
  189. WALK_CTXT * FindRecursiveContext( node_skl * self );
  190. // for my context, find the appropriate pointer kind ( and extract it if needed )
  191. PTRTYPE GetPtrKind( BOOL * pfExplicitPtrAttr = NULL );
  192. // get all the operation bits (MAYBE, IDEMPOTENT, BROADCAST, etc.
  193. unsigned short GetOperationBits();
  194. // these functions maintain the attribute list and summary together
  195. // note: multiple field attrs & summary
  196. void ExtractFieldAttributes( FIELD_ATTR_INFO * pFA )
  197. {
  198. pDownAttrList->ExtractFieldAttributes( pFA );
  199. }
  200. node_base_attr * ExtractAttribute( ATTR_T At )
  201. {
  202. return pDownAttrList->ExtractAttribute( At );
  203. }
  204. node_base_attr * GetAttribute( ATTR_T At )
  205. {
  206. return pDownAttrList->GetAttribute( At );
  207. }
  208. node_base_attr * AttrInSummary( ATTR_T At )
  209. {
  210. return ExtractAttribute( At );
  211. }
  212. BOOL FInSummary( ATTR_T Attr )
  213. {
  214. return pDownAttrList->FInSummary( Attr );
  215. }
  216. void AddAttributes( named_node * );
  217. void ProcessDuplicates( node_base_attr * );
  218. void ClearAttributes()
  219. {
  220. pDownAttrList->ClearAttributes();
  221. }
  222. BOOL HasAttributes()
  223. {
  224. return ( pDownAttrList->HasAttributes() );
  225. }
  226. void Add( node_base_attr * pAttr )
  227. {
  228. pDownAttrList->Add(pAttr);
  229. }
  230. /**************************************************
  231. here are the typical functions that would be used to do
  232. up and down propogation of context info
  233. // used to move values from the child context
  234. // up into the current context
  235. virtual
  236. void ReturnValues( WALK_CTXT * pChildCtxt )
  237. {
  238. }
  239. // used to move values from the current context
  240. // down into the child context
  241. virtual
  242. void PassValues( WALK_CTXT * pParentCtxt )
  243. {
  244. }
  245. **********************************************************/
  246. };
  247. // prototype for semantic error routines
  248. extern void
  249. SemError( node_skl *, WALK_CTXT &, STATUS_T, char * );
  250. #endif // __WALKCTXT_HXX__