[m-rev.] for review: rename mercury_mcpp to mercury_dotnet

Peter Ross pro at missioncriticalit.com
Fri Nov 14 01:12:54 AEDT 2003


Hi,

for fjh to review.


===================================================================


Estimated hours taken: 1.5
Branches: main

Rename mercury_mcpp.cs to mercury_dotnet.cs and switch it to under
control of configure.  Switching to under the control of configure
allows us to define some constants determined at configure time.

runtime/mercury_mcpp.cs:
runtime/mercury_dotnet.cs.in:
	Copy mercury_mcpp.cs to mercury_dotnet.cs.in and define two
	new constants MR_VERSION and MR_FULLARCH which are needed by
	library.version/1.

library/library.m:
	Rewrite library.version/1 in C#.

configure.in:
	Add runtime/mercury_dotnet.cs to the list of files under
	control.

compiler/mlds_to_managed.m:
compiler/modules.m:
library/Mmakefile:
library/private_builtin.m:
runtime/Mmakefile:
	Updates to reflect the name change from mercury_mcpp to
	mercury_dotnet.
	

Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.380
diff -u -r1.380 configure.in
--- configure.in	13 Nov 2003 11:19:56 -0000	1.380
+++ configure.in	13 Nov 2003 14:05:03 -0000
@@ -3678,7 +3678,7 @@
 scripts/canonical_grade
 scripts/mkfifo_using_mknod bindist/bindist.INSTALL bindist/bindist.Makefile
 scripts/mercury_config scripts/Mercury.config scripts/Mercury.config.bootstrap
