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.

231 lines
5.6 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. cgmain.cxx
  5. Abstract:
  6. The main entry point for the code generator.
  7. Notes:
  8. History:
  9. VibhasC Aug-13-1993 Created.
  10. ----------------------------------------------------------------------------*/
  11. /****************************************************************************
  12. * include files
  13. ***************************************************************************/
  14. #include "becls.hxx"
  15. #pragma hdrstop
  16. #include "control.hxx"
  17. #include "ilreg.hxx"
  18. /****************************************************************************
  19. * local definitions
  20. ***************************************************************************/
  21. /****************************************************************************
  22. * local data
  23. ***************************************************************************/
  24. /****************************************************************************
  25. * externs
  26. ***************************************************************************/
  27. extern node_interface * pBaseInterfaceNode;
  28. extern CMD_ARG * pCommand;
  29. extern ccontrol * pCompiler;
  30. extern CG_CLASS * Transform( node_skl * pIL );
  31. extern void print_memstats();
  32. /****************************************************************************/
  33. void
  34. CGMain(
  35. node_skl * pNode )
  36. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  37. Routine Description:
  38. The main code generator entry point.
  39. Arguments:
  40. pNode - A pointer to the type graph source node.
  41. Return Value:
  42. Code generation status.
  43. Notes:
  44. ----------------------------------------------------------------------------*/
  45. {
  46. CG_CLASS * pCGSource;
  47. //
  48. // Transform the type graph into the Code generation IL.
  49. //
  50. pCompiler->SetPassNumber( ILXLAT_PASS );
  51. pCGSource = Transform( pNode );
  52. #ifdef MIDL_INTERNAL
  53. printf("ILxlate done\n");
  54. if(pCommand->IsSwitchDefined( SWITCH_DUMP ) )
  55. {
  56. print_memstats();
  57. };
  58. #endif // MIDL_INTERNAL
  59. //
  60. // This is temporary initialization code. The final code may differ.
  61. //
  62. CCB CCB( DEFAULT_GB_RTN_NAME,
  63. DEFAULT_SR_RTN_NAME,
  64. DEFAULT_FB_RTN_NAME,
  65. pCommand->GetOptimizationFlags(),
  66. pCommand->IsSwitchDefined( SWITCH_USE_EPV ),
  67. pCommand->IsSwitchDefined( SWITCH_NO_DEFAULT_EPV ),
  68. pCommand->IsSwitchDefined( SWITCH_OLDNAMES ),
  69. pCommand->IsSwitchDefined( SWITCH_MS_EXT ) ? 1 : 0,
  70. pCommand->IsRpcSSAllocateEnabled(),
  71. ((pCommand->GetErrorOption() & ERROR_ALLOCATION) == ERROR_ALLOCATION),
  72. ((pCommand->GetErrorOption() & ERROR_REF) == ERROR_REF),
  73. ((pCommand->GetErrorOption() & ERROR_ENUM) == ERROR_ENUM),
  74. ((pCommand->GetErrorOption() & ERROR_BOUNDS_CHECK) == ERROR_BOUNDS_CHECK),
  75. ((pCommand->GetErrorOption() & ERROR_STUB_DATA) == ERROR_STUB_DATA)
  76. );
  77. //
  78. // Do the code generation.
  79. //
  80. #ifdef MIDL_INTERNAL
  81. if( pCommand->IsSwitchDefined( SWITCH_DUMP ) )
  82. {
  83. printf("dumping IL\n");
  84. pCGSource->Dump(0);
  85. }
  86. #endif // MIDL_INTERNAL
  87. pCompiler->SetPassNumber( CODEGEN_PASS );
  88. // define NO_CODEGEN to stop after IL translation
  89. #ifndef NO_CODEGEN
  90. pCGSource->GenCode( &CCB );
  91. #endif
  92. }
  93. CG_CLASS* ILSecondGenTransform( CG_CLASS *pClass );
  94. void
  95. Ndr64CGMain(
  96. node_skl * pNode )
  97. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  98. Routine Description:
  99. The main code generator entry point.
  100. Arguments:
  101. pNode - A pointer to the type graph source node.
  102. Return Value:
  103. Code generation status.
  104. Notes:
  105. ----------------------------------------------------------------------------*/
  106. {
  107. CG_CLASS * pCGSource;
  108. //
  109. // Transform the type graph into the Code generation IL.
  110. //
  111. pCompiler->SetPassNumber( NDR64_ILXLAT_PASS );
  112. pCGSource = Transform( pNode );
  113. #ifdef MIDL_INTERNAL
  114. printf("\nStage1 of ILxlate done\n");
  115. if(pCommand->IsSwitchDefined( SWITCH_DUMP ) )
  116. {
  117. printf("\n");
  118. printf("dumping stage 1 IL\n");
  119. pCGSource->Dump();
  120. };
  121. #endif // MIDL_INTERNAL
  122. pCGSource = ILSecondGenTransform( pCGSource );
  123. #ifdef MIDL_INTERNAL
  124. printf("\nStage2 of ILxlate done\n");
  125. if(pCommand->IsSwitchDefined( SWITCH_DUMP ) )
  126. {
  127. printf("\n");
  128. printf("dumping stage 2 IL\n");
  129. pCGSource->Dump();
  130. };
  131. #endif // MIDL_INTERNAL
  132. //
  133. // This is temporary initialization code. The final code may differ.
  134. //
  135. CCB CCB( DEFAULT_GB_RTN_NAME,
  136. DEFAULT_SR_RTN_NAME,
  137. DEFAULT_FB_RTN_NAME,
  138. pCommand->GetOptimizationFlags(),
  139. pCommand->IsSwitchDefined( SWITCH_USE_EPV ),
  140. pCommand->IsSwitchDefined( SWITCH_NO_DEFAULT_EPV ),
  141. pCommand->IsSwitchDefined( SWITCH_OLDNAMES ),
  142. pCommand->IsSwitchDefined( SWITCH_MS_EXT ) ? 1 : 0,
  143. pCommand->IsRpcSSAllocateEnabled(),
  144. ((pCommand->GetErrorOption() & ERROR_ALLOCATION) == ERROR_ALLOCATION),
  145. ((pCommand->GetErrorOption() & ERROR_REF) == ERROR_REF),
  146. ((pCommand->GetErrorOption() & ERROR_ENUM) == ERROR_ENUM),
  147. ((pCommand->GetErrorOption() & ERROR_BOUNDS_CHECK) == ERROR_BOUNDS_CHECK),
  148. ((pCommand->GetErrorOption() & ERROR_STUB_DATA) == ERROR_STUB_DATA)
  149. );
  150. //
  151. // Do the code generation.
  152. //
  153. pCompiler->SetPassNumber( NDR64_CODEGEN_PASS );
  154. // define NO_CODEGEN to stop after IL translation
  155. #ifndef NO_CODEGEN
  156. pCGSource->GenCode( &CCB );
  157. #endif
  158. }