[m-rev.] for review: new foreign_type syntax

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Dec 6 16:08:05 AEDT 2001


On 06-Dec-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> +++ compiler/make_hlds.m	5 Dec 2001 22:40:16 -0000
> @@ -395,18 +395,47 @@
>  		{ Pragma = foreign_proc(_, _, _, _, _, _) },
>  		{ Module = Module0 }
>  	;	
> -		{ Pragma = foreign_type(Backend, _MercuryType, Name,
> -				ForeignType) },
> +		{ Pragma = foreign_type(Backend, _MercuryType, Name) },

I suggest s/Backend/BackendType/g
or s/Backend/ForeignType/g

> Index: compiler/mercury_to_mercury.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
> retrieving revision 1.198
> diff -u -r1.198 mercury_to_mercury.m
> --- compiler/mercury_to_mercury.m	8 Nov 2001 15:30:31 -0000	1.198
> +++ compiler/mercury_to_mercury.m	21 Nov 2001 05:33:10 -0000
> @@ -467,18 +467,18 @@
>  			PredOrFunc, Vars, VarSet, PragmaCode)
>  	;
>  		{ Pragma = foreign_type(Backend, _MercuryType,
> -				MercuryTypeSymName, ForeignType) },
> +				MercuryTypeSymName) },

Likewise.

> Index: compiler/module_qual.m
> @@ -893,11 +893,11 @@
>  qualify_pragma(source_file(File), source_file(File), Info, Info) --> [].
>  qualify_pragma(foreign_decl(L, Code), foreign_decl(L, Code), Info, Info) --> [].
>  qualify_pragma(foreign_code(L, C), foreign_code(L, C), Info, Info) --> [].
> +qualify_pragma(foreign_type(Backend, Type0, SymName),
> +		foreign_type(Backend, Type, SymName), Info0, Info) -->

Likewise.

> +++ compiler/prog_data.m	22 Nov 2001 02:10:47 -0000
> @@ -288,9 +287,10 @@
>  % Stuff for the foreign interfacing pragmas.
>  %
>  
> -:- type backend
> -			% The location of the il name.
> -	--->	il(string).
> +:- type backend_type
> +			% The location of the il name, and the .NET type name
> +			% (represented as a sym_name)
> +	--->	il(string, sym_name).

It would be helpful here to have a comment indicating what
the `backend_type' type is supposed to represent.

Shouldn't it be named "foreign_language_type" rather than "backend_type"?

> Index: compiler/prog_io_pragma.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
> retrieving revision 1.38
> diff -u -r1.38 prog_io_pragma.m
> --- compiler/prog_io_pragma.m	20 Nov 2001 13:53:20 -0000	1.38
> +++ compiler/prog_io_pragma.m	28 Nov 2001 07:37:58 -0000
> @@ -70,52 +70,43 @@
>  			ErrorTerm)
>  	).
>  
> -/*
>  parse_pragma_type(ModuleName, "foreign_type", PragmaTerms,
>              ErrorTerm, _VarSet, Result) :-
> -    ( PragmaTerms = [MercuryName, ForeignName, Target] ->
> -    	(
> -	    parse_backend(Target, Backend)
> -	->
> -	    parse_implicitly_qualified_term(ModuleName, MercuryName,
> +    ( PragmaTerms = [LangTerm, MercuryName, BackendTerm] ->
> +	( parse_foreign_language(LangTerm, Language) ->
> +	    parse_backend(BackendTerm, Language, MaybeBackend),

I suggest s/backend/foreign_type_name/g
and s/Backend/ForeignTypeName/g

> -:- pred parse_backend(term, backend).
> -:- mode parse_backend(in, out) is semidet.
> +:- pred parse_backend(term, foreign_language, maybe1(backend_type)).
> +:- mode parse_backend(in, in, out) is det.
> +
> +parse_backend(InputTerm, Language, Result) :-

Likewise.

> +parse_il_type_name(String0, ErrorTerm, BackendType) :-
> +	( 
> +		string__append("class [", String1, String0),
> +		string__sub_string_search(String1, "]", Index)
> +	->
> +		string__left(String1, Index, AssemblyName),
> +		string__split(String1, Index + 1, _, TypeNameStr),
> +		string_to_sym_name(TypeNameStr, ".", TypeSymName),
> +		BackendType = ok(il(AssemblyName, TypeSymName))
> +	;
> +		BackendType = error("invalid backend type description", 
> +			ErrorTerm)
> +	).

Likewise.

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