Example #1
0
static void
process_pu (PU_Info *pu_tree)
{
    PU_Info *pu;

    for (pu = pu_tree; pu != NULL; pu = PU_Info_next(pu)) {
	Current_PU_Info = pu;
	MEM_POOL_Push (MEM_pu_nz_pool_ptr);
	Read_Local_Info (MEM_pu_nz_pool_ptr, pu);

	if (vflag)
	  printf ("%*sProcessing PU: %s\n", indent, "",
	          ST_name(PU_Info_proc_sym(pu)));
	indent += indent_inc;
	Process_PU (pu);

	process_stab (PU_Info_symtab_ptr(pu));

	process_func (PU_Info_tree_ptr(pu));

	if (PU_Info_child(pu)) {
	    process_pu (PU_Info_child(pu));
	}

#ifdef WRITE_IRB
	Write_PU_Info (pu);
#endif

	indent -= indent_inc;
	Free_Local_Info (pu);
	MEM_POOL_Pop (MEM_pu_nz_pool_ptr);

    }
}
Example #2
0
INT
main (INT argc,       /* Number of command line arguments */
      char *argv[],   /* Array of command line arguments */
      char *envp[])   /* Array of environment pointers */
{
   WN          *pu;
   INT32        ecount = 0, wcount = 0, local_ecount = 0, local_wcount = 0;
   INT32        inp_file_count;
   PU_Info     *pu_tree, *current_pu;

   /* Here are things that every process driver should do as soon as
   * possible upon start-up.
   */
   MEM_Initialize();
   Init_Error_Handler(10);
   Set_Error_Line(ERROR_LINE_UNKNOWN);
   Set_Error_Phase("Whirl2c");
   Set_Error_File(NULL); /* Use stderr */

   Preconfigure(); /* Setup target and host specific info before flags */
   Process_Common_Options(argc, argv, envp); /* Common options */
   Configure();    /* Setup target and host specific info after flags */

   Init_Operator_To_Opcode_Table();
    
   /* Process the source files */
   inp_file_count = Get_Irb_File_Name(argc, argv);
   if (inp_file_count == 0)
   {
      Usage(argv[0]);
      fprintf(stderr, "ERROR: missing input file on command-line\n");
   }
   else if (inp_file_count > 1)
   {
      Usage(argv[0]);
      fprintf(stderr, "ERROR: too many input files on command-line\n");
   }
   else
   {
      /* Get the global symbol table, the string table, the constant table,
       * and the initialization table, before initializing the translation
       * to C.
       */
      (void)Open_Input_Info(Irb_File_Name);
      pu_tree = Read_Global_Info(NULL);
      W2C_Process_Command_Line(argc, argv, argc, argv);
      W2C_Init(TRUE/*emit_global_decls*/);

      /* Loop thru all the PUs */
      for (current_pu = pu_tree;
	   current_pu != NULL;
	   current_pu = PU_Info_next (current_pu)) {

	 Current_PU_Info = current_pu;
	 MEM_POOL_Push (MEM_pu_nz_pool_ptr);
	 Read_Local_Info (MEM_pu_nz_pool_ptr, current_pu);
	 pu = PU_Info_tree_ptr(current_pu);

	 W2C_Translate_Pu(pu, TRUE/*emit_global_decls*/);

	 if (PU_Info_child(current_pu)) {
	    fprintf(stderr, "WARNING: ignoring nested procedures in \"%s\"\n",
		    ST_name(PU_Info_proc_sym(current_pu)));
	 }

	 Free_Local_Info (current_pu);
	 MEM_POOL_Pop (MEM_pu_nz_pool_ptr);
      } /* for each PU */

      W2C_Fini(TRUE/*emit_global_decls*/);
      Cleanup_Files(TRUE, FALSE);
   }
   
   /* If we've seen errors, note them and terminate: */
   if (Get_Error_Count(&local_ecount, &local_wcount))
   {
      ecount += local_ecount;
      wcount += local_wcount;
   }
   if ( ecount > 0 )
   {
      Local_Terminate();
      Terminate(1);
   }
   
   exit(0);
} /* main */