[m-dev.] for review: fix pragma import of polymorphic preds

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jul 20 20:37:08 AEST 2000


On 20-Jul-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> Fix a bug where pragma imports of polymorphic predicates where not

s/where not/were not/

> having typeinfos prepended to the call.
> 
> compiler/prog_data.m:
>     Add a the new functor import/4 to pragma_c_code impl.

s/a the/a/
s/code impl/code_impl/

>     The functor stores all the information needed to constuct a C code

s/constuct/construct/

>     fragment a pragma import.

s/a/for a/

> compiler/make_hlds.m:
>     Rather then constructing the C code fragment immediately, construct

s/then/than/

> Index: compiler/polymorphism.m
> @@ -988,6 +1012,26 @@
>  polymorphism__process_goal_expr(bi_implication(_, _), _, _) -->
>  	% these should have been expanded out by now
>  	{ error("polymorphism__process_goal_expr: unexpected bi_implication") }.
> +
> +
> +	% type_info_vars construcs a comma seperated list of variables.
> +	% It places an & at the start of the variable name if variable
> +	% is an output variable.
> +:- func type_info_vars(module_info, list(maybe(pair(string, mode)))) = string.

s/construcs/constructs/
s/seperated/separated/
s/&/`&'/
s/if variable/if the variable/

Is the list comma terminated too?  If so, the comment should say that.

Should it be?  What about the case where there are no variables in the
argument list other than the type_info variables?
I think your code won't handle that case correctly.
E.g. consider

	:- some [T] func foo = T.
	:- pragma import(foo = out, "imp_foo").
	:- pragma export(foo = out, "exp_foo").

I think your code will generate invalid C code for that test case.

> +++ compiler/prog_data.m	2000/07/20 09:51:13
> @@ -385,6 +385,15 @@
>  					% Shared code that is executed after
>  					% both the previous code fragments.
>  					% May not access the input variables.
> +		)
> +	;	import(
> +			string,		% Pragma imported C func name
> +			string,		% Code to handle return value
> +			string,		% Comma seperated variables which
> +					% the import function is called
> +					% with.

s/seperated/separated/

Apart from that, this code looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list