[m-rev.] for review: implement pragma export on the .NET backend.

Peter Ross peter.ross at miscrit.be
Thu Aug 23 01:52:45 AEST 2001


On Wed, Aug 22, 2001 at 02:14:21PM +0200, Tyson Dowd wrote:
> Hi,
> 
> 
> ===================================================================
> 
> 
> Estimated hours taken: 8
> Branches: main
> 
> Implement pragma export on the .NET backend.
> 
> We just generate a forwarding call from the "exported" name (which
> occurs in the same class and module) to the specified predicate.
> 
> compiler/ml_code_gen.m:
> 	Generate exports for IL as well as C.
> 
> compiler/mlds_to_il.m:
> 	Generate a forwarding function for each exported predicate.
> 	Put the forwarding function inside the wrapper class.
> 	Generate a more specific error message if an return statement
> 	has an empty list of return values.
> 
> 

> Index: compiler/mlds_to_il.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
> retrieving revision 1.76
> diff -u -r1.76 mlds_to_il.m
> --- compiler/mlds_to_il.m	16 Aug 2001 15:04:03 -0000	1.76
> +++ compiler/mlds_to_il.m	22 Aug 2001 12:02:40 -0000
> @@ -276,11 +278,21 @@
>  :- func transform_mlds(mlds) = mlds.
>  
>  transform_mlds(MLDS0) = MLDS :-
> +	AllExports = list__condense(
> +		list__map(
> +			(func(mlds__foreign_code(_, _, Exports)) = Exports),
> +			map__values(MLDS0 ^ foreign_code))
> +		),
> +
> +		% Generate the exports for this file, they will be placed
> +		% into global methods.
> +	list__map(mlds_export_to_mlds_defn, AllExports, ExportDefns),
> +

This comment is contradictory with the log message.  Shouldn't this be
in the wrapper class?

> @@ -1082,6 +1094,83 @@
>  %-----------------------------------------------------------------------------%
>  %-----------------------------------------------------------------------------%
>  
> +	% MLDS exports are converted into forwarding functions, which are
> +	% marked as public, are given the specified name, and simply call to
> +	% the "exported" function.
> +	%
> +	% They will be placed inside the "mercury_code" wrapper class with
> +	% all the other procedures.
> +	%
> +	% XXX much of this code should be generalized and turned into a
> +	% more general routine for generating MLDS forwarding functions.
> +	% We could use almost the same approach for outline_foreign_code
> +	% to generate the forwarding function.
> +
The generalised routine might also be useful for the the foreign_code
branch when we extend an object.

> +:- pred mlds_export_to_mlds_defn(mlds__pragma_export::in, mlds__defn::out)
> +	is det.
> +
> +mlds_export_to_mlds_defn(
> +	ml_pragma_export(ExportName, EntityName, Params, Context), Defn) :- 
> +	EntityName = qual(ModuleName, UnqualName),
> +
> +	Params = mlds__func_params(Inputs, RetTypes),
> +	list__map_foldl((pred(RT::in, RV - Lval::out,
> +			N0::in, N0 + 1::out) is det :-
> +		VN = var_name("returnval" ++ int_to_string(N0), no),
> +		RV = ml_gen_mlds_var_decl(var(VN), RT, no_initializer, Context),
> +		Lval = var(qual(ModuleName, VN), RT)),
> +			RetTypes, ReturnVars, 0, _),

	list__map_foldl(
		(pred(RT::in, RV - Lval::out, N0::in, N0 + 1::out) is det :-
			VN = var_name("returnval" ++ int_to_string(N0), no),
			RV = ml_gen_mlds_var_decl(var(VN), RT,
					no_initializer, Context),
			Lval = var(qual(ModuleName, VN), RT)
		), RetTypes, ReturnVars, 0, _),

I would set out this code as above I think it makes it more clear which
part of the code is the lambda expression.


Otherwise this change looks fine.
--------------------------------------------------------------------------
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