[m-rev.] for review: fix foreign type import bug

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Dec 29 10:39:30 AEDT 2003


On 24-Dec-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> If a module exports foreign types, the interface files need
> to contain a `:- pragma foreign_import_module' declaration
> for the module to avoid target code compilation errors in
> importing modules.
...
> Index: compiler/modules.m
...
> @@ -3940,6 +3969,7 @@
>  %
>  :- pred add_int_deps(relation_key, module_imports, deps_rel, deps_rel).
>  :- mode add_int_deps(in, in, in, out) is det.
> +:- pragma no_inline(add_int_deps/4).

Either there should be a comment explaining why this is needed,
or the `pragma no_inline' declaration here should be deleted.

> @@ -3951,6 +3981,7 @@
>  %
>  :- pred add_impl_deps(relation_key, module_imports, deps_rel, deps_rel).
>  :- mode add_impl_deps(in, in, in, out) is det.
> +:- pragma no_inline(add_impl_deps/4).

Likewise.

> @@ -3971,6 +4002,15 @@
>  	map__lookup(DepsMap, Parent, deps(_, ParentModuleImports)),
>  	add_impl_deps(ModuleKey, ParentModuleImports, Rel0, Rel).
>  
> +:- pred add_parent_impl_deps_list(deps_map, relation_key, list(module_name),
> +			deps_rel, deps_rel).
> +:- mode add_parent_impl_deps_list(in, in, in, in, out) is det.
> +
> +add_parent_impl_deps_list(_, _, [], !Rel).
> +add_parent_impl_deps_list(DepsMap, ModuleKey, [Parent | Parents], !Rel) :-
> +	add_parent_impl_deps(DepsMap, ModuleKey, Parent, !Rel),
> +	add_parent_impl_deps_list(DepsMap, ModuleKey, Parents, !Rel).

Any particular reason to not use list.foldl here, like the previous code did?

> @@ -6881,6 +6933,20 @@
>  item_needs_imports(promise(_, _, _, _)) = yes.
>  item_needs_imports(nothing(_)) = no.
>  
> +:- pred item_needs_foreign_imports(item, foreign_language).
> +:- mode item_needs_foreign_imports(in, out) is semidet.
> +
> +item_needs_foreign_imports(Item @ type_defn(_, _, _, _, _), Lang) :-
> +	Item ^ td_ctor_defn = foreign_type(ForeignType, _),
> +	( ForeignType = il(_), Lang = il
> +	; ForeignType = c(_), Lang = c
> +	; ForeignType = java(_), Lang = java
> +	).

That switch on ForeignType should be extracted out into a separate
(det) function.

Otherwise that looks fine, I think.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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