[m-dev.] for review: int__xor

Simon Taylor stayl at cs.mu.OZ.AU
Mon Nov 1 12:05:14 AEDT 1999



Estimated hours taken: 0.5

Make `int:^/2' obsolete.

library/int.m:
	Uncomment the `:- pragma obsolete' declaration for `int:^/2'.

NEWS:
	Mention that `int:^/2' is now obsolete.

configure.in:
	Check for `int__xor/2' when checking that
	the current compiler is up-to-date.

compiler/ml_code_gen.m:
	Handle `int__xor/2' as a builtin.

compiler/const_prop.m:
library/string.m:
	Rename calls to `int:^/2' to `int__xor/2'.


Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.185
diff -u -u -r1.185 configure.in
--- configure.in	1999/10/24 08:38:54	1.185
+++ configure.in	1999/10/31 23:22:08
@@ -84,8 +84,8 @@
 		:- implementation.
 		:- import_module int.
 		main --> 
-			% check that we have unchecked_left_shift
-			{ _X = unchecked_left_shift(2,2) },
+			% check that we have int__xor.
+			{ _X = int__xor(2,2) },
 			print("Hello, world\n").
 EOF
 	if
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.149
diff -u -u -r1.149 NEWS
--- NEWS	1999/10/20 03:13:52	1.149
+++ NEWS	1999/11/01 01:01:21
@@ -96,6 +96,9 @@
   and `int:unchecked_right_shift/2' that, like the previous implementations
   of `int:>>/2' and `int:<</2', do not check for these cases.
 
+* `int:^/2' has been replaced by `int__xor/2', and will be removed in
+  a future release. The operator `^' will be used by record syntax.
+
 New library packages in the Mercury extras distribution:
 ********************************************************
 
Index: compiler/const_prop.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/const_prop.m,v
retrieving revision 1.10
diff -u -u -r1.10 const_prop.m
--- const_prop.m	1999/04/23 01:02:35	1.10
+++ const_prop.m	1999/10/31 23:01:27
@@ -244,7 +244,12 @@
 evaluate_builtin_tri("int", "^", 0, X, Y, Z, Z, int_const(ZVal)) :-
 	X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
 	Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
-	ZVal is XVal ^ YVal.
+	ZVal = int__xor(XVal, YVal).
+
+evaluate_builtin_tri("int", "xor", 0, X, Y, Z, Z, int_const(ZVal)) :-
+	X = _XVar - bound(_XUniq, [functor(int_const(XVal), [])]),
+	Y = _YVar - bound(_YUniq, [functor(int_const(YVal), [])]),
+	ZVal = int__xor(XVal, YVal).
 
 	%
 	% float arithmetic
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.10
diff -u -u -r1.10 ml_code_gen.m
--- ml_code_gen.m	1999/10/25 03:49:18	1.10
+++ ml_code_gen.m	1999/11/01 00:52:41
@@ -1355,6 +1355,8 @@
 	no, yes(Z - binop((^), lval(X), lval(Y)))).
 ml_translate_builtin_2("int", "^", 0, [X, Y, Z],
 	no, yes(Z - binop((^), lval(X), lval(Y)))).
+ml_translate_builtin_2("int", "xor", 0, [X, Y, Z],
+	no, yes(Z - binop((^), lval(X), lval(Y)))).
 ml_translate_builtin_2("int", "builtin_unary_plus", 0, [X, Y],
 	no, yes(Y - lval(X))).
 ml_translate_builtin_2("int", "+", 0, [X, Y],
Index: library/int.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/int.m,v
retrieving revision 1.61
diff -u -u -r1.61 int.m
--- int.m	1999/10/26 23:22:21	1.61
+++ int.m	1999/10/31 23:21:33
@@ -163,10 +163,7 @@
 	% is needed for record syntax.
 :- func int ^ int = int.
 :- mode in  ^ in  = uo  is det.
-/***
-XXX this can't be added yet, for bootstrapping reasons
 :- pragma obsolete('^'/2).
-***/
 
 	% bitwise complement
 :- func \ int = int.
@@ -275,8 +272,6 @@
 
 % Most of the arithmetic and comparison operators are recognized by
 % the compiler as builtins, so we don't need to define them here.
-
-:- external(int__xor/2).
 
 X div Y = Div :-
 	Trunc = X // Y,
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.117
diff -u -u -r1.117 string.m
--- string.m	1999/10/15 21:13:42	1.117
+++ string.m	1999/10/31 23:03:06
@@ -752,7 +752,7 @@
 	string__length(String, Length),
 	string__to_int_list(String, CodeList),
 	string__hash_2(CodeList, 0, HashVal0),
-	HashVal is HashVal0 ^ Length.
+	HashVal = int__xor(HashVal0, Length).
 
 :- pred string__hash_2(list(int), int, int).
 :- mode string__hash_2(in, in, out) is det.
@@ -766,9 +766,9 @@
 :- mode string__combine_hash(in, in, out) is det.
 
 string__combine_hash(H0, X, H) :-
-	H1 is H0 << 5,
-	H2 is H1 ^ H0,
-	H is H2 ^ X.
+	H1 = H0 << 5,
+	H2 = int__xor(H1, H0),
+	H = int__xor(H2, X).
 
 %-----------------------------------------------------------------------------%
 
--------------------------------------------------------------------------
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