1 (* M2Options.def initializes the user options.
3 Copyright (C) 2001-2023 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
22 DEFINITION MODULE M2Options ;
27 Date : 27/5/87 [$Date: 2013/08/14 20:39:40 $]
28 SYSTEM : UNIX (GNU Modula-2)
29 Description: Initializes the user options in the Modula-2 compiler.
30 Version : $Revision: 1.31 $
33 FROM SYSTEM IMPORT ADDRESS ;
34 FROM DynamicStrings IMPORT String ;
35 FROM m2linemap IMPORT location_t ;
37 EXPORT QUALIFIED SetReturnCheck, SetNilCheck, SetCaseCheck,
38 SetCheckAll, SetVerboseUnbounded, SetQuiet, SetCpp, GetCpp,
39 (* SetMakeall, SetMakeall0, SetIncludePath, *) SetAutoInit,
40 SetUnboundedByReference,
41 SetSearchPath, SetISO, SetPIM, SetPIM2, SetPIM3, SetPIM4,
42 SetPositiveModFloor, SetCompilerDebugging, SetExceptions,
43 SetStyle, SetPedantic, SetPedanticParamNames, SetPedanticCast,
44 SetExtendedOpaque, SetXCode, SetQuadDebugging, SetSources,
46 SetSwig, SetOptimizing, SetForcedLocation,
47 SetCC1Quiet, SetWholeProgram, SetDebugTraceQuad, SetDebugTraceAPI,
48 SetVerbose, SetM2g, GetM2g,
49 GetISO, GetPIM, GetPIM2, GetPIM3, GetPIM4,
51 SetFloatValueCheck, GetFloatValueCheck,
52 SetWholeValueCheck, GetWholeValueCheck,
54 SetIndex, SetRange, SetWholeDiv, SetStrictTypeChecking,
55 Setc, Getc, SetUselist, GetUselist, GetUselistFilename,
58 Iso, Pim, Pim2, Pim3, Pim4,
61 Pedantic, Verbose, Statistics,
62 UnboundedByReference, VerboseUnbounded,
63 Profiling, Coding, Optimizing,
64 OptimizeBasicBlock, OptimizeUncalledProcedures,
65 OptimizeCommonSubExpressions,
66 StyleChecking, WholeProgram,
68 WholeDivChecking, WholeValueChecking,
69 IndexChecking, RangeChecking,
70 ReturnChecking, CaseElseChecking,
73 UnusedVariableChecking, UnusedParameterChecking,
74 SetUnusedVariableChecking, SetUnusedParameterChecking,
75 Quiet, LineDirectives, StrictTypeChecking,
76 CPreProcessor, Xcode, ExtendedOpaque,
78 PedanticParamNames, PedanticCast,
79 DisplayQuadruples, DebugTraceQuad, DebugTraceAPI,
80 CompilerDebugging, GenerateDebugging, GenerateLineDebug,
81 DumpSystemExports, GenerateSwig, Exceptions,
82 OverrideLocation, FinaliseOptions,
83 DebugBuiltins, setdefextension, setmodextension,
84 SetStatistics, SetWall,
85 SetSaveTemps, SetSaveTempsDir, SaveTemps, GetSaveTempsDir,
87 CppArg, CppCommandLine, CppRemember,
88 SetDebugFunctionLineNumbers, DebugFunctionLineNumbers,
89 SetGenerateStatementNote, GenerateStatementNote,
90 ScaffoldDynamic, ScaffoldStatic,
91 SetScaffoldDynamic, SetScaffoldStatic,
92 SetScaffoldMain, ScaffoldMain,
93 SetRuntimeModuleOverride, GetRuntimeModuleOverride,
94 SetGenModuleList, GetGenModuleFilename, SharedFlag,
99 cflag, (* -c flag present? *)
100 Iso, (* -fiso use ISO SYSTEM.def *)
101 Pim, (* -fpim use PIM [234] SYSTEM.def *)
102 Pim2, (* -fpim2 use strict rules. *)
103 Pim3, (* -fpim3 use strict rules. *)
104 Pim4, (* -fpim4 use strict rules. *)
105 PositiveModFloorDiv, (* Force PIM4 behaviour for DIV and MOD *)
106 CompilerDebugging, (* -fd internal debugging messages *)
107 DebugTraceQuad, (* -fdebug-trace-quad *)
108 DebugTraceAPI, (* -fdebug-trace-api *)
109 GenerateDebugging, (* -g option to generate info for gdb/dbx *)
110 GenerateLineDebug, (* -gline to generate line debugging. *)
111 Verbose, (* -verbose produce verbose error messages. *)
112 Pedantic, (* -pedantic be pedantic on error checking. *)
113 PedanticParamNames, (* -Wpedantic-param-names *)
114 PedanticCast, (* -Wpedantic-cast warns if sizes differ. *)
115 Statistics, (* -fstatistics information about code *)
116 StyleChecking, (* -Wstudents checks for common student errs*)
117 DisplayQuadruples, (* -Wq option will display quadruples. *)
118 UnboundedByReference, (* -funbounded-by-reference *)
119 VerboseUnbounded, (* -Wverbose-unbounded *)
120 OptimizeUncalledProcedures, (* -Ouncalled removes uncalled procedures *)
121 OptimizeBasicBlock, (* -Obb create basic blocks and optimize. *)
122 OptimizeCommonSubExpressions, (* -Ocse optimize common subexpressions *)
123 WholeProgram, (* -fwhole-program optimization. *)
124 NilChecking, (* -fnil makes compiler test for pointer *)
126 WholeDivChecking, (* -fwholediv produces code to raise an *)
127 (* exception if a whole number divide by *)
129 WholeValueChecking, (* -fwholevalue produces code to raise an *)
130 (* exception if a whole value variable is *)
131 (* about to exceed the type limits. *)
132 FloatValueChecking, (* -ffloatvalue produces code to raise an *)
133 (* exception if a floating point variable *)
134 (* is about to exceed the type limits. *)
135 IndexChecking, (* -findex array bounds checking. *)
136 RangeChecking, (* -frange assignment, set values, *)
137 (* constructor values in range. *)
138 ReturnChecking, (* -freturn checks that functions always *)
139 (* exit with a RETURN statement. *)
140 CaseElseChecking, (* -fcase checks program does not need an *)
141 (* else statement within an case statement *)
142 (* when the user omits one *)
143 VariantValueChecking, (* Should we check all values are present *)
144 (* in a variant record? True for ISO and *)
146 Quiet, (* -fquiet option specified. *)
147 LineDirectives, (* Should compiler understand preprocessor *)
148 (* # linenumber "filename" markers? *)
149 StrictTypeChecking, (* -fm2-strict-type experimental checker. *)
150 CPreProcessor, (* Must we run the cpp on the source? *)
151 Xcode, (* Should errors follow Xcode format? *)
152 ExtendedOpaque, (* Do we allow non pointer opaque types? *)
153 DumpSystemExports, (* Print all inbuilt system items? *)
154 GenerateSwig, (* Should we generate a swig interface file?*)
155 Exceptions, (* Should we generate exception code? *)
156 UnusedVariableChecking, (* Should we warn about unused variables? *)
157 UnusedParameterChecking, (* Should we warn about unused parameters? *)
158 LowerCaseKeywords, (* Should keywords in errors be in lower? *)
159 DebugBuiltins, (* Should we always call a real function? *)
160 AutoInit, (* -fauto-init assigns pointers to NIL. *)
161 SaveTemps, (* -save-temps save all temporary files. *)
162 ScaffoldDynamic, (* Should we generate a dynamic scaffold? *)
163 ScaffoldStatic, (* Should we generate a static scaffold? *)
164 ScaffoldMain, (* Should we generate a main function? *)
165 GenModuleList, (* Should the compiler generate a list of *)
166 (* all modules used? *)
167 SharedFlag, (* -fshared indicating this module needs *)
168 (* the shared library version of the *)
171 DebugFunctionLineNumbers,
172 GenerateStatementNote,
175 Profiling : BOOLEAN ;
179 Setc - set the cflag (compile only flag -c) to value.
182 PROCEDURE Setc (value: BOOLEAN) ;
186 Getc - get the cflag (compile only flag -c).
189 PROCEDURE Getc () : BOOLEAN ;
193 SetB - assigns Barg to arg.
196 PROCEDURE SetB (arg: ADDRESS) ;
200 GetB - returns argument to the -B option as a string or NIL if it were never set.
203 PROCEDURE GetB () : ADDRESS ;
207 SetScaffoldDynamic - set the -fscaffold-dynamic flag.
210 PROCEDURE SetScaffoldDynamic (value: BOOLEAN) ;
214 SetScaffoldStatic - set the -fscaffold-static flag.
217 PROCEDURE SetScaffoldStatic (value: BOOLEAN) ;
221 GetScaffoldDynamic - get the -fscaffold-dynamic flag.
224 PROCEDURE GetScaffoldDynamic () : BOOLEAN ;
228 GetScaffoldStatic - get the -fscaffold-static flag.
231 PROCEDURE GetScaffoldStatic () : BOOLEAN ;
235 SetScaffoldMain - set the -fscaffold-main flag.
238 PROCEDURE SetScaffoldMain (value: BOOLEAN) ;
242 SetRuntimeModuleOverride - set the override sequence used for module
243 initialization and finialization.
246 PROCEDURE SetRuntimeModuleOverride (override: ADDRESS) ;
250 GetRuntimeModuleOverride - return a string containing any user override
251 or the default module initialization override
255 PROCEDURE GetRuntimeModuleOverride () : ADDRESS ;
259 SetUselist - set the uselist flag to value and remember the filename.
262 PROCEDURE SetUselist (value: BOOLEAN; filename: ADDRESS) ;
266 GetUselist - return the uselist flag.
269 PROCEDURE GetUselist () : BOOLEAN ;
273 GetUselistFilename - return the uselist filename as a String.
276 PROCEDURE GetUselistFilename () : String ;
280 SetWholeProgram - sets the WholeProgram flag (-fwhole-program).
283 PROCEDURE SetWholeProgram (value: BOOLEAN) ;
287 SetAutoInit - set the auto initialization flag to value. If the value
288 is true then all pointers are automatically
292 PROCEDURE SetAutoInit (value: BOOLEAN) : BOOLEAN ;
296 SetReturnCheck - set return statement checking in procedure functions
300 PROCEDURE SetReturnCheck (value: BOOLEAN) : BOOLEAN ;
304 SetNilCheck - set access through NIL violation runtime checking to value.
307 PROCEDURE SetNilCheck (value: BOOLEAN) : BOOLEAN ;
311 SetCaseCheck - set else case checking to, value.
314 PROCEDURE SetCaseCheck (value: BOOLEAN) : BOOLEAN ;
318 SetCheckAll - set all runtime checking to, value.
321 PROCEDURE SetCheckAll (value: BOOLEAN) : BOOLEAN ;
325 SetVerboseUnbounded - sets the VerboseUnbounded flag to, value.
328 PROCEDURE SetVerboseUnbounded (value: BOOLEAN) : BOOLEAN ;
332 SetQuiet - sets the quiet flag to, value.
335 PROCEDURE SetQuiet (value: BOOLEAN) : BOOLEAN ;
339 SetCC1Quiet - sets the cc1quiet flag to, value.
342 PROCEDURE SetCC1Quiet (value: BOOLEAN) ;
349 PROCEDURE SetCpp (value: BOOLEAN) : BOOLEAN ;
353 GetCpp - returns TRUE if the C preprocessor was used.
356 PROCEDURE GetCpp () : BOOLEAN ;
360 SetM2g - set the -fm2-g flag.
363 PROCEDURE SetM2g (value: BOOLEAN) : BOOLEAN ;
367 GetM2g - returns TRUE if the -fm2-g flags was used.
370 PROCEDURE GetM2g () : BOOLEAN ;
374 SetLowerCaseKeywords - set the lower case keyword flag and return the result.
377 PROCEDURE SetLowerCaseKeywords (value: BOOLEAN) : BOOLEAN ;
383 PROCEDURE SetMakeall (value: BOOLEAN) : BOOLEAN ;
390 PROCEDURE SetMakeall0 (value: BOOLEAN) : BOOLEAN ;
397 PROCEDURE SetIncludePath (arg: ADDRESS) : BOOLEAN ;
402 SetUnboundedByReference -
405 PROCEDURE SetUnboundedByReference (value: BOOLEAN) : BOOLEAN ;
412 PROCEDURE SetSearchPath (arg: ADDRESS) ;
419 PROCEDURE SetISO (value: BOOLEAN) ;
426 PROCEDURE SetPIM (value: BOOLEAN) ;
433 PROCEDURE SetPIM2 (value: BOOLEAN) ;
440 PROCEDURE SetPIM3 (value: BOOLEAN) ;
447 PROCEDURE SetPIM4 (value: BOOLEAN) ;
451 SetPositiveModFloor -
454 PROCEDURE SetPositiveModFloor (value: BOOLEAN) ;
458 SetWholeDiv - sets the whole division flag.
461 PROCEDURE SetWholeDiv (value: BOOLEAN) ;
465 SetIndex - sets the runtime array index checking flag.
468 PROCEDURE SetIndex (value: BOOLEAN) ;
472 SetRange - sets the runtime range checking flag.
475 PROCEDURE SetRange (value: BOOLEAN) ;
482 PROCEDURE SetExceptions (value: BOOLEAN) ;
489 PROCEDURE SetStyle (value: BOOLEAN) ;
496 PROCEDURE SetPedantic (value: BOOLEAN) ;
500 SetPedanticParamNames -
503 PROCEDURE SetPedanticParamNames (value: BOOLEAN) ;
510 PROCEDURE SetPedanticCast (value: BOOLEAN) ;
517 PROCEDURE SetExtendedOpaque (value: BOOLEAN) ;
524 PROCEDURE SetXCode (value: BOOLEAN) ;
528 SetCompilerDebugging - turn on internal compiler debugging.
531 PROCEDURE SetCompilerDebugging (value: BOOLEAN) ;
535 SetQuadDebugging - display the quadruples (internal debugging).
538 PROCEDURE SetQuadDebugging (value: BOOLEAN) ;
545 PROCEDURE SetDebugTraceQuad (value: BOOLEAN) ;
552 PROCEDURE SetDebugTraceAPI (value: BOOLEAN) ;
556 SetDebugFunctionLineNumbers - turn DebugFunctionLineNumbers on/off
557 (used internally for debugging).
560 PROCEDURE SetDebugFunctionLineNumbers (value: BOOLEAN) ;
564 SetGenerateStatementNote - turn on generation of nops if necessary
565 to generate pedalogical single stepping.
568 PROCEDURE SetGenerateStatementNote (value: BOOLEAN) ;
575 PROCEDURE SetSources (value: BOOLEAN) ;
579 SetDumpSystemExports -
582 PROCEDURE SetDumpSystemExports (value: BOOLEAN) ;
589 PROCEDURE SetSwig (value: BOOLEAN) ;
596 PROCEDURE SetOptimizing (value: CARDINAL) ;
600 OverrideLocation - possibly override the location value, depending upon
601 whether the -flocation= option was used.
604 PROCEDURE OverrideLocation (location: location_t) : location_t ;
608 SetForcedLocation - sets the location for the lifetime of this compile to, location.
609 This is primarily an internal debugging switch.
612 PROCEDURE SetForcedLocation (location: location_t) ;
616 SetUnusedVariableChecking - assigns the UnusedVariableChecking to value.
619 PROCEDURE SetUnusedVariableChecking (value: BOOLEAN) ;
623 SetUnusedParameterChecking - assigns the UnusedParameterChecking to value.
626 PROCEDURE SetUnusedParameterChecking (value: BOOLEAN) ;
630 SetStrictTypeChecking - assigns the StrictTypeChecking flag to value.
633 PROCEDURE SetStrictTypeChecking (value: BOOLEAN) ;
640 PROCEDURE setdefextension (arg: ADDRESS) ;
647 PROCEDURE setmodextension (arg: ADDRESS) ;
651 SetStatistics - turn on/off generate of compile time statistics.
654 PROCEDURE SetStatistics (on: BOOLEAN) ;
658 SetVerbose - set the Verbose flag to, value. It returns TRUE.
661 PROCEDURE SetVerbose (value: BOOLEAN) : BOOLEAN ;
665 CppArg - sets the option and arg in the cpp command line.
668 PROCEDURE CppArg (opt, arg: ADDRESS; joined: BOOLEAN) ;
672 CppCommandLine - returns the Cpp command line and all arguments.
675 PROCEDURE CppCommandLine () : String ;
679 CppRemember - remember a string, s, as a cpp related argument.
680 The string, s, is not garbage collected.
683 PROCEDURE CppRemember (s: String) ;
687 GetISO - return TRUE if -fiso was present on the command line.
690 PROCEDURE GetISO () : BOOLEAN ;
694 GetPIM - return TRUE if -fpim was present on the command line.
697 PROCEDURE GetPIM () : BOOLEAN ;
701 GetPIM2 - return TRUE if -fpim2 was present on the command line.
704 PROCEDURE GetPIM2 () : BOOLEAN ;
708 GetPIM3 - return TRUE if -fpim3 was present on the command line.
711 PROCEDURE GetPIM3 () : BOOLEAN ;
715 GetPIM4 - return TRUE if -fpim4 was present on the command line.
718 PROCEDURE GetPIM4 () : BOOLEAN ;
722 GetPositiveModFloor - return TRUE if -fpositive-mod-floor was present
726 PROCEDURE GetPositiveModFloor () : BOOLEAN ;
730 GetFloatValueCheck - return TRUE if -ffloatvalue was present on the
734 PROCEDURE GetFloatValueCheck () : BOOLEAN ;
738 SetFloatValueCheck - set depending upon the -ffloatvalue.
741 PROCEDURE SetFloatValueCheck (value: BOOLEAN) ;
745 GetWholeValueCheck - return TRUE if -fwholevalue was present on the
749 PROCEDURE GetWholeValueCheck () : BOOLEAN ;
753 SetWholeValueCheck - set depending upon the -fwholevalue.
756 PROCEDURE SetWholeValueCheck (value: BOOLEAN) ;
760 SetWall - set all warnings to, value.
763 PROCEDURE SetWall (value: BOOLEAN) ;
767 SetSaveTemps - turn on/off -save-temps.
770 PROCEDURE SetSaveTemps (value: BOOLEAN) ;
774 SetSaveTempsDir - turn on/off -save-temps specifying the
778 PROCEDURE SetSaveTempsDir (arg: ADDRESS) ;
782 GetSaveTempsDir - return SaveTempsDir or NIL if -save-temps was not used.
785 PROCEDURE GetSaveTempsDir () : String ;
789 SetGenModuleList - set the GenModuleList flag to value and pass
790 set GenModuleListFilename to filename.
793 PROCEDURE SetGenModuleList (value: BOOLEAN; filename: ADDRESS) ;
797 GetGenModuleFilename - returns the filename set by SetGenModuleList.
800 PROCEDURE GetGenModuleFilename () : String ;
804 SetShared - sets the SharedFlag to value.
807 PROCEDURE SetShared (value: BOOLEAN) ;
811 FinaliseOptions - once all options have been parsed we set any inferred
815 PROCEDURE FinaliseOptions ;