[m-rev.] for review: fix foreign_types and pragma export
Simon Taylor
stayl at cs.mu.OZ.AU
Sun Jul 21 12:52:57 AEST 2002
On 19-Jul-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> From: "Simon Taylor" <stayl at cs.mu.OZ.AU>
> > 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.
Another problem with this change is that as far as I can tell it
only fixes the problem when the foreign type and the `pragma export'
are in the same module.
> > 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?
Yes.
> > > +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.
A much better way to deal with this would be to write the
foreign_decls to both the `.mh' file (without line numbers) and
the C or `.mih' file (with line numbers). That would allow errors
to be reported with the correct line numbers when compiling the
module containing the foreign_decl, but wouldn't cause unnecessary
recompilation of the C code for importing modules.
Where is the relative diff for the change you committed?
Simon.
--------------------------------------------------------------------------
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