[m-rev.] for review: fix foreign_types and pragma export

Peter Ross pro at missioncriticalit.com
Fri Jul 19 20:22:19 AEST 2002


----- Original Message -----
From: "Simon Taylor" <stayl at cs.mu.OZ.AU>
To: <mercury-reviews at cs.mu.OZ.AU>
Sent: Thursday, July 18, 2002 6:32 AM
Subject: Re: [m-rev.] for review: fix foreign_types and pragma export


> On 18-Jul-2002, Peter Ross <petdr at cs.mu.OZ.AU> wrote:
> > Estimated hours taken: 8
> > Branches: main
> >
> > Fix generated C errors where a `:- pragma foreign_type' refers to a
C
> > type which is not in scope where it is used in the prototype for a
> > predicate with a `:- pragma export' declaration.
>
> > Index: compiler/export.m
> > ===================================================================
> > @@ -656,6 +676,20 @@
> >  "#include ""mercury_deep_profiling.h""\n",
> >  "#endif\n",
> >  "\n"]),
> > +
> > + ( { MaybeForeignDecls = yes(ForeignDecls) } ->
> > + ( { HighLevelCode = yes } ->
> > + module_name_to_file_name(ModuleName,
> > + ".mih", no, MIHName),
> > + io__write_strings(
> > + ["#include """, MIHName, """\n"])
> > + ;
> > + list__foldl(output_foreign_decl, ForeignDecls)
> > + )
> > + ;
> > + []
> > + ),
>
> The `.mh' file is meant to be grade independent.
> It may be better to always write the foreign_decls to
> the `.mh' file. That could also solve the problems where
> the foreign_decls are imported twice with `--highlevel-code'
> and `--intermodule-optimization'.
>
Do you mean regardless of whether or not a foreign_type has been
declared?  If so, then we need to change the logic of when we produce a
.mh file.  Currently we produce when when either the file contains
exported procedures or foreign types.

I now write them regardless of whether or not we are using
high_level_code, and am just bootchecking that change now.

> > +export__output_foreign_decl(foreign_decl_code(Lang, Code,
Context)) -->
> > + ( { Lang = c } ->
> > + { term__context_file(Context, FileName) },
> > + { term__context_line(Context, LineNumber) },
> > + c_util__set_line_num(FileName, LineNumber),
> > + io__write_string(Code),
> > + io__nl,
> > + c_util__reset_line_num
> > + ;
> > + []
> > + ).
>
> Setting the line numbers here is probably a bad idea because it
> will cause a lot of unnecessary recompilation.
>
I see your point, but also not setting them means that sometimes it can
be hard to relate the problem back to a source line in the .m file.
Remember that --no-line-numbers turns off outputting line numbers, so I
am inclined to leave them in for the moment.

Pete

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list