Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include "defs.h"
00049 #include "region_util.h"
00050 #include "tracing.h"
00051 #include "config.h"
00052 #include "phase.h"
00053 #include "driver_util.h"
00054 #include "cxx_memory.h"
00055 #include "config_wopt.h"
00056 #include "flags.h"
00057 #include "options_stack.h"
00058
00059
00060 #if defined(_GCC_NO_PRAGMAWEAK) || defined(__CYGWIN__)
00061 extern "C" void Process_Command_Line (INT, char **) { }
00062 #else
00063 # pragma weak Process_Command_Line
00064 #endif
00065
00066
00067
00068
00069
00070 void
00071 OPTIONS_STACK::Push_Current_Options(void)
00072 {
00073
00074 char *tmp = CXX_NEW_ARRAY(char, OPTIONS_SIZE, &MEM_pu_nz_pool);
00075
00076
00077 Save_or_restore_options(tmp, OPTIONS_SIZE, TRUE);
00078
00079
00080 _options_stack.Push(tmp);
00081
00082 Is_Trace(Trace(), (TFile,"OPTIONS_STACK::Push_Current_Options, size=%d\n",
00083 _options_stack.Elements()));
00084 }
00085
00086
00087
00088
00089
00090 void
00091 OPTIONS_STACK::Pop_Current_Options(void)
00092 {
00093
00094 char *tmp = _options_stack.Top();
00095 _options_stack.Pop();
00096 CXX_DELETE_ARRAY(tmp, &MEM_pu_nz_pool);
00097
00098
00099 tmp = _options_stack.Top();
00100
00101
00102 Save_or_restore_options(tmp, OPTIONS_SIZE, FALSE);
00103
00104 Is_Trace(Trace(), (TFile,"OPTIONS_STACK::Pop_Current_Options, size=%d\n",
00105 _options_stack.Elements()));
00106 }
00107
00108
00109
00110
00111
00112 INT32
00113 OPTIONS_STACK::str2argv(char *str, char ***argv, MEM_POOL *pool)
00114 {
00115
00116 INT32 argc = 2;
00117 INT32 i;
00118 for (i=0; i<strlen(str); i++)
00119 if (str[i] == '-')
00120 argc++;
00121
00122
00123 *argv = CXX_NEW_ARRAY(char *, argc, pool);
00124 (*argv)[0] = "";
00125 (*argv)[argc-1] = "";
00126
00127
00128 INT32 pos = 0;
00129 for (i=1; i<argc-1; i++) {
00130
00131 while (str[pos] == ' ')
00132 pos++;
00133
00134 INT32 len;
00135 for (len=0; str[pos+len] != ' ' && str[pos+len] != '\0'; len++)
00136 ;
00137
00138 (*argv)[i] = CXX_NEW_ARRAY(char, len+1, pool);
00139
00140 strncpy((*argv)[i], &str[pos], len);
00141 (*argv)[i][len] = '\0';
00142
00143 pos += len + 1;
00144 }
00145
00146 #ifdef Is_True_On
00147 if (Trace()) {
00148 fprintf(TFile, "OPTIONS_STACK::str2argv, argc=%d\n", argc);
00149 for (i=0; i<argc; i++)
00150 fprintf(TFile, " %d: %s\n", i, (*argv)[i]);
00151 }
00152 #endif
00153
00154 return argc;
00155 }
00156
00157
00158
00159
00160
00161 void
00162 OPTIONS_STACK::Process_Pragma_Options(char *options_string)
00163 {
00164 if (options_string == NULL)
00165 return;
00166
00167 Is_Trace(Trace(),
00168 (TFile,"OPTIONS_STACK::Process_Pragma_Options, options = %s\n",
00169 options_string));
00170
00171
00172 Push_Current_Options();
00173
00174
00175 MEM_POOL Options_pool;
00176 MEM_POOL_Initialize(&Options_pool, "Options_pool", FALSE);
00177 MEM_POOL_Push(&Options_pool);
00178 char **argv;
00179
00180 INT32 argc = str2argv(options_string, &argv, &Options_pool);
00181
00182 Process_Command_Line(argc, argv);
00183 MEM_POOL_Pop(&Options_pool);
00184
00185 #ifdef Is_True_On
00186 if (Trace()) {
00187 OPTION_GROUP *og = Get_Command_Line_Group(Common_Option_Groups, "WOPT");
00188 Is_True(og != NULL, ("OPTIONS_STACK::Process_Pragma_Options, "
00189 "could not find WOPT group"));
00190 Trace_Command_Line_Group(TFile, og);
00191 }
00192 #endif
00193 }