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.

203 lines
4.4 KiB

4 years ago
  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. Notes:
  6. History:
  7. ----------------------------------------------------------------------------*/
  8. /****************************************************************************
  9. * include files
  10. ***************************************************************************/
  11. #include "becls.hxx"
  12. #pragma hdrstop
  13. /****************************************************************************
  14. * local definitions
  15. ***************************************************************************/
  16. /****************************************************************************
  17. * local data
  18. ***************************************************************************/
  19. /****************************************************************************
  20. * externs
  21. ***************************************************************************/
  22. /****************************************************************************/
  23. CG_STATUS
  24. CG_STRUCT::GenCode(
  25. CCB * pCCB )
  26. {
  27. ANALYSIS_INFO Analysis;
  28. // Set up.
  29. pCCB->SetCodeGenSide( CGSIDE_AUX );
  30. pCCB->SetCodeGenPhase( CGPHASE_MARSHALL );
  31. Analysis.SetCurrentSide( A_SIDE );
  32. Analysis.SetCurrentPhase( ANA_PHASE_AUX_MARSHALL );
  33. Analysis.SetOptimOption( pCCB->GetOptimOption() );
  34. // Perform the marshall analysis. This also performs the sizing
  35. // analysis. And puts all the local vaiables in the transient dictionary.
  36. AuxMarshallAnalysis( &Analysis );
  37. // Transfer the transient local dictionary from the analysis block to the
  38. // code generation block.
  39. pCCB->SetResDictDatabase( Analysis.GetResDictDatabase() );
  40. GenAuxSizing( pCCB );
  41. GenAuxMarshall( pCCB );
  42. // For the unmarshall pass, allocate a fresh transient resource dictionary
  43. // again.
  44. AuxUnMarshallAnalysis( &Analysis );
  45. GenAuxUnMarshall( pCCB );
  46. GenAuxMemSizing( pCCB );
  47. GenAuxFree( pCCB );
  48. return CG_OK;
  49. }
  50. CG_STATUS
  51. CG_STRUCT::GenAuxMarshall(
  52. CCB * pCCB )
  53. {
  54. return CG_OK;
  55. }
  56. CG_STATUS
  57. CG_STRUCT::GenAuxUnMarshall(
  58. CCB * pCCB )
  59. {
  60. return CG_OK;
  61. }
  62. CG_STATUS
  63. CG_STRUCT::GenAuxMemSizing(
  64. CCB * pCCB )
  65. {
  66. return CG_OK;
  67. }
  68. CG_STATUS
  69. CG_STRUCT::GenAuxFree(
  70. CCB * pCCB )
  71. {
  72. return CG_OK;
  73. }
  74. CG_STATUS
  75. CG_STRUCT::GenAuxSizing(
  76. CCB * pCCB )
  77. {
  78. ITERATOR I;
  79. ITERATOR T;
  80. RESOURCE * pStruct;
  81. RESOURCE * Length;
  82. node_skl * pNode;
  83. CG_FIELD * pField;
  84. // Add a parameter which is the structure pointer.
  85. // Add a length parameter.
  86. pNode = MakePtrParamNode( STRUCT_PTR_NAME, GetType() );
  87. pStruct = pCCB->AddParamResource( STRUCT_PTR_NAME, pNode );
  88. pCCB->SetSourceExpression( pStruct );
  89. pNode = MakeParamNodeFromTypeName( LENGTH_VAR_NAME, LENGTH_VAR_TYPE_NAME );
  90. Length = pCCB->AddParamResource( LENGTH_VAR_NAME, pNode );
  91. // Prepare the list of params to the sizing aux routine,
  92. ITERATOR_INSERT( I, pStruct );
  93. ITERATOR_INSERT( I, Length );
  94. // Emit the proto for the auxillary routine.
  95. Out_EmitSizingProlog( pCCB, I, GetType() );
  96. pCCB->GetListOfTransientResources( T );
  97. Out_ClientLocalVariables( pCCB, T );
  98. // Emit code to align the length by the natural alignment of the struct.
  99. Out_ForceAlignment( pCCB,
  100. Length,
  101. GetWireAlignment() );
  102. // Emit the fixed size.
  103. Out_PlusEquals( pCCB, Length, GetSizeExpression() );
  104. // Ask each of the fields about their size. Emit the initial
  105. // assignment to the length variable, which is the fixed size.
  106. pCCB->SetSourceExpression( pStruct );
  107. pCCB->SetPrefix( STRUCT_PTR_NAME"->" );
  108. GetMembers( I );
  109. while( ITERATOR_GETNEXT( I, pField ) )
  110. {
  111. pField->GenSizing( pCCB );
  112. }
  113. Out_EndSizingProc( pCCB );
  114. pCCB->SetPrefix( 0 );
  115. return CG_OK;
  116. }
  117. CG_STATUS
  118. CG_FIELD::GenSizing(
  119. CCB * pCCB )
  120. {
  121. if( (GetRpcBufSizeProperty() & BSIZE_UNKNOWN) == BSIZE_UNKNOWN )
  122. {
  123. expr_node * pExpr;
  124. pCCB->ResetIndirectionLevel();
  125. pCCB->ResetRefAllocDone();
  126. pCCB->SetMemoryAllocDone();
  127. pCCB->ResetReturnContext();
  128. pCCB->SetDeferPointee();
  129. pExpr = new expr_op_binary( OP_POINTSTO,
  130. pCCB->GetSourceExpression(),
  131. GetResource()
  132. );
  133. pCCB->SetSourceExpression( pExpr );
  134. ((CG_NDR *)GetChild())->GenSizing( pCCB );
  135. if( pCCB->HasAtLeastOneDeferredPointee() )
  136. {
  137. pCCB->ResetIndirectionLevel();
  138. pCCB->ResetRefAllocDone();
  139. pCCB->SetMemoryAllocDone();
  140. pCCB->ResetReturnContext();
  141. pCCB->ResetDeferPointee();
  142. }
  143. return CG_OK;
  144. }
  145. return CG_OK;
  146. }