[m-rev.] diff: work around lcc type error in hlc grades

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 18 21:14:11 AEDT 2002


Estimated hours taken: 1
Branches: main, release

Work around a bug that resulted in a type error in when compiling the stage 1
compiler/recompilation.c with lcc.

compiler/timestamp.m:
	Define the `timestamp' type as a no-tag type rather than an
	abstract equivalence type.  This avoids the problem with abstract
	equivalence types in the hlc back-end.

Workspace: /home/mars/fjh/ws1/mercury
Index: compiler/timestamp.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/timestamp.m,v
retrieving revision 1.5
diff -u -d -r1.5 timestamp.m
--- compiler/timestamp.m	20 Mar 2002 12:37:29 -0000	1.5
+++ compiler/timestamp.m	18 Nov 2002 10:06:09 -0000
@@ -54,29 +54,33 @@
 
 	% A timestamp is a string formatted as "yyyy-mm-dd hh:mm:ss"
 	% representing a time expressed as UTC (Universal Coordinated Time).
-:- type timestamp == string.
+	%
+	% We use a no-tag type rather than an abstract equivalence type
+	% to avoid type errors with abstract equivalence types in the hlc
+	% back-end.
+:- type timestamp ---> timestamp(string).
 
-oldest_timestamp = "0000-00-00 00:00:00".
-newest_timestamp = "9999-99-99 99:99:99".
+oldest_timestamp = timestamp("0000-00-00 00:00:00").
+newest_timestamp = timestamp("9999-99-99 99:99:99").
 
 time_t_to_timestamp(Time) = gmtime_to_timestamp(time__gmtime(Time)).
 
 :- func gmtime_to_timestamp(tm) = timestamp.
 
 gmtime_to_timestamp(tm(Year, Month, MD, Hrs, Min, Sec, YD, WD, DST)) =
-	gmtime_to_timestamp(Year, Month, MD, Hrs, Min, Sec,
-		YD, WD, maybe_dst_to_int(DST)).
+	timestamp(gmtime_to_timestamp_2(Year, Month, MD, Hrs, Min, Sec,
+		YD, WD, maybe_dst_to_int(DST))).
 
-:- func gmtime_to_timestamp(int, int, int, int,
-		int, int, int, int, int) = timestamp.
+:- func gmtime_to_timestamp_2(int, int, int, int,
+		int, int, int, int, int) = string.
 
 :- pragma foreign_decl("C", "
 	#include ""mercury_string.h""
 	#include <time.h>
 ").
 :- pragma foreign_proc("C",
-	gmtime_to_timestamp(Yr::in, Mnt::in, MD::in, Hrs::in, Min::in, Sec::in,
-		YD::in, WD::in, N::in) = (Result::out),
+	gmtime_to_timestamp_2(Yr::in, Mnt::in, MD::in, Hrs::in, Min::in,
+		Sec::in, YD::in, WD::in, N::in) = (Result::out),
 	[will_not_call_mercury, promise_pure],
 "{
 	int size;
@@ -99,7 +103,7 @@
 }").
 
 :- pragma foreign_proc("MC++",
-	gmtime_to_timestamp(_Yr::in, _Mnt::in, _MD::in, _Hrs::in, _Min::in,
+	gmtime_to_timestamp_2(_Yr::in, _Mnt::in, _MD::in, _Hrs::in, _Min::in,
 		_Sec::in, _YD::in, _WD::in, _N::in) = (_Result::out),
 	[will_not_call_mercury, promise_pure],
 "{
@@ -117,9 +121,9 @@
 		N = -1
 	).
 
-timestamp_to_string(Timestamp) = Timestamp.
+timestamp_to_string(timestamp(Timestamp)) = Timestamp.
 
-string_to_timestamp(Timestamp) = Timestamp :-
+string_to_timestamp(Timestamp) = timestamp(Timestamp) :-
 	string__length(Timestamp) `with_type` int =
 		string__length("yyyy-mm-dd hh:mm:ss"),
 

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