[m-rev.] for review: fix foreign_types and pragma export
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Jul 18 14:32:59 AEST 2002
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'.
> +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.
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