]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-compiler/M2Options.mod
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / gm2-compiler / M2Options.mod
1 (* M2Options.mod initializes the user options.
2
3 Copyright (C) 2001-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6 This file is part of GNU Modula-2.
7
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)
11 any later version.
12
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.
17
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/>. *)
21
22 IMPLEMENTATION MODULE M2Options ;
23
24
25 IMPORT CmdArgs ;
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 m2linemap IMPORT location_t ;
34 FROM m2configure IMPORT FullPathCPP ;
35
36
37 FROM DynamicStrings IMPORT String, Length, InitString, Mark, Slice, EqualArray,
38 InitStringCharStar, ConCatChar, ConCat, KillString,
39 Dup, string, char,
40 PushAllocation, PopAllocationExemption,
41 InitStringDB, InitStringCharStarDB,
42 InitStringCharDB, MultDB, DupDB, SliceDB ;
43
44 (*
45 #define InitString(X) InitStringDB(X, __FILE__, __LINE__)
46 #define InitStringCharStar(X) InitStringCharStarDB(X, __FILE__, __LINE__)
47 #define InitStringChar(X) InitStringCharDB(X, __FILE__, __LINE__)
48 #define Mult(X,Y) MultDB(X, Y, __FILE__, __LINE__)
49 #define Dup(X) DupDB(X, __FILE__, __LINE__)
50 #define Slice(X,Y,Z) SliceDB(X, Y, Z, __FILE__, __LINE__)
51 *)
52
53 CONST
54 Debugging = FALSE ;
55 DefaultRuntimeModuleOverride = "m2iso:RTentity,m2iso:Storage,m2iso:SYSTEM,m2iso:M2RTS,m2iso:RTExceptions,m2iso:IOLink" ;
56
57 VAR
58 M2Prefix,
59 M2PathName,
60 Barg,
61 MFarg,
62 MTFlag,
63 MQFlag,
64 DepTarget,
65 CmdLineObj,
66 SaveTempsDir,
67 DumpDir,
68 GenModuleListFilename,
69 UselistFilename,
70 RuntimeModuleOverride,
71 CppArgs : String ;
72 MFlag,
73 MMFlag,
74 MPFlag,
75 MDFlag,
76 MMDFlag,
77 UselistFlag,
78 CC1Quiet,
79 SeenSources : BOOLEAN ;
80 ForcedLocationValue : location_t ;
81
82
83 (* String garbage collection debugging routines.
84
85 (*
86 doDSdbEnter -
87 *)
88
89 PROCEDURE doDSdbEnter ;
90 BEGIN
91 PushAllocation
92 END doDSdbEnter ;
93
94
95 (*
96 doDSdbExit -
97 *)
98
99 PROCEDURE doDSdbExit (s: String) ;
100 BEGIN
101 s := PopAllocationExemption (TRUE, s)
102 END doDSdbExit ;
103
104
105 (*
106 DSdbEnter -
107 *)
108
109 PROCEDURE DSdbEnter ;
110 BEGIN
111 END DSdbEnter ;
112
113
114 (*
115 DSdbExit -
116 *)
117
118 PROCEDURE DSdbExit (s: String) ;
119 BEGIN
120 END DSdbExit ;
121 *)
122
123 (*
124 #define DSdbEnter doDSdbEnter
125 #define DSdbExit doDSdbExit
126 *)
127
128
129 (*
130 SetM2Prefix - assign arg to M2Prefix.
131 *)
132
133 PROCEDURE SetM2Prefix (arg: ADDRESS) ;
134 BEGIN
135 M2Prefix := KillString (M2Prefix) ;
136 M2Prefix := InitStringCharStar (arg)
137 END SetM2Prefix ;
138
139
140 (*
141 GetM2Prefix - return M2Prefix as a C string.
142 *)
143
144 PROCEDURE GetM2Prefix () : ADDRESS ;
145 BEGIN
146 RETURN string (M2Prefix)
147 END GetM2Prefix ;
148
149
150 (*
151 SetM2PathName - assign arg to M2PathName.
152 *)
153
154 PROCEDURE SetM2PathName (arg: ADDRESS) ;
155 BEGIN
156 M2PathName := KillString (M2PathName) ;
157 M2PathName := InitStringCharStar (arg) ;
158 (* fprintf1 (StdErr, "M2PathName = %s\n", M2PathName) *)
159 END SetM2PathName ;
160
161
162 (*
163 GetM2PathName - return M2PathName as a C string.
164 *)
165
166 PROCEDURE GetM2PathName () : ADDRESS ;
167 BEGIN
168 RETURN string (M2PathName)
169 END GetM2PathName ;
170
171
172 (*
173 SetB - assigns Barg to arg.
174 *)
175
176 PROCEDURE SetB (arg: ADDRESS) ;
177 BEGIN
178 Barg := KillString (Barg) ;
179 Barg := InitStringCharStar (arg)
180 END SetB ;
181
182
183 (*
184 GetB - returns Barg value as a C string or NIL if it was never set.
185 *)
186
187 PROCEDURE GetB () : ADDRESS ;
188 BEGIN
189 RETURN string (Barg)
190 END GetB ;
191
192
193 (*
194 SetM - set the MFlag.
195 *)
196
197 PROCEDURE SetM (value: BOOLEAN) ;
198 BEGIN
199 MFlag := value
200 END SetM ;
201
202
203 (*
204 GetM - set the MFlag.
205 *)
206
207 PROCEDURE GetM () : BOOLEAN ;
208 BEGIN
209 RETURN MFlag
210 END GetM ;
211
212
213 (*
214 SetMM - set the MMFlag.
215 *)
216
217 PROCEDURE SetMM (value: BOOLEAN) ;
218 BEGIN
219 MMFlag := value
220 END SetMM ;
221
222
223 (*
224 GetMM - set the MMFlag.
225 *)
226
227 PROCEDURE GetMM () : BOOLEAN ;
228 BEGIN
229 RETURN MMFlag
230 END GetMM ;
231
232
233 (*
234 SetMD - set the MDFlag to value.
235 *)
236
237 PROCEDURE SetMD (value: BOOLEAN) ;
238 BEGIN
239 MDFlag := value
240 END SetMD ;
241
242
243 (*
244 GetMD - return the MDFlag.
245 *)
246
247 PROCEDURE GetMD () : BOOLEAN ;
248 BEGIN
249 RETURN MDFlag
250 END GetMD ;
251
252
253 (*
254 SetMMD - set the MMDFlag to value.
255 *)
256
257 PROCEDURE SetMMD (value: BOOLEAN) ;
258 BEGIN
259 MMDFlag := value
260 END SetMMD ;
261
262
263 (*
264 GetMMD - return the MMDFlag.
265 *)
266
267 PROCEDURE GetMMD () : BOOLEAN ;
268 BEGIN
269 RETURN MMDFlag
270 END GetMMD ;
271
272
273 (*
274 SetMF - assigns MFarg to the filename from arg.
275 *)
276
277 PROCEDURE SetMF (arg: ADDRESS) ;
278 BEGIN
279 MFarg := KillString (MFarg) ;
280 MFarg := InitStringCharStar (arg)
281 END SetMF ;
282
283
284 (*
285 GetMF - returns MFarg or NIL if never set.
286 *)
287
288 PROCEDURE GetMF () : ADDRESS ;
289 BEGIN
290 RETURN string (MFarg)
291 END GetMF ;
292
293
294 (*
295 SetMP - set the MPflag to value.
296 *)
297
298 PROCEDURE SetMP (value: BOOLEAN) ;
299 BEGIN
300 MPFlag := value
301 END SetMP ;
302
303
304 (*
305 GetMP - get the MPflag.
306 *)
307
308 PROCEDURE GetMP () : BOOLEAN ;
309 BEGIN
310 RETURN MPFlag
311 END GetMP ;
312
313
314 (*
315 AddWord - concats a word to sentence inserting a space if necessary.
316 sentence is returned. sentence will be created if it is NIL.
317 *)
318
319 PROCEDURE AddWord (sentence, word: String) : String ;
320 BEGIN
321 IF word # NIL
322 THEN
323 IF sentence = NIL
324 THEN
325 sentence := Dup (word)
326 ELSE
327 sentence := ConCatChar (sentence, ' ') ;
328 sentence := ConCat (sentence, word)
329 END
330 END ;
331 RETURN sentence
332 END AddWord ;
333
334
335 (*
336 QuoteTarget - quote the '$' character.
337 *)
338
339 PROCEDURE QuoteTarget (target: String) : String ;
340 VAR
341 quoted: String ;
342 i, n : CARDINAL ;
343 BEGIN
344 quoted := InitString ('') ;
345 i := 0 ;
346 n := Length (target) ;
347 WHILE i < n DO
348 CASE char (target, i) OF
349
350 '$': quoted := ConCat (quoted, Mark (InitString ('$$')))
351
352 ELSE
353 quoted := ConCatChar (quoted, char (target, i))
354 END ;
355 INC (i)
356 END ;
357 RETURN quoted
358 END QuoteTarget ;
359
360
361 (*
362 SetMQ - adds a quoted target arg to the DepTarget sentence.
363 *)
364
365 PROCEDURE SetMQ (arg: ADDRESS) ;
366 BEGIN
367 DepTarget := AddWord (DepTarget, QuoteTarget (InitStringCharStar (arg))) ;
368 MQFlag := AddWord (MQFlag, Mark (InitString ('-MQ'))) ;
369 MQFlag := AddWord (MQFlag, Mark (InitStringCharStar (arg)))
370 END SetMQ ;
371
372
373 (*
374 GetMQ - returns a C string containing all the -MQ arg values.
375 *)
376
377 PROCEDURE GetMQ () : ADDRESS ;
378 BEGIN
379 RETURN string (MQFlag)
380 END GetMQ ;
381
382
383 (*
384 SetMT - adds a target arg to the DepTarget sentence.
385 *)
386
387 PROCEDURE SetMT (arg: ADDRESS) ;
388 BEGIN
389 DepTarget := AddWord (DepTarget, InitStringCharStar (arg)) ;
390 MTFlag := AddWord (MTFlag, Mark (InitString ('-MT'))) ;
391 MTFlag := AddWord (MTFlag, Mark (InitStringCharStar (arg)))
392 END SetMT ;
393
394
395 (*
396 GetMT - returns a C string containing all the -MT arg values.
397 *)
398
399 PROCEDURE GetMT () : ADDRESS ;
400 BEGIN
401 RETURN string (MTFlag)
402 END GetMT ;
403
404
405 (*
406 GetDepTarget - returns the DepTarget as a C string.
407 *)
408
409 PROCEDURE GetDepTarget () : ADDRESS ;
410 BEGIN
411 RETURN string (DepTarget)
412 END GetDepTarget ;
413
414
415 (*
416 SetObj - assigns CmdLineObj to the filename from arg.
417 *)
418
419 PROCEDURE SetObj (arg: ADDRESS) ;
420 BEGIN
421 CmdLineObj := KillString (CmdLineObj) ;
422 CmdLineObj := InitStringCharStar (arg)
423 END SetObj ;
424
425
426 (*
427 GetObj - returns CmdLineObj filename as a c-string or NIL if it was never set.
428 *)
429
430 PROCEDURE GetObj () : ADDRESS ;
431 BEGIN
432 RETURN string (CmdLineObj)
433 END GetObj ;
434
435
436 (*
437 CppCommandLine - returns the Cpp command line and all arguments.
438 NIL is returned if the -fcpp is absent.
439 *)
440
441 PROCEDURE CppCommandLine () : String ;
442 VAR
443 s: String ;
444 BEGIN
445 IF CPreProcessor
446 THEN
447 s := InitStringCharStar (FullPathCPP ()) ;
448 s := ConCat (ConCatChar (s, ' '), CppArgs) ;
449 IF CC1Quiet
450 THEN
451 s := ConCat (ConCatChar (s, ' '), Mark (InitString ('-quiet')))
452 END ;
453 RETURN s
454 ELSE
455 RETURN NIL
456 END
457 END CppCommandLine ;
458
459
460 (*
461 CppArg - sets the option and arg in the cpp command line.
462 *)
463
464 PROCEDURE CppArg (opt, arg: ADDRESS; joined: BOOLEAN) ;
465 VAR
466 s: String ;
467 BEGIN
468 s := InitStringCharStar(opt) ;
469 IF EqualArray(s, '-fcpp-begin') OR EqualArray(s, '-fcpp-end')
470 THEN
471 (* do nothing *)
472 ELSE
473 IF NOT EqualArray(CppArgs, '')
474 THEN
475 CppArgs := ConCatChar(CppArgs, ' ')
476 END ;
477 CppArgs := ConCat(CppArgs, Mark(s)) ;
478 IF arg#NIL
479 THEN
480 s := InitStringCharStar(arg) ;
481 IF NOT joined
482 THEN
483 CppArgs := ConCatChar(CppArgs, ' ')
484 END ;
485 CppArgs := ConCat(CppArgs, s)
486 END
487 END
488 END CppArg ;
489
490
491 (*
492 CppRemember - remember a string, s, as a cpp related argument.
493 The string, s, is not garbage collected.
494 *)
495
496 PROCEDURE CppRemember (s: String) ;
497 BEGIN
498 IF (CppArgs=NIL) OR EqualArray (CppArgs, '')
499 THEN
500 CppArgs := Dup (s)
501 ELSE
502 CppArgs := ConCatChar (CppArgs, ' ') ;
503 CppArgs := ConCat (CppArgs, s)
504 END
505 END CppRemember ;
506
507
508 (*
509 FinaliseOptions - once all options have been parsed we set any inferred
510 values.
511 *)
512
513 PROCEDURE FinaliseOptions ;
514 BEGIN
515 (* currently only one value, this could be make an option in the future *)
516 VariantValueChecking := Iso
517 END FinaliseOptions ;
518
519
520 (*
521 SetWholeProgram - sets the WholeProgram flag (-fwhole-program).
522 *)
523
524 PROCEDURE SetWholeProgram (value: BOOLEAN) ;
525 BEGIN
526 WholeProgram := value
527 END SetWholeProgram ;
528
529
530 (*
531 SetReturnCheck -
532 *)
533
534 PROCEDURE SetReturnCheck (value: BOOLEAN) : BOOLEAN ;
535 BEGIN
536 ReturnChecking := value ;
537 RETURN TRUE
538 END SetReturnCheck ;
539
540
541 (*
542 SetNilCheck -
543 *)
544
545 PROCEDURE SetNilCheck (value: BOOLEAN) : BOOLEAN ;
546 BEGIN
547 NilChecking := value ;
548 RETURN TRUE
549 END SetNilCheck ;
550
551
552 (*
553 SetCaseCheck - set else case checking to, value.
554 *)
555
556 PROCEDURE SetCaseCheck (value: BOOLEAN) : BOOLEAN ;
557 BEGIN
558 CaseElseChecking := value ;
559 RETURN TRUE
560 END SetCaseCheck ;
561
562
563 (*
564 SetCheckAll - set all runtime checking to, value.
565 *)
566
567 PROCEDURE SetCheckAll (value: BOOLEAN) : BOOLEAN ;
568 BEGIN
569 NilChecking := value ;
570 WholeDivChecking := value ;
571 IndexChecking := value ;
572 RangeChecking := value ;
573 ReturnChecking := value ;
574 NilChecking := value ;
575 CaseElseChecking := value ;
576 FloatValueChecking := value ;
577 WholeValueChecking := value ;
578 RETURN TRUE
579 END SetCheckAll ;
580
581
582 (*
583 SetAutoInit - -fauto-init turns on automatic initialization of pointers to NIL.
584 TRUE is returned.
585 *)
586
587 PROCEDURE SetAutoInit (value: BOOLEAN) ;
588 BEGIN
589 AutoInit := value ;
590 RETURN TRUE
591 END SetAutoInit ;
592
593
594 (*
595 SetUnusedVariableChecking - assigns the UnusedVariableChecking to value.
596 *)
597
598 PROCEDURE SetUnusedVariableChecking (value: BOOLEAN) ;
599 BEGIN
600 UnusedVariableChecking := value
601 END SetUnusedVariableChecking ;
602
603
604 (*
605 SetUnusedParameterChecking - assigns the UnusedParameterChecking to value.
606 *)
607
608 PROCEDURE SetUnusedParameterChecking (value: BOOLEAN) ;
609 BEGIN
610 UnusedParameterChecking := value
611 END SetUnusedParameterChecking ;
612
613
614 (*
615 SetStrictTypeChecking - assigns the StrictTypeChecking flag to value.
616 *)
617
618 PROCEDURE SetStrictTypeChecking (value: BOOLEAN) ;
619 BEGIN
620 StrictTypeChecking := value
621 END SetStrictTypeChecking ;
622
623
624 (*
625 SetVerboseUnbounded - sets the VerboseUnbounded flag to, value.
626 *)
627
628 PROCEDURE SetVerboseUnbounded (value: BOOLEAN) : BOOLEAN ;
629 BEGIN
630 VerboseUnbounded := value ;
631 RETURN TRUE
632 END SetVerboseUnbounded ;
633
634
635 (*
636 SetQuiet - sets the quiet flag to, value.
637 *)
638
639 PROCEDURE SetQuiet (value: BOOLEAN) : BOOLEAN ;
640 BEGIN
641 Quiet := value ;
642 RETURN TRUE
643 END SetQuiet ;
644
645
646 (*
647 SetCpp - enables the source to be preprocessed and enables the
648 recognition of C preprocessor line directives.
649 *)
650
651 PROCEDURE SetCpp (value: BOOLEAN) : BOOLEAN ;
652 BEGIN
653 CPreProcessor := value ;
654 LineDirectives := value ;
655 RETURN TRUE
656 END SetCpp ;
657
658
659 (*
660 GetCpp - returns TRUE if the C preprocessor was used.
661 *)
662
663 PROCEDURE GetCpp () : BOOLEAN ;
664 BEGIN
665 RETURN CPreProcessor
666 END GetCpp ;
667
668
669 (*
670 SetPPOnly - set the PPonly (preprocess only) to value.
671 *)
672
673 PROCEDURE SetPPOnly (value: BOOLEAN) ;
674 BEGIN
675 PPonly := value
676 END SetPPOnly ;
677
678 (*
679 GetPPOnly - get the PPonly (preprocess only).
680 *)
681
682 PROCEDURE GetPPOnly () : BOOLEAN ;
683 BEGIN
684 RETURN PPonly
685 END GetPPOnly ;
686
687
688 (*
689 Setc - set the cflag (compile only flag -c) to value.
690 *)
691
692 PROCEDURE Setc (value: BOOLEAN) ;
693 BEGIN
694 cflag := value
695 END Setc ;
696
697
698 (*
699 Getc - get the cflag (compile only flag -c).
700 *)
701
702 PROCEDURE Getc () : BOOLEAN ;
703 BEGIN
704 RETURN cflag
705 END Getc ;
706
707
708 (*
709 SetUselist - set the uselist flag to value and remember the filename.
710 *)
711
712 PROCEDURE SetUselist (value: BOOLEAN; filename: ADDRESS) ;
713 BEGIN
714 UselistFlag := value ;
715 UselistFilename := KillString (UselistFilename) ;
716 IF filename # NIL
717 THEN
718 UselistFilename := InitStringCharStar (filename)
719 END
720 END SetUselist ;
721
722
723 (*
724 GetUselist - return the uselist flag.
725 *)
726
727 PROCEDURE GetUselist () : BOOLEAN ;
728 BEGIN
729 RETURN UselistFlag
730 END GetUselist ;
731
732
733 (*
734 GetUselistFilename - return the uselist filename as a String.
735 *)
736
737 PROCEDURE GetUselistFilename () : String ;
738 BEGIN
739 RETURN UselistFilename
740 END GetUselistFilename ;
741
742
743 (*
744 SetM2g - set GenerateStatementNote to value and return value.
745 Corresponds to the -fm2-g flag.
746 *)
747
748 PROCEDURE SetM2g (value: BOOLEAN) : BOOLEAN ;
749 BEGIN
750 GenerateStatementNote := value ;
751 RETURN GenerateStatementNote
752 END SetM2g ;
753
754
755 (*
756 GetM2g - returns TRUE if the -fm2-g flags was used.
757 *)
758
759 PROCEDURE GetM2g () : BOOLEAN ;
760 BEGIN
761 RETURN GenerateStatementNote
762 END GetM2g ;
763
764
765 (*
766 SetLowerCaseKeywords - set the lower case keyword flag and return the result.
767 *)
768
769 PROCEDURE SetLowerCaseKeywords (value: BOOLEAN) : BOOLEAN ;
770 BEGIN
771 LowerCaseKeywords := value ;
772 RETURN LowerCaseKeywords
773 END SetLowerCaseKeywords ;
774
775
776 (*
777 SetVerbose - set the Verbose flag to, value. It returns TRUE.
778 *)
779
780 PROCEDURE SetVerbose (value: BOOLEAN) : BOOLEAN ;
781 BEGIN
782 Verbose := value ;
783 RETURN( TRUE )
784 END SetVerbose ;
785
786
787 (*
788 SetMakeall -
789
790 PROCEDURE SetMakeall (value: BOOLEAN) : BOOLEAN ;
791 BEGIN
792 (* value is unused *)
793 RETURN( TRUE )
794 END SetMakeall ;
795 *)
796
797
798 (*
799 SetMakeall0 -
800
801 PROCEDURE SetMakeall0 (value: BOOLEAN) : BOOLEAN ;
802 BEGIN
803 (* value is unused *)
804 RETURN( TRUE )
805 END SetMakeall0 ;
806 *)
807
808
809 (*
810 SetIncludePath -
811
812 PROCEDURE SetIncludePath (arg: ADDRESS) : BOOLEAN ;
813 BEGIN
814 RETURN( TRUE )
815 END SetIncludePath ;
816 *)
817
818
819 (*
820 SetUnboundedByReference -
821 *)
822
823 PROCEDURE SetUnboundedByReference (value: BOOLEAN) : BOOLEAN ;
824 BEGIN
825 UnboundedByReference := value ;
826 RETURN( TRUE )
827 END SetUnboundedByReference ;
828
829
830 (*
831 (*
832 SetDebugging - sets the debugging flag to, v.
833 *)
834
835 PROCEDURE SetDebugging (value: BOOLEAN) ;
836 BEGIN
837 GenerateDebugging := value
838 END SetDebugging ;
839
840
841 (*
842 SetProfiling - dummy procedure, as profiling is implemented in the gcc backend.
843 *)
844
845 PROCEDURE SetProfiling (value: BOOLEAN) ;
846 BEGIN
847 (* nothing to do *)
848 END SetProfiling ;
849 *)
850
851
852 (*
853 SetISO -
854 *)
855
856 PROCEDURE SetISO (value: BOOLEAN) ;
857 BEGIN
858 Iso := value ;
859 Pim := NOT value ;
860 Pim2 := NOT value ;
861 (* Pim4 is the default, leave it alone since the DIV and MOD rules are the
862 same as ISO. *)
863 END SetISO ;
864
865
866 (*
867 SetPIM -
868 *)
869
870 PROCEDURE SetPIM (value: BOOLEAN) ;
871 BEGIN
872 Pim := value ;
873 Iso := NOT value
874 END SetPIM ;
875
876
877 (*
878 SetPIM2 -
879 *)
880
881 PROCEDURE SetPIM2 (value: BOOLEAN) ;
882 BEGIN
883 Pim := value ;
884 Pim2 := value ;
885 Iso := NOT value ;
886 IF value
887 THEN
888 (* Pim4 is the default, turn it off. *)
889 Pim4 := FALSE
890 END
891 END SetPIM2 ;
892
893
894 (*
895 SetPIM3 -
896 *)
897
898 PROCEDURE SetPIM3 (value: BOOLEAN) ;
899 BEGIN
900 Pim := value ;
901 Pim3 := value ;
902 Iso := NOT value ;
903 IF value
904 THEN
905 (* Pim4 is the default, turn it off. *)
906 Pim4 := FALSE
907 END
908 END SetPIM3 ;
909
910
911 (*
912 SetPIM4 -
913 *)
914
915 PROCEDURE SetPIM4 (value: BOOLEAN) ;
916 BEGIN
917 Pim := value ;
918 Pim4 := value ;
919 Iso := NOT value
920 END SetPIM4 ;
921
922
923 (*
924 SetPositiveModFloor - sets the positive mod floor option.
925 *)
926
927 PROCEDURE SetPositiveModFloor (value: BOOLEAN) ;
928 BEGIN
929 PositiveModFloorDiv := value
930 END SetPositiveModFloor ;
931
932
933 (*
934 SetWholeDiv - sets the whole division flag.
935 *)
936
937 PROCEDURE SetWholeDiv (value: BOOLEAN) ;
938 BEGIN
939 WholeDivChecking := value
940 END SetWholeDiv ;
941
942
943 (*
944 SetIndex - sets the runtime array index checking flag.
945 *)
946
947 PROCEDURE SetIndex (value: BOOLEAN) ;
948 BEGIN
949 IndexChecking := value
950 END SetIndex ;
951
952
953 (*
954 SetRange - sets the runtime range checking flag.
955 *)
956
957 PROCEDURE SetRange (value: BOOLEAN) ;
958 BEGIN
959 RangeChecking := value
960 END SetRange ;
961
962
963 (*
964 SetExceptions - sets the enable runtime exceptions flag.
965 *)
966
967 PROCEDURE SetExceptions (value: BOOLEAN) ;
968 BEGIN
969 Exceptions := value
970 END SetExceptions ;
971
972
973 (*
974 SetStyle -
975 *)
976
977 PROCEDURE SetStyle (value: BOOLEAN) ;
978 BEGIN
979 StyleChecking := value
980 END SetStyle ;
981
982
983 (*
984 SetPedantic -
985 *)
986
987 PROCEDURE SetPedantic (value: BOOLEAN) ;
988 BEGIN
989 Pedantic := value
990 END SetPedantic ;
991
992
993 (*
994 SetPedanticParamNames - sets the pedantic parameter name flag.
995 *)
996
997 PROCEDURE SetPedanticParamNames (value: BOOLEAN) ;
998 BEGIN
999 PedanticParamNames := value
1000 END SetPedanticParamNames ;
1001
1002
1003 (*
1004 SetPedanticCast - sets the pedantic cast flag.
1005 *)
1006
1007 PROCEDURE SetPedanticCast (value: BOOLEAN) ;
1008 BEGIN
1009 PedanticCast := value
1010 END SetPedanticCast ;
1011
1012
1013 (*
1014 SetExtendedOpaque - sets the ExtendedOpaque flag.
1015 *)
1016
1017 PROCEDURE SetExtendedOpaque (value: BOOLEAN) ;
1018 BEGIN
1019 ExtendedOpaque := value
1020 END SetExtendedOpaque ;
1021
1022
1023 (*
1024 SetXCode - sets the xcode flag.
1025 *)
1026
1027 PROCEDURE SetXCode (value: BOOLEAN) ;
1028 BEGIN
1029 Xcode := value
1030 END SetXCode ;
1031
1032
1033 (*
1034 SetSwig -
1035 *)
1036
1037 PROCEDURE SetSwig (value: BOOLEAN) ;
1038 BEGIN
1039 GenerateSwig := value
1040 END SetSwig ;
1041
1042
1043 (*
1044 SetQuadDebugging - display the quadruples (internal debugging).
1045 *)
1046
1047 PROCEDURE SetQuadDebugging (value: BOOLEAN) ;
1048 BEGIN
1049 DisplayQuadruples := value
1050 END SetQuadDebugging ;
1051
1052
1053 (*
1054 SetCompilerDebugging - turn on internal compiler debugging.
1055 *)
1056
1057 PROCEDURE SetCompilerDebugging (value: BOOLEAN) ;
1058 BEGIN
1059 CompilerDebugging := value
1060 END SetCompilerDebugging ;
1061
1062
1063 (*
1064 SetDebugTraceQuad -
1065 *)
1066
1067 PROCEDURE SetDebugTraceQuad (value: BOOLEAN) ;
1068 BEGIN
1069 DebugTraceQuad := value
1070 END SetDebugTraceQuad ;
1071
1072
1073 (*
1074 SetDebugTraceAPI -
1075 *)
1076
1077 PROCEDURE SetDebugTraceAPI (value: BOOLEAN) ;
1078 BEGIN
1079 DebugTraceAPI := value
1080 END SetDebugTraceAPI ;
1081
1082
1083 (*
1084 SetSources -
1085 *)
1086
1087 PROCEDURE SetSources (value: BOOLEAN) ;
1088 BEGIN
1089 Quiet := NOT value ;
1090 SeenSources := value
1091 END SetSources ;
1092
1093
1094 (*
1095 SetDumpSystemExports -
1096 *)
1097
1098 PROCEDURE SetDumpSystemExports (value: BOOLEAN) ;
1099 BEGIN
1100 DumpSystemExports := value
1101 END SetDumpSystemExports ;
1102
1103
1104 (*
1105 SetSearchPath -
1106 *)
1107
1108 PROCEDURE SetSearchPath (arg: ADDRESS) ;
1109 VAR
1110 s: String ;
1111 BEGIN
1112 s := InitStringCharStar (arg) ;
1113 AddInclude (M2PathName, s) ;
1114 IF Debugging
1115 THEN
1116 DumpPathName ("path name entries: ")
1117 END ;
1118 s := KillString (s)
1119 END SetSearchPath ;
1120
1121
1122 (*
1123 setdefextension - set the source file definition module extension to arg.
1124 This should include the . and by default it is set to .def.
1125 *)
1126
1127 PROCEDURE setdefextension (arg: ADDRESS) ;
1128 VAR
1129 s: String ;
1130 BEGIN
1131 s := InitStringCharStar (arg) ;
1132 SetDefExtension (s) ;
1133 s := KillString (s)
1134 END setdefextension ;
1135
1136
1137 (*
1138 setmodextension - set the source file module extension to arg.
1139 This should include the . and by default it is set to .mod.
1140 *)
1141
1142 PROCEDURE setmodextension (arg: ADDRESS) ;
1143 VAR
1144 s: String ;
1145 BEGIN
1146 s := InitStringCharStar (arg) ;
1147 SetModExtension (s) ;
1148 s := KillString (s)
1149 END setmodextension ;
1150
1151
1152 (*
1153 SetOptimizing -
1154 *)
1155
1156 PROCEDURE SetOptimizing (value: CARDINAL) ;
1157 BEGIN
1158 IF value>0
1159 THEN
1160 Optimizing := TRUE ;
1161 OptimizeBasicBlock := TRUE ;
1162 OptimizeUncalledProcedures := TRUE ;
1163 OptimizeCommonSubExpressions := TRUE
1164 ELSE
1165 Optimizing := FALSE ;
1166 OptimizeBasicBlock := FALSE ;
1167 OptimizeUncalledProcedures := FALSE ;
1168 OptimizeCommonSubExpressions := FALSE
1169 END
1170 END SetOptimizing ;
1171
1172
1173 (*
1174 SetForcedLocation - sets the location for the lifetime of this compile to, location.
1175 This is primarily an internal debugging switch.
1176 *)
1177
1178 PROCEDURE SetForcedLocation (location: location_t) ;
1179 BEGIN
1180 ForcedLocation := TRUE ;
1181 ForcedLocationValue := location
1182 END SetForcedLocation ;
1183
1184
1185 (*
1186 SetCC1Quiet - sets the cc1quiet flag to, value.
1187 *)
1188
1189 PROCEDURE SetCC1Quiet (value: BOOLEAN) ;
1190 BEGIN
1191 CC1Quiet := value
1192 END SetCC1Quiet ;
1193
1194
1195 (*
1196 SetStatistics - turn on/off generate of compile time statistics.
1197 *)
1198
1199 PROCEDURE SetStatistics (on: BOOLEAN) ;
1200 BEGIN
1201 Statistics := on
1202 END SetStatistics ;
1203
1204
1205 (*
1206 OverrideLocation - possibly override the location value, depending upon
1207 whether the -flocation= option was used.
1208 *)
1209
1210 PROCEDURE OverrideLocation (location: location_t) : location_t ;
1211 BEGIN
1212 IF ForcedLocation
1213 THEN
1214 RETURN( ForcedLocationValue )
1215 ELSE
1216 RETURN( location )
1217 END
1218 END OverrideLocation ;
1219
1220
1221 (*
1222 SetDebugFunctionLineNumbers - turn DebugFunctionLineNumbers on/off
1223 (used internally for debugging).
1224 *)
1225
1226 PROCEDURE SetDebugFunctionLineNumbers (value: BOOLEAN) ;
1227 BEGIN
1228 DebugFunctionLineNumbers := value
1229 END SetDebugFunctionLineNumbers ;
1230
1231
1232 (*
1233 SetGenerateStatementNote - turn on generation of nops if necessary
1234 to generate pedalogical single stepping.
1235 *)
1236
1237 PROCEDURE SetGenerateStatementNote (value: BOOLEAN) ;
1238 BEGIN
1239 GenerateStatementNote := value
1240 END SetGenerateStatementNote ;
1241
1242
1243 (*
1244 GetISO - return TRUE if -fiso was present on the command line.
1245 *)
1246
1247 PROCEDURE GetISO () : BOOLEAN ;
1248 BEGIN
1249 RETURN Iso
1250 END GetISO ;
1251
1252
1253 (*
1254 GetPIM - return TRUE if -fpim was present on the command line.
1255 *)
1256
1257 PROCEDURE GetPIM () : BOOLEAN ;
1258 BEGIN
1259 RETURN Pim
1260 END GetPIM ;
1261
1262
1263 (*
1264 GetPIM2 - return TRUE if -fpim2 was present on the command line.
1265 *)
1266
1267 PROCEDURE GetPIM2 () : BOOLEAN ;
1268 BEGIN
1269 RETURN Pim2
1270 END GetPIM2 ;
1271
1272
1273 (*
1274 GetPIM3 - return TRUE if -fpim3 was present on the command line.
1275 *)
1276
1277 PROCEDURE GetPIM3 () : BOOLEAN ;
1278 BEGIN
1279 RETURN Pim3
1280 END GetPIM3 ;
1281
1282
1283 (*
1284 GetPIM4 - return TRUE if -fpim4 was present on the command line.
1285 *)
1286
1287 PROCEDURE GetPIM4 () : BOOLEAN ;
1288 BEGIN
1289 RETURN Pim4
1290 END GetPIM4 ;
1291
1292
1293 (*
1294 GetPositiveModFloor - return TRUE if -fpositive-mod-floor was present
1295 on the command line.
1296 *)
1297
1298 PROCEDURE GetPositiveModFloor () : BOOLEAN ;
1299 BEGIN
1300 RETURN PositiveModFloorDiv
1301 END GetPositiveModFloor ;
1302
1303
1304 (*
1305 GetFloatValueCheck - return TRUE if -ffloatvalue was present on the
1306 command line.
1307 *)
1308
1309 PROCEDURE GetFloatValueCheck () : BOOLEAN ;
1310 BEGIN
1311 RETURN FloatValueChecking
1312 END GetFloatValueCheck ;
1313
1314
1315 (*
1316 SetFloatValueCheck - set depending upon the -ffloatvalue.
1317 *)
1318
1319 PROCEDURE SetFloatValueCheck (value: BOOLEAN) ;
1320 BEGIN
1321 FloatValueChecking := value
1322 END SetFloatValueCheck ;
1323
1324
1325 (*
1326 GetWholeValueCheck - return TRUE if -fwholevalue was present on the
1327 command line.
1328 *)
1329
1330 PROCEDURE GetWholeValueCheck () : BOOLEAN ;
1331 BEGIN
1332 RETURN WholeValueChecking
1333 END GetWholeValueCheck ;
1334
1335
1336 (*
1337 SetWholeValueCheck - set depending upon the -fwholevalue.
1338 *)
1339
1340 PROCEDURE SetWholeValueCheck (value: BOOLEAN) ;
1341 BEGIN
1342 WholeValueChecking := value
1343 END SetWholeValueCheck ;
1344
1345
1346 (*
1347 SetWall - set all warnings to, value.
1348 *)
1349
1350 PROCEDURE SetWall (value: BOOLEAN) ;
1351 BEGIN
1352 UnusedVariableChecking := value ;
1353 UnusedParameterChecking := value ;
1354 UninitVariableChecking := value ;
1355 PedanticCast := value ;
1356 PedanticParamNames := value ;
1357 StyleChecking := value ;
1358 CaseEnumChecking := value
1359 END SetWall ;
1360
1361
1362 (*
1363 SetSaveTemps - turn on/off -save-temps.
1364 *)
1365
1366 PROCEDURE SetSaveTemps (value: BOOLEAN) ;
1367 BEGIN
1368 SaveTemps := value
1369 END SetSaveTemps ;
1370
1371
1372 (*
1373 SetSaveTempsDir - turn on/off -save-temps and specify the directory.
1374 *)
1375
1376 PROCEDURE SetSaveTempsDir (arg: ADDRESS) ;
1377 BEGIN
1378 SaveTempsDir := InitStringCharStar (arg) ;
1379 SaveTemps := TRUE
1380 END SetSaveTempsDir ;
1381
1382
1383 (*
1384 GetSaveTempsDir - return SaveTempsDir or NIL if -save-temps was not used.
1385 *)
1386
1387 PROCEDURE GetSaveTempsDir () : String ;
1388 BEGIN
1389 RETURN SaveTempsDir
1390 END GetSaveTempsDir ;
1391
1392
1393 (*
1394 SetDumpDir - Set the dump dir.
1395 *)
1396
1397 PROCEDURE SetDumpDir (arg: ADDRESS) ;
1398 BEGIN
1399 DumpDir := InitStringCharStar (arg)
1400 END SetDumpDir ;
1401
1402
1403 (*
1404 GetDumpDir - return DumpDir or NIL.
1405 *)
1406
1407 PROCEDURE GetDumpDir () : String ;
1408 BEGIN
1409 RETURN DumpDir
1410 END GetDumpDir ;
1411
1412 (*
1413 SetScaffoldDynamic - set the -fscaffold-dynamic flag.
1414 *)
1415
1416 PROCEDURE SetScaffoldDynamic (value: BOOLEAN) ;
1417 BEGIN
1418 ScaffoldDynamic := value ;
1419 IF ScaffoldDynamic
1420 THEN
1421 ScaffoldStatic := FALSE
1422 END
1423 END SetScaffoldDynamic ;
1424
1425
1426 (*
1427 SetScaffoldStatic - set the -fscaffold-static flag.
1428 *)
1429
1430 PROCEDURE SetScaffoldStatic (value: BOOLEAN) ;
1431 BEGIN
1432 ScaffoldStatic := value ;
1433 IF ScaffoldStatic
1434 THEN
1435 ScaffoldDynamic := FALSE
1436 END
1437 END SetScaffoldStatic ;
1438
1439
1440 (*
1441 GetScaffoldDynamic - get the -fscaffold-dynamic flag.
1442 *)
1443
1444 PROCEDURE GetScaffoldDynamic () : BOOLEAN ;
1445 BEGIN
1446 RETURN ScaffoldDynamic
1447 END GetScaffoldDynamic ;
1448
1449
1450 (*
1451 GetScaffoldStatic - get the -fscaffold-static flag.
1452 *)
1453
1454 PROCEDURE GetScaffoldStatic () : BOOLEAN ;
1455 BEGIN
1456 RETURN ScaffoldStatic
1457 END GetScaffoldStatic ;
1458
1459
1460 (*
1461 SetScaffoldMain - set the -fscaffold-main flag.
1462 *)
1463
1464 PROCEDURE SetScaffoldMain (value: BOOLEAN) ;
1465 BEGIN
1466 ScaffoldMain := value
1467 END SetScaffoldMain ;
1468
1469
1470 (*
1471 SetRuntimeModuleOverride - set the override sequence used for module
1472 initialization and finialization.
1473 *)
1474
1475 PROCEDURE SetRuntimeModuleOverride (override: ADDRESS) ;
1476 BEGIN
1477 RuntimeModuleOverride := KillString (RuntimeModuleOverride) ;
1478 RuntimeModuleOverride := InitStringCharStar (override)
1479 END SetRuntimeModuleOverride ;
1480
1481
1482 (*
1483 GetRuntimeModuleOverride - return a string containing any user override
1484 or the default module initialization override
1485 sequence.
1486 *)
1487
1488 PROCEDURE GetRuntimeModuleOverride () : ADDRESS ;
1489 BEGIN
1490 RETURN string (RuntimeModuleOverride)
1491 END GetRuntimeModuleOverride ;
1492
1493
1494 (*
1495 SetGenModuleList - set the GenModuleList flag to true and pass
1496 set GenModuleListFilename to filename.
1497 *)
1498
1499 PROCEDURE SetGenModuleList (value: BOOLEAN; filename: ADDRESS) ;
1500 BEGIN
1501 GenModuleListFilename := KillString (GenModuleListFilename) ;
1502 IF filename # NIL
1503 THEN
1504 GenModuleListFilename := InitStringCharStar (filename)
1505 END ;
1506 GenModuleList := value
1507 END SetGenModuleList ;
1508
1509
1510 (*
1511 GetGenModuleFilename - returns the filename set by SetGenModuleList.
1512 *)
1513
1514 PROCEDURE GetGenModuleFilename () : String ;
1515 BEGIN
1516 RETURN GenModuleListFilename
1517 END GetGenModuleFilename ;
1518
1519
1520 (*
1521 SetShared - sets the SharedFlag to value.
1522 *)
1523
1524 PROCEDURE SetShared (value: BOOLEAN) ;
1525 BEGIN
1526 SharedFlag := value
1527 END SetShared ;
1528
1529
1530 (*
1531 SetUninitVariableChecking - sets the UninitVariableChecking and
1532 UninitVariableConditionalChecking flags to value
1533 depending upon arg string. The arg string
1534 can be: "all", "known,cond", "cond,known", "known"
1535 or "cond".
1536 *)
1537
1538 PROCEDURE SetUninitVariableChecking (value: BOOLEAN; arg: ADDRESS) : INTEGER ;
1539 VAR
1540 s: String ;
1541 BEGIN
1542 IF Debugging
1543 THEN
1544 IF value
1545 THEN
1546 printf ("SetUninitVariableChecking (TRUE, %s)\n", arg)
1547 ELSE
1548 printf ("SetUninitVariableChecking (FALSE, %s)\n", arg)
1549 END
1550 END ;
1551 s := InitStringCharStar (arg) ;
1552 IF EqualArray (s, "all") OR
1553 EqualArray (s, "known,cond") OR
1554 EqualArray (s, "cond,known")
1555 THEN
1556 UninitVariableChecking := value ;
1557 UninitVariableConditionalChecking := value ;
1558 s := KillString (s) ;
1559 RETURN 1
1560 ELSIF EqualArray (s, "known")
1561 THEN
1562 UninitVariableChecking := value ;
1563 s := KillString (s) ;
1564 RETURN 1
1565 ELSIF EqualArray (s, "cond")
1566 THEN
1567 UninitVariableConditionalChecking := value ;
1568 s := KillString (s) ;
1569 RETURN 1
1570 ELSE
1571 s := KillString (s) ;
1572 RETURN 0
1573 END
1574 END SetUninitVariableChecking ;
1575
1576
1577 (*
1578 SetCaseEnumChecking - sets the CaseEnumChecking to value.
1579 *)
1580
1581 PROCEDURE SetCaseEnumChecking (value: BOOLEAN) ;
1582 BEGIN
1583 CaseEnumChecking := value
1584 END SetCaseEnumChecking ;
1585
1586
1587 (*
1588 SetDebugBuiltins - sets the DebugBuiltins to value.
1589 *)
1590
1591 PROCEDURE SetDebugBuiltins (value: BOOLEAN) ;
1592 BEGIN
1593 DebugBuiltins := value
1594 END SetDebugBuiltins ;
1595
1596
1597 BEGIN
1598 cflag := FALSE ; (* -c. *)
1599 RuntimeModuleOverride := InitString (DefaultRuntimeModuleOverride) ;
1600 CppArgs := InitString ('') ;
1601 Pim := TRUE ;
1602 Pim2 := FALSE ;
1603 Pim3 := FALSE ;
1604 Pim4 := TRUE ;
1605 PositiveModFloorDiv := FALSE ;
1606 Iso := FALSE ;
1607 SeenSources := FALSE ;
1608 Statistics := FALSE ;
1609 StyleChecking := FALSE ;
1610 CompilerDebugging := FALSE ;
1611 GenerateDebugging := FALSE ;
1612 Optimizing := FALSE ;
1613 Pedantic := FALSE ;
1614 Verbose := FALSE ;
1615 Quiet := TRUE ;
1616 CC1Quiet := TRUE ;
1617 Profiling := FALSE ;
1618 DisplayQuadruples := FALSE ;
1619 OptimizeBasicBlock := FALSE ;
1620 OptimizeUncalledProcedures := FALSE ;
1621 OptimizeCommonSubExpressions := FALSE ;
1622 NilChecking := FALSE ;
1623 WholeDivChecking := FALSE ;
1624 WholeValueChecking := FALSE ;
1625 FloatValueChecking := FALSE ;
1626 IndexChecking := FALSE ;
1627 RangeChecking := FALSE ;
1628 ReturnChecking := FALSE ;
1629 CaseElseChecking := FALSE ;
1630 CPreProcessor := FALSE ;
1631 LineDirectives := FALSE ;
1632 ExtendedOpaque := FALSE ;
1633 UnboundedByReference := FALSE ;
1634 VerboseUnbounded := FALSE ;
1635 PedanticParamNames := FALSE ;
1636 PedanticCast := FALSE ;
1637 Xcode := FALSE ;
1638 DumpSystemExports := FALSE ;
1639 GenerateSwig := FALSE ;
1640 Exceptions := TRUE ;
1641 DebugBuiltins := FALSE ;
1642 ForcedLocation := FALSE ;
1643 WholeProgram := FALSE ;
1644 DebugTraceQuad := FALSE ;
1645 DebugTraceAPI := FALSE ;
1646 DebugFunctionLineNumbers := FALSE ;
1647 GenerateStatementNote := FALSE ;
1648 LowerCaseKeywords := FALSE ;
1649 UnusedVariableChecking := FALSE ;
1650 UnusedParameterChecking := FALSE ;
1651 StrictTypeChecking := TRUE ;
1652 AutoInit := FALSE ;
1653 SaveTemps := FALSE ;
1654 ScaffoldDynamic := TRUE ;
1655 ScaffoldStatic := FALSE ;
1656 ScaffoldMain := FALSE ;
1657 UselistFilename := NIL ;
1658 GenModuleList := FALSE ;
1659 GenModuleListFilename := NIL ;
1660 SharedFlag := FALSE ;
1661 Barg := NIL ;
1662 MDFlag := FALSE ;
1663 MMDFlag := FALSE ;
1664 DepTarget := NIL ;
1665 MPFlag := FALSE ;
1666 SaveTempsDir := NIL ;
1667 DumpDir := NIL ;
1668 UninitVariableChecking := FALSE ;
1669 UninitVariableConditionalChecking := FALSE ;
1670 CaseEnumChecking := FALSE ;
1671 MFlag := FALSE ;
1672 MMFlag := FALSE ;
1673 MFarg := NIL ;
1674 MTFlag := NIL ;
1675 MQFlag := NIL ;
1676 M2Prefix := InitString ('') ;
1677 M2PathName := InitString ('')
1678 END M2Options.