[m-rev.] for review: fix header file problems

Fergus Henderson fjh at cs.mu.OZ.AU
Thu May 30 15:04:32 AEST 2002


Given that we already rely to some degree on file names containing
multiple extensions (e.g. *.c.tmp), I'd be tempted to go for `.m.h'
rather than `.mh'.

On 29-May-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> @@ -583,8 +612,12 @@
>  			"extern ""C"" {\n",
>  			"#endif\n",
>  			"\n",
> +			"#ifdef MR_HIGHLEVEL_CODE\n",
> +			"#include ""mercury.h""\n",
> +			"#else\n",
>  			"#ifndef MERCURY_HDR_EXCLUDE_IMP_H\n",
>  			"#include ""mercury_imp.h""\n",
> +			"#endif\n",
>  			"#endif\n",
>  			"#ifdef MR_DEEP_PROFILING\n",
>  			"#include ""mercury_deep_profiling.h""\n",

The generated code here should conform to our indentation guidelines.

> +++ compiler/make.module_target.m	18 May 2002 17:53:20 -0000
> @@ -497,23 +497,12 @@
>  		    % When compiling to high-level C, we always generate
>  		    % a header file.
>  		    %
> -		    { HeaderModuleNames = SourceFileModuleNames }
> +		    { HeaderModuleNames = SourceFileModuleNames },
> +		    { HeaderTargets0 = make_target_list(HeaderModuleNames,
> +		    			c_header(mih)) }
>  		;
> -		    %
> -		    % When compiling to low-level C, we only generate a
> -		    % header file if the module contains `:- pragma export'
> -		    % declarations.
> -		    %
> -		    { HeaderModuleNames =
> -			list__filter_map(
> -			    (func(MImports) =
> -			    		MImports ^ module_name is semidet :-
> -				contains_foreign_export =
> -				    MImports ^ contains_foreign_export
> -			    ), ModuleImportsList) }
> -		),
...
> +	    { ( CompilationTarget = c ; CompilationTarget = asm ) ->
> +	    	PragmaExportModuleNames =
> +			list__filter_map(
> +			    (func(MImports) =
> +			    		MImports ^ module_name is semidet :-
> +				contains_foreign_export =
> +				    MImports ^ contains_foreign_export
> +			    ), ModuleImportsList),
> +	    	HeaderTargets =
> +			make_target_list(PragmaExportModuleNames, c_header(mh))
> +			++ HeaderTargets0

There should be a comment here explaining this code,
e.g. something similar to the comment that was deleted.

> Index: compiler/mlds.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
> retrieving revision 1.90
> diff -u -u -r1.90 mlds.m
> --- compiler/mlds.m	7 May 2002 11:03:04 -0000	1.90
> +++ compiler/mlds.m	18 May 2002 18:34:49 -0000
> @@ -324,13 +324,29 @@
>  
>  :- type mlds__imports == list(mlds__import).
>  
> +:- type mercury_mlds_import_type
> +	--->	import_interface	% Import the user-visible interface
> +					% to the target code (the prototypes
> +					% for the `:- pragma export'
> +					% declarations).
> +
> +	;	import_implementation.	% Import the implementation part
> +					% of the target code.

The names `import_interface' and `import_implementation' are
a bit misleading, IMHO.

`import_implementation' doesn't import the implementation part
of the target code.  The implementation part would be the `.c' file!

I think it would be better to distinguish between the user-visible interface
section and the (Mercury-)compiler-visible interface section.

E.g.

	:- type mercury_mlds_import_type
		---> user_visible_interface.
		;    compiler_visible_interface.

Also, it's not clear what is supposed to happen for target languages
that don't support multiple interfaces like this.  Some comments about
that might be helpful for people developing new back-ends.

>  % Currently an import just gives the name of the package to be imported.
>  % This might perhaps need to be expanded to cater to different kinds of
>  % imports, e.g. imports with wild-cards ("import java.lang.*").
>  :- type mlds__import
> -	--->	mercury_import(
> +	--->
> +		% Import the user-visible interface of the target code
> +		% for the module (e.g. for C, the function prototypes for
> +		% predicates and functions with `:- pragma export'
> +		% declarations, which are contained in the `.mh' file).
> +		mercury_import(
> +			mercury_mlds_import_type :: mercury_mlds_import_type,

This comment is wrong; the kind of import will depend on the value
of the first field.

Otherwise, that looks fine.

-- 
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