@@ -130,85 +130,55 @@ protected override void ParseArgument(string/*!*/ arg) {
130130 LanguageSetup . Options [ "Arguments" ] = PopRemainingArgs ( ) ;
131131 break ;
132132
133+ case "-X" :
134+ HandleImplementationSpecificOption ( PopNextArg ( ) ) ;
135+ break ;
136+
137+ // old implementation specific options for compat
133138 case "-X:NoFrames" :
134- if ( LanguageSetup . Options . ContainsKey ( "Frames" ) && LanguageSetup . Options [ "Frames" ] != ScriptingRuntimeHelpers . False ) {
135- throw new InvalidOptionException ( "Only one of -X:[Full]Frames/-X:NoFrames may be specified" ) ;
136- }
137- LanguageSetup . Options [ "Frames" ] = ScriptingRuntimeHelpers . False ;
139+ HandleImplementationSpecificOption ( "NoFrames" ) ;
138140 break ;
139141 case "-X:Frames" :
140- if ( LanguageSetup . Options . ContainsKey ( "Frames" ) && LanguageSetup . Options [ "Frames" ] != ScriptingRuntimeHelpers . True ) {
141- throw new InvalidOptionException ( "Only one of -X:[Full]Frames/-X:NoFrames may be specified" ) ;
142- }
143- LanguageSetup . Options [ "Frames" ] = ScriptingRuntimeHelpers . True ;
142+ HandleImplementationSpecificOption ( "Frames" ) ;
144143 break ;
145144 case "-X:FullFrames" :
146- if ( LanguageSetup . Options . ContainsKey ( "Frames" ) && LanguageSetup . Options [ "Frames" ] != ScriptingRuntimeHelpers . True ) {
147- throw new InvalidOptionException ( "Only one of -X:[Full]Frames/-X:NoFrames may be specified" ) ;
148- }
149- LanguageSetup . Options [ "Frames" ] = LanguageSetup . Options [ "FullFrames" ] = ScriptingRuntimeHelpers . True ;
145+ HandleImplementationSpecificOption ( "FullFrames" ) ;
150146 break ;
151147 case "-X:Tracing" :
152- LanguageSetup . Options [ "Tracing" ] = ScriptingRuntimeHelpers . True ;
148+ HandleImplementationSpecificOption ( "Tracing" ) ;
153149 break ;
154150 case "-X:GCStress" :
155- int gcStress ;
156- if ( ! int . TryParse ( PopNextArg ( ) , out gcStress ) || ( gcStress < 0 || gcStress > GC . MaxGeneration ) ) {
157- throw new InvalidOptionException ( String . Format ( "The argument for the {0} option must be between 0 and {1}." , arg , GC . MaxGeneration ) ) ;
158- }
159-
160- LanguageSetup . Options [ "GCStress" ] = gcStress ;
151+ HandleImplementationSpecificOption ( "GCStress=" + PopNextArg ( ) ) ;
161152 break ;
162-
163153 case "-X:MaxRecursion" :
164- // we need about 6 frames for starting up, so 10 is a nice round number.
165- int limit ;
166- if ( ! int . TryParse ( PopNextArg ( ) , out limit ) || limit < 10 ) {
167- throw new InvalidOptionException ( String . Format ( "The argument for the {0} option must be an integer >= 10." , arg ) ) ;
168- }
169-
170- LanguageSetup . Options [ "RecursionLimit" ] = limit ;
154+ HandleImplementationSpecificOption ( "MaxRecursion=" + PopNextArg ( ) ) ;
171155 break ;
172-
173156 case "-X:EnableProfiler" :
174- LanguageSetup . Options [ "EnableProfiler" ] = ScriptingRuntimeHelpers . True ;
157+ HandleImplementationSpecificOption ( "EnableProfiler" ) ;
175158 break ;
176-
177159 case "-X:LightweightScopes" :
178- LanguageSetup . Options [ "LightweightScopes" ] = ScriptingRuntimeHelpers . True ;
160+ HandleImplementationSpecificOption ( "LightweightScopes" ) ;
179161 break ;
180-
181162 case "-X:MTA" :
182- ConsoleOptions . IsMta = true ;
163+ HandleImplementationSpecificOption ( "MTA" ) ;
183164 break ;
184-
185165 case "-X:Debug" :
186- RuntimeSetup . DebugMode = true ;
187- LanguageSetup . Options [ "Debug" ] = ScriptingRuntimeHelpers . True ;
166+ HandleImplementationSpecificOption ( "Debug" ) ;
188167 break ;
189-
190168 case "-X:NoDebug" :
191- string regex = PopNextArg ( ) ;
192- try {
193- LanguageSetup . Options [ "NoDebug" ] = new Regex ( regex ) ;
194- } catch {
195- throw InvalidOptionValue ( "-X:NoDebug" , regex ) ;
196- }
197-
169+ HandleImplementationSpecificOption ( "NoDebug=" + PopNextArg ( ) ) ;
198170 break ;
199-
200171 case "-X:BasicConsole" :
201- ConsoleOptions . BasicConsole = true ;
172+ HandleImplementationSpecificOption ( " BasicConsole" ) ;
202173 break ;
203-
204174#if DEBUG
205175 case "-X:NoImportLib" :
206- LanguageSetup . Options [ "NoImportLib" ] = ScriptingRuntimeHelpers . True ;
176+ HandleImplementationSpecificOption ( "NoImportLib" ) ;
207177 break ;
208178#endif
209179
210180 default :
211- if ( arg . StartsWith ( "-W" ) ) {
181+ if ( arg . StartsWith ( "-W" ) ) {
212182 if ( _warningFilters == null ) {
213183 _warningFilters = new List < string > ( ) ;
214184 }
@@ -231,6 +201,92 @@ protected override void ParseArgument(string/*!*/ arg) {
231201 }
232202 break ;
233203 }
204+
205+ void HandleImplementationSpecificOption ( string opt ) {
206+ var split = opt . Split ( new [ ] { '=' } , 2 ) ;
207+ var arg = split [ 0 ] ;
208+ var val = split . Length > 1 ? split [ 1 ] : string . Empty ;
209+
210+ switch ( arg ) {
211+ case "NoFrames" :
212+ if ( LanguageSetup . Options . ContainsKey ( "Frames" ) && LanguageSetup . Options [ "Frames" ] != ScriptingRuntimeHelpers . False ) {
213+ throw new InvalidOptionException ( "Only one of -X [Full]Frames/NoFrames may be specified" ) ;
214+ }
215+ LanguageSetup . Options [ "Frames" ] = ScriptingRuntimeHelpers . False ;
216+ break ;
217+
218+ case "Frames" :
219+ if ( LanguageSetup . Options . ContainsKey ( "Frames" ) && LanguageSetup . Options [ "Frames" ] != ScriptingRuntimeHelpers . True ) {
220+ throw new InvalidOptionException ( "Only one of -X [Full]Frames/NoFrames may be specified" ) ;
221+ }
222+ LanguageSetup . Options [ "Frames" ] = ScriptingRuntimeHelpers . True ;
223+ break ;
224+
225+ case "FullFrames" :
226+ if ( LanguageSetup . Options . ContainsKey ( "Frames" ) && LanguageSetup . Options [ "Frames" ] != ScriptingRuntimeHelpers . True ) {
227+ throw new InvalidOptionException ( "Only one of -X [Full]Frames/NoFrames may be specified" ) ;
228+ }
229+ LanguageSetup . Options [ "Frames" ] = LanguageSetup . Options [ "FullFrames" ] = ScriptingRuntimeHelpers . True ;
230+ break ;
231+
232+ case "Tracing" :
233+ LanguageSetup . Options [ "Tracing" ] = ScriptingRuntimeHelpers . True ;
234+ break ;
235+
236+ case "GCStress" :
237+ int gcStress ;
238+ if ( ! int . TryParse ( val , out gcStress ) || gcStress < 0 || gcStress > GC . MaxGeneration ) {
239+ throw new InvalidOptionException ( string . Format ( "The argument for the -X {0} option must be between 0 and {1}." , arg , GC . MaxGeneration ) ) ;
240+ }
241+ LanguageSetup . Options [ "GCStress" ] = gcStress ;
242+ break ;
243+
244+ case "MaxRecursion" :
245+ // we need about 6 frames for starting up, so 10 is a nice round number.
246+ int limit ;
247+ if ( ! int . TryParse ( val , out limit ) || limit < 10 ) {
248+ throw new InvalidOptionException ( string . Format ( "The argument for the -X {0} option must be an integer >= 10." , arg ) ) ;
249+ }
250+ LanguageSetup . Options [ "RecursionLimit" ] = limit ;
251+ break ;
252+
253+ case "EnableProfiler" :
254+ LanguageSetup . Options [ "EnableProfiler" ] = ScriptingRuntimeHelpers . True ;
255+ break ;
256+
257+ case "LightweightScopes" :
258+ LanguageSetup . Options [ "LightweightScopes" ] = ScriptingRuntimeHelpers . True ;
259+ break ;
260+
261+ case "MTA" :
262+ ConsoleOptions . IsMta = true ;
263+ break ;
264+
265+ case "Debug" :
266+ RuntimeSetup . DebugMode = true ;
267+ LanguageSetup . Options [ "Debug" ] = ScriptingRuntimeHelpers . True ;
268+ break ;
269+
270+ case "NoDebug" :
271+ string regex = val ;
272+ try {
273+ LanguageSetup . Options [ "NoDebug" ] = new Regex ( regex ) ;
274+ } catch {
275+ throw InvalidOptionValue ( "NoDebug" , regex ) ;
276+ }
277+ break ;
278+
279+ case "BasicConsole" :
280+ ConsoleOptions . BasicConsole = true ;
281+ break ;
282+
283+ #if DEBUG
284+ case "NoImportLib" :
285+ LanguageSetup . Options [ "NoImportLib" ] = ScriptingRuntimeHelpers . True ;
286+ break ;
287+ #endif
288+ }
289+ }
234290 }
235291
236292 protected override void AfterParse ( ) {
@@ -253,7 +309,7 @@ public override void GetHelp(out string commandLine, out string[,] options, out
253309 { "-v" , "Verbose (trace import statements) (also PYTHONVERBOSE=x)" } ,
254310#endif
255311 { "-b" , "issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str. (-bb: issue errors)" } ,
256- { "-m module" , "run library module as a script" } ,
312+ { "-m mod" , "run library module as a script" } ,
257313 { "-x" , "Skip first line of the source" } ,
258314 { "-u" , "Unbuffered stdout & stderr" } ,
259315 { "-O" , "generate optimized code" } ,
@@ -265,20 +321,20 @@ public override void GetHelp(out string commandLine, out string[,] options, out
265321 { "-W arg" , "Warning control (arg is action:message:category:module:lineno) also IRONPYTHONWARNINGS=arg" } ,
266322 { "-q" , "don't print version and copyright messages on interactive startup" } ,
267323
268- { "-X: NoFrames" , "Disable sys._getframe support, can improve execution speed" } ,
269- { "-X: Frames" , "Enable basic sys._getframe support" } ,
270- { "-X: FullFrames" , "Enable sys._getframe with access to locals" } ,
271- { "-X: Tracing" , "Enable support for tracing all methods even before sys.settrace is called" } ,
272- { "-X: GCStress" , "Specifies the GC stress level (the generation to collect each statement)" } ,
273- { "-X: MaxRecursion" , "Set the maximum recursion level" } ,
274- { "-X: Debug" , "Enable application debugging (preferred over -D)" } ,
275- { "-X:NoDebug <regex>" , "Provides a regular expression of files which should not be emitted in debug mode" } ,
276- { "-X: MTA" , "Run in multithreaded apartment" } ,
277- { "-X: EnableProfiler" , "Enables profiling support in the compiler" } ,
278- { "-X: LightweightScopes" , "Generate optimized scopes that can be garbage collected" } ,
279- { "-X: BasicConsole" , "Use only the basic console features" } ,
324+ { "-X NoFrames" , "Disable sys._getframe support, can improve execution speed" } ,
325+ { "-X Frames" , "Enable basic sys._getframe support" } ,
326+ { "-X FullFrames" , "Enable sys._getframe with access to locals" } ,
327+ { "-X Tracing" , "Enable support for tracing all methods even before sys.settrace is called" } ,
328+ { "-X GCStress=<level>" , "Specifies the GC stress level (the generation to collect each statement)" } ,
329+ { "-X MaxRecursion=<level>" , "Set the maximum recursion level" } ,
330+ { "-X Debug" , "Enable application debugging (preferred over -D)" } ,
331+ { "-X NoDebug= <regex>" , "Provides a regular expression of files which should not be emitted in debug mode" } ,
332+ { "-X MTA" , "Run in multithreaded apartment" } ,
333+ { "-X EnableProfiler" , "Enables profiling support in the compiler" } ,
334+ { "-X LightweightScopes" , "Generate optimized scopes that can be garbage collected" } ,
335+ { "-X BasicConsole" , "Use only the basic console features" } ,
280336#if DEBUG
281- { "-X: NoImportLib" , "Don't bootstrap importlib" } ,
337+ { "-X NoImportLib" , "Don't bootstrap importlib [debug only] " } ,
282338#endif
283339 } ;
284340
0 commit comments