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.

136 lines
3.2 KiB

4 years ago
  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989 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. pCGSource = Transform( pNode );
  51. #ifdef MIDL_INTERNAL
  52. printf("ILxlate done\n");
  53. if(pCommand->IsSwitchDefined( SWITCH_DUMP ) )
  54. {
  55. print_memstats();
  56. };
  57. #endif // MIDL_INTERNAL
  58. //
  59. // This is temporary initialization code. The final code may differ.
  60. //
  61. CCB CCB( DEFAULT_GB_RTN_NAME,
  62. DEFAULT_SR_RTN_NAME,
  63. DEFAULT_FB_RTN_NAME,
  64. pCommand->GetOptimizationFlags(),
  65. pCommand->IsSwitchDefined( SWITCH_USE_EPV ),
  66. pCommand->IsSwitchDefined( SWITCH_NO_DEFAULT_EPV ),
  67. pCommand->IsSwitchDefined( SWITCH_OLDNAMES ),
  68. pCommand->IsSwitchDefined( SWITCH_MS_EXT ) ? 1 : 0,
  69. pCommand->IsRpcSSAllocateEnabled(),
  70. ((pCommand->GetErrorOption() & ERROR_ALLOCATION) == ERROR_ALLOCATION),
  71. ((pCommand->GetErrorOption() & ERROR_REF) == ERROR_REF),
  72. ((pCommand->GetErrorOption() & ERROR_ENUM) == ERROR_ENUM),
  73. ((pCommand->GetErrorOption() & ERROR_BOUNDS_CHECK) == ERROR_BOUNDS_CHECK),
  74. ((pCommand->GetErrorOption() & ERROR_STUB_DATA) == ERROR_STUB_DATA)
  75. );
  76. //
  77. // Do the code generation.
  78. //
  79. #ifdef MIDL_INTERNAL
  80. if( pCommand->IsSwitchDefined( SWITCH_DUMP ) )
  81. {
  82. printf("dumping IL\n");
  83. pCGSource->Dump(0);
  84. }
  85. #endif // MIDL_INTERNAL
  86. pCompiler->SetPassNumber( CODEGEN_PASS );
  87. // define NO_CODEGEN to stop after IL translation
  88. #ifndef NO_CODEGEN
  89. pCGSource->GenCode( &CCB );
  90. #endif
  91. }