Windows NT 4.0 source code leak
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.

107 lines
2.6 KiB

4 years ago
  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. uniongen.cxx
  5. Abstract:
  6. union base in-line stuff.
  7. Notes:
  8. History:
  9. Jan-06-1994 VibhasC Created
  10. ----------------------------------------------------------------------------*/
  11. /****************************************************************************
  12. * include files
  13. ***************************************************************************/
  14. #include "becls.hxx"
  15. #pragma hdrstop
  16. /****************************************************************************
  17. * local definitions
  18. ***************************************************************************/
  19. /****************************************************************************
  20. * local data
  21. ***************************************************************************/
  22. /****************************************************************************
  23. * externs
  24. ***************************************************************************/
  25. /****************************************************************************/
  26. CG_STATUS
  27. CG_UNION::S_GenInitOutLocals(
  28. CCB * pCCB )
  29. {
  30. char Buffer[ 256 ];
  31. RESOURCE * pResource;
  32. PNAME p;
  33. CG_NDR * pLPC = pCCB->GetLastPlaceholderClass();
  34. sprintf( Buffer, "%s", pLPC->GetType()->GetSymName() );
  35. p = pCCB->GenTRNameOffLastParam( Buffer );
  36. pResource = pCCB->GetLocalResource( p );
  37. // There is a pointer for the top level structure.
  38. Out_Assign( pCCB,
  39. pCCB->GetSourceExpression(),
  40. MakeAddressExpressionNoMatterWhat( pResource )
  41. );
  42. if( HasPointer() )
  43. {
  44. expr_node * pSrc = pCCB->GetSourceExpression();
  45. // BUGBUG: Embedded structure are not inited yet!!
  46. // It is enough to emit code to set just the first pointer field to
  47. // 0. Guess why ?. Base type fields need not be set to 0.
  48. expr_proc_call * pProc = new expr_proc_call( MIDL_MEMSET_RTN_NAME );
  49. pProc->SetParam( new expr_param( pSrc ) );
  50. pProc->SetParam( new expr_param( new expr_constant( 0L ) ) );
  51. pProc->SetParam( new expr_param( new expr_sizeof( GetType())));
  52. pCCB->GetStream()->NewLine();
  53. pProc->PrintCall( pCCB->GetStream(), 0, 0 );
  54. }
  55. return CG_OK;
  56. }
  57. short
  58. CG_UNION::GetPointerMembers(
  59. ITERATOR& I )
  60. {
  61. CG_ITERATOR M;
  62. CG_CASE * pCase;
  63. short Count = 0;
  64. if( HasPointer() )
  65. {
  66. GetMembers( M );
  67. while( ITERATOR_GETNEXT( M, pCase ) )
  68. {
  69. CG_FIELD * pField = (CG_FIELD *)pCase->GetChild();
  70. if((pCase->FLastCase()||(pCase->GetCGID() == ID_CG_DEFAULT_CASE))&&
  71. pField && (pField->GetChild()) &&
  72. pField->GetChild()->IsPointer() )
  73. {
  74. ITERATOR_INSERT( I, pField );
  75. Count++;
  76. }
  77. }
  78. }
  79. return Count;
  80. }