[m-rev.] diff: .NET backend runtime and library fixes

Tyson Dowd trd at cs.mu.OZ.AU
Thu May 3 01:37:10 AEST 2001


Oops, fired that mail off too soon.

> > Index: library/math.m
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/library/math.m,v
> > retrieving revision 1.27
> > diff -u -r1.27 math.m
> > --- library/math.m	2001/03/15 07:42:23	1.27
> > +++ library/math.m	2001/05/02 13:28:28
> > @@ -307,7 +307,7 @@
> >  :- pragma foreign_proc("MC++", 
> >  	math__ceiling(Num::in) = (Ceil::out),
> >  		[will_not_call_mercury, thread_safe],"
> > -	Ceil = System::Math::Ceil(Num);
> > +	Ceil = System::Math::Ceiling(Num);
> >  ").
> >  
> >  %
> > @@ -360,7 +360,7 @@
> >  	math__truncate(X::in) = (Trunc::out),
> >  		[will_not_call_mercury, thread_safe],"
> >  	if (X < 0.0) {
> > -		Trunc = System::Math::Ceil(X);
> > +		Trunc = System::Math::Ceiling(X);
> >  	} else {
> >  		Trunc = System::Math::Floor(X);
> >  	}
> 
> I thikn it would be better to implement math__truncate in Mercury.


math__truncate(X) = (X < 0.0 -> math__ceiling(X) ; math__floor(X)).

> 
> > Index: runtime/mercury_il.il
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/runtime/mercury_il.il,v
> > retrieving revision 1.3
> > diff -u -r1.3 mercury_il.il
> > --- runtime/mercury_il.il	2001/01/22 04:20:40	1.3
> > +++ runtime/mercury_il.il	2001/05/02 13:28:40
> > @@ -11,11 +11,16 @@
> >  
> >  // Declare the assemblies we use
> >  
> > -.assembly extern mercury { }
> > -
> > -.assembly extern 'mercury_mcpp' { }
> > +.assembly extern 'mercury'{
> > +	.ver 0:0:0:0
> > +	.publickeytoken = ( 22 8C 16 7D 12 AA B B ) 
> > +}
> 
> You should document where those magic numbers came from.

Done now.

> 
> > -.assembly extern 'mercury.io' { }
> > +.assembly extern 'mscorlib'{
> > +	.ver 1:0:2411:0
> > +	.publickeytoken = ( B7 7A 5C 56 19 34 E0 89 ) 
> > +	.hash = ( B0 73 F2 4C 14 39 A 35 25 EA 45 F 60 58 C3 84 E0 3B E0 95 ) 
> > +}
> 
> Likewise.
> 
> > Index: runtime/mercury_mcpp.cpp
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/runtime/mercury_mcpp.cpp,v
> > retrieving revision 1.4
> > diff -u -r1.4 mercury_mcpp.cpp
> > --- runtime/mercury_mcpp.cpp	2001/01/22 04:20:41	1.4
> > +++ runtime/mercury_mcpp.cpp	2001/05/02 13:28:40
> > @@ -30,7 +30,7 @@
> >  {
> >  public:
> >  	// XXX there should be a Mercury object here.
> > -    Exception(MR_String Msg) : Exception(Msg)
> > +    Exception(MR_String Msg)
> 
> Shouldn't that be
> 
>     Exception(MR_String Msg) : System::Exception(Msg)
> 
> ?

That's what I ended up commiting.

I also fixed the reference to hard-coded places which need to be updated
if the key changes to include runtime/mercury_il.il.

Here's the diff:

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


Estimated hours taken: 0.5
Branches: main

Make changes to .NET backend fixes that fjh suggested in review.

library/.cvsignore:
	Remove *.cpp and *.il, add *__c_code.cpp.

library/Mmakefile:
library/exception.m:
runtime/mercury_il.il:
	Add some comments.

library/math.m:
	Reimplement math__truncate in Mercury.


Index: library/.cvsignore
===================================================================
RCS file: /home/mercury1/repository/mercury/library/.cvsignore,v
retrieving revision 1.17
diff -u -r1.17 .cvsignore
--- library/.cvsignore	2001/05/02 14:44:24	1.17
+++ library/.cvsignore	2001/05/02 15:34:55
@@ -24,7 +24,6 @@
 Mercury
 *.ilk
 *.pdb
-*.cpp
+*__c_code.cpp
 *.dll
-*.il
 libmer_std.lib
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.61
diff -u -r1.61 Mmakefile
--- library/Mmakefile	2001/05/02 14:44:24	1.61
+++ library/Mmakefile	2001/05/02 15:34:55
@@ -86,6 +86,7 @@
 			$(INTERMODULE_OPTS) $(CHECK_TERM_OPTS)
 MGNUC	=	$(M_ENV) $(SCRIPTS_DIR)/mgnuc
 MGNUCFLAGS =	$(DLL_CFLAGS)
+	# -AI sets the assembly search path (just like -I for assemblies)
 MS_CLFLAGS  =	-AI$(RUNTIME_DIR) -I$(RUNTIME_DIR)
 MS_CL_NOASM=:noAssembly
 LDFLAGS	=	-L$(BOEHM_GC_DIR) -L$(RUNTIME_DIR)
@@ -244,6 +245,10 @@
 EMBED_ALL_DLLS = $(foreach dll_name,$(ALL_DLLS_BASE),$(EMBED_ONE_DLL))
 EMBED_ONE_DLL  = /embed:$(dll_name).dll,$(dll_name)
 
+# For the moment we generate the library using one big DLL, as there are bugs
+# in the assembly cache installer (gacutil) that prevent us from installing
+# large numbers of assemblies.  The HACK_* versions of the variables implement
+# the big file hack.
 HACK_ALL_DLLS=$(CPP_DLLS) mercury_all.dll $(RUNTIME_DLLS)
 
 HACK_ALL_DLLS_BASE  = $(HACK_ALL_DLLS:%.dll=%)
@@ -254,18 +259,17 @@
 #MS_ILASMFLAGS = /debug
 
 
-# If you do generate a new strong name, you had better update the compiler
-# to generate references to it.  This is sub-optimal -- the compiler should
-# automatically find out what the strong name is.
+# If you do generate a new strong name, you had better update
+# compiler/mlds_to_il.m to generate references to it.  It is also hard-coded
+# in runtime/mercury_il.il.
+# This is hard-coding is sub-optimal -- the compiler should automatically find
+# out what the strong name is.
 library_strong_name.sn:
 	sn -k library_strong_name.sn
 
 mercury_all.il: $(library.ils)
 	cat $(library.ils) > mercury_all.il	
 
-# For the moment we do this using one big DLL, as there are bugs in the
-# assembly cache installer (gacutil) that prevent us from installing large
-# numbers of assemblies.
 mercury.dll: $(HACK_ALL_DLLS) mercury_all.dll library_strong_name.sn
 	$(MS_AL) -v:0.0.0.0 -keyf:library_strong_name.sn -out:mercury.dll $(HACK_ALL_DLLS)
 
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.46
diff -u -r1.46 exception.m
--- library/exception.m	2001/05/02 14:44:25	1.46
+++ library/exception.m	2001/05/02 15:34:57
@@ -308,6 +308,8 @@
 	** The constants in these #defines must be in the same
 	** order as the functors in the Mercury type `determinism'
 	** defined above.
+	** XXX It would be nice to use an enum here, but at the moment
+	** I can't convince the MC++ compiler to accept the syntax for it.
 	*/
 
 #define ML_DET	0
Index: library/math.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/math.m,v
retrieving revision 1.28
diff -u -r1.28 math.m
--- library/math.m	2001/05/02 14:44:27	1.28
+++ library/math.m	2001/05/02 15:34:57
@@ -347,24 +347,7 @@
 % math__truncate(X) = Trunc is true if Trunc is the integer
 % closest to X such that |Trunc| =< |X|.
 %
-:- pragma foreign_proc("C",
-	math__truncate(X::in) = (Trunc::out),
-		[will_not_call_mercury, thread_safe],"
-	if (X < 0.0) {
-		Trunc = ceil(X);
-	} else {
-		Trunc = floor(X);
-	}
-").
-:- pragma foreign_proc("MC++",
-	math__truncate(X::in) = (Trunc::out),
-		[will_not_call_mercury, thread_safe],"
-	if (X < 0.0) {
-		Trunc = System::Math::Ceiling(X);
-	} else {
-		Trunc = System::Math::Floor(X);
-	}
-").
+math__truncate(X) = (X < 0.0 -> math__ceiling(X) ; math__floor(X)).
 
 %
 % math__sqrt(X) = Sqrt is true if Sqrt is the positive square
Index: runtime/mercury_il.il
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_il.il,v
retrieving revision 1.4
diff -u -r1.4 mercury_il.il
--- runtime/mercury_il.il	2001/05/02 14:44:31	1.4
+++ runtime/mercury_il.il	2001/05/02 15:34:58
@@ -12,13 +12,22 @@
 // Declare the assemblies we use
 
 .assembly extern 'mercury'{
+	// The version number (we don't really use this at the moment)
 	.ver 0:0:0:0
+
+	// The publickeytoken specifies the public key used to sign the
+	// mercury assembly.  You can retrieve this number using ildasm
+	// or gacutil, or the System.Reflection API.
 	.publickeytoken = ( 22 8C 16 7D 12 AA B B ) 
 }
 
 .assembly extern 'mscorlib'{
 	.ver 1:0:2411:0
 	.publickeytoken = ( B7 7A 5C 56 19 34 E0 89 ) 
+
+	// The hash is the crytographic hash of the contents of the assembly
+	// ildasm will tell you what this number is (and probably the
+	// reflection API).
 	.hash = ( B0 73 F2 4C 14 39 A 35 25 EA 45 F 60 58 C3 84 E0 3B E0 95 ) 
 }
 



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