[m-dev.] samples/calculator on .NET

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jul 29 04:33:28 AEST 2001


On 26-Jul-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> Simplify boxing, unboxing and casts in the IL backend.
> 
> compiler/mlds_to_il.m:
> 	Previously we generated calls to out-of-line procedures written
> 	in C++ (and then they forwarded to ones written in IL) for
> 	various reasons mostly to do with churn of the .NET
> 	implementation of boxing.
> 
> 	Now we generate much better code:
> 		- "unbox" and "ldobj" for unboxing
> 		- "box" for boxing
> 		- "castclass" for casts between reference types
> 		- nothing for casts to the same type
> 		- for casting from mercury types to value types we
> 		  unload from the MR_Word, and unbox the value
> 
> 	The last item fixes a bug where unification for characters
> 	wasn't working as it was being passed as an MR_Word, and was not
> 	being unpacked correctly.  This means samples/calculator.m now
> 	works (modulo cygwin not passing EOF correctly at the moment).

What's the issue with EOF?

Cygwin handles EOF fine, AFAIK.  Note that the EOF character is control-Z
not control-D.

Last time I looked there was an issue with the input containing carriage returns.
But that is a bug in our implementation of the Mercury I/O library for .NET,
not a problem with Cygwin, I'm pretty sure.

I have been using the following patch to work around it.

Index: calculator.m
===================================================================
RCS file: /home/mercury1/repository/mercury/samples/calculator.m,v
retrieving revision 1.9
diff -u -d -u -r1.9 calculator.m
--- calculator.m	3 Feb 2000 05:13:09 -0000	1.9
+++ calculator.m	28 Jul 2001 18:31:57 -0000
@@ -32,7 +32,8 @@
 	; { Res = eof },
 		io__write_string("EOF\n")
 	; { Res = ok(Line0) },
-		{ list__delete_all(Line0, ' ', Line) },
+		{ list__delete_all(Line0, ' ', Line1) },
+		{ list__delete_all(Line1, '\r', Line) },
 		( { fullexpr(X,Line,[]) } ->
 			{ Num = evalexpr(X) },
 			io__write_int(Num),

-- 
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-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list