[m-rev.] for review: improve MC++ support

Tyson Dowd trd at cs.mu.OZ.AU
Sat May 25 10:59:47 AEST 2002


On 20-May-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> Hi,
> 
> For Fergus or Tyson to review.
> 
> ===================================================================
> 
> 
> Estimated hours taken: 16
> Branches: main
> 
> Output Managed C++ code using the same mechanisms as we do for C# code,
> rather than using pragma_c_gen to generate MC++ code.  This fixes the
> problem that functions couldn't be defined in MC++, and also should make
> the code more maintainable in the future as MC++ is much more similar to
> C# than to C.
> 
> compiler/mlds_to_managed.m:
>     Generalise mlds_to_csharp so that it can also output valid MC++
>     code.
> 
> compiler/ml_code_gen.m:
>     Use the context of the string which contains the pragma foreign
>     proc body for the context of the foreign proc.  This ensures that
>     error messages refer to the correct line number.
>     Generate a foreign proc for MC++ the same way we generate a foreign
>     proc for C#.
> 
> compiler/mlds_to_il.m:
>     Allow functions in MC++.
> 
> compiler/mlds_to_ilasm.m:
>     Changes required to move to using mlds_to_managed.
>     Delete some now unnecessary imports from the llds backend.
> 
> compiler/ml_backend.m:
>     Add the new module and remove mlds_to_mcpp and mlds_to_csharp.
> 
> compiler/mlds_to_csharp.m:
> compiler/mlds_to_mcpp.m:
>     Deleted files whose functionality has been subsumed by
>     mlds_to_managed.
> 
> library/construct.m:
> library/exception.m:
> library/io.m:
> library/rtti_implementation.m:
> library/std_util.m:
>     Changes required to get the library to be able compile in the ilc
>     grade.  These consist of
>         - getting rid of references to anonymous variables
>         - giving variables which are passed by reference an initial value
>         - adding a missing ; in std_util.

Is this only required for ILC grade or is this related to the change for
MC++?  The changes are fine but I want to know whether they are related
or not.

If you have to give initial values for Mercury output variables then
this needs a small amount of documentation.

> Index: compiler/mlds_to_il.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
> retrieving revision 1.114
> diff -u -r1.114 mlds_to_il.m
> --- compiler/mlds_to_il.m	7 May 2002 11:03:07 -0000	1.114
> +++ compiler/mlds_to_il.m	20 May 2002 14:17:47 -0000
> @@ -1912,7 +1912,9 @@
>  		; RetType = simple_type(bool) ->
>  			StoreReturnInstr = instr_node(stloc(name("succeeded")))
>  		;
> -			sorry(this_file, "functions in MC++")
> +			StoreReturnInstr = empty
>  		},
>  		MethodName =^ method_name,
>  		{ assoc_list__keys(Params, TypeParams) },

If we are using the same system as for C# this code should not even get
called for MC++.  It should generate an error message instead (like the
other cases for inline_target_code in the IL backend).

> Index: compiler/mlds_to_managed.m
> ===================================================================
> RCS file: compiler/mlds_to_managed.m
> diff -N compiler/mlds_to_managed.m
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ compiler/mlds_to_managed.m	20 May 2002 14:17:47 -0000
> @@ -0,0 +1,787 @@
> +%-----------------------------------------------------------------------------%
> +% Copyright (C) 2002 The University of Melbourne.
> +% This file may only be copied under the terms of the GNU General
> +% Public License - see the file COPYING in the Mercury distribution.
> +%-----------------------------------------------------------------------------%
> +%
> +% Module: 	mlds_to_managed 
> +% Main author: 	trd, petdr.
> +%
> +% Generate code for the foreign language interface to C# and managed C++.
> +%
> +
> +:- module ml_backend__mlds_to_managed.
> +:- interface.
> +
> +:- import_module ml_backend__mlds.
> +:- import_module libs__globals.
> +:- import_module io.
> +
> +:- inst managed_lang == bound(csharp; managed_cplusplus).

Might be easier to define a mode for in(managed_lang) too.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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