libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / m2 / mc-boot / GmcOptions.cc
blob5a0606047092a46b3dbf6eaf62b7adc0355e469f
1 /* do not edit automatically generated by mc from mcOptions. */
2 /* This file is part of GNU Modula-2.
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
7 version.
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3. If not see
16 <http://www.gnu.org/licenses/>. */
18 #include "config.h"
19 #include "system.h"
20 #include <stdbool.h>
21 # if !defined (PROC_D)
22 # define PROC_D
23 typedef void (*PROC_t) (void);
24 typedef struct { PROC_t proc; } PROC;
25 # endif
27 # if !defined (TRUE)
28 # define TRUE (1==1)
29 # endif
31 # if !defined (FALSE)
32 # define FALSE (1==0)
33 # endif
35 #if defined(__cplusplus)
36 # undef NULL
37 # define NULL 0
38 #endif
39 #define _mcOptions_C
41 #include "GmcOptions.h"
42 # include "GSArgs.h"
43 # include "GmcSearch.h"
44 # include "Glibc.h"
45 # include "GmcPrintf.h"
46 # include "GDebug.h"
47 # include "GStrLib.h"
48 # include "Gdecl.h"
49 # include "GDynamicStrings.h"
50 # include "GFIO.h"
51 # include "GSFIO.h"
53 static bool langC;
54 static bool langCPP;
55 static bool langM2;
56 static bool gplHeader;
57 static bool glplHeader;
58 static bool summary;
59 static bool contributed;
60 static bool scaffoldMain;
61 static bool scaffoldDynamic;
62 static bool caseRuntime;
63 static bool arrayRuntime;
64 static bool returnRuntime;
65 static bool suppressNoReturn;
66 static bool useBoolType;
67 static bool gccConfigSystem;
68 static bool ignoreFQ;
69 static bool debugTopological;
70 static bool extendedOpaque;
71 static bool internalDebugging;
72 static bool verbose;
73 static bool quiet;
74 static DynamicStrings_String CReal;
75 static DynamicStrings_String CLongReal;
76 static DynamicStrings_String CShortReal;
77 static DynamicStrings_String projectContents;
78 static DynamicStrings_String summaryContents;
79 static DynamicStrings_String contributedContents;
80 static DynamicStrings_String hPrefix;
81 static DynamicStrings_String outputFile;
82 static DynamicStrings_String cppArgs;
83 static DynamicStrings_String cppProgram;
86 handleOptions - iterates over all options setting appropriate
87 values and returns the single source file
88 if found at the end of the arguments.
91 extern "C" DynamicStrings_String mcOptions_handleOptions (void);
94 getQuiet - return the value of quiet.
97 extern "C" bool mcOptions_getQuiet (void);
100 getVerbose - return the value of verbose.
103 extern "C" bool mcOptions_getVerbose (void);
106 getInternalDebugging - return the value of internalDebugging.
109 extern "C" bool mcOptions_getInternalDebugging (void);
112 getCppCommandLine - returns the Cpp command line and all arguments.
115 extern "C" DynamicStrings_String mcOptions_getCppCommandLine (void);
118 getOutputFile - sets the output filename to output.
121 extern "C" DynamicStrings_String mcOptions_getOutputFile (void);
124 getExtendedOpaque - return the extendedOpaque value.
127 extern "C" bool mcOptions_getExtendedOpaque (void);
130 setDebugTopological - sets the flag debugTopological to value.
133 extern "C" void mcOptions_setDebugTopological (bool value);
136 getDebugTopological - returns the flag value of the command
137 line option --debug-top.
140 extern "C" bool mcOptions_getDebugTopological (void);
143 getHPrefix - saves the H file prefix.
146 extern "C" DynamicStrings_String mcOptions_getHPrefix (void);
149 getIgnoreFQ - returns the ignorefq flag.
152 extern "C" bool mcOptions_getIgnoreFQ (void);
155 getGccConfigSystem - return the value of the gccConfigSystem flag.
158 extern "C" bool mcOptions_getGccConfigSystem (void);
161 getScaffoldDynamic - return true if the --scaffold-dynamic option was present.
164 extern "C" bool mcOptions_getScaffoldDynamic (void);
167 getScaffoldMain - return true if the --scaffold-main option was present.
170 extern "C" bool mcOptions_getScaffoldMain (void);
173 writeGPLheader - writes out the GPL or the LGPL as a comment.
176 extern "C" void mcOptions_writeGPLheader (FIO_File f);
179 setSuppressNoReturn - set suppressNoReturn to value.
182 extern "C" void mcOptions_setSuppressNoReturn (bool value);
185 getSuppressNoReturn - return the suppressNoReturn value.
188 extern "C" bool mcOptions_getSuppressNoReturn (void);
191 useBool - should mc use the bool type instead of int.
194 extern "C" bool mcOptions_useBool (void);
197 getCRealType - returns the string representing the REAL type
198 used by C. By default this is "double".
201 extern "C" DynamicStrings_String mcOptions_getCRealType (void);
204 getCLongRealType - returns the string representing the REAL type
205 used by C. By default this is "long double".
208 extern "C" DynamicStrings_String mcOptions_getCLongRealType (void);
211 getCShortRealType - returns the string representing the REAL type
212 used by C. By default this is "float".
215 extern "C" DynamicStrings_String mcOptions_getCShortRealType (void);
218 getYear - return the year.
221 static unsigned int getYear (void);
224 displayVersion - displays the version of the compiler.
227 static void displayVersion (bool mustExit);
230 displayHelp - display the mc help summary.
233 static void displayHelp (void);
236 commentBegin - issue a start of comment for the appropriate language.
239 static void commentBegin (FIO_File f);
242 commentEnd - issue an end of comment for the appropriate language.
245 static void commentEnd (FIO_File f);
248 comment - write a comment to file, f, and also a newline.
251 static void comment (FIO_File f, const char *a_, unsigned int _a_high);
254 commentS - write a comment to file, f, and also a newline.
257 static void commentS (FIO_File f, DynamicStrings_String s);
260 gplBody -
263 static void gplBody (FIO_File f);
266 glplBody -
269 static void glplBody (FIO_File f);
272 issueGPL - writes out the summary, GPL/LGPL and/or contributed as a single comment.
275 static void issueGPL (FIO_File f);
278 setOutputFile - sets the output filename to output.
281 static void setOutputFile (DynamicStrings_String output);
284 setQuiet - sets the quiet flag to, value.
287 static void setQuiet (bool value);
290 setVerbose - sets the verbose flag to, value.
293 static void setVerbose (bool value);
296 setExtendedOpaque - set extendedOpaque to value.
299 static void setExtendedOpaque (bool value);
302 setSearchPath - set the search path for the module sources.
305 static void setSearchPath (DynamicStrings_String arg);
308 setInternalDebugging - turn on/off internal debugging.
311 static void setInternalDebugging (bool value);
314 setHPrefix - saves the H file prefix.
317 static void setHPrefix (DynamicStrings_String s);
320 setIgnoreFQ - sets the ignorefq flag.
323 static void setIgnoreFQ (bool value);
326 toCType - returns a new string which has all occurences of '-'
327 replaced by ' '.
330 static DynamicStrings_String toCType (DynamicStrings_String namedType);
333 setCReal - assigns CReal to namedType after it has been transformed by
334 toCType.
337 static void setCReal (DynamicStrings_String namedType);
340 setCShortReal - assigns CShortReal to namedType after it has been
341 transformed by toCType.
344 static void setCShortReal (DynamicStrings_String namedType);
347 setCLongReal - assigns CLongReal to namedType after it has been
348 transformed by toCType.
351 static void setCLongReal (DynamicStrings_String namedType);
354 optionIs - returns TRUE if the first len (right) characters
355 match left.
358 static bool optionIs (const char *left_, unsigned int _left_high, DynamicStrings_String right);
361 setLang - set the appropriate output language.
364 static void setLang (DynamicStrings_String arg);
367 handleOption -
370 static void handleOption (DynamicStrings_String arg);
374 getYear - return the year.
377 static unsigned int getYear (void)
379 libc_time_t epoch;
380 libc_ptrToTM localTime;
382 epoch = libc_time (NULL);
383 localTime = static_cast<libc_ptrToTM> (libc_localtime (&epoch));
384 return localTime->tm_year+1900;
385 /* static analysis guarentees a RETURN statement will be used before here. */
386 __builtin_unreachable ();
391 displayVersion - displays the version of the compiler.
394 static void displayVersion (bool mustExit)
396 unsigned int year;
398 year = getYear ();
399 /* These first three calls to printf hide the first line of text away from the year change script. */
400 mcPrintf_printf0 ((const char *) "Copyright ", 10);
401 mcPrintf_printf0 ((const char *) "(C)", 3); /* A unicode char here would be good. */
402 mcPrintf_printf1 ((const char *) " %d Free Software Foundation, Inc.\\n", 36, (const unsigned char *) &year, (sizeof (year)-1)); /* A unicode char here would be good. */
403 mcPrintf_printf0 ((const char *) "License GPLv3: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\\n", 78);
404 mcPrintf_printf0 ((const char *) "This is free software: you are free to change and redistribute it.\\n", 68);
405 mcPrintf_printf0 ((const char *) "There is NO WARRANTY, to the extent permitted by law.\\n", 55);
406 if (mustExit)
408 libc_exit (0);
414 displayHelp - display the mc help summary.
417 static void displayHelp (void)
419 mcPrintf_printf0 ((const char *) "usage: mc [--cpp] [-g] [--quiet] [--extended-opaque] [-q] [-v]", 62);
420 mcPrintf_printf0 ((const char *) " [--verbose] [--version] [--help] [-h] [-Ipath] [--olang=c]", 59);
421 mcPrintf_printf0 ((const char *) " [--olang=c++] [--olang=m2] [--debug-top]", 41);
422 mcPrintf_printf0 ((const char *) " [--gpl-header] [--glpl-header] [--summary=\"foo\"]", 49);
423 mcPrintf_printf0 ((const char *) " [--contributed=\"foo\"] [--project=\"foo\"]", 40);
424 mcPrintf_printf0 ((const char *) " [--h-file-prefix=foo] [--automatic] [-o=foo] filename\\n", 56);
425 mcPrintf_printf0 ((const char *) " --cpp preprocess through the C preprocessor\\n", 61);
426 mcPrintf_printf0 ((const char *) " -g emit debugging directives in the output language", 70);
427 mcPrintf_printf0 ((const char *) " so that the debugger will refer to the source\\n", 69);
428 mcPrintf_printf0 ((const char *) " -q --quiet no output unless an error occurs\\n", 56);
429 mcPrintf_printf0 ((const char *) " -v --verbose display preprocessor if invoked\\n", 55);
430 mcPrintf_printf0 ((const char *) " --version display version and exit\\n", 48);
431 mcPrintf_printf0 ((const char *) " -h --help display this help message\\n", 49);
432 mcPrintf_printf0 ((const char *) " -Ipath set the module search path\\n", 50);
433 mcPrintf_printf0 ((const char *) " --olang=c generate ansi C output\\n", 46);
434 mcPrintf_printf0 ((const char *) " --olang=c++ generate ansi C++ output\\n", 48);
435 mcPrintf_printf0 ((const char *) " --olang=m2 generate PIM4 output\\n", 44);
436 mcPrintf_printf0 ((const char *) " --extended-opaque parse definition and implementation modules to\\n", 70);
437 mcPrintf_printf0 ((const char *) " generate full type debugging of opaque types\\n", 68);
438 mcPrintf_printf0 ((const char *) " --debug-top debug topological data structure resolving (internal)\\n", 77);
439 mcPrintf_printf0 ((const char *) " --h-file-prefix=foo set the h file prefix to foo\\n", 52);
440 mcPrintf_printf0 ((const char *) " -o=foo set the output file to foo\\n", 50);
441 mcPrintf_printf0 ((const char *) " --ignore-fq do not generate fully qualified idents\\n", 62);
442 mcPrintf_printf0 ((const char *) " --gcc-config-system do not use standard host include files, use gcc config and system instead\\n", 97);
443 mcPrintf_printf0 ((const char *) " --gpl-header generate a GPL3 header comment at the top of the file\\n", 77);
444 mcPrintf_printf0 ((const char *) " --glpl-header generate a GLPL3 header comment at the top of the file\\n", 78);
445 mcPrintf_printf0 ((const char *) " --summary=\"foo\" generate a one line summary comment at the top of the file\\n", 82);
446 mcPrintf_printf0 ((const char *) " --contributed=\"foo\" generate a one line contribution comment near the top of the file\\n", 89);
447 mcPrintf_printf0 ((const char *) " --project=\"foo\" include the project name within the GPL3 or GLPL3 header\\n", 80);
448 mcPrintf_printf0 ((const char *) " --automatic generate a comment at the start of the file warning not to edit as it was automatically generated\\n", 121);
449 mcPrintf_printf0 ((const char *) " --scaffold-dynamic generate dynamic module initialization code for C++\\n", 75);
450 mcPrintf_printf0 ((const char *) " --scaffold-main generate main function which calls upon the dynamic initialization support in M2RTS\\n", 107);
451 mcPrintf_printf0 ((const char *) " --suppress-noreturn suppress the emission of any attribute noreturn\\n", 71);
452 mcPrintf_printf0 ((const char *) " filename the source file must be the last option\\n", 63);
453 libc_exit (0);
458 commentBegin - issue a start of comment for the appropriate language.
461 static void commentBegin (FIO_File f)
463 if (langC || langCPP)
465 FIO_WriteString (f, (const char *) "/* ", 3);
467 else if (langM2)
469 /* avoid dangling else. */
470 FIO_WriteString (f, (const char *) "(* ", 3);
476 commentEnd - issue an end of comment for the appropriate language.
479 static void commentEnd (FIO_File f)
481 if (langC || langCPP)
483 FIO_WriteString (f, (const char *) " */", 3);
484 FIO_WriteLine (f);
486 else if (langM2)
488 /* avoid dangling else. */
489 FIO_WriteString (f, (const char *) " *)", 3);
490 FIO_WriteLine (f);
496 comment - write a comment to file, f, and also a newline.
499 static void comment (FIO_File f, const char *a_, unsigned int _a_high)
501 char a[_a_high+1];
503 /* make a local copy of each unbounded array. */
504 memcpy (a, a_, _a_high+1);
506 FIO_WriteString (f, (const char *) a, _a_high);
507 FIO_WriteLine (f);
512 commentS - write a comment to file, f, and also a newline.
515 static void commentS (FIO_File f, DynamicStrings_String s)
517 s = SFIO_WriteS (f, s);
518 FIO_WriteLine (f);
523 gplBody -
526 static void gplBody (FIO_File f)
528 unsigned int year;
530 year = getYear ();
531 mcPrintf_printf1 ((const char *) "Copyright (C) %d Free Software Foundation, Inc.\\n", 49, (const unsigned char *) &year, (sizeof (year)-1));
532 if (contributed)
534 FIO_WriteString (f, (const char *) "Contributed by ", 15);
535 contributedContents = SFIO_WriteS (f, contributedContents);
536 FIO_WriteString (f, (const char *) ".", 1);
537 FIO_WriteLine (f);
539 FIO_WriteLine (f);
540 FIO_WriteString (f, (const char *) "This file is part of ", 21);
541 projectContents = SFIO_WriteS (f, projectContents);
542 FIO_WriteString (f, (const char *) ".", 1);
543 FIO_WriteLine (f);
544 FIO_WriteLine (f);
545 projectContents = SFIO_WriteS (f, projectContents);
546 comment (f, (const char *) " is software; you can redistribute it and/or modify", 51);
547 comment (f, (const char *) "it under the terms of the GNU General Public License as published by", 68);
548 comment (f, (const char *) "the Free Software Foundation; either version 3, or (at your option)", 67);
549 comment (f, (const char *) "any later version.", 18);
550 FIO_WriteLine (f);
551 projectContents = SFIO_WriteS (f, projectContents);
552 comment (f, (const char *) " is distributed in the hope that it will be useful, but", 55);
553 comment (f, (const char *) "WITHOUT ANY WARRANTY; without even the implied warranty of", 58);
554 comment (f, (const char *) "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU", 65);
555 comment (f, (const char *) "General Public License for more details.", 40);
556 FIO_WriteLine (f);
557 comment (f, (const char *) "You should have received a copy of the GNU General Public License", 65);
558 FIO_WriteString (f, (const char *) "along with ", 11);
559 projectContents = SFIO_WriteS (f, projectContents);
560 comment (f, (const char *) "; see the file COPYING. If not,", 32);
561 FIO_WriteString (f, (const char *) "see <https://www.gnu.org/licenses/>. ", 37);
566 glplBody -
569 static void glplBody (FIO_File f)
571 unsigned int year;
573 year = getYear ();
574 mcPrintf_printf1 ((const char *) "Copyright (C) %d Free Software Foundation, Inc.\\n", 49, (const unsigned char *) &year, (sizeof (year)-1));
575 if (contributed)
577 FIO_WriteString (f, (const char *) "Contributed by ", 15);
578 contributedContents = SFIO_WriteS (f, contributedContents);
579 FIO_WriteString (f, (const char *) ".", 1);
580 FIO_WriteLine (f);
582 FIO_WriteLine (f);
583 FIO_WriteString (f, (const char *) "This file is part of ", 21);
584 projectContents = SFIO_WriteS (f, projectContents);
585 FIO_WriteString (f, (const char *) ".", 1);
586 FIO_WriteLine (f);
587 FIO_WriteLine (f);
588 projectContents = SFIO_WriteS (f, projectContents);
589 comment (f, (const char *) " is free software; you can redistribute it and/or modify", 56);
590 comment (f, (const char *) "it under the terms of the GNU General Public License as published by", 68);
591 comment (f, (const char *) "the Free Software Foundation; either version 3, or (at your option)", 67);
592 comment (f, (const char *) "any later version.", 18);
593 FIO_WriteLine (f);
594 projectContents = SFIO_WriteS (f, projectContents);
595 comment (f, (const char *) " is software; you can redistribute it and/or modify", 51);
596 comment (f, (const char *) "it under the terms of the GNU Lesser General Public License", 59);
597 comment (f, (const char *) "as published by the Free Software Foundation; either version 3,", 63);
598 comment (f, (const char *) "or (at your option) any later version.", 38);
599 FIO_WriteLine (f);
600 projectContents = SFIO_WriteS (f, projectContents);
601 comment (f, (const char *) " is distributed in the hope that it will be useful, but", 55);
602 comment (f, (const char *) "WITHOUT ANY WARRANTY; without even the implied warranty of", 58);
603 comment (f, (const char *) "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU", 65);
604 comment (f, (const char *) "General Public License for more details.", 40);
605 FIO_WriteLine (f);
606 comment (f, (const char *) "You should have received a copy of the GNU General Public License", 65);
607 FIO_WriteString (f, (const char *) "along with ", 11);
608 projectContents = SFIO_WriteS (f, projectContents);
609 comment (f, (const char *) "; see the file COPYING3. If not see", 36);
610 comment (f, (const char *) "<http://www.gnu.org/licenses/>.", 31);
611 FIO_WriteLine (f);
612 comment (f, (const char *) "You should have received a copy of the GNU Lesser General Public License", 72);
613 FIO_WriteString (f, (const char *) "along with ", 11);
614 projectContents = SFIO_WriteS (f, projectContents);
615 comment (f, (const char *) "; see the file COPYING. If not,", 32);
616 FIO_WriteString (f, (const char *) "see <https://www.gnu.org/licenses/>. ", 37);
621 issueGPL - writes out the summary, GPL/LGPL and/or contributed as a single comment.
624 static void issueGPL (FIO_File f)
626 if (((summary || contributed) || gplHeader) || glplHeader)
628 commentBegin (f);
629 if (summary)
631 commentS (f, summaryContents);
632 FIO_WriteLine (f);
634 if (gplHeader)
636 gplBody (f);
638 if (glplHeader)
640 glplBody (f);
642 commentEnd (f);
643 FIO_WriteLine (f);
649 setOutputFile - sets the output filename to output.
652 static void setOutputFile (DynamicStrings_String output)
654 outputFile = output;
659 setQuiet - sets the quiet flag to, value.
662 static void setQuiet (bool value)
664 quiet = value;
669 setVerbose - sets the verbose flag to, value.
672 static void setVerbose (bool value)
674 verbose = value;
679 setExtendedOpaque - set extendedOpaque to value.
682 static void setExtendedOpaque (bool value)
684 extendedOpaque = value;
689 setSearchPath - set the search path for the module sources.
692 static void setSearchPath (DynamicStrings_String arg)
694 mcSearch_prependSearchPath (arg);
699 setInternalDebugging - turn on/off internal debugging.
702 static void setInternalDebugging (bool value)
704 internalDebugging = value;
709 setHPrefix - saves the H file prefix.
712 static void setHPrefix (DynamicStrings_String s)
714 hPrefix = s;
719 setIgnoreFQ - sets the ignorefq flag.
722 static void setIgnoreFQ (bool value)
724 ignoreFQ = value;
729 toCType - returns a new string which has all occurences of '-'
730 replaced by ' '.
733 static DynamicStrings_String toCType (DynamicStrings_String namedType)
735 return DynamicStrings_ReplaceChar (DynamicStrings_Dup (namedType), '-', ' ');
736 /* static analysis guarentees a RETURN statement will be used before here. */
737 __builtin_unreachable ();
742 setCReal - assigns CReal to namedType after it has been transformed by
743 toCType.
746 static void setCReal (DynamicStrings_String namedType)
748 CReal = toCType (namedType);
753 setCShortReal - assigns CShortReal to namedType after it has been
754 transformed by toCType.
757 static void setCShortReal (DynamicStrings_String namedType)
759 CShortReal = toCType (namedType);
764 setCLongReal - assigns CLongReal to namedType after it has been
765 transformed by toCType.
768 static void setCLongReal (DynamicStrings_String namedType)
770 CLongReal = toCType (namedType);
775 optionIs - returns TRUE if the first len (right) characters
776 match left.
779 static bool optionIs (const char *left_, unsigned int _left_high, DynamicStrings_String right)
781 DynamicStrings_String s;
782 char left[_left_high+1];
784 /* make a local copy of each unbounded array. */
785 memcpy (left, left_, _left_high+1);
787 if ((DynamicStrings_Length (right)) == (StrLib_StrLen ((const char *) left, _left_high)))
789 return DynamicStrings_EqualArray (right, (const char *) left, _left_high);
791 else if ((DynamicStrings_Length (right)) > (StrLib_StrLen ((const char *) left, _left_high)))
793 /* avoid dangling else. */
794 s = DynamicStrings_Mark (DynamicStrings_Slice (right, 0, static_cast<int> (StrLib_StrLen ((const char *) left, _left_high))));
795 return DynamicStrings_EqualArray (s, (const char *) left, _left_high);
797 else
799 /* avoid dangling else. */
800 return false;
802 /* static analysis guarentees a RETURN statement will be used before here. */
803 __builtin_unreachable ();
808 setLang - set the appropriate output language.
811 static void setLang (DynamicStrings_String arg)
813 /* must check the longest distinctive string first. */
814 if (optionIs ((const char *) "c++", 3, arg))
816 decl_setLangCP ();
817 langCPP = true;
819 else if (optionIs ((const char *) "c", 1, arg))
821 /* avoid dangling else. */
822 decl_setLangC ();
823 langC = true;
825 else if (optionIs ((const char *) "m2", 2, arg))
827 /* avoid dangling else. */
828 decl_setLangM2 ();
829 langM2 = true;
831 else
833 /* avoid dangling else. */
834 displayHelp ();
840 handleOption -
843 static void handleOption (DynamicStrings_String arg)
845 if ((optionIs ((const char *) "--quiet", 7, arg)) || (optionIs ((const char *) "-q", 2, arg)))
847 setQuiet (true);
849 else if ((optionIs ((const char *) "--verbose", 9, arg)) || (optionIs ((const char *) "-v", 2, arg)))
851 /* avoid dangling else. */
852 setVerbose (true);
854 else if (optionIs ((const char *) "--version", 9, arg))
856 /* avoid dangling else. */
857 displayVersion (true);
859 else if (optionIs ((const char *) "--olang=", 8, arg))
861 /* avoid dangling else. */
862 setLang (DynamicStrings_Slice (arg, 8, 0));
864 else if (optionIs ((const char *) "-I", 2, arg))
866 /* avoid dangling else. */
867 setSearchPath (DynamicStrings_Slice (arg, 2, 0));
869 else if ((optionIs ((const char *) "--help", 6, arg)) || (optionIs ((const char *) "-h", 2, arg)))
871 /* avoid dangling else. */
872 displayHelp ();
874 else if (optionIs ((const char *) "--cpp", 5, arg))
876 /* avoid dangling else. */
877 cppProgram = DynamicStrings_InitString ((const char *) "cpp", 3);
879 else if (optionIs ((const char *) "-o=", 3, arg))
881 /* avoid dangling else. */
882 setOutputFile (DynamicStrings_Slice (arg, 3, 0));
884 else if (optionIs ((const char *) "--extended-opaque", 17, arg))
886 /* avoid dangling else. */
887 /* setExtendedOpaque (TRUE) */
888 mcPrintf_printf0 ((const char *) "IGNORING --extended-opaque - this option is no longer implemented - please adjust the call to mc\\n", 98);
890 else if (optionIs ((const char *) "--debug-top", 11, arg))
892 /* avoid dangling else. */
893 mcOptions_setDebugTopological (true);
895 else if (optionIs ((const char *) "--h-file-prefix=", 16, arg))
897 /* avoid dangling else. */
898 setHPrefix (DynamicStrings_Slice (arg, 16, 0));
900 else if (optionIs ((const char *) "--ignore-fq", 11, arg))
902 /* avoid dangling else. */
903 setIgnoreFQ (true);
905 else if (optionIs ((const char *) "--gpl-header", 12, arg))
907 /* avoid dangling else. */
908 gplHeader = true;
910 else if (optionIs ((const char *) "--glpl-header", 13, arg))
912 /* avoid dangling else. */
913 glplHeader = true;
915 else if (optionIs ((const char *) "--summary=\"", 11, arg))
917 /* avoid dangling else. */
918 summary = true;
919 summaryContents = DynamicStrings_Slice (arg, 11, -1);
921 else if (optionIs ((const char *) "--contributed=\"", 15, arg))
923 /* avoid dangling else. */
924 contributed = true;
925 contributedContents = DynamicStrings_Slice (arg, 13, -1);
927 else if (optionIs ((const char *) "--project=\"", 11, arg))
929 /* avoid dangling else. */
930 projectContents = DynamicStrings_Slice (arg, 10, -1);
932 else if (optionIs ((const char *) "--gcc-config-system", 19, arg))
934 /* avoid dangling else. */
935 gccConfigSystem = true;
937 else if (optionIs ((const char *) "--scaffold-main", 15, arg))
939 /* avoid dangling else. */
940 scaffoldMain = true;
942 else if (optionIs ((const char *) "--scaffold-dynamic", 18, arg))
944 /* avoid dangling else. */
945 scaffoldDynamic = true;
947 else if (optionIs ((const char *) "--suppress-noreturn", 19, arg))
949 /* avoid dangling else. */
950 suppressNoReturn = true;
952 else if (optionIs ((const char *) "--real=", 7, arg))
954 /* avoid dangling else. */
955 setCReal (DynamicStrings_Slice (arg, 7, 0));
957 else if (optionIs ((const char *) "--longreal=", 11, arg))
959 /* avoid dangling else. */
960 setCLongReal (DynamicStrings_Slice (arg, 11, 0));
962 else if (optionIs ((const char *) "--shortreal=", 12, arg))
964 /* avoid dangling else. */
965 setCShortReal (DynamicStrings_Slice (arg, 12, 0));
971 handleOptions - iterates over all options setting appropriate
972 values and returns the single source file
973 if found at the end of the arguments.
976 extern "C" DynamicStrings_String mcOptions_handleOptions (void)
978 unsigned int i;
979 DynamicStrings_String arg;
981 i = 1;
982 while (SArgs_GetArg (&arg, i))
984 if ((DynamicStrings_Length (arg)) > 0)
986 /* avoid gcc warning by using compound statement even if not strictly necessary. */
987 if ((DynamicStrings_char (arg, 0)) == '-')
989 handleOption (arg);
991 else
993 if (! summary)
995 summaryContents = DynamicStrings_ConCatChar (DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "automatically created by mc from ", 33), arg), '.');
996 summary = false;
998 return arg;
1001 i += 1;
1003 return static_cast<DynamicStrings_String> (NULL);
1004 /* static analysis guarentees a RETURN statement will be used before here. */
1005 __builtin_unreachable ();
1010 getQuiet - return the value of quiet.
1013 extern "C" bool mcOptions_getQuiet (void)
1015 return quiet;
1016 /* static analysis guarentees a RETURN statement will be used before here. */
1017 __builtin_unreachable ();
1022 getVerbose - return the value of verbose.
1025 extern "C" bool mcOptions_getVerbose (void)
1027 return verbose;
1028 /* static analysis guarentees a RETURN statement will be used before here. */
1029 __builtin_unreachable ();
1034 getInternalDebugging - return the value of internalDebugging.
1037 extern "C" bool mcOptions_getInternalDebugging (void)
1039 return internalDebugging;
1040 /* static analysis guarentees a RETURN statement will be used before here. */
1041 __builtin_unreachable ();
1046 getCppCommandLine - returns the Cpp command line and all arguments.
1049 extern "C" DynamicStrings_String mcOptions_getCppCommandLine (void)
1051 DynamicStrings_String s;
1053 if (DynamicStrings_EqualArray (cppProgram, (const char *) "", 0))
1055 return static_cast<DynamicStrings_String> (NULL);
1057 else
1059 s = DynamicStrings_Dup (cppProgram);
1060 s = DynamicStrings_ConCat (DynamicStrings_ConCatChar (s, ' '), cppArgs);
1061 if (mcOptions_getQuiet ())
1063 s = DynamicStrings_ConCat (DynamicStrings_ConCatChar (s, ' '), DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "-quiet", 6)));
1065 return s;
1067 /* static analysis guarentees a RETURN statement will be used before here. */
1068 __builtin_unreachable ();
1073 getOutputFile - sets the output filename to output.
1076 extern "C" DynamicStrings_String mcOptions_getOutputFile (void)
1078 return outputFile;
1079 /* static analysis guarentees a RETURN statement will be used before here. */
1080 __builtin_unreachable ();
1085 getExtendedOpaque - return the extendedOpaque value.
1088 extern "C" bool mcOptions_getExtendedOpaque (void)
1090 return extendedOpaque;
1091 /* static analysis guarentees a RETURN statement will be used before here. */
1092 __builtin_unreachable ();
1097 setDebugTopological - sets the flag debugTopological to value.
1100 extern "C" void mcOptions_setDebugTopological (bool value)
1102 debugTopological = value;
1107 getDebugTopological - returns the flag value of the command
1108 line option --debug-top.
1111 extern "C" bool mcOptions_getDebugTopological (void)
1113 return debugTopological;
1114 /* static analysis guarentees a RETURN statement will be used before here. */
1115 __builtin_unreachable ();
1120 getHPrefix - saves the H file prefix.
1123 extern "C" DynamicStrings_String mcOptions_getHPrefix (void)
1125 return hPrefix;
1126 /* static analysis guarentees a RETURN statement will be used before here. */
1127 __builtin_unreachable ();
1132 getIgnoreFQ - returns the ignorefq flag.
1135 extern "C" bool mcOptions_getIgnoreFQ (void)
1137 return ignoreFQ;
1138 /* static analysis guarentees a RETURN statement will be used before here. */
1139 __builtin_unreachable ();
1144 getGccConfigSystem - return the value of the gccConfigSystem flag.
1147 extern "C" bool mcOptions_getGccConfigSystem (void)
1149 return gccConfigSystem;
1150 /* static analysis guarentees a RETURN statement will be used before here. */
1151 __builtin_unreachable ();
1156 getScaffoldDynamic - return true if the --scaffold-dynamic option was present.
1159 extern "C" bool mcOptions_getScaffoldDynamic (void)
1161 return scaffoldDynamic;
1162 /* static analysis guarentees a RETURN statement will be used before here. */
1163 __builtin_unreachable ();
1168 getScaffoldMain - return true if the --scaffold-main option was present.
1171 extern "C" bool mcOptions_getScaffoldMain (void)
1173 return scaffoldMain;
1174 /* static analysis guarentees a RETURN statement will be used before here. */
1175 __builtin_unreachable ();
1180 writeGPLheader - writes out the GPL or the LGPL as a comment.
1183 extern "C" void mcOptions_writeGPLheader (FIO_File f)
1185 issueGPL (f);
1190 setSuppressNoReturn - set suppressNoReturn to value.
1193 extern "C" void mcOptions_setSuppressNoReturn (bool value)
1195 suppressNoReturn = value;
1200 getSuppressNoReturn - return the suppressNoReturn value.
1203 extern "C" bool mcOptions_getSuppressNoReturn (void)
1205 return suppressNoReturn;
1206 /* static analysis guarentees a RETURN statement will be used before here. */
1207 __builtin_unreachable ();
1212 useBool - should mc use the bool type instead of int.
1215 extern "C" bool mcOptions_useBool (void)
1217 return useBoolType;
1218 /* static analysis guarentees a RETURN statement will be used before here. */
1219 __builtin_unreachable ();
1224 getCRealType - returns the string representing the REAL type
1225 used by C. By default this is "double".
1228 extern "C" DynamicStrings_String mcOptions_getCRealType (void)
1230 return CReal;
1231 /* static analysis guarentees a RETURN statement will be used before here. */
1232 __builtin_unreachable ();
1237 getCLongRealType - returns the string representing the REAL type
1238 used by C. By default this is "long double".
1241 extern "C" DynamicStrings_String mcOptions_getCLongRealType (void)
1243 return CLongReal;
1244 /* static analysis guarentees a RETURN statement will be used before here. */
1245 __builtin_unreachable ();
1250 getCShortRealType - returns the string representing the REAL type
1251 used by C. By default this is "float".
1254 extern "C" DynamicStrings_String mcOptions_getCShortRealType (void)
1256 return CShortReal;
1257 /* static analysis guarentees a RETURN statement will be used before here. */
1258 __builtin_unreachable ();
1261 extern "C" void _M2_mcOptions_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
1263 langC = true;
1264 langCPP = false;
1265 langM2 = false;
1266 gplHeader = false;
1267 glplHeader = false;
1268 summary = false;
1269 contributed = false;
1270 caseRuntime = false;
1271 arrayRuntime = false;
1272 returnRuntime = false;
1273 internalDebugging = false;
1274 quiet = false;
1275 verbose = false;
1276 extendedOpaque = false;
1277 debugTopological = false;
1278 ignoreFQ = false;
1279 gccConfigSystem = false;
1280 scaffoldMain = false;
1281 scaffoldDynamic = false;
1282 suppressNoReturn = false;
1283 useBoolType = true;
1284 hPrefix = DynamicStrings_InitString ((const char *) "", 0);
1285 cppArgs = DynamicStrings_InitString ((const char *) "", 0);
1286 cppProgram = DynamicStrings_InitString ((const char *) "", 0);
1287 outputFile = DynamicStrings_InitString ((const char *) "-", 1);
1288 summaryContents = DynamicStrings_InitString ((const char *) "", 0);
1289 contributedContents = DynamicStrings_InitString ((const char *) "", 0);
1290 projectContents = DynamicStrings_InitString ((const char *) "GNU Modula-2", 12);
1291 CReal = DynamicStrings_InitString ((const char *) "double", 6);
1292 CLongReal = DynamicStrings_InitString ((const char *) "long double", 11);
1293 CShortReal = DynamicStrings_InitString ((const char *) "float", 5);
1296 extern "C" void _M2_mcOptions_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])