1 (* M2Options.mod initializes the user options.
3 Copyright (C) 2001-2025 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 IMPLEMENTATION MODULE M2Options
;
26 FROM SArgs
IMPORT GetArg
, Narg
;
27 FROM M2Search
IMPORT SetDefExtension
, SetModExtension
;
28 FROM PathName
IMPORT DumpPathName
, AddInclude
;
29 FROM M2Printf
IMPORT printf0
, printf1
, fprintf1
;
30 FROM FIO
IMPORT StdErr
;
31 FROM libc
IMPORT exit
, printf
;
32 FROM Debug
IMPORT Halt
;
33 FROM gcctypes
IMPORT location_t
;
34 FROM m2configure
IMPORT FullPathCPP
, TargetIEEEQuadDefault
;
35 FROM M2Error
IMPORT InternalError
;
36 FROM FormatStrings
IMPORT Sprintf1
;
37 FROM m2misc
IMPORT cerror
;
39 FROM DynamicStrings
IMPORT String
, Length
, InitString
, Mark
, Slice
, EqualArray
,
40 InitStringCharStar
, ConCatChar
, ConCat
, KillString
,
41 Dup
, string
, char
, Index
,
42 PushAllocation
, PopAllocationExemption
,
43 InitStringDB
, InitStringCharStarDB
,
44 InitStringCharDB
, MultDB
, DupDB
, SliceDB
;
47 #define InitString(X) InitStringDB(X, __FILE__, __LINE__)
48 #define InitStringCharStar(X) InitStringCharStarDB(X, __FILE__, __LINE__)
49 #define InitStringChar(X) InitStringCharDB(X, __FILE__, __LINE__)
50 #define Mult(X,Y) MultDB(X, Y, __FILE__, __LINE__)
51 #define Dup(X) DupDB(X, __FILE__, __LINE__)
52 #define Slice(X,Y,Z) SliceDB(X, Y, Z, __FILE__, __LINE__)
57 DefaultRuntimeModuleOverride
= "m2iso:RTentity,m2iso:Storage,m2iso:SYSTEM,m2iso:M2RTS,m2iso:RTExceptions,m2iso:IOLink" ;
75 GenModuleListFilename
,
77 RuntimeModuleOverride
,
80 DebugFunctionLineNumbers
,
81 DebugTraceQuad
, (* -fm2-debug-trace=quad. *)
82 DebugTraceLine
, (* -fm2-debug-trace=line. *)
83 DebugTraceToken
, (* -fm2-debug-trace=token. *)
84 DebugTraceTree
, (* -fm2-debug-trace=tree. (not yet implemented). *)
85 DumpDecl
, (* -fm2-dump=decl. *)
86 DumpGimple
, (* -fm2-dump=gimple. *)
87 DumpQuad
, (* -fq, -fm2-dump=quad dump quadruples. *)
97 SeenSources
: BOOLEAN ;
99 ForcedLocationValue
: location_t
;
102 (* String garbage collection debugging routines.
108 PROCEDURE doDSdbEnter
;
118 PROCEDURE doDSdbExit (s
: String
) ;
120 s
:= PopAllocationExemption (TRUE, s
)
128 PROCEDURE DSdbEnter
;
137 PROCEDURE DSdbExit (s
: String
) ;
143 #define DSdbEnter doDSdbEnter
144 #define DSdbExit doDSdbExit
149 SetM2Prefix - assign arg to M2Prefix.
152 PROCEDURE SetM2Prefix (arg
: ADDRESS
) ;
154 M2Prefix
:= KillString (M2Prefix
) ;
155 M2Prefix
:= InitStringCharStar (arg
)
160 GetM2Prefix - return M2Prefix as a C string.
163 PROCEDURE GetM2Prefix () : ADDRESS
;
165 RETURN string (M2Prefix
)
170 SetM2PathName - assign arg to M2PathName.
173 PROCEDURE SetM2PathName (arg
: ADDRESS
) ;
175 M2PathName
:= KillString (M2PathName
) ;
176 M2PathName
:= InitStringCharStar (arg
) ;
177 (* fprintf1 (StdErr, "M2PathName = %s\n", M2PathName) *)
182 GetM2PathName - return M2PathName as a C string.
185 PROCEDURE GetM2PathName () : ADDRESS
;
187 RETURN string (M2PathName
)
192 SetB - assigns Barg to arg.
195 PROCEDURE SetB (arg
: ADDRESS
) ;
197 Barg
:= KillString (Barg
) ;
198 Barg
:= InitStringCharStar (arg
)
203 GetB - returns Barg value as a C string or NIL if it was never set.
206 PROCEDURE GetB () : ADDRESS
;
213 SetM - set the MFlag.
216 PROCEDURE SetM (value
: BOOLEAN) ;
223 GetM - set the MFlag.
226 PROCEDURE GetM () : BOOLEAN ;
233 SetMM - set the MMFlag.
236 PROCEDURE SetMM (value
: BOOLEAN) ;
243 GetMM - set the MMFlag.
246 PROCEDURE GetMM () : BOOLEAN ;
253 SetMD - set the MDFlag to value.
256 PROCEDURE SetMD (value
: BOOLEAN) ;
263 GetMD - return the MDFlag.
266 PROCEDURE GetMD () : BOOLEAN ;
273 SetMMD - set the MMDFlag to value.
276 PROCEDURE SetMMD (value
: BOOLEAN) ;
283 GetMMD - return the MMDFlag.
286 PROCEDURE GetMMD () : BOOLEAN ;
293 SetMF - assigns MFarg to the filename from arg.
296 PROCEDURE SetMF (arg
: ADDRESS
) ;
298 MFarg
:= KillString (MFarg
) ;
299 MFarg
:= InitStringCharStar (arg
)
304 GetMF - returns MFarg or NIL if never set.
307 PROCEDURE GetMF () : ADDRESS
;
309 RETURN string (MFarg
)
314 SetMP - set the MPflag to value.
317 PROCEDURE SetMP (value
: BOOLEAN) ;
324 GetMP - get the MPflag.
327 PROCEDURE GetMP () : BOOLEAN ;
337 PROCEDURE errors1 (format
: ARRAY OF CHAR; arg
: String
) ;
342 message
:= Sprintf1 (InitString (format
), arg
) ;
343 cstr
:= string (message
) ;
350 AddWord - concats a word to sentence inserting a space if necessary.
351 sentence is returned. sentence will be created if it is NIL.
354 PROCEDURE AddWord (sentence
, word
: String
) : String
;
360 sentence
:= Dup (word
)
362 sentence
:= ConCatChar (sentence
, ' ') ;
363 sentence
:= ConCat (sentence
, word
)
371 QuoteTarget - quote the '$' character.
374 PROCEDURE QuoteTarget (target
: String
) : String
;
379 quoted
:= InitString ('') ;
381 n
:= Length (target
) ;
383 CASE char (target
, i
) OF
385 '$': quoted
:= ConCat (quoted
, Mark (InitString ('$$')))
388 quoted
:= ConCatChar (quoted
, char (target
, i
))
397 SetMQ - adds a quoted target arg to the DepTarget sentence.
400 PROCEDURE SetMQ (arg
: ADDRESS
) ;
402 DepTarget
:= AddWord (DepTarget
, QuoteTarget (InitStringCharStar (arg
))) ;
403 MQFlag
:= AddWord (MQFlag
, Mark (InitString ('-MQ'))) ;
404 MQFlag
:= AddWord (MQFlag
, Mark (InitStringCharStar (arg
)))
409 GetMQ - returns a C string containing all the -MQ arg values.
412 PROCEDURE GetMQ () : ADDRESS
;
414 RETURN string (MQFlag
)
419 SetMT - adds a target arg to the DepTarget sentence.
422 PROCEDURE SetMT (arg
: ADDRESS
) ;
424 DepTarget
:= AddWord (DepTarget
, InitStringCharStar (arg
)) ;
425 MTFlag
:= AddWord (MTFlag
, Mark (InitString ('-MT'))) ;
426 MTFlag
:= AddWord (MTFlag
, Mark (InitStringCharStar (arg
)))
431 GetMT - returns a C string containing all the -MT arg values.
434 PROCEDURE GetMT () : ADDRESS
;
436 RETURN string (MTFlag
)
441 GetDepTarget - returns the DepTarget as a C string.
444 PROCEDURE GetDepTarget () : ADDRESS
;
446 RETURN string (DepTarget
)
451 SetObj - assigns CmdLineObj to the filename from arg.
454 PROCEDURE SetObj (arg
: ADDRESS
) ;
456 CmdLineObj
:= KillString (CmdLineObj
) ;
457 CmdLineObj
:= InitStringCharStar (arg
)
462 GetObj - returns CmdLineObj filename as a c-string or NIL if it was never set.
465 PROCEDURE GetObj () : ADDRESS
;
467 RETURN string (CmdLineObj
)
472 CppCommandLine - returns the Cpp command line and all arguments.
473 NIL is returned if the -fcpp is absent.
476 PROCEDURE CppCommandLine () : String
;
482 s
:= InitStringCharStar (FullPathCPP ()) ;
483 s
:= ConCat (ConCatChar (s
, ' '), CppArgs
) ;
486 s
:= ConCat (ConCatChar (s
, ' '), Mark (InitString ('-quiet')))
496 CppArg - sets the option and arg in the cpp command line.
499 PROCEDURE CppArg (opt
, arg
: ADDRESS
; joined
: BOOLEAN) ;
503 s
:= InitStringCharStar(opt
) ;
504 IF EqualArray(s
, '-fcpp-begin') OR EqualArray(s
, '-fcpp-end')
508 IF NOT EqualArray(CppArgs
, '')
510 CppArgs
:= ConCatChar(CppArgs
, ' ')
512 CppArgs
:= ConCat(CppArgs
, Mark(s
)) ;
515 s
:= InitStringCharStar(arg
) ;
518 CppArgs
:= ConCatChar(CppArgs
, ' ')
520 CppArgs
:= ConCat(CppArgs
, s
)
527 CppRemember - remember a string, s, as a cpp related argument.
528 The string, s, is not garbage collected.
531 PROCEDURE CppRemember (s
: String
) ;
533 IF (CppArgs
=NIL) OR EqualArray (CppArgs
, '')
537 CppArgs
:= ConCatChar (CppArgs
, ' ') ;
538 CppArgs
:= ConCat (CppArgs
, s
)
544 FinaliseOptions - once all options have been parsed we set any inferred
548 PROCEDURE FinaliseOptions
;
550 (* currently only one value, this could be make an option in the future *)
551 VariantValueChecking
:= Iso
552 END FinaliseOptions
;
556 SetWholeProgram - sets the WholeProgram flag (-fwhole-program).
559 PROCEDURE SetWholeProgram (value
: BOOLEAN) ;
561 WholeProgram
:= value
562 END SetWholeProgram
;
569 PROCEDURE SetReturnCheck (value
: BOOLEAN) : BOOLEAN ;
571 ReturnChecking
:= value
;
580 PROCEDURE SetNilCheck (value
: BOOLEAN) : BOOLEAN ;
582 NilChecking
:= value
;
588 SetCaseCheck - set else case checking to, value.
591 PROCEDURE SetCaseCheck (value
: BOOLEAN) : BOOLEAN ;
593 CaseElseChecking
:= value
;
599 SetCheckAll - set all runtime checking to, value.
602 PROCEDURE SetCheckAll (value
: BOOLEAN) : BOOLEAN ;
604 NilChecking
:= value
;
605 WholeDivChecking
:= value
;
606 IndexChecking
:= value
;
607 RangeChecking
:= value
;
608 ReturnChecking
:= value
;
609 NilChecking
:= value
;
610 CaseElseChecking
:= value
;
611 FloatValueChecking
:= value
;
612 WholeValueChecking
:= value
;
618 SetAutoInit - -fauto-init turns on automatic initialization of pointers to NIL.
622 PROCEDURE SetAutoInit (value
: BOOLEAN) : BOOLEAN ;
630 SetUnusedVariableChecking - assigns the UnusedVariableChecking to value.
633 PROCEDURE SetUnusedVariableChecking (value
: BOOLEAN) ;
635 UnusedVariableChecking
:= value
636 END SetUnusedVariableChecking
;
640 SetUnusedParameterChecking - assigns the UnusedParameterChecking to value.
643 PROCEDURE SetUnusedParameterChecking (value
: BOOLEAN) ;
645 UnusedParameterChecking
:= value
646 END SetUnusedParameterChecking
;
650 SetStrictTypeChecking - assigns the StrictTypeChecking flag to value.
653 PROCEDURE SetStrictTypeChecking (value
: BOOLEAN) ;
655 StrictTypeChecking
:= value
656 END SetStrictTypeChecking
;
660 SetVerboseUnbounded - sets the VerboseUnbounded flag to, value.
663 PROCEDURE SetVerboseUnbounded (value
: BOOLEAN) : BOOLEAN ;
665 VerboseUnbounded
:= value
;
667 END SetVerboseUnbounded
;
671 SetQuiet - sets the quiet flag to, value.
674 PROCEDURE SetQuiet (value
: BOOLEAN) : BOOLEAN ;
682 SetCpp - enables the source to be preprocessed and enables the
683 recognition of C preprocessor line directives.
686 PROCEDURE SetCpp (value
: BOOLEAN) : BOOLEAN ;
688 CPreProcessor
:= value
;
689 LineDirectives
:= value
;
695 GetCpp - returns TRUE if the C preprocessor was used.
698 PROCEDURE GetCpp () : BOOLEAN ;
705 GetLineDirectives - returns TRUE if line directives are allowed.
708 PROCEDURE GetLineDirectives () : BOOLEAN ;
710 RETURN LineDirectives
711 END GetLineDirectives
;
715 SetPPOnly - set the PPonly (preprocess only) to value.
718 PROCEDURE SetPPOnly (value
: BOOLEAN) ;
724 GetPPOnly - get the PPonly (preprocess only).
727 PROCEDURE GetPPOnly () : BOOLEAN ;
734 Setc - set the cflag (compile only flag -c) to value.
737 PROCEDURE Setc (value
: BOOLEAN) ;
744 Getc - get the cflag (compile only flag -c).
747 PROCEDURE Getc () : BOOLEAN ;
754 SetUselist - set the uselist flag to value and remember the filename.
757 PROCEDURE SetUselist (value
: BOOLEAN; filename
: ADDRESS
) ;
759 UselistFlag
:= value
;
760 UselistFilename
:= KillString (UselistFilename
) ;
763 UselistFilename
:= InitStringCharStar (filename
)
769 GetUselist - return the uselist flag.
772 PROCEDURE GetUselist () : BOOLEAN ;
779 GetUselistFilename - return the uselist filename as a String.
782 PROCEDURE GetUselistFilename () : String
;
784 RETURN UselistFilename
785 END GetUselistFilename
;
789 SetM2g - set GenerateStatementNote to value and return value.
790 Corresponds to the -fm2-g flag.
793 PROCEDURE SetM2g (value
: BOOLEAN) : BOOLEAN ;
795 GenerateStatementNote
:= value
;
796 RETURN GenerateStatementNote
801 GetM2g - returns TRUE if the -fm2-g flags was used.
804 PROCEDURE GetM2g () : BOOLEAN ;
806 RETURN GenerateStatementNote
811 SetLowerCaseKeywords - set the lower case keyword flag and return the result.
814 PROCEDURE SetLowerCaseKeywords (value
: BOOLEAN) : BOOLEAN ;
816 LowerCaseKeywords
:= value
;
817 RETURN LowerCaseKeywords
818 END SetLowerCaseKeywords
;
822 SetVerbose - set the Verbose flag to, value. It returns TRUE.
825 PROCEDURE SetVerbose (value
: BOOLEAN) : BOOLEAN ;
835 PROCEDURE SetMakeall (value: BOOLEAN) : BOOLEAN ;
837 (* value is unused *)
846 PROCEDURE SetMakeall0 (value: BOOLEAN) : BOOLEAN ;
848 (* value is unused *)
857 PROCEDURE SetIncludePath (arg: ADDRESS) : BOOLEAN ;
865 SetUnboundedByReference -
868 PROCEDURE SetUnboundedByReference (value
: BOOLEAN) : BOOLEAN ;
870 UnboundedByReference
:= value
;
872 END SetUnboundedByReference
;
877 SetDebugging - sets the debugging flag to, v.
880 PROCEDURE SetDebugging (value
: BOOLEAN) ;
882 GenerateDebugging
:= value
887 SetProfiling - dummy procedure, as profiling is implemented in the gcc backend.
890 PROCEDURE SetProfiling (value
: BOOLEAN) ;
901 PROCEDURE SetISO (value
: BOOLEAN) ;
906 (* Pim4 is the default, leave it alone since the DIV and MOD rules are the
915 PROCEDURE SetPIM (value
: BOOLEAN) ;
926 PROCEDURE SetPIM2 (value
: BOOLEAN) ;
933 (* Pim4 is the default, turn it off. *)
943 PROCEDURE SetPIM3 (value
: BOOLEAN) ;
950 (* Pim4 is the default, turn it off. *)
960 PROCEDURE SetPIM4 (value
: BOOLEAN) ;
969 SetPositiveModFloor - sets the positive mod floor option.
972 PROCEDURE SetPositiveModFloor (value
: BOOLEAN) ;
974 PositiveModFloorDiv
:= value
975 END SetPositiveModFloor
;
979 SetWholeDiv - sets the whole division flag.
982 PROCEDURE SetWholeDiv (value
: BOOLEAN) ;
984 WholeDivChecking
:= value
989 SetIndex - sets the runtime array index checking flag.
992 PROCEDURE SetIndex (value
: BOOLEAN) ;
994 IndexChecking
:= value
999 SetRange - sets the runtime range checking flag.
1002 PROCEDURE SetRange (value
: BOOLEAN) ;
1004 RangeChecking
:= value
1009 SetExceptions - sets the enable runtime exceptions flag.
1012 PROCEDURE SetExceptions (value
: BOOLEAN) ;
1022 PROCEDURE SetStyle (value
: BOOLEAN) ;
1024 StyleChecking
:= value
1032 PROCEDURE SetPedantic (value
: BOOLEAN) ;
1039 SetPedanticParamNames - sets the pedantic parameter name flag.
1042 PROCEDURE SetPedanticParamNames (value
: BOOLEAN) ;
1044 PedanticParamNames
:= value
1045 END SetPedanticParamNames
;
1049 SetPedanticCast - sets the pedantic cast flag.
1052 PROCEDURE SetPedanticCast (value
: BOOLEAN) ;
1054 PedanticCast
:= value
1055 END SetPedanticCast
;
1059 SetExtendedOpaque - sets the ExtendedOpaque flag.
1062 PROCEDURE SetExtendedOpaque (value
: BOOLEAN) ;
1064 ExtendedOpaque
:= value
1065 END SetExtendedOpaque
;
1069 SetXCode - sets the xcode flag.
1072 PROCEDURE SetXCode (value
: BOOLEAN) ;
1082 PROCEDURE SetSwig (value
: BOOLEAN) ;
1084 GenerateSwig
:= value
1089 SetQuadDebugging - display the quadruples (internal debugging).
1092 PROCEDURE SetQuadDebugging (value
: BOOLEAN) ;
1095 DumpQuadFilename
:= KillString (DumpQuadFilename
) ;
1096 DumpQuadFilename
:= InitString ('-')
1097 END SetQuadDebugging
;
1101 SetCompilerDebugging - turn on internal compiler debugging.
1102 Enabled via the command line option -fd.
1105 PROCEDURE SetCompilerDebugging (value
: BOOLEAN) ;
1107 CompilerDebugging
:= value
1108 END SetCompilerDebugging
;
1112 SetM2DebugTraceFilter - set internal debug flags. The flags should be
1113 specified as a comma separated list. The full
1114 list allowed is quad,line,token,all.
1117 PROCEDURE SetM2DebugTraceFilter (value
: BOOLEAN; filter
: ADDRESS
) ;
1124 full
:= InitStringCharStar (filter
) ;
1127 i
:= Index (full
, ',', start
) ;
1130 word
:= Slice (full
, start
, 0)
1132 word
:= Slice (full
, start
, i
)
1134 SetM2DebugTrace (word
, value
) ;
1135 word
:= KillString (word
) ;
1138 full
:= KillString (full
) ;
1139 END SetM2DebugTraceFilter
;
1146 PROCEDURE SetM2DebugTrace (word
: String
; value
: BOOLEAN) ;
1148 IF EqualArray (word
, 'all')
1150 (* DebugTraceTree := value ; *)
1151 DebugTraceQuad
:= value
;
1152 DebugTraceToken
:= value
;
1153 DebugTraceLine
:= value
1154 ELSIF EqualArray (word
, 'quad')
1156 DebugTraceQuad
:= value
1157 ELSIF EqualArray (word
, 'token')
1159 DebugTraceToken
:= value
1160 ELSIF EqualArray (word
, 'line')
1162 DebugTraceLine
:= value
1164 errors1 ("unrecognized filter %s seen in -fm2-debug-trace= option\n", word
)
1166 END SetM2DebugTrace
;
1170 SetDebugFunctionLineNumbers - set DebugFunctionLineNumbers.
1173 PROCEDURE SetDebugFunctionLineNumbers (value
: BOOLEAN) ;
1175 DebugFunctionLineNumbers
:= value
1176 END SetDebugFunctionLineNumbers
;
1180 GetDebugTraceQuad - return DebugTraceQuad.
1183 PROCEDURE GetDebugTraceQuad () : BOOLEAN ;
1185 RETURN DebugTraceQuad
1186 END GetDebugTraceQuad
;
1190 GetDebugTraceTree - return DebugTraceTree.
1193 PROCEDURE GetDebugTraceTree () : BOOLEAN ;
1195 RETURN DebugTraceTree
1196 END GetDebugTraceTree
;
1200 GetDebugTraceToken - return DebugTraceToken.
1203 PROCEDURE GetDebugTraceToken () : BOOLEAN ;
1205 RETURN DebugTraceToken
1206 END GetDebugTraceToken
;
1210 GetDebugTraceLine - return DebugTraceLine.
1213 PROCEDURE GetDebugTraceLine () : BOOLEAN ;
1215 RETURN DebugTraceLine
1216 END GetDebugTraceLine
;
1220 GetDebugFunctionLineNumbers - return DebugFunctionLineNumbers.
1223 PROCEDURE GetDebugFunctionLineNumbers () : BOOLEAN ;
1225 RETURN DebugFunctionLineNumbers
1226 END GetDebugFunctionLineNumbers
;
1233 PROCEDURE SetSources (value
: BOOLEAN) ;
1235 Quiet
:= NOT value
;
1236 SeenSources
:= value
1241 SetDumpSystemExports -
1244 PROCEDURE SetDumpSystemExports (value
: BOOLEAN) ;
1246 DumpSystemExports
:= value
1247 END SetDumpSystemExports
;
1254 PROCEDURE SetSearchPath (arg
: ADDRESS
) ;
1258 s
:= InitStringCharStar (arg
) ;
1259 AddInclude (M2PathName
, s
) ;
1262 DumpPathName ("path name entries: ")
1269 setdefextension - set the source file definition module extension to arg.
1270 This should include the . and by default it is set to .def.
1273 PROCEDURE setdefextension (arg
: ADDRESS
) ;
1277 s
:= InitStringCharStar (arg
) ;
1278 SetDefExtension (s
) ;
1280 END setdefextension
;
1284 setmodextension - set the source file module extension to arg.
1285 This should include the . and by default it is set to .mod.
1288 PROCEDURE setmodextension (arg
: ADDRESS
) ;
1292 s
:= InitStringCharStar (arg
) ;
1293 SetModExtension (s
) ;
1295 END setmodextension
;
1302 PROCEDURE SetOptimizing (value
: CARDINAL) ;
1306 Optimizing
:= TRUE ;
1307 OptimizeBasicBlock
:= TRUE ;
1308 OptimizeUncalledProcedures
:= TRUE ;
1309 OptimizeCommonSubExpressions
:= TRUE
1311 Optimizing
:= FALSE ;
1312 OptimizeBasicBlock
:= FALSE ;
1313 OptimizeUncalledProcedures
:= FALSE ;
1314 OptimizeCommonSubExpressions
:= FALSE
1320 SetForcedLocation - sets the location for the lifetime of this compile to, location.
1321 This is primarily an internal debugging switch.
1324 PROCEDURE SetForcedLocation (location
: location_t
) ;
1326 ForcedLocation
:= TRUE ;
1327 ForcedLocationValue
:= location
1328 END SetForcedLocation
;
1332 SetCC1Quiet - sets the cc1quiet flag to, value.
1335 PROCEDURE SetCC1Quiet (value
: BOOLEAN) ;
1342 SetStatistics - turn on/off generate of compile time statistics.
1345 PROCEDURE SetStatistics (on
: BOOLEAN) ;
1352 OverrideLocation - possibly override the location value, depending upon
1353 whether the -flocation= option was used.
1356 PROCEDURE OverrideLocation (location
: location_t
) : location_t
;
1360 RETURN( ForcedLocationValue
)
1364 END OverrideLocation
;
1368 SetGenerateStatementNote - turn on generation of nops if necessary
1369 to generate pedalogical single stepping.
1372 PROCEDURE SetGenerateStatementNote (value
: BOOLEAN) ;
1374 GenerateStatementNote
:= value
1375 END SetGenerateStatementNote
;
1379 GetISO - return TRUE if -fiso was present on the command line.
1382 PROCEDURE GetISO () : BOOLEAN ;
1389 GetPIM - return TRUE if -fpim was present on the command line.
1392 PROCEDURE GetPIM () : BOOLEAN ;
1399 GetPIM2 - return TRUE if -fpim2 was present on the command line.
1402 PROCEDURE GetPIM2 () : BOOLEAN ;
1409 GetPIM3 - return TRUE if -fpim3 was present on the command line.
1412 PROCEDURE GetPIM3 () : BOOLEAN ;
1419 GetPIM4 - return TRUE if -fpim4 was present on the command line.
1422 PROCEDURE GetPIM4 () : BOOLEAN ;
1429 GetPositiveModFloor - return TRUE if -fpositive-mod-floor was present
1430 on the command line.
1433 PROCEDURE GetPositiveModFloor () : BOOLEAN ;
1435 RETURN PositiveModFloorDiv
1436 END GetPositiveModFloor
;
1440 GetFloatValueCheck - return TRUE if -ffloatvalue was present on the
1444 PROCEDURE GetFloatValueCheck () : BOOLEAN ;
1446 RETURN FloatValueChecking
1447 END GetFloatValueCheck
;
1451 SetFloatValueCheck - set depending upon the -ffloatvalue.
1454 PROCEDURE SetFloatValueCheck (value
: BOOLEAN) ;
1456 FloatValueChecking
:= value
1457 END SetFloatValueCheck
;
1461 GetWholeValueCheck - return TRUE if -fwholevalue was present on the
1465 PROCEDURE GetWholeValueCheck () : BOOLEAN ;
1467 RETURN WholeValueChecking
1468 END GetWholeValueCheck
;
1472 SetWholeValueCheck - set depending upon the -fwholevalue.
1475 PROCEDURE SetWholeValueCheck (value
: BOOLEAN) ;
1477 WholeValueChecking
:= value
1478 END SetWholeValueCheck
;
1482 SetWall - set all warnings to, value.
1485 PROCEDURE SetWall (value
: BOOLEAN) ;
1487 UnusedVariableChecking
:= value
;
1488 UnusedParameterChecking
:= value
;
1489 UninitVariableChecking
:= value
;
1490 PedanticCast
:= value
;
1491 PedanticParamNames
:= value
;
1492 StyleChecking
:= value
;
1493 CaseEnumChecking
:= value
1498 SetSaveTemps - turn on/off -save-temps.
1501 PROCEDURE SetSaveTemps (value
: BOOLEAN) ;
1508 SetSaveTempsDir - turn on/off -save-temps and specify the directory.
1511 PROCEDURE SetSaveTempsDir (arg
: ADDRESS
) ;
1513 SaveTempsDir
:= InitStringCharStar (arg
) ;
1515 END SetSaveTempsDir
;
1519 GetSaveTempsDir - return SaveTempsDir or NIL if -save-temps was not used.
1522 PROCEDURE GetSaveTempsDir () : String
;
1525 END GetSaveTempsDir
;
1529 SetDumpDir - Set the dump dir.
1532 PROCEDURE SetDumpDir (arg
: ADDRESS
) ;
1534 DumpDir
:= InitStringCharStar (arg
)
1539 GetDumpDir - return DumpDir or NIL.
1542 PROCEDURE GetDumpDir () : String
;
1548 SetScaffoldDynamic - set the -fscaffold-dynamic flag.
1551 PROCEDURE SetScaffoldDynamic (value
: BOOLEAN) ;
1553 ScaffoldDynamic
:= value
;
1556 ScaffoldStatic
:= FALSE
1558 END SetScaffoldDynamic
;
1562 SetScaffoldStatic - set the -fscaffold-static flag.
1565 PROCEDURE SetScaffoldStatic (value
: BOOLEAN) ;
1567 ScaffoldStatic
:= value
;
1570 ScaffoldDynamic
:= FALSE
1572 END SetScaffoldStatic
;
1576 GetScaffoldDynamic - get the -fscaffold-dynamic flag.
1579 PROCEDURE GetScaffoldDynamic () : BOOLEAN ;
1581 RETURN ScaffoldDynamic
1582 END GetScaffoldDynamic
;
1586 GetScaffoldStatic - get the -fscaffold-static flag.
1589 PROCEDURE GetScaffoldStatic () : BOOLEAN ;
1591 RETURN ScaffoldStatic
1592 END GetScaffoldStatic
;
1596 SetScaffoldMain - set the -fscaffold-main flag.
1599 PROCEDURE SetScaffoldMain (value
: BOOLEAN) ;
1601 ScaffoldMain
:= value
1602 END SetScaffoldMain
;
1606 SetRuntimeModuleOverride - set the override sequence used for module
1607 initialization and finialization.
1610 PROCEDURE SetRuntimeModuleOverride (override
: ADDRESS
) ;
1612 RuntimeModuleOverride
:= KillString (RuntimeModuleOverride
) ;
1613 RuntimeModuleOverride
:= InitStringCharStar (override
)
1614 END SetRuntimeModuleOverride
;
1618 GetRuntimeModuleOverride - return a string containing any user override
1619 or the default module initialization override
1623 PROCEDURE GetRuntimeModuleOverride () : ADDRESS
;
1625 RETURN string (RuntimeModuleOverride
)
1626 END GetRuntimeModuleOverride
;
1630 SetGenModuleList - set the GenModuleList flag to true and pass
1631 set GenModuleListFilename to filename.
1634 PROCEDURE SetGenModuleList (value
: BOOLEAN; filename
: ADDRESS
) ;
1636 GenModuleListFilename
:= KillString (GenModuleListFilename
) ;
1639 GenModuleListFilename
:= InitStringCharStar (filename
)
1641 GenModuleList
:= value
1642 END SetGenModuleList
;
1646 GetGenModuleFilename - returns the filename set by SetGenModuleList.
1649 PROCEDURE GetGenModuleFilename () : String
;
1651 RETURN GenModuleListFilename
1652 END GetGenModuleFilename
;
1656 SetShared - sets the SharedFlag to value.
1659 PROCEDURE SetShared (value
: BOOLEAN) ;
1666 SetUninitVariableChecking - sets the UninitVariableChecking and
1667 UninitVariableConditionalChecking flags to value
1668 depending upon arg string. The arg string
1669 can be: "all", "known,cond", "cond,known", "known"
1673 PROCEDURE SetUninitVariableChecking (value
: BOOLEAN; arg
: ADDRESS
) : INTEGER ;
1681 printf ("SetUninitVariableChecking (TRUE, %s)\n", arg
)
1683 printf ("SetUninitVariableChecking (FALSE, %s)\n", arg
)
1686 s
:= InitStringCharStar (arg
) ;
1687 IF EqualArray (s
, "all") OR
1688 EqualArray (s
, "known,cond") OR
1689 EqualArray (s
, "cond,known")
1691 UninitVariableChecking
:= value
;
1692 UninitVariableConditionalChecking
:= value
;
1693 s
:= KillString (s
) ;
1695 ELSIF EqualArray (s
, "known")
1697 UninitVariableChecking
:= value
;
1698 s
:= KillString (s
) ;
1700 ELSIF EqualArray (s
, "cond")
1702 UninitVariableConditionalChecking
:= value
;
1703 s
:= KillString (s
) ;
1706 s
:= KillString (s
) ;
1709 END SetUninitVariableChecking
;
1713 SetCaseEnumChecking - sets the CaseEnumChecking to value.
1716 PROCEDURE SetCaseEnumChecking (value
: BOOLEAN) ;
1718 CaseEnumChecking
:= value
1719 END SetCaseEnumChecking
;
1723 SetDebugBuiltins - sets the DebugBuiltins to value.
1726 PROCEDURE SetDebugBuiltins (value
: BOOLEAN) ;
1728 DebugBuiltins
:= value
1729 END SetDebugBuiltins
;
1733 SetIBMLongDouble - enable/disable LONGREAL to map onto the
1734 IBM long double 128 bit data type.
1735 (Only available on the ppc).
1738 PROCEDURE SetIBMLongDouble (value
: BOOLEAN) ;
1740 IBMLongDouble
:= value
;
1743 IEEELongDouble
:= FALSE
1745 END SetIBMLongDouble
;
1749 GetIBMLongDouble - return the value of IBMLongDouble.
1752 PROCEDURE GetIBMLongDouble () : BOOLEAN ;
1754 RETURN IBMLongDouble
1755 END GetIBMLongDouble
;
1759 SetIEEELongDouble - enable/disable LONGREAL to map onto the
1760 IEEE long double 128 bit data type.
1761 (Only available on the ppc).
1764 PROCEDURE SetIEEELongDouble (value
: BOOLEAN) ;
1766 IEEELongDouble
:= value
;
1769 IBMLongDouble
:= FALSE
1771 END SetIEEELongDouble
;
1775 GetIEEELongDouble - return the value of IEEELongDouble.
1778 PROCEDURE GetIEEELongDouble () : BOOLEAN ;
1780 RETURN IEEELongDouble
1781 END GetIEEELongDouble
;
1785 InitializeLongDoubleFlags - initialize the long double related flags
1786 with default values given during gcc configure.
1789 PROCEDURE InitializeLongDoubleFlags
;
1791 IBMLongDouble
:= FALSE ;
1792 IEEELongDouble
:= FALSE ;
1793 CASE TargetIEEEQuadDefault () OF
1796 0: IBMLongDouble
:= TRUE |
1797 1: IEEELongDouble
:= TRUE
1800 InternalError ('unexpected value returned from TargetIEEEQuadDefault ()')
1802 END InitializeLongDoubleFlags
;
1806 GetDumpDeclFilename - returns the DumpDeclFilename.
1809 PROCEDURE GetDumpDeclFilename () : String
;
1811 RETURN DumpDeclFilename
1812 END GetDumpDeclFilename
;
1816 SetDumpDeclFilename -
1819 PROCEDURE SetDumpDeclFilename (value
: BOOLEAN; filename
: ADDRESS
) ;
1822 DumpDeclFilename
:= KillString (DumpDeclFilename
) ;
1825 DumpDeclFilename
:= InitStringCharStar (filename
)
1827 END SetDumpDeclFilename
;
1831 GetDumpQuadFilename - returns the DumpQuadFilename.
1834 PROCEDURE GetDumpQuadFilename () : String
;
1836 RETURN DumpQuadFilename
1837 END GetDumpQuadFilename
;
1841 SetDumpQuadFilename -
1844 PROCEDURE SetDumpQuadFilename (value
: BOOLEAN; filename
: ADDRESS
) ;
1847 DumpQuadFilename
:= KillString (DumpQuadFilename
) ;
1850 DumpQuadFilename
:= InitStringCharStar (filename
)
1852 END SetDumpQuadFilename
;
1856 GetDumpGimpleFilename - returns the DumpGimpleFilename.
1859 PROCEDURE GetDumpGimpleFilename () : String
;
1861 RETURN DumpGimpleFilename
1862 END GetDumpGimpleFilename
;
1866 SetDumpGimpleFilename - set DumpGimpleFilename to filename.
1869 PROCEDURE SetDumpGimpleFilename (value
: BOOLEAN; filename
: ADDRESS
) ;
1871 DumpGimple
:= value
;
1872 DumpGimpleFilename
:= KillString (DumpGimpleFilename
) ;
1873 IF value
AND (filename #
NIL)
1875 DumpGimpleFilename
:= InitStringCharStar (filename
)
1877 END SetDumpGimpleFilename
;
1881 SetM2DumpFilter - sets the filter to a comma separated list of procedures
1882 and modules. Not to be confused with SetM2Dump below
1883 which enables the class of data structures to be dumped.
1886 PROCEDURE SetM2DumpFilter (value
: BOOLEAN; filter
: ADDRESS
) ;
1888 M2DumpFilter
:= KillString (M2DumpFilter
) ;
1889 IF value
AND (filter #
NIL)
1891 M2DumpFilter
:= InitStringCharStar (filter
)
1893 END SetM2DumpFilter
;
1897 GetM2DumpFilter - returns the dump filter.
1900 PROCEDURE GetM2DumpFilter () : ADDRESS
;
1902 IF M2DumpFilter
= NIL
1906 RETURN string (M2DumpFilter
)
1908 END GetM2DumpFilter
;
1912 MatchDump - enable/disable dump using value. It returns TRUE if dump
1916 PROCEDURE MatchDump (dump
: String
; value
: BOOLEAN) : BOOLEAN ;
1918 IF EqualArray (dump
, 'all')
1922 DumpGimple
:= value
;
1924 ELSIF EqualArray (dump
, 'decl')
1928 ELSIF EqualArray (dump
, 'gimple')
1930 DumpGimple
:= value
;
1932 ELSIF EqualArray (dump
, 'quad')
1942 SetM2Dump - sets the dump via a comma separated list: quad,decl,gimple,all.
1943 It returns TRUE if the comma separated list is valid.
1946 PROCEDURE SetM2Dump (value
: BOOLEAN; filter
: ADDRESS
) : BOOLEAN ;
1959 M2Dump
:= KillString (M2Dump
)
1961 M2Dump
:= InitStringCharStar (filter
) ;
1964 i
:= Index (M2Dump
, ',', start
) ;
1967 dump
:= Slice (M2Dump
, start
, 0)
1969 dump
:= Slice (M2Dump
, start
, i
)
1971 result
:= MatchDump (dump
, value
) ;
1972 dump
:= KillString (dump
) ;
1984 GetDumpGimple - return TRUE if the dump gimple flag is set from SetM2Dump.
1987 PROCEDURE GetDumpGimple () : BOOLEAN ;
1994 GetDumpQuad - return TRUE if the dump quad flag is set from SetM2Dump.
1997 PROCEDURE GetDumpQuad () : BOOLEAN ;
2004 GetDumpDecl - return TRUE if the dump decl flag is set from SetM2Dump.
2007 PROCEDURE GetDumpDecl () : BOOLEAN ;
2014 GetEnableForward - return EnableForward.
2017 PROCEDURE GetEnableForward () : BOOLEAN ;
2019 RETURN EnableForward
2020 END GetEnableForward
;
2024 SetEnableForward - set EnableForward to value.
2027 PROCEDURE SetEnableForward (value
: BOOLEAN) ;
2029 EnableForward
:= value
2030 END SetEnableForward
;
2034 SetFileOffsetBits - create SYSTEM.COFF_T as a signed integer of size bits.
2037 PROCEDURE SetFileOffsetBits (value
: BOOLEAN; bits
: CARDINAL) : BOOLEAN ;
2044 END SetFileOffsetBits
;
2048 GetFileOffsetBits - return the number of bits used to create SYSTEM.COFF_T.
2051 PROCEDURE GetFileOffsetBits () : CARDINAL ;
2054 END GetFileOffsetBits
;
2058 cflag
:= FALSE ; (* -c. *)
2059 RuntimeModuleOverride
:= InitString (DefaultRuntimeModuleOverride
) ;
2060 CppArgs
:= InitString ('') ;
2065 PositiveModFloorDiv
:= FALSE ;
2067 SeenSources
:= FALSE ;
2068 Statistics
:= FALSE ;
2069 StyleChecking
:= FALSE ;
2070 CompilerDebugging
:= FALSE ;
2071 GenerateDebugging
:= FALSE ;
2072 Optimizing
:= FALSE ;
2077 Profiling
:= FALSE ;
2079 OptimizeBasicBlock
:= FALSE ;
2080 OptimizeUncalledProcedures
:= FALSE ;
2081 OptimizeCommonSubExpressions
:= FALSE ;
2082 NilChecking
:= FALSE ;
2083 WholeDivChecking
:= FALSE ;
2084 WholeValueChecking
:= FALSE ;
2085 FloatValueChecking
:= FALSE ;
2086 IndexChecking
:= FALSE ;
2087 RangeChecking
:= FALSE ;
2088 ReturnChecking
:= FALSE ;
2089 CaseElseChecking
:= FALSE ;
2090 CPreProcessor
:= FALSE ;
2091 LineDirectives
:= TRUE ;
2092 ExtendedOpaque
:= FALSE ;
2093 UnboundedByReference
:= FALSE ;
2094 VerboseUnbounded
:= FALSE ;
2095 PedanticParamNames
:= FALSE ;
2096 PedanticCast
:= FALSE ;
2098 DumpSystemExports
:= FALSE ;
2099 GenerateSwig
:= FALSE ;
2100 Exceptions
:= TRUE ;
2101 DebugBuiltins
:= FALSE ;
2102 ForcedLocation
:= FALSE ;
2103 WholeProgram
:= FALSE ;
2104 DebugTraceQuad
:= FALSE ;
2105 DebugTraceTree
:= FALSE ;
2106 DebugTraceLine
:= FALSE ;
2107 DebugTraceToken
:= FALSE ;
2108 DebugFunctionLineNumbers
:= FALSE ;
2109 GenerateStatementNote
:= FALSE ;
2110 LowerCaseKeywords
:= FALSE ;
2111 UnusedVariableChecking
:= FALSE ;
2112 UnusedParameterChecking
:= FALSE ;
2113 StrictTypeChecking
:= TRUE ;
2115 SaveTemps
:= FALSE ;
2116 ScaffoldDynamic
:= TRUE ;
2117 ScaffoldStatic
:= FALSE ;
2118 ScaffoldMain
:= FALSE ;
2119 UselistFilename
:= NIL ;
2120 GenModuleList
:= FALSE ;
2121 GenModuleListFilename
:= NIL ;
2122 SharedFlag
:= FALSE ;
2128 SaveTempsDir
:= NIL ;
2130 UninitVariableChecking
:= FALSE ;
2131 UninitVariableConditionalChecking
:= FALSE ;
2132 CaseEnumChecking
:= FALSE ;
2138 InitializeLongDoubleFlags
;
2139 M2Prefix
:= InitString ('') ;
2140 M2PathName
:= InitString ('') ;
2141 DumpQuadFilename
:= NIL ;
2142 DumpGimpleFilename
:= NIL ;
2143 DumpDeclFilename
:= NIL ;
2146 DumpGimple
:= FALSE ;
2148 M2DumpFilter
:= NIL ;
2149 EnableForward
:= TRUE ;
2150 OffTBits
:= 0 ; (* Default to CSSIZE_T. *)