Source code of Windows XP (NT5)
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.

3397 lines
101 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #ifndef __NODESKL_HXX__
  3. #define __NODESKL_HXX__
  4. #pragma warning ( disable : 4710 4706 )
  5. #include "common.hxx"
  6. #include "errors.hxx"
  7. #include "midlnode.hxx"
  8. #include "symtable.hxx"
  9. #include "symtable.hxx"
  10. #include "stream.hxx"
  11. #include "prttype.hxx"
  12. #include "expr.hxx"
  13. #include "attrlist.hxx"
  14. #include "linenum.hxx"
  15. #include "freelist.hxx"
  16. class node_guid;
  17. /***
  18. *** Here is the class hierarcy for the typegraph nodes.
  19. *** (last updated 6/22/95)
  20. ***/
  21. /*
  22. node_skl
  23. named_node \\nodes with siblings and names and attributes
  24. node_base_type
  25. node_def
  26. node_def_fe
  27. node_e_status_t
  28. node_echo_string
  29. node_pragma_pack
  30. node_field
  31. node_bitfield
  32. node_file
  33. node_forward
  34. node_href
  35. node_id
  36. node_id_fe \\ front-end version of node_id
  37. node_interface
  38. node_coclass
  39. node_dispinterface
  40. node_libarary
  41. node_module
  42. node_pipe_object
  43. node_interface_reference
  44. node_label
  45. node_param
  46. node_proc
  47. node_su_base
  48. node_enum
  49. node_struct
  50. node_en_struct
  51. node_union
  52. node_en_union
  53. node_wchar_t
  54. node_error
  55. node_source
  56. npa_nodes
  57. node_array
  58. node_pointer
  59. node_safearray
  60. */
  61. /***
  62. *** The base node type all the nodes in the typegraph are derived from.
  63. *** This is a virtual class; there are no nodes directly of this type.
  64. *** It is used to describe the routines used to walk the typegraph.
  65. ***/
  66. // forward class declarations
  67. class CG_CLASS;
  68. class XLAT_CTXT;
  69. class SEM_ANALYSIS_CTXT;
  70. class node_interface;
  71. class node_file;
  72. class gplistmgr;
  73. extern unsigned short CurrentIntfKey;
  74. enum TypeSet
  75. {
  76. ts_UnsignedFixedPoint,
  77. ts_FixedPoint,
  78. ts_FloatingPoint,
  79. ts_Character,
  80. ts_String,
  81. ts_Interface,
  82. };
  83. class MODIFIER_SET
  84. {
  85. private:
  86. unsigned _int64 ModifierBits; // Modifier bits
  87. unsigned short Align; // alignment from __declspec(align(N))
  88. char * pUnknownTxt; // Text for unknown __declspec"
  89. public:
  90. BOOL IsFlagAModifier(ATTR_T flag) const;
  91. BOOL IsModifierSet(ATTR_T flag) const;
  92. BOOL AnyModifiersSet() const;
  93. void SetModifier(ATTR_T flag);
  94. void ClearModifier(ATTR_T flag);
  95. void SetDeclspecAlign( unsigned short NewAlign);
  96. unsigned short GetDeclspecAlign() const;
  97. void SetDeclspecUnknown(char *pNewUnknownTxt);
  98. char *GetDeclspecUnknown() const;
  99. void Clear();
  100. void Merge(const MODIFIER_SET & MergeModifierSet);
  101. void PrintDebugInfo() const;
  102. };
  103. class INITIALIZED_MODIFIER_SET : public MODIFIER_SET
  104. {
  105. public:
  106. INITIALIZED_MODIFIER_SET() {Clear();}
  107. INITIALIZED_MODIFIER_SET( ATTR_T flag ) {Clear(); SetModifier( flag );}
  108. };
  109. struct FRONT_MEMORY_INFO
  110. {
  111. unsigned long Size; // Size of the item
  112. unsigned short Align; // Required memory alignment
  113. BOOL IsMustAlign; // Has __declspec(align())
  114. FRONT_MEMORY_INFO()
  115. : Size(0),
  116. Align(1),
  117. IsMustAlign(FALSE)
  118. {
  119. }
  120. FRONT_MEMORY_INFO(unsigned long NewSize, unsigned short NewAlign, BOOL NewIsMustAlign)
  121. : Size(NewSize),
  122. Align(NewAlign),
  123. IsMustAlign(NewIsMustAlign)
  124. {
  125. }
  126. void Init(unsigned long NewSize, unsigned short NewAlign, BOOL NewIsMustAlign )
  127. {
  128. Size = NewSize; Align = NewAlign; IsMustAlign = NewIsMustAlign;
  129. }
  130. };
  131. class node_skl
  132. {
  133. private:
  134. node_skl * pChild;
  135. node_file * pTLBFile;
  136. // ISSUE-2000/08/03-mikew
  137. // The ia64 compiler is optimizing bitfields badly. The C guys said
  138. // it will be fixed in the next drop.
  139. #ifdef IA64
  140. unsigned long Kind ;// : 8;
  141. protected:
  142. unsigned long MiscBits ;// : 8; // this field should be cleared by any
  143. // class that uses it
  144. private:
  145. unsigned long IntfKey ;// : 16;
  146. #else // !IA64
  147. unsigned long Kind : 8;
  148. protected:
  149. unsigned long MiscBits : 8; // this field should be cleared by any
  150. // class that uses it
  151. private:
  152. unsigned long IntfKey : 16;
  153. #endif
  154. INITIALIZED_MODIFIER_SET ModiferSet;
  155. public:
  156. node_skl( )
  157. {
  158. Kind = (unsigned long) NODE_ILLEGAL;
  159. pChild = NULL;
  160. IntfKey = CurrentIntfKey;
  161. pTLBFile = NULL;
  162. }
  163. node_skl( NODE_T NodeKind, node_skl * pCh = NULL)
  164. {
  165. Kind = (unsigned long) NodeKind;
  166. pChild = pCh;
  167. IntfKey = CurrentIntfKey;
  168. pTLBFile = NULL;
  169. }
  170. // lightweight version for backend use
  171. node_skl( node_skl * pCh, NODE_T NodeKind )
  172. {
  173. Kind = (unsigned long) NodeKind;
  174. pChild = pCh;
  175. IntfKey = 0;
  176. pTLBFile = NULL;
  177. }
  178. virtual unsigned long
  179. GetInterfaceKey() { return IntfKey; };
  180. virtual void
  181. SetInterfaceKey( unsigned long uIntfKey ) { IntfKey = uIntfKey; };
  182. node_skl * GetChild()
  183. {
  184. return pChild;
  185. }
  186. node_skl * SetChild(node_skl * pCh)
  187. {
  188. return pChild = pCh;
  189. }
  190. node_skl * GetBasicType();
  191. node_skl * GetNonDefChild()
  192. {
  193. node_skl * p = pChild;
  194. while ( p && p->NodeKind() == NODE_DEF )
  195. p = p->GetChild();
  196. return p;
  197. }
  198. node_skl * GetNonDefSelf()
  199. {
  200. node_skl * p = this;
  201. while ( p->NodeKind() == NODE_DEF )
  202. p = p->GetChild();
  203. return p;
  204. }
  205. node_skl * SetBasicType(node_skl * pBT)
  206. {
  207. return pChild = pBT;
  208. };
  209. NODE_T NodeKind()
  210. {
  211. return (NODE_T) Kind;
  212. };
  213. node_interface *GetMyInterfaceNode();
  214. virtual
  215. node_file * GetDefiningFile();
  216. virtual
  217. BOOL IsStringableType()
  218. {
  219. return FALSE;
  220. }
  221. node_file * GetDefiningTLB()
  222. {
  223. return pTLBFile;
  224. }
  225. void SetDefiningTLB(node_file *p)
  226. {
  227. pTLBFile = p;
  228. }
  229. inline // see sneaky definition for this below named_node
  230. char * GetSymName();
  231. inline // see sneaky definition for this below named_node
  232. char * GetCurrentSpelling();
  233. MODIFIER_SET & GetModifiers() { return ModiferSet;}
  234. BOOL IsDef()
  235. {
  236. return ! GetModifiers().IsModifierSet(ATTR_TAGREF);
  237. };
  238. void SetEdgeType( EDGE_T Et )
  239. {
  240. if (Et == EDGE_USE)
  241. {
  242. GetModifiers().SetModifier( ATTR_TAGREF );
  243. };
  244. };
  245. virtual
  246. BOOL FInSummary( ATTR_T )
  247. {
  248. return FALSE;
  249. };
  250. virtual
  251. BOOL HasAttributes()
  252. {
  253. return FALSE;
  254. }
  255. virtual
  256. BOOL IsEncapsulatedStruct()
  257. {
  258. return FALSE;
  259. }
  260. virtual
  261. BOOL IsEncapsulatedUnion()
  262. {
  263. return FALSE;
  264. }
  265. virtual
  266. BOOL IsPtrOrArray()
  267. {
  268. return FALSE;
  269. }
  270. virtual
  271. BOOL IsStructOrUnion()
  272. {
  273. return FALSE;
  274. }
  275. virtual
  276. BOOL IsBasicType()
  277. {
  278. return FALSE;
  279. }
  280. // virtual
  281. // bool IsCompatibleType( TypeSet )
  282. // {
  283. // return FALSE;
  284. // }
  285. virtual
  286. BOOL IsInterfaceOrObject()
  287. {
  288. return FALSE;
  289. }
  290. FRONT_MEMORY_INFO AdjustMemoryInfoForModifiers(FRONT_MEMORY_INFO OrigInfo);
  291. // For use by classes that just use the child memory size modified with
  292. // modifiers.
  293. FRONT_MEMORY_INFO GetModifiedMemoryInfoFromChild();
  294. FRONT_MEMORY_INFO GetInvalidMemoryInfo();
  295. virtual
  296. FRONT_MEMORY_INFO GetMemoryInfo() = 0;
  297. unsigned long GetSize()
  298. {
  299. return GetMemoryInfo().Size;
  300. }
  301. unsigned short GetAlign()
  302. {
  303. return GetMemoryInfo().Align;
  304. }
  305. BOOL IsMustAlign()
  306. {
  307. return GetMemoryInfo().IsMustAlign;
  308. }
  309. virtual
  310. void PrintMemoryInfo(ISTREAM *pStream, BOOL bNewLine);
  311. virtual
  312. EXPR_VALUE ConvertMyKindOfValueToEXPR_VALUE( EXPR_VALUE value )
  313. {
  314. return value;
  315. }
  316. virtual
  317. void GetPositionInfo( tracked_node& )
  318. {
  319. }
  320. virtual
  321. STATUS_T DoPrintType( PRTFLAGS ,
  322. BufferManager * ,
  323. ISTREAM * ,
  324. node_skl * ,
  325. node_skl * )
  326. {
  327. return STATUS_OK;
  328. };
  329. virtual
  330. STATUS_T DoPrintDecl( PRTFLAGS ,
  331. BufferManager * ,
  332. ISTREAM * ,
  333. node_skl * ,
  334. node_skl * )
  335. {
  336. return STATUS_OK;
  337. };
  338. STATUS_T PrintType(PRTFLAGS Flags,
  339. ISTREAM * pStream,
  340. node_skl * pParent = NULL,
  341. node_skl * pIntf = NULL);
  342. void EmitModifiers( BufferManager *, bool fSuppressConst);
  343. void EmitProcModifiers( BufferManager *, PRTFLAGS );
  344. void EmitModelModifiers( BufferManager *);
  345. virtual void EmitPtrModifiers( BufferManager *, unsigned long ulFlags = 0 );
  346. void CheckDeclspecAlign( SEM_ANALYSIS_CTXT & MyContext );
  347. virtual
  348. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  349. virtual
  350. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  351. void * operator new ( size_t size )
  352. {
  353. return AllocateOnceNew( size );
  354. }
  355. void operator delete( void * ptr )
  356. {
  357. AllocateOnceDelete( ptr );
  358. }
  359. virtual
  360. node_skl* GetDuplicateGuid (
  361. node_guid*,
  362. SymTable*
  363. );
  364. // returns true if context_handle attribute is present
  365. // semantic checks for context handle
  366. virtual bool CheckContextHandle( SEM_ANALYSIS_CTXT& );
  367. }; // end of class node_skl
  368. /***
  369. *** Here are the direct descendents of node_skl; nodes with symtab entries
  370. *** and nodes without them
  371. ***/
  372. // named nodes that can be on a list (have siblings)
  373. class named_node : public node_skl
  374. {
  375. private:
  376. char * pName;
  377. char * pCurrentSpelling;
  378. class named_node *pSibling;
  379. class ATTRLIST AttrList; // attributes dangle from here
  380. protected:
  381. unsigned int fBeingAnalyzed : 1;
  382. public:
  383. // lightweight version for backend use
  384. named_node( char * psz, NODE_T Kind )
  385. : node_skl( NULL, Kind ),
  386. fBeingAnalyzed( FALSE )
  387. {
  388. pCurrentSpelling =
  389. pName = psz;
  390. pSibling = NULL;
  391. AttrList.MakeAttrList();
  392. };
  393. named_node( NODE_T Kind, char * psz = NULL)
  394. : node_skl( Kind, NULL ),
  395. fBeingAnalyzed( FALSE )
  396. {
  397. pCurrentSpelling =
  398. pName = psz;
  399. pSibling = NULL;
  400. AttrList.MakeAttrList();
  401. };
  402. // convert constructor (for node_id to other named_node)
  403. named_node( NODE_T Kind, class named_node * pID )
  404. : node_skl( Kind, pID->GetChild() ),
  405. fBeingAnalyzed( FALSE )
  406. {
  407. pCurrentSpelling =
  408. pName = pID->pName;
  409. pSibling = pID->pSibling;
  410. AttrList = pID->AttrList;
  411. GetModifiers() = pID->GetModifiers();
  412. };
  413. virtual void CopyAttributes( named_node* pNode )
  414. {
  415. AttrList = pNode->AttrList.Clone();
  416. // Clone reverses the order of the list. Fix it.
  417. AttrList.Reverse();
  418. }
  419. char * SetCurrentSpelling(char * sz)
  420. {
  421. return pCurrentSpelling = sz;
  422. };
  423. char * SetSymName(char * psz)
  424. {
  425. return pName = psz;
  426. };
  427. class named_node * GetSibling()
  428. {
  429. return pSibling;
  430. };
  431. class named_node * SetSibling(named_node * pSib)
  432. {
  433. return pSibling = pSib;
  434. };
  435. void SetAttributes( ATTRLIST & AList )
  436. {
  437. AttrList = AList;
  438. };
  439. void SetAttribute( ATTR_T bit )
  440. {
  441. AttrList.Add( bit );
  442. };
  443. void SetAttribute( node_base_attr * attr )
  444. {
  445. AttrList.Add( attr );
  446. };
  447. void AddAttributes( ATTRLIST & AList )
  448. {
  449. AttrList.Merge( AList );
  450. };
  451. void RemoveAttribute( ATTR_T atrib )
  452. {
  453. AttrList.Remove( atrib );
  454. };
  455. node_base_attr * GetAttribute( ATTR_T flag )
  456. {
  457. return AttrList.GetAttribute( flag );
  458. };
  459. ATTRLIST & GetAttributeList( ATTRLIST & AList )
  460. {
  461. return (AList = AttrList);
  462. }
  463. void GetAttributeList( type_node_list * AList )
  464. {
  465. AttrList.GetAttributeList( AList );
  466. }
  467. void DumpAttributes( ISTREAM * pStream );
  468. virtual
  469. BOOL HasAttributes()
  470. {
  471. return AttrList.NonNull();
  472. }
  473. BOOL FInSummary( ATTR_T flag )
  474. {
  475. BOOL result;
  476. if ( GetModifiers().IsFlagAModifier(flag) )
  477. {
  478. result = GetModifiers().IsModifierSet( flag );
  479. }
  480. else
  481. {
  482. result = AttrList.FInSummary( flag );
  483. }
  484. return result;
  485. };
  486. BOOL FMATTRInSummary( MATTR_T flag)
  487. {
  488. return AttrList.FMATTRInSummary(flag);
  489. };
  490. BOOL FTATTRInSummary( TATTR_T flag)
  491. {
  492. return AttrList.FTATTRInSummary(flag);
  493. };
  494. BOOL IsNamedNode();
  495. virtual
  496. node_file * GetFileNode()
  497. {
  498. return NULL;
  499. }
  500. virtual
  501. node_file * SetFileNode(node_file *)
  502. {
  503. return NULL;
  504. }
  505. virtual char*
  506. GetDeclSpecGuid();
  507. // to allow the below GetSymName to work
  508. friend class node_skl;
  509. }; // end of class named_node
  510. inline
  511. char *
  512. node_skl::GetCurrentSpelling()
  513. {
  514. if ( IS_NAMED_NODE(NodeKind()) )
  515. {
  516. return ((named_node *)this)->pCurrentSpelling;
  517. }
  518. else
  519. {
  520. return "";
  521. }
  522. }
  523. inline
  524. char *
  525. node_skl::GetSymName()
  526. {
  527. if ( IS_NAMED_NODE(NodeKind()) )
  528. {
  529. return ((named_node *)this)->pName;
  530. }
  531. else
  532. {
  533. return "";
  534. }
  535. }
  536. class SIBLING_LIST;
  537. class MEMLIST
  538. {
  539. protected:
  540. named_node * pMembers;
  541. public:
  542. MEMLIST( named_node * pHead = NULL)
  543. {
  544. pMembers = pHead;
  545. };
  546. MEMLIST( MEMLIST * pList )
  547. {
  548. *this = *pList;
  549. };
  550. void SetMembers( SIBLING_LIST & MemList );
  551. STATUS_T GetMembers( class type_node_list * MemList );
  552. node_skl * GetFirstMember()
  553. {
  554. return pMembers;
  555. }
  556. void SetFirstMember( named_node * pNode )
  557. {
  558. pMembers = pNode;
  559. }
  560. short GetNumberOfArguments();
  561. void AddLastMember( named_node * pNode );
  562. void RemoveLastMember();
  563. void AddFirstMember( named_node * pNode )
  564. {
  565. pNode->SetSibling( pMembers );
  566. pMembers = pNode;
  567. }
  568. void RemoveFirstMember()
  569. {
  570. if (pMembers) pMembers = pMembers->GetSibling();
  571. }
  572. void AddSecondMember( named_node* pNode );
  573. void MergeMembersToTail( SIBLING_LIST & MemList );
  574. void MergeMembersToTail( MEMLIST & ML )
  575. {
  576. AddLastMember( ML.pMembers );
  577. }
  578. void MergeMembersToHead( MEMLIST & ML )
  579. {
  580. ML.MergeMembersToTail( *this );
  581. pMembers = ML.pMembers;
  582. }
  583. };
  584. class MEM_ITER : public MEMLIST
  585. {
  586. private:
  587. named_node * pCur;
  588. public:
  589. MEM_ITER( MEMLIST * pList )
  590. : MEMLIST( pList )
  591. {
  592. pCur = pMembers;
  593. }
  594. named_node * GetNext()
  595. {
  596. named_node * Ret = pCur;
  597. pCur = (pCur) ? pCur->GetSibling() : NULL;
  598. return Ret;
  599. }
  600. void Init()
  601. {
  602. pCur = pMembers;
  603. }
  604. };
  605. // identifiers
  606. class node_id : public named_node
  607. {
  608. public:
  609. expr_node * pInit;
  610. // lightweight version for backend
  611. node_id( char * pNewName)
  612. : named_node( pNewName, NODE_ID )
  613. {
  614. pInit = NULL;
  615. };
  616. // heavier version for frontend
  617. node_id( NODE_T Kind, char * pNewName)
  618. : named_node( Kind, pNewName )
  619. {
  620. pInit = NULL;
  621. };
  622. expr_node * GetInitList()
  623. {
  624. return pInit;
  625. };
  626. expr_node * GetExpr()
  627. {
  628. return pInit;
  629. };
  630. void SetExpr( expr_node * pExpr )
  631. {
  632. pInit = pExpr;
  633. };
  634. // these two functions are only valid after the defining declaration is complete
  635. BOOL IsConstant()
  636. {
  637. return (BOOL) ( pInit &&
  638. pInit->IsConstant() &&
  639. (FInSummary( ATTR_CONST ) || IsConstantString() ) );
  640. }
  641. BOOL IsConstantString();
  642. virtual
  643. STATUS_T DoPrintType( PRTFLAGS Flags,
  644. BufferManager * pBuffer,
  645. ISTREAM * pStream,
  646. node_skl * pParent,
  647. node_skl * pIntf );
  648. virtual
  649. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  650. BufferManager * pBuffer,
  651. ISTREAM * pStream,
  652. node_skl * pParent,
  653. node_skl * pIntf );
  654. virtual
  655. FRONT_MEMORY_INFO GetMemoryInfo() {return GetModifiedMemoryInfoFromChild();}
  656. virtual
  657. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  658. virtual
  659. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  660. // here is the use of the private memory allocator
  661. private:
  662. static
  663. FreeListMgr MyFreeList;
  664. public:
  665. void * operator new (size_t size)
  666. {
  667. return (MyFreeList.Get (size));
  668. }
  669. void operator delete (void * pX)
  670. {
  671. MyFreeList.Put (pX);
  672. }
  673. }; // end of class node_id
  674. // this is what a node_id generated in the front-end looks like
  675. // it has tracking added
  676. class node_id_fe : public node_id, public tracked_node
  677. {
  678. public:
  679. node_id_fe( char * pNewName)
  680. : node_id( NODE_ID, pNewName )
  681. {
  682. };
  683. virtual
  684. void GetPositionInfo( tracked_node & Posn )
  685. {
  686. if (this->HasTracking() )
  687. Posn = * ((tracked_node *) this);
  688. }
  689. // here is the use of the private memory allocator
  690. private:
  691. static
  692. FreeListMgr MyFreeList;
  693. public:
  694. void * operator new (size_t size)
  695. {
  696. return (MyFreeList.Get (size));
  697. }
  698. void operator delete (void * pX)
  699. {
  700. MyFreeList.Put (pX);
  701. }
  702. };
  703. /***
  704. *** named nodes
  705. ***
  706. *** These nodes may be constructed
  707. ***/
  708. // enum labels
  709. class node_label : public named_node
  710. {
  711. public:
  712. expr_node * pExpr;
  713. node_label( char * LabelName, expr_node * pNewExpr )
  714. : named_node( NODE_LABEL, LabelName )
  715. {
  716. pExpr = pNewExpr;
  717. };
  718. EXPR_VALUE GetValue()
  719. {
  720. return pExpr->GetValue();
  721. }
  722. virtual
  723. STATUS_T DoPrintType( PRTFLAGS Flags,
  724. BufferManager * pBuffer,
  725. ISTREAM * pStream,
  726. node_skl * pParent,
  727. node_skl * pIntf );
  728. virtual
  729. FRONT_MEMORY_INFO GetMemoryInfo();
  730. virtual
  731. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  732. virtual
  733. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  734. }; // end of class node_label
  735. // handle types stored for node_def and node_param
  736. // these are in order of increasing precedence as binding handles
  737. #define HDL_NONE 0x00
  738. #define HDL_CTXT 0x01
  739. #define HDL_GEN 0x02
  740. #define HDL_PRIM 0x04
  741. // comm/fault status kind
  742. #define STATUS_NONE 0
  743. #define STATUS_COMM 1
  744. #define STATUS_FAULT 2
  745. #define STATUS_BOTH 3
  746. class CG_PARAM;
  747. // function formal parameters
  748. class node_param : public named_node
  749. {
  750. private:
  751. BOOL fOptional : 1; // odl attribute
  752. BOOL fRetval : 1;
  753. BOOL fLCID : 1;
  754. BOOL fExtraStatusParam : 1; // invisible fault or comm status
  755. BOOL fIsAsyncHandle : 1;
  756. BOOL fGenDefaultValueExpr : 1;
  757. BOOL fSaveForAsyncFinish : 1;
  758. BOOL fHasCSSTag : 1;
  759. BOOL fHasCSDRTag : 1;
  760. BOOL fHasCSRTag : 1;
  761. node_param* pAsyncBeginSibling;
  762. node_param* pAsyncFinishSibling;
  763. CG_PARAM* pCGParam;
  764. public:
  765. // the kind of handle, and whether it was applied to the
  766. // param node directly, or to the TypeSpecifier
  767. unsigned long HandleKind : 4;
  768. unsigned long fAppliedHere : 1;
  769. // true if the handle is an [in] handle
  770. unsigned long fBindingParam : 1;
  771. // for below field: bits 1=>toplevel 2=>non-toplevel
  772. unsigned long fDontCallFreeInst : 2;
  773. unsigned long Statuses : 2; // comm/fault statuses
  774. // copy fields from the pID
  775. node_param( node_id_fe * pID)
  776. : named_node( NODE_PARAM, pID ),
  777. fOptional ( 0 ),
  778. fLCID ( 0 ),
  779. fRetval ( 0 ),
  780. fExtraStatusParam ( 0 ),
  781. HandleKind ( 0 ),
  782. fAppliedHere ( 0 ),
  783. fBindingParam ( 0 ),
  784. fDontCallFreeInst ( 0 ),
  785. fIsAsyncHandle ( 0 ),
  786. fGenDefaultValueExpr( 0 ),
  787. Statuses ( STATUS_NONE ),
  788. pAsyncBeginSibling( 0 ),
  789. pAsyncFinishSibling( 0 ),
  790. fSaveForAsyncFinish( 0 ),
  791. fHasCSSTag ( 0 ),
  792. fHasCSDRTag ( 0 ),
  793. fHasCSRTag ( 0 )
  794. {
  795. }
  796. node_param()
  797. : named_node( NODE_PARAM ),
  798. fOptional ( 0 ),
  799. fLCID ( 0 ),
  800. fRetval ( 0 ),
  801. fExtraStatusParam ( 0 ),
  802. HandleKind ( 0 ),
  803. fAppliedHere ( 0 ),
  804. fBindingParam ( 0 ),
  805. fDontCallFreeInst ( 0 ),
  806. fIsAsyncHandle ( 0 ),
  807. fGenDefaultValueExpr( 0 ),
  808. Statuses ( STATUS_NONE ),
  809. pAsyncBeginSibling( 0 ),
  810. pAsyncFinishSibling( 0 ),
  811. fSaveForAsyncFinish( 0 ),
  812. fHasCSSTag ( 0 ),
  813. fHasCSDRTag ( 0 ),
  814. fHasCSRTag ( 0 )
  815. {
  816. }
  817. virtual CG_PARAM*
  818. GetCG()
  819. {
  820. return pCGParam;
  821. }
  822. virtual void
  823. SetCG( CG_PARAM* pCG )
  824. {
  825. pCGParam = pCG;
  826. }
  827. virtual void
  828. SetAsyncBeginSibling( node_param* pParam ) { pAsyncBeginSibling = pParam; };
  829. virtual node_param*
  830. GetAsyncBeginSibling( void ) { return pAsyncBeginSibling; };
  831. virtual void
  832. SetAsyncFinishSibling( node_param* pParam ) { pAsyncFinishSibling = pParam; };
  833. virtual node_param*
  834. GetAsyncFinishSibling( void ) { return pAsyncFinishSibling; };
  835. virtual void SaveForAsyncFinish( void ) { fSaveForAsyncFinish = TRUE; };
  836. virtual BOOL IsSaveForAsyncFinish( void ) { return fSaveForAsyncFinish; };
  837. BOOL HasExplicitHandle()
  838. {
  839. return (HandleKind != HDL_NONE);
  840. }
  841. unsigned short GetHandleKind()
  842. {
  843. return (unsigned short) HandleKind;
  844. }
  845. BOOL IsBindingParam()
  846. {
  847. return ( fBindingParam );
  848. }
  849. BOOL IsExtraStatusParam()
  850. {
  851. return ( fExtraStatusParam );
  852. }
  853. void SetExtraStatusParam()
  854. {
  855. fExtraStatusParam = TRUE;
  856. }
  857. BOOL IsAsyncHandleParam()
  858. {
  859. return ( fIsAsyncHandle );
  860. }
  861. void SetIsAsyncHandleParam()
  862. {
  863. fIsAsyncHandle = TRUE;
  864. }
  865. virtual
  866. STATUS_T DoPrintType( PRTFLAGS Flags,
  867. BufferManager * pBuffer,
  868. ISTREAM * pStream,
  869. node_skl * pParent,
  870. node_skl * pIntf );
  871. virtual
  872. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  873. BufferManager * pBuffer,
  874. ISTREAM * pStream,
  875. node_skl * pParent,
  876. node_skl * pIntf );
  877. virtual
  878. FRONT_MEMORY_INFO GetMemoryInfo() {return GetModifiedMemoryInfoFromChild();}
  879. virtual
  880. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  881. virtual
  882. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  883. void Optional(void)
  884. {
  885. fOptional = TRUE;
  886. }
  887. BOOL IsOptional(void)
  888. {
  889. return fOptional;
  890. }
  891. void Retval(void)
  892. {
  893. fRetval = TRUE;
  894. }
  895. BOOL IsRetval(void)
  896. {
  897. return fRetval;
  898. }
  899. void LCID(void)
  900. {
  901. fLCID = TRUE;
  902. }
  903. BOOL IsLCID(void)
  904. {
  905. return fLCID;
  906. }
  907. void GenDefaultValueExpr( BOOL fGen = TRUE )
  908. {
  909. fGenDefaultValueExpr = fGen;
  910. }
  911. BOOL HasGenDefaultValueExpr( void )
  912. {
  913. return fGenDefaultValueExpr;
  914. }
  915. void SetHasCSSTag()
  916. {
  917. fHasCSSTag = TRUE;
  918. }
  919. void SetHasCSDRTag()
  920. {
  921. fHasCSDRTag = TRUE;
  922. }
  923. void SetHasCSRTag()
  924. {
  925. fHasCSRTag = TRUE;
  926. }
  927. BOOL HasCSTag()
  928. {
  929. return fHasCSSTag | fHasCSRTag | fHasCSDRTag;
  930. }
  931. }; // end of class node_param
  932. class CG_PROC;
  933. // imported files
  934. class node_file : public named_node, public MEMLIST
  935. {
  936. private:
  937. char * pActualFileName;
  938. short ImportLevel;
  939. BOOL fAcfInclude : 1;
  940. BOOL fIsXXXBaseIdl : 1;
  941. BOOL fHasComClasses : 1;
  942. public:
  943. node_file( char *, short );
  944. short GetImportLevel()
  945. {
  946. return ImportLevel;
  947. }
  948. char * GetFileName()
  949. {
  950. return pActualFileName;
  951. }
  952. BOOL AcfExists();
  953. void AcfName( char * );
  954. void SetFileName( char * );
  955. BOOL IsAcfInclude()
  956. {
  957. return fAcfInclude;
  958. }
  959. BOOL HasComClasses()
  960. {
  961. return fHasComClasses;
  962. }
  963. BOOL SetHasComClasses( BOOL yes = TRUE )
  964. {
  965. return (fHasComClasses = yes);
  966. }
  967. virtual
  968. STATUS_T DoPrintType( PRTFLAGS Flags,
  969. BufferManager * pBuffer,
  970. ISTREAM * pStream,
  971. node_skl * pParent,
  972. node_skl * pIntf );
  973. virtual
  974. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();};
  975. virtual
  976. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  977. virtual
  978. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  979. void SetXXXBaseIdl()
  980. {
  981. fIsXXXBaseIdl = TRUE;
  982. }
  983. BOOL IsXXXBaseIdl()
  984. {
  985. return fIsXXXBaseIdl;
  986. }
  987. }; // end of class node_file
  988. // functions and procs
  989. class node_proc : public named_node, public tracked_node, public MEMLIST
  990. {
  991. unsigned long ProcNum : 16;
  992. unsigned long OptimFlags : 8;
  993. unsigned long ImportLevel : 4;
  994. unsigned long fHasFullPointer : 1;
  995. unsigned long fHasAtLeastOneIn : 1;
  996. unsigned long fHasAtLeastOneOut : 1;
  997. unsigned long fHasExplicitHandle : 1;
  998. unsigned long fHasPointer : 1; // ANYWHERE below us
  999. unsigned long fHasStatuses : 1; // has comm/fault status
  1000. unsigned long fHasExtraStatusParam: 1; // has the "invisible" status param
  1001. unsigned long fCallAsTarget : 1; // the target of a call_as
  1002. unsigned long RTStatuses : 2; // return type statuses
  1003. unsigned long fHasPipes : 1;
  1004. unsigned long fForcedI2 : 1; // true if -Oi2 mode has been forced
  1005. unsigned long fForcedS : 1; // true if -Os mode has been forced
  1006. unsigned long fHasAsyncHandle : 1;
  1007. unsigned long fHasDeny : 1; // true on /deny
  1008. unsigned long fHasServerCorr : 1; // correlation on Server
  1009. unsigned long fHasClientCorr : 1; // correlation on Client
  1010. unsigned long fHasAsyncUUID : 1; // async_uuid
  1011. unsigned long fIsBeginProc : 1; // Begin_*
  1012. unsigned long fIsFinishProc : 1; // Finish_*
  1013. unsigned long fObjectProc : 1; // object proc
  1014. unsigned long ulServerCorrCount;
  1015. unsigned long ulClientCorrCount;
  1016. class node_proc * pCallAsType; // if this is a call_as function
  1017. // then this pointer will be set to
  1018. // points to its companion during
  1019. // semantic analysis
  1020. node_proc* pBeginProc;
  1021. node_proc* pCSTagRoutine; // from [cs_tag_rtn]
  1022. OPT_LEVEL_ENUM OptimLevel;
  1023. public:
  1024. node_proc( short level, BOOL ) :
  1025. named_node ( NODE_PROC ),
  1026. ProcNum ( 0xffff ),
  1027. OptimFlags ( 0 ),
  1028. ImportLevel ( ( level > 15 ) ? 15 : level ),
  1029. fHasAtLeastOneIn ( FALSE ),
  1030. fHasAtLeastOneOut ( FALSE ),
  1031. fHasExplicitHandle ( FALSE ),
  1032. fHasPointer ( FALSE ),
  1033. fHasFullPointer ( FALSE ),
  1034. fHasStatuses ( FALSE ),
  1035. fHasExtraStatusParam ( FALSE ),
  1036. fCallAsTarget ( FALSE ),
  1037. RTStatuses ( STATUS_NONE ),
  1038. fHasPipes ( FALSE ),
  1039. fForcedI2 ( FALSE ),
  1040. fForcedS ( FALSE ),
  1041. fHasAsyncHandle ( FALSE ),
  1042. pCallAsType ( NULL ),
  1043. OptimLevel ( OPT_LEVEL_OS ),
  1044. fHasDeny ( FALSE ),
  1045. fHasServerCorr ( FALSE ),
  1046. fHasClientCorr ( FALSE ),
  1047. fHasAsyncUUID ( FALSE ),
  1048. fIsBeginProc ( FALSE ),
  1049. fIsFinishProc ( FALSE ),
  1050. ulClientCorrCount ( 0 ),
  1051. ulServerCorrCount ( 0 ),
  1052. pBeginProc ( 0 ),
  1053. pCSTagRoutine ( 0 ),
  1054. fObjectProc ( FALSE )
  1055. {
  1056. }
  1057. node_proc( short level, BOOL , node_id_fe * pID)
  1058. : named_node ( NODE_PROC, pID ),
  1059. ProcNum ( 0xffff ),
  1060. OptimFlags ( 0 ),
  1061. ImportLevel ( ( level > 15 ) ? 15 : level ),
  1062. fHasAtLeastOneIn ( FALSE ),
  1063. fHasAtLeastOneOut ( FALSE ),
  1064. fHasExplicitHandle ( FALSE ),
  1065. fHasPointer ( FALSE ),
  1066. fHasFullPointer ( FALSE ),
  1067. fHasStatuses ( FALSE ),
  1068. fHasExtraStatusParam ( FALSE ),
  1069. fCallAsTarget ( FALSE ),
  1070. RTStatuses ( STATUS_NONE ),
  1071. fHasPipes ( FALSE ),
  1072. fForcedI2 ( FALSE ),
  1073. fForcedS ( FALSE ),
  1074. fHasAsyncHandle ( FALSE ),
  1075. pCallAsType ( NULL ),
  1076. OptimLevel ( OPT_LEVEL_OS ),
  1077. fHasDeny ( FALSE ),
  1078. fHasServerCorr ( FALSE ),
  1079. fHasClientCorr ( FALSE ),
  1080. fHasAsyncUUID ( FALSE ),
  1081. fIsBeginProc ( FALSE ),
  1082. fIsFinishProc ( FALSE ),
  1083. ulClientCorrCount ( 0 ),
  1084. ulServerCorrCount ( 0 ),
  1085. pBeginProc ( 0 ),
  1086. pCSTagRoutine ( 0 ),
  1087. fObjectProc ( FALSE )
  1088. {
  1089. }
  1090. node_proc( node_proc * pClone )
  1091. : named_node( NODE_PROC )
  1092. {
  1093. *this = *pClone;
  1094. }
  1095. BOOL IsObjectProc() { return fObjectProc; };
  1096. void SetObjectProc( BOOL fObject = TRUE ) { fObjectProc = fObject; };
  1097. node_proc* GetBeginProc()
  1098. {
  1099. return pBeginProc;
  1100. }
  1101. void SetBeginProc( node_proc* pBegin )
  1102. {
  1103. pBeginProc = pBegin;
  1104. }
  1105. node_proc * SetCallAsType(node_proc *p)
  1106. {
  1107. return (pCallAsType = p);
  1108. }
  1109. node_proc * GetCallAsType()
  1110. {
  1111. return (pCallAsType);
  1112. }
  1113. STATUS_T GetParameterList( class type_node_list * MemList )
  1114. {
  1115. return GetMembers( MemList );
  1116. };
  1117. node_skl * GetReturnType()
  1118. {
  1119. return GetChild();
  1120. };
  1121. short GetImportLevel()
  1122. {
  1123. return (short) ImportLevel;
  1124. }
  1125. unsigned short GetOptimizationFlags()
  1126. {
  1127. return (unsigned short)OptimFlags;
  1128. }
  1129. unsigned short SetOptimizationFlags( unsigned short OF )
  1130. {
  1131. return (unsigned short)(OptimFlags = OF);
  1132. }
  1133. OPT_LEVEL_ENUM GetOptimizationLevel()
  1134. {
  1135. return (OPT_LEVEL_ENUM) OptimLevel;
  1136. }
  1137. OPT_LEVEL_ENUM SetOptimizationLevel( OPT_LEVEL_ENUM Level )
  1138. {
  1139. return OptimLevel = Level;
  1140. }
  1141. BOOL ForceNonInterpret();
  1142. BOOL ForceInterpret2();
  1143. void AddStatusParam( char * pName, ATTRLIST Alist );
  1144. void AddExplicitHandle (
  1145. SEM_ANALYSIS_CTXT* pParentCtxt,
  1146. unsigned int uParamNumber = 1
  1147. );
  1148. void AddFullAsyncHandle (
  1149. SEM_ANALYSIS_CTXT* pParentCtxt,
  1150. node_skl* pType,
  1151. char* szType
  1152. );
  1153. // returns ATTR_NONE if none explicitly specified
  1154. BOOL GetCallingConvention( ATTR_T & Attr );
  1155. BOOL HasPipes()
  1156. {
  1157. return fHasPipes;
  1158. }
  1159. BOOL HasAtLeastOneIn()
  1160. {
  1161. return fHasAtLeastOneIn;
  1162. };
  1163. BOOL HasAtLeastOneOut()
  1164. {
  1165. return fHasAtLeastOneOut;
  1166. };
  1167. BOOL HasExplicitHandle()
  1168. {
  1169. return fHasExplicitHandle;
  1170. };
  1171. BOOL HasAtLeastOneHandle()
  1172. {
  1173. // for now....
  1174. return fHasExplicitHandle;
  1175. };
  1176. BOOL SetHasExtraStatusParam()
  1177. {
  1178. return fHasExtraStatusParam = TRUE;
  1179. }
  1180. BOOL HasExtraStatusParam()
  1181. {
  1182. return fHasExtraStatusParam;
  1183. }
  1184. BOOL HasPointer()
  1185. {
  1186. return fHasPointer;
  1187. };
  1188. BOOL IsCallAsTarget()
  1189. {
  1190. return fCallAsTarget;
  1191. }
  1192. BOOL HasAtLeastOneShipped();
  1193. BOOL HasReturn()
  1194. {
  1195. node_skl * pCh = GetNonDefChild();
  1196. return (pCh) && (pCh->NodeKind() != NODE_VOID);
  1197. };
  1198. void SetHasAsyncHandle()
  1199. {
  1200. fHasAsyncHandle = TRUE;
  1201. }
  1202. BOOL HasAsyncHandle()
  1203. {
  1204. return fHasAsyncHandle;
  1205. }
  1206. void SetHasAsyncUUID()
  1207. {
  1208. fHasAsyncUUID = TRUE;
  1209. }
  1210. BOOL HasAsyncUUID()
  1211. {
  1212. return fHasAsyncUUID;
  1213. }
  1214. void SetHasServerCorr()
  1215. {
  1216. fHasServerCorr = TRUE;
  1217. }
  1218. BOOL HasServerCorr()
  1219. {
  1220. return fHasServerCorr;
  1221. }
  1222. void SetHasClientCorr()
  1223. {
  1224. fHasClientCorr = TRUE;
  1225. }
  1226. BOOL HasClientCorr()
  1227. {
  1228. return fHasClientCorr;
  1229. }
  1230. void SetIsBeginProc()
  1231. {
  1232. fIsBeginProc = TRUE;
  1233. }
  1234. BOOL IsBeginProc()
  1235. {
  1236. return fIsBeginProc;
  1237. }
  1238. void SetIsFinishProc()
  1239. {
  1240. fIsFinishProc = TRUE;
  1241. }
  1242. BOOL IsFinishProc()
  1243. {
  1244. return fIsFinishProc;
  1245. }
  1246. BOOL HasAParameter()
  1247. {
  1248. // check if the first one is different from void
  1249. node_skl * pParam = GetFirstMember();
  1250. if ( !pParam || pParam->NodeKind() == NODE_VOID )
  1251. return FALSE;
  1252. if ( pParam->NodeKind() == NODE_DEF )
  1253. {
  1254. node_skl * pCh = pParam->GetNonDefChild();
  1255. if ( !pCh || pCh->NodeKind() == NODE_VOID )
  1256. return FALSE;
  1257. }
  1258. return TRUE;
  1259. };
  1260. node_param * GetParamNode( char * pName )
  1261. {
  1262. node_param * pCur = (node_param *) GetFirstMember();
  1263. while ( pCur )
  1264. {
  1265. if ( strcmp( pCur->GetSymName(), pName ) == 0 )
  1266. return pCur;
  1267. pCur = (node_param *) pCur->GetSibling();
  1268. }
  1269. return NULL;
  1270. }
  1271. virtual
  1272. FRONT_MEMORY_INFO GetMemoryInfo() {return GetReturnType()->GetMemoryInfo();}
  1273. virtual
  1274. void GetPositionInfo( tracked_node & Posn )
  1275. {
  1276. if (this->HasTracking() )
  1277. Posn = * ((tracked_node *) this);
  1278. }
  1279. virtual unsigned long
  1280. GetServerCorrelationCount()
  1281. {
  1282. return ulServerCorrCount;
  1283. }
  1284. virtual unsigned long
  1285. GetClientCorrelationCount()
  1286. {
  1287. return ulClientCorrCount;
  1288. }
  1289. virtual void
  1290. SetServerCorrelationCount( unsigned long ulCount = 0 )
  1291. {
  1292. ulServerCorrCount = ulCount;
  1293. }
  1294. virtual void
  1295. SetClientCorrelationCount( unsigned long ulCount = 0 )
  1296. {
  1297. ulClientCorrCount = ulCount;
  1298. }
  1299. virtual void
  1300. IncServerCorrelationCount( unsigned long ulInc )
  1301. {
  1302. ulServerCorrCount += ulInc;
  1303. }
  1304. virtual void
  1305. IncClientCorrelationCount( unsigned long ulInc )
  1306. {
  1307. ulClientCorrCount += ulInc;
  1308. }
  1309. void SetCSTagRoutine(node_proc *p)
  1310. {
  1311. pCSTagRoutine = p;
  1312. }
  1313. node_proc * GetCSTagRoutine()
  1314. {
  1315. return pCSTagRoutine;
  1316. }
  1317. virtual
  1318. STATUS_T DoPrintType( PRTFLAGS Flags,
  1319. BufferManager * pBuffer,
  1320. ISTREAM * pStream,
  1321. node_skl * pParent,
  1322. node_skl * pIntf );
  1323. virtual
  1324. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  1325. BufferManager * pBuffer,
  1326. ISTREAM * pStream,
  1327. node_skl * pParent,
  1328. node_skl * pIntf );
  1329. virtual
  1330. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1331. virtual
  1332. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1333. }; // end of class node_proc
  1334. class SymTable;
  1335. // forward declarations -- may go away
  1336. class node_forward : public named_node, public tracked_node
  1337. {
  1338. SymKey SKey;
  1339. SymTable * pSymTbl;
  1340. public:
  1341. node_forward( SymKey key, SymTable * pTbl )
  1342. : named_node( NODE_FORWARD )
  1343. {
  1344. SKey = key;
  1345. pSymTbl = pTbl;
  1346. pTbl->SetHasFwds();
  1347. MiscBits = 0;
  1348. };
  1349. named_node * ResolveFDecl();
  1350. void GetSymDetails( NAME_T * nm, char ** ppszName);
  1351. BOOL IsFirstPass()
  1352. {
  1353. return ( MiscBits == 0 );
  1354. }
  1355. void MarkSecondPass()
  1356. {
  1357. MiscBits = 1;
  1358. }
  1359. void MarkFirstPass()
  1360. {
  1361. MiscBits = 0;
  1362. }
  1363. virtual
  1364. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();}
  1365. virtual
  1366. void GetPositionInfo( tracked_node & Posn )
  1367. {
  1368. if (this->HasTracking() )
  1369. Posn = * ((tracked_node *) this);
  1370. }
  1371. virtual
  1372. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  1373. BufferManager * pBuffer,
  1374. ISTREAM * pStream,
  1375. node_skl * pParent,
  1376. node_skl * pIntf );
  1377. virtual
  1378. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1379. virtual
  1380. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1381. };
  1382. // reference to a type defined in an importlib
  1383. class node_href : public named_node, public tracked_node
  1384. {
  1385. SymKey SKey;
  1386. SymTable * pSymTbl;
  1387. void * pTypeInfo;
  1388. node_file * pFile;
  1389. public:
  1390. node_href( SymKey key, SymTable * pTbl, void * pti, node_file * pf)
  1391. : named_node( NODE_HREF, key.GetString() )
  1392. {
  1393. SKey = key;
  1394. pSymTbl = pTbl;
  1395. pTbl->SetHasFwds();
  1396. MiscBits = 0;
  1397. pTypeInfo = pti;
  1398. pFile = pf;
  1399. };
  1400. ~node_href();
  1401. named_node * Resolve();
  1402. void GetSymDetails( NAME_T * pTag, char ** ppszName)
  1403. {
  1404. *pTag = SKey.GetKind();
  1405. *ppszName = SKey.GetString();
  1406. };
  1407. virtual
  1408. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  1409. BufferManager * pBuffer,
  1410. ISTREAM * pStream,
  1411. node_skl * pParent,
  1412. node_skl * pIntf );
  1413. virtual
  1414. FRONT_MEMORY_INFO GetMemoryInfo();
  1415. virtual
  1416. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1417. virtual
  1418. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1419. virtual
  1420. node_file * GetDefiningFile()
  1421. {
  1422. return pFile;
  1423. };
  1424. };
  1425. // fields in structures
  1426. class node_field : public named_node
  1427. {
  1428. public:
  1429. node_field( char * pNewName = NULL )
  1430. : named_node( NODE_FIELD, pNewName )
  1431. {
  1432. MiscBits = 0;
  1433. };
  1434. node_field( node_id_fe * pId )
  1435. : named_node( NODE_FIELD, pId )
  1436. {
  1437. MiscBits = 0;
  1438. };
  1439. BOOL HasUnknownRepAs()
  1440. {
  1441. return (BOOL) MiscBits & 1;
  1442. };
  1443. BOOL SetHasUnknownRepAs()
  1444. {
  1445. return (BOOL) (MiscBits |= 1);
  1446. };
  1447. BOOL IsEmptyArm()
  1448. {
  1449. return (GetChild()->NodeKind() == NODE_ERROR);
  1450. };
  1451. BOOL IsLastField()
  1452. {
  1453. return !(GetSibling());
  1454. };
  1455. virtual
  1456. BOOL IsBitField()
  1457. {
  1458. return FALSE;
  1459. }
  1460. virtual
  1461. short GetFieldSize()
  1462. {
  1463. return 0;
  1464. };
  1465. virtual
  1466. STATUS_T DoPrintType( PRTFLAGS Flags,
  1467. BufferManager * pBuffer,
  1468. ISTREAM * pStream,
  1469. node_skl * pParent,
  1470. node_skl * pIntf );
  1471. virtual
  1472. FRONT_MEMORY_INFO GetMemoryInfo() {return GetModifiedMemoryInfoFromChild();}
  1473. virtual
  1474. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1475. virtual
  1476. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1477. }; // end of class node_field
  1478. // bitfields in structures
  1479. class node_bitfield : public node_field
  1480. {
  1481. public:
  1482. unsigned char fBitField;
  1483. node_bitfield( char * pNewName = NULL)
  1484. : node_field( pNewName )
  1485. {
  1486. fBitField = 0;
  1487. };
  1488. node_bitfield( node_id_fe * pId )
  1489. : node_field( pId )
  1490. {
  1491. fBitField = 0;
  1492. };
  1493. virtual
  1494. BOOL IsBitField()
  1495. {
  1496. return TRUE;
  1497. }
  1498. virtual
  1499. short GetFieldSize()
  1500. {
  1501. return fBitField;
  1502. };
  1503. virtual
  1504. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1505. virtual
  1506. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1507. }; // end of class node_bitfield
  1508. // bits for different kinds of arrays as fields.
  1509. // if more than one bit is set, it is a complex array
  1510. #define FLD_PLAIN 0x0
  1511. #define FLD_VAR 0x1
  1512. #define FLD_CONF 0x2
  1513. #define FLD_CONF_VAR 0x4
  1514. #define FLD_COMPLEX 0x8 // don't check for equality here!
  1515. // structures and unions, and enums, too
  1516. class node_su_base : public named_node, public tracked_node, public MEMLIST
  1517. {
  1518. protected:
  1519. unsigned long ZeePee : 16;
  1520. unsigned long Complexity : 8;
  1521. unsigned long fHasAtLeastOnePointer : 1;
  1522. unsigned long fSemAnalyzed : 1;
  1523. unsigned long fHasConformance : 1;
  1524. char * szTypeInfoName;
  1525. public:
  1526. node_su_base( NODE_T Kind, char * pName )
  1527. : named_node( Kind, pName )
  1528. {
  1529. fHasAtLeastOnePointer = 0;
  1530. ZeePee = 0;
  1531. Complexity = 0;
  1532. fSemAnalyzed = 0;
  1533. fHasConformance = 0;
  1534. szTypeInfoName = pName;
  1535. };
  1536. unsigned short SetZeePee( unsigned short zp )
  1537. {
  1538. return (unsigned short) (ZeePee = zp);
  1539. };
  1540. unsigned short GetZeePee()
  1541. {
  1542. return (unsigned short) ZeePee;
  1543. };
  1544. unsigned short SetHasAtLeastOnePointer( unsigned short HP )
  1545. {
  1546. return (unsigned short) (fHasAtLeastOnePointer = HP);
  1547. };
  1548. unsigned short HasAtLeastOnePointer()
  1549. {
  1550. return (unsigned short) fHasAtLeastOnePointer;
  1551. };
  1552. virtual
  1553. void GetPositionInfo( tracked_node & Posn )
  1554. {
  1555. if (this->HasTracking() )
  1556. Posn = * ((tracked_node *) this);
  1557. }
  1558. BOOL HasConformance()
  1559. {
  1560. return fHasConformance;
  1561. }
  1562. void CheckLegalParent(SEM_ANALYSIS_CTXT & MyContext);
  1563. void SetTypeInfoName(char * szName)
  1564. {
  1565. szTypeInfoName = szName;
  1566. }
  1567. char * GetTypeInfoName(void)
  1568. {
  1569. return szTypeInfoName;
  1570. }
  1571. }; // end of class node_su_base
  1572. // enum and its tag
  1573. class node_enum : public node_su_base
  1574. {
  1575. BOOL fLong : 1;
  1576. public:
  1577. node_enum (
  1578. char* pTagName
  1579. ) :
  1580. node_su_base( NODE_ENUM, pTagName ),
  1581. fLong( FALSE )
  1582. {
  1583. }
  1584. virtual
  1585. STATUS_T DoPrintType( PRTFLAGS Flags,
  1586. BufferManager * pBuffer,
  1587. ISTREAM * pStream,
  1588. node_skl * pParent,
  1589. node_skl * pIntf );
  1590. virtual
  1591. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  1592. BufferManager * pBuffer,
  1593. ISTREAM * pStream,
  1594. node_skl * pParent,
  1595. node_skl * pIntf );
  1596. virtual
  1597. FRONT_MEMORY_INFO GetMemoryInfo();
  1598. virtual
  1599. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1600. virtual
  1601. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1602. }; // end of class node_enum
  1603. // structures
  1604. class node_struct : public node_su_base
  1605. {
  1606. public:
  1607. node_struct( char * pNewName )
  1608. : node_su_base( NODE_STRUCT, pNewName )
  1609. {
  1610. };
  1611. virtual
  1612. BOOL IsEncapsulatedStruct()
  1613. {
  1614. return FALSE;
  1615. }
  1616. virtual
  1617. BOOL IsStructOrUnion()
  1618. {
  1619. return TRUE;
  1620. }
  1621. virtual
  1622. BOOL IsStringableType();
  1623. virtual
  1624. STATUS_T DoPrintType( PRTFLAGS Flags,
  1625. BufferManager * pBuffer,
  1626. ISTREAM * pStream,
  1627. node_skl * pParent,
  1628. node_skl * pIntf );
  1629. virtual
  1630. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  1631. BufferManager * pBuffer,
  1632. ISTREAM * pStream,
  1633. node_skl * pParent,
  1634. node_skl * pIntf );
  1635. virtual
  1636. FRONT_MEMORY_INFO GetMemoryInfo();
  1637. virtual
  1638. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1639. virtual
  1640. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1641. }; // end of class node_struct
  1642. class node_en_struct : public node_struct
  1643. {
  1644. public:
  1645. node_en_struct( char * pNewName )
  1646. : node_struct( pNewName )
  1647. {
  1648. };
  1649. BOOL IsEncapsulatedStruct()
  1650. {
  1651. return TRUE;
  1652. }
  1653. node_skl * GetSwitchField()
  1654. {
  1655. return GetFirstMember();
  1656. }
  1657. virtual
  1658. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1659. virtual
  1660. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1661. }; // end of class node_en_struct
  1662. // unions
  1663. class node_union : public node_su_base
  1664. {
  1665. public:
  1666. node_union( char * pNewName )
  1667. : node_su_base( NODE_UNION, pNewName )
  1668. {
  1669. };
  1670. virtual
  1671. BOOL IsStructOrUnion()
  1672. {
  1673. return TRUE;
  1674. }
  1675. virtual
  1676. STATUS_T DoPrintType( PRTFLAGS Flags,
  1677. BufferManager * pBuffer,
  1678. ISTREAM * pStream,
  1679. node_skl * pParent,
  1680. node_skl * pIntf );
  1681. virtual
  1682. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  1683. BufferManager * pBuffer,
  1684. ISTREAM * pStream,
  1685. node_skl * pParent,
  1686. node_skl * pIntf );
  1687. virtual
  1688. FRONT_MEMORY_INFO GetMemoryInfo();
  1689. virtual
  1690. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1691. virtual
  1692. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1693. }; // end of class node_union
  1694. class node_en_union : public node_union
  1695. {
  1696. public:
  1697. node_en_union( char * pNewName )
  1698. : node_union( pNewName )
  1699. {
  1700. };
  1701. virtual
  1702. BOOL IsEncapsulatedUnion()
  1703. {
  1704. return TRUE;
  1705. }
  1706. virtual
  1707. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1708. virtual
  1709. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1710. }; // end of class node_en_union
  1711. #define HANDLE_KIND_MASK 0x7
  1712. #define HRESULT_FLAG_MASK 0x8
  1713. // typedef entries
  1714. class node_def : public named_node
  1715. {
  1716. public:
  1717. // (lightweight version) make a typedef with a given name
  1718. node_def( char * pName = NULL)
  1719. : named_node( pName, NODE_DEF )
  1720. {
  1721. SetHandleKind( HDL_NONE );
  1722. };
  1723. // make a typedef with a given name and child
  1724. node_def( char * pName, node_skl * pChld )
  1725. : named_node( NODE_DEF, pName )
  1726. {
  1727. MiscBits = 0;
  1728. SetHandleKind( HDL_NONE );
  1729. SetChild( pChld );
  1730. };
  1731. // make a typedef cloned from a node_id
  1732. node_def( node_id_fe * pIdent )
  1733. : named_node( NODE_DEF, pIdent )
  1734. {
  1735. MiscBits = 0;
  1736. SetHandleKind( HDL_NONE );
  1737. };
  1738. // make a typedef node for (above) a proc
  1739. node_def( node_proc * pProc )
  1740. : named_node( NODE_DEF, (node_id_fe *) pProc )
  1741. {
  1742. MiscBits = 0;
  1743. SetChild( pProc );
  1744. SetHandleKind( HDL_NONE );
  1745. };
  1746. unsigned long GetHandleKind()
  1747. {
  1748. return MiscBits & HANDLE_KIND_MASK;
  1749. }
  1750. unsigned long SetHandleKind( unsigned long H )
  1751. {
  1752. MiscBits = ( MiscBits & ~HANDLE_KIND_MASK ) | H;
  1753. return H;
  1754. }
  1755. void SetIsHResultOrSCode()
  1756. {
  1757. MiscBits |= HRESULT_FLAG_MASK;
  1758. }
  1759. BOOL IsHResultOrSCode()
  1760. {
  1761. return ( MiscBits & HRESULT_FLAG_MASK ) != 0;
  1762. }
  1763. BOOL HasAnyHandleSpecification()
  1764. {
  1765. return (GetHandleKind() != HDL_NONE);
  1766. };
  1767. BOOL HasAnyCtxtHdlSpecification()
  1768. {
  1769. return (GetHandleKind() == HDL_CTXT);
  1770. };
  1771. // return the transmit_as type (or NULL)
  1772. node_skl * GetTransmittedType();
  1773. // return the represent_as type (or NULL)
  1774. char * GetRepresentationName();
  1775. virtual
  1776. STATUS_T DoPrintType( PRTFLAGS Flags,
  1777. BufferManager * pBuffer,
  1778. ISTREAM * pStream,
  1779. node_skl * pParent,
  1780. node_skl * pIntf );
  1781. virtual
  1782. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  1783. BufferManager * pBuffer,
  1784. ISTREAM * pStream,
  1785. node_skl * pParent,
  1786. node_skl * pIntf );
  1787. void MarkDontCallFreeInst( SEM_ANALYSIS_CTXT * pCtxt );
  1788. virtual
  1789. FRONT_MEMORY_INFO GetMemoryInfo();
  1790. virtual
  1791. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  1792. void
  1793. node_def::SemanticAnalysisForTransmit( SEM_ANALYSIS_CTXT *pMyContext,
  1794. BOOL fPresented );
  1795. void
  1796. node_def::SemanticAnalysisForWireMarshal( SEM_ANALYSIS_CTXT *pMyContext,
  1797. BOOL fPresented );
  1798. virtual
  1799. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  1800. }; // end of class node_def
  1801. // front-end only version of node_def ( adds line number tracking )
  1802. class node_def_fe : public node_def, public tracked_node
  1803. {
  1804. public:
  1805. // make a typedef with a given name and child
  1806. node_def_fe( char * pName, node_skl * pChld )
  1807. : node_def( pName, pChld )
  1808. {
  1809. }
  1810. // make a typedef cloned from a node_id
  1811. node_def_fe( node_id_fe * pIdent )
  1812. : node_def( pIdent )
  1813. {
  1814. }
  1815. // make a typedef node for (above) a proc
  1816. node_def_fe( node_proc * pProc )
  1817. : node_def( pProc )
  1818. {
  1819. };
  1820. virtual
  1821. void GetPositionInfo( tracked_node & Posn )
  1822. {
  1823. if (this->HasTracking() )
  1824. Posn = * ((tracked_node *) this);
  1825. }
  1826. }; // end of class node_def_fe
  1827. typedef struct tagIDLISTMEM
  1828. {
  1829. struct tagIDLISTMEM * pNext;
  1830. char * szName;
  1831. __int64 lId;
  1832. } IDLISTMEM;
  1833. // class for checking for duplicate dispatch ids
  1834. class CIDLIST
  1835. {
  1836. private:
  1837. IDLISTMEM * pHead;
  1838. public:
  1839. CIDLIST()
  1840. {
  1841. pHead = NULL;
  1842. };
  1843. ~CIDLIST()
  1844. {
  1845. while (pHead)
  1846. {
  1847. IDLISTMEM * pThis = pHead;
  1848. pHead = pHead->pNext;
  1849. delete pThis;
  1850. }
  1851. };
  1852. BOOL AddId(__int64 lId, char * szName);
  1853. };
  1854. // the interface
  1855. class node_interface : public named_node, public MEMLIST, public tracked_node
  1856. {
  1857. protected:
  1858. named_node * pBaseIntf; // base interface if derived intf
  1859. node_file * pDefiningFile;
  1860. CG_CLASS * pMyCG;
  1861. CG_CLASS * pMyTlbCG; // CG node generated in library block
  1862. SymTable * pProcTbl;
  1863. unsigned short ProcCount;
  1864. unsigned short CallBackProcCount;
  1865. unsigned short OptimFlags;
  1866. OPT_LEVEL_ENUM OptimLevel;
  1867. BOOL fIAmIUnknown : 1;
  1868. BOOL fPickle : 1;
  1869. BOOL fHasProcsWithRpcSs : 1;
  1870. BOOL fSemAnalyzed : 1;
  1871. BOOL fPrintedDef : 1;
  1872. BOOL fPrintedIID : 1;
  1873. BOOL fHasOLEAutomation : 1;
  1874. BOOL fIsAsyncClone : 1;
  1875. BOOL fHasMSConfStructAttr: 1;
  1876. BOOL fIs2ndCodegen : 1;
  1877. CIDLIST IdList;
  1878. node_interface* pAsyncInterface;
  1879. void ResetCGIfNecessary();
  1880. public:
  1881. node_interface( NODE_T Kind = NODE_INTERFACE );
  1882. unsigned short &GetProcCount()
  1883. {
  1884. return ProcCount;
  1885. }
  1886. unsigned short &GetCallBackProcCount()
  1887. {
  1888. return CallBackProcCount;
  1889. }
  1890. void GetVersionDetails( unsigned short * Maj,
  1891. unsigned short * Min );
  1892. BOOL AddId(__int64 lId, char * szName)
  1893. {
  1894. return IdList.AddId(lId, szName);
  1895. }
  1896. virtual BOOL IsAsyncClone()
  1897. {
  1898. return fIsAsyncClone;
  1899. }
  1900. virtual void SetIsAsyncClone()
  1901. {
  1902. fIsAsyncClone = TRUE;
  1903. }
  1904. virtual
  1905. BOOL IsInterfaceOrObject()
  1906. {
  1907. return TRUE;
  1908. }
  1909. BOOL IsValidRootInterface()
  1910. {
  1911. return fIAmIUnknown;
  1912. }
  1913. void SetValidRootInterface()
  1914. {
  1915. fIAmIUnknown = TRUE;
  1916. }
  1917. BOOL IsPickleInterface()
  1918. {
  1919. return fPickle;
  1920. }
  1921. void SetPickleInterface()
  1922. {
  1923. fPickle = TRUE;
  1924. }
  1925. BOOL GetHasProcsWithRpcSs()
  1926. {
  1927. return fHasProcsWithRpcSs;
  1928. }
  1929. virtual
  1930. node_file * GetDefiningFile()
  1931. {
  1932. return pDefiningFile;
  1933. }
  1934. void SetHasProcsWithRpcSs()
  1935. {
  1936. fHasProcsWithRpcSs = TRUE;
  1937. }
  1938. BOOL PrintedDef()
  1939. {
  1940. return fPrintedDef;
  1941. }
  1942. void SetPrintedDef()
  1943. {
  1944. fPrintedDef = TRUE;
  1945. }
  1946. BOOL PrintedIID()
  1947. {
  1948. return fPrintedIID;
  1949. }
  1950. void SetPrintedIID()
  1951. {
  1952. fPrintedIID = TRUE;
  1953. }
  1954. node_interface *GetMyBaseInterface();
  1955. // note that my base interface reference may be
  1956. // a fwd or null
  1957. named_node * GetMyBaseInterfaceReference()
  1958. {
  1959. return pBaseIntf;
  1960. }
  1961. named_node * SetMyBaseInterfaceReference( named_node * pIF )
  1962. {
  1963. return (pBaseIntf = pIF);
  1964. }
  1965. virtual
  1966. node_file * GetFileNode()
  1967. {
  1968. return pDefiningFile;
  1969. }
  1970. virtual
  1971. node_file * SetFileNode(node_file * pF)
  1972. {
  1973. return (pDefiningFile = pF);
  1974. }
  1975. CG_CLASS * GetCG(BOOL fInLibrary)
  1976. {
  1977. ResetCGIfNecessary();
  1978. if (fInLibrary)
  1979. return pMyTlbCG;
  1980. else
  1981. return pMyCG;
  1982. }
  1983. CG_CLASS * SetCG(BOOL fInLibrary, CG_CLASS * pF)
  1984. {
  1985. if (fInLibrary)
  1986. return (pMyTlbCG = pF);
  1987. else
  1988. return (pMyCG = pF);
  1989. }
  1990. SymTable * GetProcTbl()
  1991. {
  1992. return pProcTbl;
  1993. }
  1994. SymTable * SetProcTbl( SymTable * pS )
  1995. {
  1996. return (pProcTbl = pS);
  1997. }
  1998. unsigned short GetOptimizationFlags()
  1999. {
  2000. return OptimFlags;
  2001. }
  2002. unsigned short SetOptimizationFlags(unsigned short F)
  2003. {
  2004. return (OptimFlags = F);
  2005. }
  2006. OPT_LEVEL_ENUM GetOptimizationLevel()
  2007. {
  2008. return (OPT_LEVEL_ENUM) OptimLevel;
  2009. }
  2010. OPT_LEVEL_ENUM SetOptimizationLevel( OPT_LEVEL_ENUM Level )
  2011. {
  2012. return OptimLevel = Level;
  2013. }
  2014. virtual
  2015. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();}
  2016. virtual
  2017. void GetPositionInfo( tracked_node & Posn )
  2018. {
  2019. if (this->HasTracking() )
  2020. Posn = * ((tracked_node *) this);
  2021. }
  2022. virtual
  2023. STATUS_T DoPrintType( PRTFLAGS Flags,
  2024. BufferManager * pBuffer,
  2025. ISTREAM * pStream,
  2026. node_skl * pParent,
  2027. node_skl * pIntf );
  2028. virtual
  2029. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2030. virtual
  2031. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2032. virtual BOOL HasOLEAutomation() { return fHasOLEAutomation; };
  2033. virtual void HasOLEAutomation(BOOL fHas) { fHasOLEAutomation = fHas; };
  2034. virtual node_interface*
  2035. GetAsyncInterface() { return pAsyncInterface; };
  2036. virtual void
  2037. SetAsyncInterface( node_interface* pIF ) { pAsyncInterface = pIF; };
  2038. }; // end of class node_interface
  2039. class node_pipe;
  2040. // the interface
  2041. class node_interface_reference : public named_node
  2042. {
  2043. private:
  2044. public:
  2045. node_interface_reference( node_interface * pIntf )
  2046. : named_node( NODE_INTERFACE_REFERENCE )
  2047. {
  2048. SetChild( pIntf );
  2049. SetSymName( pIntf->GetSymName() );
  2050. }
  2051. node_interface *GetRealInterface()
  2052. {
  2053. return (node_interface *)GetChild();
  2054. }
  2055. named_node * GetMyBaseInterfaceReference()
  2056. {
  2057. return ((node_interface *)GetChild())->
  2058. GetMyBaseInterfaceReference();
  2059. }
  2060. virtual
  2061. STATUS_T DoPrintType( PRTFLAGS Flags,
  2062. BufferManager * pBuffer,
  2063. ISTREAM * pStream,
  2064. node_skl * pParent,
  2065. node_skl * pIntf );
  2066. virtual
  2067. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2068. BufferManager * pBuffer,
  2069. ISTREAM * pStream,
  2070. node_skl * pParent,
  2071. node_skl * pIntf );
  2072. virtual
  2073. FRONT_MEMORY_INFO GetMemoryInfo( ) { return GetInvalidMemoryInfo();}
  2074. virtual
  2075. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2076. virtual
  2077. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2078. }; // end of class node_interface_reference
  2079. /***
  2080. *** unnamed nodes
  2081. ***/
  2082. // the root of the typegraph
  2083. class node_source : public node_skl, public MEMLIST
  2084. {
  2085. public:
  2086. node_source()
  2087. : node_skl( NODE_SOURCE, NULL )
  2088. {
  2089. }
  2090. virtual
  2091. STATUS_T DoPrintType( PRTFLAGS Flags,
  2092. BufferManager * pBuffer,
  2093. ISTREAM * pStream,
  2094. node_skl * pParent,
  2095. node_skl * pIntf );
  2096. virtual
  2097. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();};
  2098. virtual
  2099. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2100. virtual
  2101. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2102. }; // end of class node_source
  2103. // pointers and arrays
  2104. class npa_nodes : public node_skl
  2105. {
  2106. unsigned long fHasCSType : 1; // An array of international chars
  2107. public:
  2108. npa_nodes( NODE_T Kind )
  2109. : node_skl( Kind, NULL )
  2110. {
  2111. fHasCSType = FALSE;
  2112. };
  2113. void SetHasCSType()
  2114. {
  2115. fHasCSType = TRUE;
  2116. }
  2117. BOOL HasCSType()
  2118. {
  2119. return fHasCSType;
  2120. }
  2121. BOOL FInSummary( ATTR_T flag )
  2122. {
  2123. BOOL result;
  2124. if ( flag >= ATTR_CPORT_ATTRIBUTES_START && flag <= ATTR_CPORT_ATTRIBUTES_END)
  2125. {
  2126. result = GetModifiers().IsModifierSet( flag );
  2127. }
  2128. else
  2129. {
  2130. result = FALSE;
  2131. }
  2132. return result;
  2133. };
  2134. BOOL IsPtrOrArray()
  2135. {
  2136. return TRUE;
  2137. }
  2138. }; // end of class npa_nodes
  2139. // pointers
  2140. class node_pointer : public npa_nodes
  2141. {
  2142. private:
  2143. public:
  2144. // constructors
  2145. node_pointer()
  2146. : npa_nodes( NODE_POINTER )
  2147. {
  2148. }
  2149. node_pointer(node_skl * pChild)
  2150. : npa_nodes( NODE_POINTER )
  2151. {
  2152. SetChild(pChild);
  2153. }
  2154. virtual
  2155. FRONT_MEMORY_INFO GetMemoryInfo();
  2156. virtual
  2157. STATUS_T DoPrintType( PRTFLAGS Flags,
  2158. BufferManager * pBuffer,
  2159. ISTREAM * pStream,
  2160. node_skl * pParent,
  2161. node_skl * pIntf );
  2162. virtual
  2163. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2164. BufferManager * pBuffer,
  2165. ISTREAM * pStream,
  2166. node_skl * pParent,
  2167. node_skl * pIntf );
  2168. virtual
  2169. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2170. virtual
  2171. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2172. }; // end of class node_pointer
  2173. // array
  2174. class node_array : public npa_nodes
  2175. {
  2176. expr_node * pUpperBound;
  2177. expr_node * pLowerBound;
  2178. unsigned long fConformant : 1;
  2179. unsigned long fMaybeVarying : 1; // set during semantic analysis
  2180. unsigned long fHasPointer : 1;
  2181. public:
  2182. node_array( expr_node * pLower, expr_node * pUpper )
  2183. : npa_nodes( NODE_ARRAY )
  2184. {
  2185. pUpperBound = pUpper;
  2186. pLowerBound = pLower;
  2187. fMaybeVarying = TRUE;
  2188. fConformant = (pUpper == (expr_node *) -1);
  2189. fHasPointer = FALSE;
  2190. }
  2191. BOOL HasPointer()
  2192. {
  2193. return fHasPointer;
  2194. };
  2195. virtual
  2196. STATUS_T DoPrintType( PRTFLAGS Flags,
  2197. BufferManager * pBuffer,
  2198. ISTREAM * pStream,
  2199. node_skl * pParent,
  2200. node_skl * pIntf );
  2201. virtual
  2202. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2203. BufferManager * pBuffer,
  2204. ISTREAM * pStream,
  2205. node_skl * pParent,
  2206. node_skl * pIntf );
  2207. virtual
  2208. FRONT_MEMORY_INFO GetMemoryInfo();
  2209. virtual
  2210. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2211. virtual
  2212. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2213. }; // end of class node_array
  2214. // misc strings to echo directly
  2215. class node_echo_string : public named_node
  2216. {
  2217. protected:
  2218. char * pString;
  2219. public:
  2220. node_echo_string( char * pStr )
  2221. : named_node( NODE_ECHO_STRING )
  2222. {
  2223. pString = pStr;
  2224. SetChild( NULL );
  2225. };
  2226. char * GetEchoString()
  2227. {
  2228. return pString;
  2229. };
  2230. virtual
  2231. void PrintSelf( ISTREAM * pStream );
  2232. virtual
  2233. STATUS_T DoPrintType( PRTFLAGS Flags,
  2234. BufferManager * pBuffer,
  2235. ISTREAM * pStream,
  2236. node_skl * pParent,
  2237. node_skl * pIntf );
  2238. virtual
  2239. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();}
  2240. virtual
  2241. void PrintMemoryInfo( ISTREAM *pStream, BOOL bNewLine );
  2242. virtual
  2243. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2244. virtual
  2245. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2246. }; // end of class node_echo_string
  2247. // #pragma pack(...) string node
  2248. #define PRAGMA_PACK_GARBAGE 0
  2249. #define PRAGMA_PACK_PUSH 1
  2250. #define PRAGMA_PACK_POP 2
  2251. #define PRAGMA_PACK_SET 3
  2252. #define PRAGMA_PACK_RESET 4
  2253. class node_pragma_pack : public node_echo_string
  2254. {
  2255. private:
  2256. node_pragma_pack * pStackLink;
  2257. unsigned short PackType;
  2258. unsigned short usPackingLevel;
  2259. unsigned short usNewLevel;
  2260. public:
  2261. node_pragma_pack( char * ID,
  2262. unsigned short lvl,
  2263. unsigned short PT,
  2264. unsigned short nlvl = 0 )
  2265. : node_echo_string( ID )
  2266. {
  2267. usPackingLevel = lvl;
  2268. PackType = PT;
  2269. usNewLevel = nlvl;
  2270. }
  2271. unsigned short GetZeePee()
  2272. {
  2273. return usPackingLevel;
  2274. }
  2275. // link self on as new top node
  2276. void Push( node_pragma_pack *& pTop );
  2277. // search for matching push and pop it off, returning new ZP
  2278. unsigned short Pop( node_pragma_pack *& pTop );
  2279. virtual
  2280. void PrintSelf( ISTREAM * pStream );
  2281. };
  2282. class node_e_status_t : public named_node
  2283. {
  2284. public:
  2285. node_e_status_t();
  2286. void VerifyParamUsage( SEM_ANALYSIS_CTXT * pCtxt );
  2287. virtual
  2288. STATUS_T DoPrintType( PRTFLAGS Flags,
  2289. BufferManager * pBuffer,
  2290. ISTREAM * pStream,
  2291. node_skl * pParent,
  2292. node_skl * pIntf );
  2293. virtual
  2294. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2295. BufferManager * pBuffer,
  2296. ISTREAM * pStream,
  2297. node_skl * pParent,
  2298. node_skl * pIntf );
  2299. virtual
  2300. FRONT_MEMORY_INFO GetMemoryInfo() {return GetModifiedMemoryInfoFromChild();}
  2301. virtual
  2302. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2303. virtual
  2304. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2305. }; // end of class node_e_status_t
  2306. // error status -- may go away
  2307. class node_error : public node_skl
  2308. {
  2309. public:
  2310. node_error()
  2311. : node_skl( NODE_ERROR, NULL )
  2312. {
  2313. }
  2314. virtual
  2315. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();}
  2316. virtual
  2317. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2318. virtual
  2319. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2320. }; // end of class node_error
  2321. // Flag if the variable is used in a size_is, etc expression, and wether or not
  2322. // it's a cs_char array expression
  2323. enum SIZE_LENGTH_USAGE
  2324. {
  2325. NoSizeLengthUsage,
  2326. CSSizeLengthUsage,
  2327. NonCSSizeLengthUsage
  2328. };
  2329. // base types e.g. char, long
  2330. class node_base_type : public named_node
  2331. {
  2332. // SIZE_LENGTH_USAGE SizeLengthUsage;
  2333. public:
  2334. node_base_type( NODE_T MyKind, ATTR_T attr )
  2335. : named_node( MyKind )
  2336. {
  2337. if ( attr != ATTR_NONE )
  2338. GetModifiers().SetModifier( attr );
  2339. // SizeLengthUsage = NoSizeLengthUsage;
  2340. };
  2341. node_base_type( const node_base_type * pOriginal )
  2342. : named_node( NODE_ILLEGAL )
  2343. {
  2344. *this = *pOriginal;
  2345. }
  2346. virtual
  2347. BOOL IsBasicType()
  2348. {
  2349. return TRUE;
  2350. }
  2351. virtual
  2352. BOOL IsStringableType()
  2353. {
  2354. return ( NodeKind() == NODE_CHAR ) ||
  2355. ( NodeKind() == NODE_BYTE );
  2356. }
  2357. BOOL IsAssignmentCompatible( node_base_type * );
  2358. // bool IsCompatibleType( TypeSet set ); Nishad
  2359. /*
  2360. BUGBUG: CG_INTERFACE_POINTER has a bug where it will case a node_base_type to
  2361. a node_interface for QI. It just happens to work at the momement but
  2362. when the size for node_base_type is increased it causes the TLB code
  2363. to AV. Put this back when that is fixed. -- MikeW
  2364. SIZE_LENGTH_USAGE GetSizeLengthUsage()
  2365. {
  2366. return SizeLengthUsage;
  2367. }
  2368. void SetSizeLengthUsage( SIZE_LENGTH_USAGE usage )
  2369. {
  2370. SizeLengthUsage = usage;
  2371. }
  2372. */
  2373. BOOL RangeCheck( __int64 Val );
  2374. BOOL IsUnsigned();
  2375. virtual
  2376. EXPR_VALUE ConvertMyKindOfValueToEXPR_VALUE( __int64 EXPR_VALUE );
  2377. void CheckVoidUsage( SEM_ANALYSIS_CTXT * pContext );
  2378. void CheckVoidUsageInDispinterface( SEM_ANALYSIS_CTXT * pContext );
  2379. virtual
  2380. STATUS_T DoPrintType( PRTFLAGS Flags,
  2381. BufferManager * pBuffer,
  2382. ISTREAM * pStream,
  2383. node_skl * pParent,
  2384. node_skl * pIntf );
  2385. virtual
  2386. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2387. BufferManager * pBuffer,
  2388. ISTREAM * pStream,
  2389. node_skl * pParent,
  2390. node_skl * pIntf );
  2391. virtual
  2392. FRONT_MEMORY_INFO GetMemoryInfo();
  2393. virtual
  2394. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2395. virtual
  2396. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2397. }; // end of class node_base_type
  2398. // character width specifier
  2399. class node_wchar_t : public named_node
  2400. {
  2401. public:
  2402. node_wchar_t();
  2403. virtual
  2404. BOOL IsStringableType()
  2405. {
  2406. return TRUE;
  2407. }
  2408. virtual
  2409. STATUS_T DoPrintType( PRTFLAGS Flags,
  2410. BufferManager * pBuffer,
  2411. ISTREAM * pStream,
  2412. node_skl * pParent,
  2413. node_skl * pIntf );
  2414. virtual
  2415. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2416. BufferManager * pBuffer,
  2417. ISTREAM * pStream,
  2418. node_skl * pParent,
  2419. node_skl * pIntf );
  2420. virtual
  2421. FRONT_MEMORY_INFO GetMemoryInfo() {return GetModifiedMemoryInfoFromChild();}
  2422. virtual
  2423. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2424. virtual
  2425. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2426. }; // end of class node_wchar_t
  2427. class node_library : public node_interface
  2428. {
  2429. private:
  2430. public:
  2431. node_library()
  2432. : node_interface( NODE_LIBRARY )
  2433. {
  2434. }
  2435. virtual
  2436. void GetPositionInfo( tracked_node & Posn )
  2437. {
  2438. if (this->HasTracking() )
  2439. Posn = * ((tracked_node *) this);
  2440. }
  2441. virtual
  2442. STATUS_T DoPrintType( PRTFLAGS Flags,
  2443. BufferManager * pBuffer,
  2444. ISTREAM * pStream,
  2445. node_skl * pParent,
  2446. node_skl * pIntf );
  2447. virtual
  2448. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2449. virtual
  2450. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2451. virtual
  2452. node_file * SetFileNode(node_file * pF)
  2453. {
  2454. named_node * pN;
  2455. MEM_ITER MemIter(this);
  2456. while ( pN = MemIter.GetNext() )
  2457. {
  2458. pN->SetFileNode( pF );
  2459. }
  2460. return (pDefiningFile = pF);
  2461. }
  2462. }; // end of class node_library
  2463. class node_coclass : public node_interface
  2464. {
  2465. private:
  2466. BOOL fNotCreatable;
  2467. protected:
  2468. public:
  2469. node_coclass()
  2470. : node_interface( NODE_COCLASS )
  2471. {
  2472. fNotCreatable = FALSE;
  2473. }
  2474. virtual
  2475. void GetPositionInfo( tracked_node & Posn )
  2476. {
  2477. if (this->HasTracking() )
  2478. Posn = * ((tracked_node *) this);
  2479. }
  2480. virtual
  2481. STATUS_T DoPrintType( PRTFLAGS Flags,
  2482. BufferManager * pBuffer,
  2483. ISTREAM * pStream,
  2484. node_skl * pParent,
  2485. node_skl * pIntf );
  2486. virtual
  2487. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2488. BufferManager * pBuffer,
  2489. ISTREAM * pStream,
  2490. node_skl * pParent,
  2491. node_skl * pIntf );
  2492. virtual
  2493. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2494. BOOL IsNotCreatable(void)
  2495. {
  2496. return fNotCreatable;
  2497. }
  2498. BOOL SetNotCreatable(BOOL f)
  2499. {
  2500. return (fNotCreatable = f);
  2501. }
  2502. virtual
  2503. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2504. }; // end of class node_coclass
  2505. class node_module : public node_interface
  2506. {
  2507. private:
  2508. protected:
  2509. public:
  2510. node_module()
  2511. : node_interface( NODE_MODULE )
  2512. {
  2513. }
  2514. virtual
  2515. void GetPositionInfo( tracked_node & Posn )
  2516. {
  2517. if (this->HasTracking() )
  2518. Posn = * ((tracked_node *) this);
  2519. }
  2520. virtual
  2521. STATUS_T DoPrintType( PRTFLAGS Flags,
  2522. BufferManager * pBuffer,
  2523. ISTREAM * pStream,
  2524. node_skl * pParent,
  2525. node_skl * pIntf );
  2526. virtual
  2527. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2528. virtual
  2529. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2530. }; // end of class node_module
  2531. class node_dispinterface : public node_interface
  2532. {
  2533. named_node * pDispatch;
  2534. protected:
  2535. public:
  2536. node_dispinterface()
  2537. : node_interface( NODE_DISPINTERFACE )
  2538. {
  2539. }
  2540. virtual
  2541. void GetPositionInfo( tracked_node & Posn )
  2542. {
  2543. if (this->HasTracking() )
  2544. Posn = * ((tracked_node *) this);
  2545. }
  2546. virtual
  2547. STATUS_T DoPrintType( PRTFLAGS Flags,
  2548. BufferManager * pBuffer,
  2549. ISTREAM * pStream,
  2550. node_skl * pParent,
  2551. node_skl * pIntf );
  2552. virtual STATUS_T
  2553. DoPrintDecl (
  2554. PRTFLAGS Flags,
  2555. BufferManager* pBuffer,
  2556. ISTREAM* pStream,
  2557. node_skl* pParent,
  2558. node_skl* pIntf
  2559. );
  2560. virtual
  2561. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2562. virtual
  2563. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2564. named_node * GetIDispatch()
  2565. {
  2566. return pDispatch;
  2567. }
  2568. }; // end of class node_dispinterface
  2569. #define SZ_ASYNCPIPEDEFPREFIX "ASYNC_"
  2570. class node_pipe : public named_node
  2571. {
  2572. private:
  2573. bool fGenAsyncPipeFlavor;
  2574. protected:
  2575. bool
  2576. GenAsyncPipeFlavor() { return fGenAsyncPipeFlavor; }
  2577. void
  2578. SetGenAsyncPipeFlavor( bool fGen = true ) { fGenAsyncPipeFlavor = fGen; }
  2579. STATUS_T PrintDeclaration(
  2580. PRTFLAGS Flags,
  2581. BufferManager* pBuffer,
  2582. ISTREAM* pStream,
  2583. node_skl* pParent,
  2584. node_skl* pIntf,
  2585. char* szPrefix
  2586. );
  2587. public:
  2588. // constructors
  2589. node_pipe()
  2590. : named_node( NODE_PIPE ),
  2591. fGenAsyncPipeFlavor( false )
  2592. {
  2593. }
  2594. node_pipe(node_skl * pType)
  2595. : named_node( NODE_PIPE ),
  2596. fGenAsyncPipeFlavor( false )
  2597. {
  2598. SetChild(pType);
  2599. }
  2600. virtual
  2601. STATUS_T DoPrintType( PRTFLAGS Flags,
  2602. BufferManager * pBuffer,
  2603. ISTREAM * pStream,
  2604. node_skl * pParent,
  2605. node_skl * pIntf );
  2606. virtual
  2607. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2608. BufferManager * pBuffer,
  2609. ISTREAM * pStream,
  2610. node_skl * pParent,
  2611. node_skl * pIntf );
  2612. virtual
  2613. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();}
  2614. virtual
  2615. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2616. virtual
  2617. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2618. }; // end of class node_pipe
  2619. class node_safearray : public npa_nodes
  2620. {
  2621. private:
  2622. // this maintains a reference to LPSAFEARRAY. This is
  2623. // necessary to generate the appropriate code when
  2624. // SAFEARRAY(type) construct is used outside the library block
  2625. named_node* pSafeArrayTypedef;
  2626. BOOL fInProxy;
  2627. public:
  2628. // constructors
  2629. node_safearray()
  2630. : npa_nodes( NODE_SAFEARRAY ),
  2631. pSafeArrayTypedef( 0 ),
  2632. fInProxy(0)
  2633. {
  2634. }
  2635. node_safearray(node_skl * pType)
  2636. : npa_nodes( NODE_SAFEARRAY ),
  2637. pSafeArrayTypedef( 0 ),
  2638. fInProxy(0)
  2639. {
  2640. SetChild(pType);
  2641. }
  2642. virtual
  2643. STATUS_T DoPrintType( PRTFLAGS Flags,
  2644. BufferManager * pBuffer,
  2645. ISTREAM * pStream,
  2646. node_skl * pParent,
  2647. node_skl * pIntf );
  2648. virtual
  2649. STATUS_T DoPrintDecl( PRTFLAGS Flags,
  2650. BufferManager * pBuffer,
  2651. ISTREAM * pStream,
  2652. node_skl * pParent,
  2653. node_skl * pIntf );
  2654. virtual
  2655. FRONT_MEMORY_INFO GetMemoryInfo();
  2656. virtual
  2657. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2658. virtual
  2659. CG_CLASS * ILxlate( XLAT_CTXT * pContext );
  2660. virtual
  2661. void SetTypeAlias( named_node* pAlias) { pSafeArrayTypedef = pAlias; };
  2662. virtual
  2663. named_node* GetTypeAlias( void ) { return pSafeArrayTypedef; };
  2664. }; // end of class node_pointer
  2665. class node_async_handle : public named_node
  2666. {
  2667. private:
  2668. public:
  2669. node_async_handle( char* szName ) : named_node( szName, NODE_ASYNC_HANDLE )
  2670. {
  2671. }
  2672. STATUS_T DoPrintDecl(PRTFLAGS Flags,
  2673. BufferManager* pBuffer,
  2674. ISTREAM* pStream,
  2675. node_skl* pParent,
  2676. node_skl* pIntf );
  2677. STATUS_T DoPrintType(PRTFLAGS Flags,
  2678. BufferManager* pBuffer,
  2679. ISTREAM* pStream,
  2680. node_skl* pParent,
  2681. node_skl* pIntf);
  2682. virtual
  2683. FRONT_MEMORY_INFO GetMemoryInfo( ) { return GetInvalidMemoryInfo();}
  2684. CG_CLASS* ILxlate( XLAT_CTXT* pContext );
  2685. void SemanticAnalysis( SEM_ANALYSIS_CTXT * pParentCtxt );
  2686. }; // node_async_handle
  2687. typedef enum __PragmaType
  2688. {
  2689. mp_MessageDisable,
  2690. mp_MessageEnable
  2691. } PragmaType;
  2692. class node_midl_pragma : public named_node
  2693. {
  2694. private:
  2695. PragmaType m_PragmaType;
  2696. gplistmgr* m_pMsgList;
  2697. public:
  2698. node_midl_pragma( PragmaType pt, gplistmgr* pList ) :
  2699. named_node( NODE_MIDL_PRAGMA, "midl_pragma" ),
  2700. m_PragmaType( pt ),
  2701. m_pMsgList( pList )
  2702. {
  2703. }
  2704. virtual
  2705. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();}
  2706. void SemanticAnalysis( SEM_ANALYSIS_CTXT* );
  2707. CG_CLASS* ILxlate( XLAT_CTXT* pContext );
  2708. void ProcessPragma();
  2709. }; // node_midl_pragma
  2710. class node_decl_guid : public named_node
  2711. {
  2712. public:
  2713. node_decl_guid( char* szName, node_guid* guid ) : named_node( NODE_DECL_GUID, szName ),
  2714. pGuid( guid )
  2715. {
  2716. }
  2717. virtual
  2718. FRONT_MEMORY_INFO GetMemoryInfo() {return GetInvalidMemoryInfo();}
  2719. void SemanticAnalysis( SEM_ANALYSIS_CTXT* );
  2720. CG_CLASS* ILxlate( XLAT_CTXT* pContext );
  2721. STATUS_T
  2722. DoPrintType (
  2723. PRTFLAGS,
  2724. BufferManager*,
  2725. ISTREAM*,
  2726. node_skl*,
  2727. node_skl*
  2728. );
  2729. STATUS_T
  2730. DoPrintDecl (
  2731. PRTFLAGS,
  2732. BufferManager*,
  2733. ISTREAM*,
  2734. node_skl*,
  2735. node_skl*
  2736. );
  2737. private:
  2738. node_guid* pGuid;
  2739. };
  2740. #endif // __NODESKL_HXX__