[m-rev.] For review: Remove support for Managed C++

Jonathan Morgan jonmmorgan at gmail.com
Fri Jul 13 23:54:39 AEST 2007


On 7/9/07, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> On Sat, 7 Jul 2007, Jonathan Morgan wrote:
>
> > This change is fairly straightforward and boring.  What I want review
> > comments on are:
> > * Is there anything that I've missed removing?
>
> Not that I can see.
>
> > * Should this change be mentioned in NEWS?
>
> Yes.

Done.  I wasn't quite sure which section to put it in, but I put it as
a compiler change since it hasn't really changed the structure of the
language.

> > * Should I move mlds_to_managed.m back to mlds_to_csharp.m (where it
> > was originally), or leave it as is?
>
> No, leave it as is, resurrecting files in CVS is problematic.
>
> > I will be bootchecking this change in hlc.gc before committing to make
> > sure, as it is the only really important MLDS-based grade.
>
> Please bootcheck it in hl.gc as well.

Done.  There were a few tests that needed changing from MC++ to C# as
well.  The interdiff follows.  Please review these changes so that I
can commit.

Jon

diff -u compiler/mlds_to_il.m compiler/mlds_to_il.m
--- compiler/mlds_to_il.m	7 Jul 2007 01:38:38 -0000
+++ compiler/mlds_to_il.m	13 Jul 2007 13:43:53 -0000
@@ -95,10 +95,9 @@
 :- func params_to_il_signature(il_data_rep, mlds_module_name,
     mlds_func_params) = signature.

-    % Generate an identifier for a pred label, to be used in one of the
-    % managed languages.
+    % Generate an identifier for a pred label, to be used in C#.
     %
-:- pred predlabel_to_managed_id(mlds_pred_label::in, proc_id::in,
+:- pred predlabel_to_csharp_id(mlds_pred_label::in, proc_id::in,
     maybe(mlds_func_sequence_num)::in, ilds.id::out) is det.

     % Generate an IL identifier for a MLDS var.
@@ -224,8 +223,8 @@
                 % method-wide attributes (static)
                 arguments           :: arguments_map,   % The arguments
                 method_name         :: member_name,     % current method name
-                managed_method_name :: member_name,
-                                    % current managed method name
+                csharp_method_name  :: member_name,
+                                    % current C# method name
                 signature           :: signature        % current return type
             ).

@@ -941,7 +940,7 @@
 entity_name_to_ilds_id(entity_export(Name)) = Name.
 entity_name_to_ilds_id(entity_function(PredLabel, ProcId, MaybeSeqNum, _))
         = Name :-
-    predlabel_to_il_id(PredLabel, ProcId, MaybeSeqNum, Name).
+    predlabel_to_ilds_id(PredLabel, ProcId, MaybeSeqNum, Name).
 entity_name_to_ilds_id(entity_type(Name, Arity))
     = string.format("%s_%d", [s(Name), i(Arity)]).
 entity_name_to_ilds_id(entity_data(DataName))
@@ -1073,7 +1072,7 @@
     (
         IsCons = yes(ParentClass),
         MemberName = ctor,
-        ManagedMemberName = ctor,
+        CSharpMemberName = ctor,
         CtorInstrs = [load_this,
             call(methoddef(call_conv(yes, default), void,
             class_member_name(ParentClass, ctor), []))]
@@ -1081,15 +1080,15 @@
         IsCons = no,
         (
             Name = entity_function(PredLabel, ProcId, MaybeSeqNum, _PredId),
-            predlabel_to_il_id(PredLabel, ProcId, MaybeSeqNum, MemberName0),
-            predlabel_to_managed_id(PredLabel, ProcId, MaybeSeqNum,
-                    ManagedMemberName0),
+            predlabel_to_ilds_id(PredLabel, ProcId, MaybeSeqNum, MemberName0),
+            predlabel_to_csharp_id(PredLabel, ProcId, MaybeSeqNum,
+                    CSharpMemberName0),
             MemberName = id(MemberName0),
-            ManagedMemberName = id(ManagedMemberName0)
+            CSharpMemberName = id(CSharpMemberName0)
         ;
             Name = entity_export(ExportName),
             MemberName = id(ExportName),
-            ManagedMemberName = id(ExportName)
+            CSharpMemberName = id(ExportName)
         ;
             ( Name = entity_type(_, _)
             ; Name = entity_data(_)
@@ -1102,7 +1101,7 @@
     Attrs = decl_flags_to_methattrs(Flags),

     % Initialize the IL info with this method info.
-    il_info_new_method(ILArgs, ILSignature, MemberName, ManagedMemberName,
+    il_info_new_method(ILArgs, ILSignature, MemberName, CSharpMemberName,
             !Info),

     % Start a new block, which we will use to wrap up the entire method.
@@ -1143,7 +1142,7 @@
             comment_node("external -- call handwritten version"),
             node(LoadInstrs),
             instr_node(call(get_static_methodref(ClassName,
-                ManagedMemberName, ILRetType, TypeParams)))
+                CSharpMemberName, ILRetType, TypeParams)))
             ]),
         MaybeRet = instr_node(ret)
     ),
