diff: extend support for `any' insts

Fergus Henderson fjh at murlibobo.cs.mu.OZ.AU
Tue Sep 16 06:07:36 AEST 1997


Oh, I missed one bit.

Extend the support for `any' insts.

compiler/inst_match.m:
	Allow `any' insts to be passed where `free' insts are expected.
	Now that we support unification of `any's, this is just an
	ordinary case of implied modes.

extras/clpr/samples/tests.m:
	Add some test cases for this group of changes.

extras/clpr/samples/tranny.m:
	Simplify the code slightly: use head unification rather than
	an explicit call to `=='.

Index: inst_match.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/inst_match.m,v
retrieving revision 1.35
diff -u -u -r1.35 inst_match.m
--- 1.35	1997/09/15 13:47:05
+++ inst_match.m	1997/09/15 19:32:22
@@ -283,8 +283,8 @@
 
 inst_matches_initial_3(any(UniqA), any(UniqB), _, _) :-
 	unique_matches_initial(UniqA, UniqB).
-/* not yet:
 inst_matches_initial_3(any(_), free, _, _).
+/* not yet:
 inst_matches_initial_3(free, any(_), _, _).
 */
 inst_matches_initial_3(free, free, _, _).
cvs diff: Diffing .
Index: tests.m
===================================================================
RCS file: /home/mercury1/repository/clpr/samples/tests.m,v
retrieving revision 1.1
diff -u -u -r1.1 tests.m
--- 1.1	1997/09/15 08:55:22
+++ tests.m	1997/09/15 19:57:18
@@ -8,7 +8,7 @@
 
 :- implementation.
 :- import_module cfloat, cfloat_float, float_cfloat, dump.
-:- import_module require, int.
+:- import_module require, int, std_util.
 
 main -->
 	print("test_delaying_1: "),
@@ -76,3 +76,24 @@
 create_unsolvable_delayed_goal(X) :-
 	sin(X) == cos(X) + 42.0.
 
+
+
+% :- mode test_modes_1.  (not yet supported)
+test_modes_1 :-
+	% test auto-initialize (implied free -> any)
+	p(_),
+	p2(_).
+
+:- mode test_modes_2(in(any)).
+test_modes_2(X) :-
+	% test implied mode
+	q(X).
+
+:- mode p(any -> any) is semidet.
+p(_) :- semidet_succeed.
+
+:- mode p2(any -> ground) is failure.
+p2(_) :- fail.
+
+:- mode q(free -> any) is det.
+q(X) :- cfloat__init(X).
Index: tranny.m
===================================================================
RCS file: /home/mercury1/repository/clpr/samples/tranny.m,v
retrieving revision 1.3
diff -u -u -r1.3 tranny.m
--- 1.3	1997/09/15 12:51:03
+++ tranny.m	1997/09/15 13:39:34
@@ -165,7 +165,7 @@
 	is semidet.
 component_ss(resistor(_,R),[V1,V2],[I,-I],Cc,Cc):- 
 	V1 - V2 = R * I.
-component_ss(capacitor(_),[V1,V2],[I,-I],Cc,Cc) :- V1 == V2.
+component_ss(capacitor(_),[V,V],[I,-I],Cc,Cc).
 component_ss(transistor(_,info(npn, _Code, active, Mean, _, _)), 
 			[Vb,_Vc,Ve], [Ib,Ic,Ie],[Icol|CC],CC):- 
 	Mean = data(Beta,_,_,Vt), 



More information about the developers mailing list