[m-dev.] for review: GCC back-end: integrate with mmc
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Jan 14 15:21:01 AEDT 2001
On 14-Jan-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 12
>
> Allow the GCC back-end and the Mercury compiler to be linked with the
> Mercury compiler (rather than the GCC back-end) defining main().
> This makes it a lot easier to integrate the GCC back-end interface
> with the rest of the Mercury implementation.
>
> Also add support to configure for determining the location of the GCC
> source code and whether or not to enable the GCC back-end interface.
Sorry, I forgot to include these two changes in my diff.
----------
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Export MR_make_argv(), for use by compiler/mlds_to_gcc.m.
Workspace: /home/hg/fjh/gcc-cvs/gcc/mercury
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.83
diff -u -d -r1.83 mercury_wrapper.c
--- runtime/mercury_wrapper.c 2000/12/13 12:13:09 1.83
+++ runtime/mercury_wrapper.c 2001/01/08 14:15:22
@@ -241,7 +241,6 @@
static void process_environment_options(void);
static void process_options(int argc, char **argv);
static void usage(void);
-static void make_argv(const char *, char **, char ***, int *);
#ifdef MEASURE_REGISTER_USAGE
static void print_register_usage_counts(void);
@@ -472,12 +471,15 @@
/*
** Given a string, parse it into arguments and create an argv vector for it.
-** Returns args, argv, and argc. It is the caller's responsibility to
+** The return value is NULL if the string parses OK, or an error message
+** if it didn't (e.g. if it contained an unterminated quoted string).
+** Also returns args, argv, and argc. It is the caller's responsibility to
** MR_GC_free() args and argv when they are no longer needed.
*/
-static void
-make_argv(const char *string, char **args_ptr, char ***argv_ptr, int *argc_ptr)
+const char *
+MR_make_argv(const char *string,
+ char **args_ptr, char ***argv_ptr, int *argc_ptr)
{
char *args;
char **argv;
@@ -511,10 +513,10 @@
/* "double quoted" arg - scan until next double quote */
while (*s != '"') {
if (s == '\0') {
- MR_fatal_error(
- "Mercury runtime: unterminated quoted string\n"
- "in MERCURY_OPTIONS environment variable\n"
- );
+ *args_ptr = NULL;
+ *argv_ptr = NULL;
+ *argc_ptr = argc;
+ return "unterminated quoted string";
}
if (*s == '\\')
s++;
@@ -582,7 +584,8 @@
*args_ptr = args;
*argv_ptr = argv;
*argc_ptr = argc;
-} /* end make_argv() */
+ return NULL; /* success */
+} /* end MR_make_argv() */
/*
** process_args() is a function that sets some global variables from the
@@ -613,13 +616,14 @@
const char *cmd;
char *arg_str, **argv;
char *dummy_command_line;
+ const char *error_msg;
int argc;
/*
** getopt() expects the options to start in argv[1],
** not argv[0], so we need to insert a dummy program
** name (we use "mercury_runtime") at the start of the
- ** options before passing them to make_argv() and then
+ ** options before passing them to MR_make_argv() and then
** to getopt().
*/
cmd = "mercury_runtime ";
@@ -628,7 +632,12 @@
strcpy(dummy_command_line, cmd);
strcat(dummy_command_line, options);
- make_argv(dummy_command_line, &arg_str, &argv, &argc);
+ error_msg = MR_make_argv(dummy_command_line,
+ &arg_str, &argv, &argc);
+ if (error_msg != NULL) {
+ MR_fatal_error("error parsing the MERCURY_OPTIONS "
+ "environment variable:\n%s\n", error_msg);
+ }
MR_GC_free(dummy_command_line);
process_options(argc, argv);
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.40
diff -u -d -r1.40 mercury_wrapper.h
--- runtime/mercury_wrapper.h 2000/12/04 18:35:11 1.40
+++ runtime/mercury_wrapper.h 2001/01/08 14:17:16
@@ -226,4 +226,7 @@
#endif
+/* This is used by compiler/mlds_to_gcc.m. */
+const char *MR_make_argv(const char *, char **, char ***, int *);
+
#endif /* not MERCURY_WRAPPER_H */
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list