@@ -1973,7 +1972,7 @@
             ReturnLvals = [_, _ | _],
             sorry(this_file, "multiple return values")
         ),
-        MethodName = !.Info ^ managed_method_name,
+        MethodName = !.Info ^ csharp_method_name,
         assoc_list.keys(Params, TypeParams),
         list.map_foldl((pred(_::in, Instr::out,
             Num::in, Num + 1::out) is det :-
@@ -3271,21 +3270,20 @@
     mangle_for_il
         % Names that are to be used only in IL are able to include spaces,
         % punctuation and other special characters, because they are in quotes.
-    ; mangle_for_managed.
-        % Names that are to be used in other managed languages (typically
-        % because they define foreign procedures in that language) must be
-        % mangled in the same way as for C.
+    ; mangle_for_csharp.
+        % Names that are to be used in C# (typically because they are foreign
+        % procedures) must be mangled in the same way as for C.

     % Create a mangled predicate identifier, suitable for use in IL.
     %
-:- pred predlabel_to_il_id(mlds_pred_label::in, proc_id::in,
+:- pred predlabel_to_ilds_id(mlds_pred_label::in, proc_id::in,
     maybe(mlds_func_sequence_num)::in, ilds.id::out) is det.

-predlabel_to_il_id(PredLabel, ProcId, MaybeSeqNum, Id) :-
+predlabel_to_ilds_id(PredLabel, ProcId, MaybeSeqNum, Id) :-
     predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, mangle_for_il, Id).

-predlabel_to_managed_id(PredLabel, ProcId, MaybeSeqNum, Id) :-
-    predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, mangle_for_managed, Id).
+predlabel_to_csharp_id(PredLabel, ProcId, MaybeSeqNum, Id) :-
+    predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, mangle_for_csharp, Id).

     % XXX We may need to do different name mangling for CLS compliance
     % than we would otherwise need.
@@ -3415,7 +3413,7 @@
 :- func mangle_pred_name(string, il_mangle_name) = string.

 mangle_pred_name(PredName, mangle_for_il) = PredName.
-mangle_pred_name(PredName, mangle_for_managed) = MangledName :-
+mangle_pred_name(PredName, mangle_for_csharp) = MangledName :-
     ( string.is_all_alnum_or_underscore(PredName) ->
         MangledName = PredName
     ;
@@ -3529,7 +3527,7 @@
 mangle_mlds_proc_label(qual(ModuleName, _, mlds_proc_label(PredLabel, ProcId)),
         MaybeSeqNum, ClassName, PredStr) :-
     ClassName = mlds_module_name_to_class_name(ModuleName),
-    predlabel_to_il_id(PredLabel, ProcId, MaybeSeqNum, PredStr).
+    predlabel_to_ilds_id(PredLabel, ProcId, MaybeSeqNum, PredStr).

 :- pred mangle_entity_name(mlds_entity_name::in, string::out) is det.

@@ -4420,11 +4418,11 @@
         DebugIlAsm, VerifiableCode, ByRefTailCalls, MsCLR, RotorCLR,
         empty, empty, [], no, set.init, set.init,
         map.init, empty, counter.init(1), counter.init(1), no,
-        Args, MethodName, ManagedMethodName, DefaultSignature) :-
+        Args, MethodName, CSharpMethodName, DefaultSignature) :-
     Args = [],
     DefaultSignature = signature(call_conv(no, default), void, []),
     MethodName = id(""),
-    ManagedMethodName = id("").
+    CSharpMethodName = id("").

 :- pred il_info_new_class(mlds_class_defn::in, il_info::in, il_info::out)
     is det.
@@ -4447,7 +4445,7 @@
 :- pred il_info_new_method(arguments_map::in, signature::in, member_name::in,
     member_name::in, il_info::in, il_info::out) is det.