-tools/lmc tools/dotime
+tools/lmc tools/dotime runtime/mercury_dotnet.cs
 ,
 [
 # Only do this when compiling the source, not when reconfiguring
Index: compiler/mlds_to_managed.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_managed.m,v
retrieving revision 1.9
diff -u -r1.9 mlds_to_managed.m
--- compiler/mlds_to_managed.m	13 Nov 2003 09:43:16 -0000	1.9
+++ compiler/mlds_to_managed.m	13 Nov 2003 14:05:04 -0000
@@ -190,7 +190,7 @@
 
 	( { mercury_std_library_module_name(ModuleName) } ->
 		io__write_strings([
-			"#using ""mercury_mcpp.dll""\n",
+			"#using ""mercury_dotnet.dll""\n",
 			"#using ""mercury_il.dll""\n"
 			%,
 			%"#using ""private_builtin.dll""\n",
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.280
diff -u -r1.280 modules.m
--- compiler/modules.m	5 Nov 2003 03:17:41 -0000	1.280
+++ compiler/modules.m	13 Nov 2003 14:05:05 -0000
@@ -5129,7 +5129,7 @@
 			% In the standard library we need to add the
 			% runtime dlls.
 		Modules = list__remove_dups(
-			[unqualified("mercury_mcpp"),
+			[unqualified("mercury_dotnet"),
 				unqualified("mercury_il") | DepModules])
 	;
 		F = (func(M) =
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.118
diff -u -r1.118 Mmakefile
--- library/Mmakefile	6 Aug 2003 12:38:13 -0000	1.118
+++ library/Mmakefile	13 Nov 2003 14:05:05 -0000
@@ -239,7 +239,7 @@
 lib_std: mercury.dll lib$(STD_LIB_NAME)
 
 # We have to hardcode the names of the runtime DLL files.
-RUNTIME_DLLS=mercury_mcpp.dll mercury_il.dll
+RUNTIME_DLLS=mercury_dotnet.dll mercury_il.dll
 
 	# -AI sets the assembly search path (just like -I for assemblies)
 MS_CLFLAGS  =	-AI`$(FIX_PATH_FOR_CL) $(RUNTIME_DIR)` -I`$(FIX_PATH_FOR_CL) $(RUNTIME_DIR)`
@@ -281,8 +281,8 @@
 mercury_il.dll: ../runtime/mercury_il.dll
 	cp ../runtime/mercury_il.dll .
 
-mercury_mcpp.dll: ../runtime/mercury_mcpp.dll
-	cp ../runtime/mercury_mcpp.dll .
+mercury_dotnet.dll: ../runtime/mercury_dotnet.dll
+	cp ../runtime/mercury_dotnet.dll .
 
 CSHARP_MODULES = array builtin char exception float io math \
 	rtti_implementation string type_desc
Index: library/library.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.71
diff -u -r1.71 library.m
--- library/library.m	20 Oct 2003 07:29:27 -0000	1.71
+++ library/library.m	13 Nov 2003 14:05:05 -0000
@@ -118,19 +118,12 @@
 	Version = (MR_String) (MR_Word) version_string;
 ").
 
-:- pragma foreign_code("MC++", "
-	#include ""mercury_conf.h""
-").
-
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
 	library__version(Version::out),
 	[will_not_call_mercury, promise_pure],
 "
-	// MR_VERSION and MR_FULLARCH are C string literals.
-	// We need to paste 'S' to the front of them to make them into .NET
-	// string literals.
-	Version = MR_PASTE2(S, MR_VERSION) S"", configured for ""
-		  MR_PASTE2(S, MR_FULLARCH);
+	Version = mercury.runtime.Constants.MR_VERSION + "" configured for ""
+			+ mercury.runtime.Constants.MR_FULLARCH;
 ").
 
 %---------------------------------------------------------------------------%
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.127
diff -u -r1.127 private_builtin.m
--- library/private_builtin.m	13 Nov 2003 12:58:06 -0000	1.127
+++ library/private_builtin.m	13 Nov 2003 14:05:06 -0000
@@ -392,15 +392,15 @@
 	MR_TYPECTOR_REP_TYPECLASSINFO) 
 
 	// XXX These static constants are duplicated both here and in
-	// mercury_mcpp.cpp.
+	// mercury_dotnet.cs.in.
 
 	// This is because other library modules reference them
 	// from MC++ code (so they depend on the versions in the runtime to
 	// make the dependencies simple) whereas the compiler generates
 	// references to the ones here. 
 
-	// See runtime/mercury_mcpp.cpp for discussion of why we aren't using
-	// enums or const static ints here.
+	// See runtime/mercury_dotnet.cs.in for discussion of why we aren't
+	// using enums or const static ints here.
 
 static int MR_TYPECTOR_REP_ENUM 		= MR_TYPECTOR_REP_ENUM_val;
 static int MR_TYPECTOR_REP_ENUM_USEREQ 		= MR_TYPECTOR_REP_ENUM_USEREQ_val;
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.106
diff -u -r1.106 Mmakefile
--- runtime/Mmakefile	25 Oct 2003 14:21:31 -0000	1.106
+++ runtime/Mmakefile	13 Nov 2003 14:05:06 -0000
@@ -289,14 +289,14 @@
 MS_CSCFLAGS=/t:module
 
 # We need to build the following DLLs for the .NET runtime
-DOTNET_DLLS=mercury_il.dll mercury_mcpp.dll
+DOTNET_DLLS=mercury_il.dll mercury_dotnet.dll
 
 clean_local:
 	rm -f $(DOTNET_DLLS)
 	
 runtime: $(DOTNET_DLLS)
 
-mercury_mcpp.dll: mercury_il.dll $(MCPP_HDRS)
+mercury_dotnet.dll: mercury_il.dll $(MCPP_HDRS)
 
 # Uncomment the following rule if you want to build Mercury in a form
 # that will work with ROTOR.
@@ -424,6 +424,11 @@
 
 #-----------------------------------------------------------------------------#
 
+mercury_dotnet.cs : mercury_dotnet.cs.in
+	(cd ..; ./config.status --file runtime/mercury_dotnet.cs)
+
+#-----------------------------------------------------------------------------#
+
 clean_local: clean_o clean_check
 
 .PHONY: clean_o
@@ -433,7 +438,7 @@
 .PHONY: realclean_local
 realclean_local:
 	rm -f lib$(RT_LIB_NAME).$A lib$(RT_LIB_NAME).so $(RT_LIB_NAME).init
-	rm -f mercury_conf.h mercury_conf.h.date
+	rm -f mercury_conf.h mercury_conf.h.date mercury_dotnet.cs
 	rm -f mercury_profiling_builtin.c mercury_profiling_builtin.h
 
 #-----------------------------------------------------------------------------#
Index: runtime/mercury_mcpp.cs
===================================================================
RCS file: runtime/mercury_mcpp.cs
diff -N runtime/mercury_mcpp.cs
--- runtime/mercury_mcpp.cs	29 Oct 2003 15:00:13 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,155 +0,0 @@
-//
-// Copyright (C) 2003 The University of Melbourne.
-// This file may only be copied under the terms of the GNU Library General
-// Public License - see the file COPYING.LIB in the Mercury distribution.
-//
-
-// mercury_mcpp.cpp - This file defines the system runtime types and
-// methods that are used when generating code for the .NET backend.
-
-// vi: ts=4 sw=4 et tw=0 wm=0
-
-namespace mercury {
-
-namespace runtime {
-
-public class SystemException : System.Exception
-{
-    public SystemException(string Msg) : base(Msg)
-    {
-        // The parent constructor sets the error message that will be printed.
-    }
-}
-
-public class Errors
-{
-    public static void SORRY(string s)
-    {
-        string msg;
-        msg = System.String.Concat("Sorry, unimplemented: ", s);
-        throw new mercury.runtime.SystemException(msg);
-    }
-
-    public static void fatal_error(string s)
-    {
-        string msg;
-        msg = System.String.Concat("Fatal error: ", s);
-        throw new mercury.runtime.SystemException(msg);
-    }
-}
-
-public class Environment
-{
-}
-
-public class Commit : System.Exception
-{
-}
-
-public class Constants
-{
-    // These constants are duplicated in library/private_builtin.m.
-    // They must be kept sychronized.
-
-	// XXX It would be nice if these could be const or an enum, but
-	// there are some problems with accessing the values from IL if we do
-	// that because neither alternatives seem to define field names we
-	// can reference from IL.
-
-    public static int MR_TYPECTOR_REP_ENUM 			= 0;
-    public static int MR_TYPECTOR_REP_ENUM_USEREQ 	= 1;
-    public static int MR_TYPECTOR_REP_DU			= 2;
-    public static int MR_TYPECTOR_REP_DU_USEREQ		= 3;
-    public static int MR_TYPECTOR_REP_NOTAG			= 4;
-    public static int MR_TYPECTOR_REP_NOTAG_USEREQ	= 5;
-    public static int MR_TYPECTOR_REP_EQUIV			= 6;
-    public static int MR_TYPECTOR_REP_FUNC			= 7;
-    public static int MR_TYPECTOR_REP_INT		   	= 8;
-    public static int MR_TYPECTOR_REP_CHAR		   	= 9;
-    public static int MR_TYPECTOR_REP_FLOAT			=10;
-    public static int MR_TYPECTOR_REP_STRING		=11;
-    public static int MR_TYPECTOR_REP_PRED		   	=12;
-    public static int MR_TYPECTOR_REP_SUBGOAL	   	=13;
-    public static int MR_TYPECTOR_REP_VOID		  	=14;
-    public static int MR_TYPECTOR_REP_C_POINTER		=15;
-    public static int MR_TYPECTOR_REP_TYPEINFO		=16;
-    public static int MR_TYPECTOR_REP_TYPECLASSINFO	=17;
-    public static int MR_TYPECTOR_REP_ARRAY			=18;
-    public static int MR_TYPECTOR_REP_SUCCIP		=19;
-    public static int MR_TYPECTOR_REP_HP			=20;
-    public static int MR_TYPECTOR_REP_CURFR			=21;
-    public static int MR_TYPECTOR_REP_MAXFR			=22;
-    public static int MR_TYPECTOR_REP_REDOFR		=23;
-    public static int MR_TYPECTOR_REP_REDOIP		=24;
-    public static int MR_TYPECTOR_REP_TRAIL_PTR		=25;
-    public static int MR_TYPECTOR_REP_TICKET		=26;
-    public static int MR_TYPECTOR_REP_NOTAG_GROUND	=27;
-    public static int MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ	=28;
-    public static int MR_TYPECTOR_REP_EQUIV_GROUND	=29;
-    public static int MR_TYPECTOR_REP_TUPLE			=30;
-    public static int MR_TYPECTOR_REP_RESERVED_ADDR	=31;
-    public static int MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ	=32;
-    public static int MR_TYPECTOR_REP_TYPECTORINFO	        =33;
-    public static int MR_TYPECTOR_REP_BASETYPECLASSINFO     =34;
-    public static int MR_TYPECTOR_REP_TYPEDESC	        	=35;
-    public static int MR_TYPECTOR_REP_TYPECTORDESC	        =36;
-    public static int MR_TYPECTOR_REP_FOREIGN			    =37;
-    public static int MR_TYPECTOR_REP_REFERENCE		        =38;
-    public static int MR_TYPECTOR_REP_STABLE_C_POINTER	    =39;
-    public static int MR_TYPECTOR_REP_UNKNOWN		        =40;
-
-    public static int MR_SECTAG_NONE				= 0;
-    public static int MR_SECTAG_LOCAL				= 1;
-    public static int MR_SECTAG_REMOTE				= 2;
-}
-
-public class LowLevelData
-{
-	// Make a Mercury enumeration with the given integer value.
-    public static object[] make_enum(int enum_value)
-    {
-        object[] e;
-        e = make_MR_Word(enum_value, 0);
-        return e;
-    }
-
-	// Make a MR_Word with the given tag and arity.
-    public static object[] make_MR_Word(int tag, int arity)
-    {
-        object[] o = new object[arity + 1];
-        o[0] = tag;
-        return o;
-    }
-
-	// Set a field of an MR_Word with a given value.
-	// The first field is at index 1.
-    public static void set_MR_Word_field(object[] w, int index, object value)
-    {
-        w[index] = value;
-    }
-
-	// Get the value from an MR_Word.
-	// The first field is at index 1.
-    public static object get_MR_Word_field(object[] w, int index)
-    {
-        return w[index];
-    }
-
-    public static bool list_is_cons(object[] w)
-    {
-	    return (System.Convert.ToInt32(w[0]) != 0);
-    }
-
-    public static object list_get_head(object[] w)
-    {
-        return w[1];
-    }
-
-    public static object[] list_get_tail(object[] w)
-    {
-        return ((object[]) w[2]);
-    }
-}
-
-}
-}

New file: runtime/mercury_dotnet.cs.in
======================================
//
// Copyright (C) 2003 The University of Melbourne.
// This file may only be copied under the terms of the GNU Library General
// Public License - see the file COPYING.LIB in the Mercury distribution.
//

// mercury_dotnet.cs - This file defines the system runtime types and
// methods that are used when generating code for the .NET backend.

namespace mercury {

namespace runtime {

public class SystemException : System.Exception
{
    public SystemException(string Msg) : base(Msg)
    {
        // The parent constructor sets the error message that will be printed.
    }
}

public class Errors
{
    public static void SORRY(string s)
    {
        string msg;
        msg = System.String.Concat("Sorry, unimplemented: ", s);
        throw new mercury.runtime.SystemException(msg);
    }

    public static void fatal_error(string s)
    {
        string msg;
        msg = System.String.Concat("Fatal error: ", s);
        throw new mercury.runtime.SystemException(msg);
    }
}

public class Environment
{
}

public class Commit : System.Exception
{
}

public class Constants
{
    // These constants are duplicated in library/private_builtin.m.
    // They must be kept sychronized.

	// XXX It would be nice if these could be const or an enum, but
	// there are some problems with accessing the values from IL if we do
	// that because neither alternatives seem to define field names we
	// can reference from IL.

    public static int MR_TYPECTOR_REP_ENUM			= 0;
    public static int MR_TYPECTOR_REP_ENUM_USEREQ 		= 1;
    public static int MR_TYPECTOR_REP_DU			= 2;
    public static int MR_TYPECTOR_REP_DU_USEREQ			= 3;
    public static int MR_TYPECTOR_REP_NOTAG			= 4;
    public static int MR_TYPECTOR_REP_NOTAG_USEREQ		= 5;
    public static int MR_TYPECTOR_REP_EQUIV			= 6;
    public static int MR_TYPECTOR_REP_FUNC			= 7;
    public static int MR_TYPECTOR_REP_INT		   	= 8;
    public static int MR_TYPECTOR_REP_CHAR		   	= 9;
    public static int MR_TYPECTOR_REP_FLOAT			=10;
    public static int MR_TYPECTOR_REP_STRING			=11;
    public static int MR_TYPECTOR_REP_PRED		   	=12;
    public static int MR_TYPECTOR_REP_SUBGOAL	   		=13;
    public static int MR_TYPECTOR_REP_VOID		  	=14;
    public static int MR_TYPECTOR_REP_C_POINTER			=15;
    public static int MR_TYPECTOR_REP_TYPEINFO			=16;
    public static int MR_TYPECTOR_REP_TYPECLASSINFO		=17;
    public static int MR_TYPECTOR_REP_ARRAY			=18;
    public static int MR_TYPECTOR_REP_SUCCIP			=19;
    public static int MR_TYPECTOR_REP_HP			=20;
    public static int MR_TYPECTOR_REP_CURFR			=21;
    public static int MR_TYPECTOR_REP_MAXFR			=22;
    public static int MR_TYPECTOR_REP_REDOFR			=23;
    public static int MR_TYPECTOR_REP_REDOIP			=24;
    public static int MR_TYPECTOR_REP_TRAIL_PTR			=25;
    public static int MR_TYPECTOR_REP_TICKET			=26;
    public static int MR_TYPECTOR_REP_NOTAG_GROUND		=27;
    public static int MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ	=28;
    public static int MR_TYPECTOR_REP_EQUIV_GROUND		=29;
    public static int MR_TYPECTOR_REP_TUPLE			=30;
    public static int MR_TYPECTOR_REP_RESERVED_ADDR		=31;
    public static int MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ	=32;
    public static int MR_TYPECTOR_REP_TYPECTORINFO		=33;
    public static int MR_TYPECTOR_REP_BASETYPECLASSINFO		=34;
    public static int MR_TYPECTOR_REP_TYPEDESC			=35;
    public static int MR_TYPECTOR_REP_TYPECTORDESC		=36;
    public static int MR_TYPECTOR_REP_FOREIGN			=37;
    public static int MR_TYPECTOR_REP_REFERENCE			=38;
    public static int MR_TYPECTOR_REP_STABLE_C_POINTER		=39;
    public static int MR_TYPECTOR_REP_UNKNOWN			=40;

    public static int MR_SECTAG_NONE				= 0;
    public static int MR_SECTAG_LOCAL				= 1;
    public static int MR_SECTAG_REMOTE				= 2;

    public static string MR_VERSION	= "@VERSION@";
    public static string MR_FULLARCH	= "@FULLARCH@";
}

public class LowLevelData
{
	// Make a Mercury enumeration with the given integer value.
    public static object[] make_enum(int enum_value)
    {
        object[] e;
        e = make_MR_Word(enum_value, 0);
        return e;
    }

	// Make a MR_Word with the given tag and arity.
    public static object[] make_MR_Word(int tag, int arity)
    {
        object[] o = new object[arity + 1];
        o[0] = tag;
        return o;
    }

	// Set a field of an MR_Word with a given value.
	// The first field is at index 1.
    public static void set_MR_Word_field(object[] w, int index, object value)
    {
        w[index] = value;
    }

	// Get the value from an MR_Word.
	// The first field is at index 1.
    public static object get_MR_Word_field(object[] w, int index)
    {
        return w[index];
    }

    public static bool list_is_cons(object[] w)
    {
	    return (System.Convert.ToInt32(w[0]) != 0);
    }

    public static object list_get_head(object[] w)
    {
        return w[1];
    }

    public static object[] list_get_tail(object[] w)
    {
        return ((object[]) w[2]);
    }
}

}
}

-- 
Peter Ross		
Software Engineer                                (Work)   +32 2 757 10 15
Mission Critical                                 (Mobile) +32 485 482 559
--------------------------------------------------------------------------
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