-il_info_new_method(ILArgs, ILSignature, MethodName, ManagedMethodName,
+il_info_new_method(ILArgs, ILSignature, MethodName, CSharpMethodName,
         !Info) :-
     Info0 = !.Info,
     (
@@ -4466,7 +4464,7 @@
     !:Info = !.Info ^ method_foreign_lang := no,
     !:Info = !.Info ^ arguments := ILArgs,
     !:Info = !.Info ^ method_name := MethodName,
-    !:Info = !.Info ^ managed_method_name := ManagedMethodName,
+    !:Info = !.Info ^ csharp_method_name := CSharpMethodName,
     !:Info = !.Info ^ signature := ILSignature.

 :- pred il_info_set_arguments(assoc_list(ilds.id, mlds_type)::in,
only in patch2:
unchanged:
--- NEWS	19 Jun 2007 04:20:39 -0000	1.468
+++ NEWS	13 Jul 2007 13:19:17 -0000
@@ -191,6 +191,9 @@
 * A new option, `--generate-standalone-interface', simplifies the task
   of calling Mercury procedures from programs written in other languages.

+* We have removed support for Managed C++ as a foreign language for the IL
+  backend.
+
 Changes to the Mercury deep profiler:

 * The deep profiler now supports measuring a proxy for time: a counter that
@@ -294,6 +297,11 @@
   such as C or C++ to initialise the Mercury runtime and libraries prior to
   calling any foreign exported procedures defined in those libraries.

+* We have removed support for Managed C++ as a foreign language for the IL
+  backend.  This was desirable because it wasn't used, because it has been
+  deprecated by Microsoft, and because it complicated the dependencies for the
+  IL backend.
+
 Changes to the Mercury standard library:

 * The predicates io.seek_binary/5 and io.binary_stream_offset/4 have been
only in patch2:
unchanged:
--- tests/hard_coded/foreign_import_module.m	23 Dec 2002 12:34:20 -0000	1.3
+++ tests/hard_coded/foreign_import_module.m	13 Jul 2007 13:06:35 -0000
@@ -21,24 +21,23 @@

 :- pragma foreign_import_module(c, foreign_import_module_2).
 :- pragma foreign_import_module(il, foreign_import_module_2).
-:- pragma foreign_import_module("MC++", foreign_import_module_2).
 % :- pragma foreign_import_module(il, std_util).

 :- pragma c_code(bar(X::in, Y::out), may_call_mercury,
 "
 	foo(X, &Y);
 ").
-:- pragma foreign_proc("MC++", bar(X::in, Y::out),
+:- pragma foreign_proc("C#", bar(X::in, Y::out),
 		[may_call_mercury, promise_pure], "
-	MR_Integer Y1, Y2;
+	int Y1, Y2;

-	foreign_import_module_2::mercury_code::foo(X, &Y1);
-	foreign_import_module_2__cpp_code::mercury_code::foo2(X, &Y2);
+	foreign_import_module_2.mercury_code.foo(X, ref Y1);
+	foreign_import_module_2__csharp_code.mercury_code.foo2(X, ref Y2);

 	if (Y1 == Y2) {
 		Y = Y1;
 	} else {
-		throw new System::Exception(""Y1 != Y2"");
+		throw new System.Exception(""Y1 != Y2"");
 	}
 ").

only in patch2:
unchanged:
--- tests/hard_coded/foreign_import_module_2.m	23 Dec 2002 12:34:20 -0000	1.2
+++ tests/hard_coded/foreign_import_module_2.m	13 Jul 2007 13:04:23 -0000
@@ -8,13 +8,13 @@

 :- import_module int.

-:- pragma export(foo(in, out), "foo").
+:- pragma foreign_export("IL", foo(in, out), "foo").

 foo(X, X+1).

-:- pragma foreign_code("MC++", "
-	static void foo2(MR_Integer X, MR_Ref(MR_Integer) Y)
+:- pragma foreign_code("C#", "
+	static void foo2(int X, ref int Y)
 	{
-		*Y = X + 1;
+		Y = X + 1;
 	}
 ").
only in patch2:
unchanged:
--- tests/hard_coded/foreign_proc_make.m	20 Dec 2002 09:47:28 -0000	1.1
+++ tests/hard_coded/foreign_proc_make.m	13 Jul 2007 13:00:21 -0000
@@ -19,5 +19,5 @@


 :- func f2 = int.
-:- pragma foreign_proc("MC++", f2 = (X::out), [promise_pure], "X=5;").
+:- pragma foreign_proc("C#", f2 = (X::out), [promise_pure], "X=5;").
 f2 = 5.
only in patch2:
unchanged:
--- tests/hard_coded/redoip_clobber.m	6 Jun 2007 01:48:11 -0000	1.5
+++ tests/hard_coded/redoip_clobber.m	13 Jul 2007 13:08:44 -0000
@@ -59,25 +59,10 @@

 	SUCCESS_INDICATOR = MR_FALSE;
 ").
-:- pragma foreign_proc("MC++", use(X::in),
+:- pragma foreign_proc("C#", use(X::in),
 	[will_not_call_mercury, promise_pure],
 "
-	/*
-	** To exhibit the bug, this predicate needs only to fail.
-	** However, the symptom of the bug is an infinite loop.
-	** To detect the presence of the bug in finite time,
-	** we abort execution if this code is executed too many times.
-	**
-	** We mention X here to shut up a warning.
-	*/
-
-	static int counter = 0;
-
-	if (++counter > 100) {
-		throw new System::Exception(""the bug is back"");
-	}
-
-	SUCCESS_INDICATOR = MR_FALSE;
+	SUCCESS_INDICATOR = false
 ").
 :- pragma foreign_proc("Erlang", use(_X::in),
 	[will_not_call_mercury, promise_pure],
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list