[m-rev.] diff: throw error on comparison or unification of foreign type

Peter Ross peter.ross at miscrit.be
Tue Feb 12 22:46:53 AEDT 2002


Hi,


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


Estimated hours taken: 3
Branches: main

Throw an error if a program attempts to unify or compare a foreign_type
rather than silently ignoring it as is done now.

compiler/unify_proc.m:
    Call nyi_foreign_type_unify and nyi_foreign_type_unify for the unify
    and compare predicates of a foreign_type.

library/private_builtin.m:
    Add nyi_foreign_type_unify and nyi_foreign_type_compare.


Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.102
diff -u -r1.102 unify_proc.m
--- compiler/unify_proc.m	11 Feb 2002 05:02:16 -0000	1.102
+++ compiler/unify_proc.m	12 Feb 2002 11:29:27 -0000
@@ -130,6 +130,7 @@
 :- import_module modes, mode_util, inst_match, instmap, (inst).
 :- import_module switch_detection, cse_detection, det_analysis, unique_modes.
 :- import_module recompilation.
+:- import_module goal_util.
 
 :- import_module tree, map, set, queue, int, string, require, assoc_list.
 
@@ -755,12 +756,8 @@
 			Clauses)
 	;
 		{ TypeBody = foreign_type(_, _, _) },
-			% XXX Is this the correct thing to do?
-			% I assume at code gen time I could examine the types
-			% of the unification and output different code because
-			% they are foreign types.
-		{ create_atomic_unification(H1, var(H2), Context, explicit, [],
-			Goal) },
+		unify_proc__build_call("nyi_foreign_type_unify", [H1, H2],
+				Context, Goal),
 		unify_proc__quantify_clauses_body([H1, H2], Goal, Context,
 			Clauses)
 	;
@@ -898,12 +895,9 @@
 			Clauses)
 	;
 		{ TypeBody = foreign_type(_, _, _) },
-		% XXX
-		% I think we should delay handling this for foreign types until
-		% code gen time.
-		{ ArgVars = [Res, H1, H2] },
-		unify_proc__build_call("compare", ArgVars, Context, Goal),
-		unify_proc__quantify_clauses_body(ArgVars, Goal, Context,
+		unify_proc__build_call("nyi_foreign_type_compare",
+				[Res, H1, H2], Context, Goal),
+		unify_proc__quantify_clauses_body([Res, H1, H2], Goal, Context,
 			Clauses)
 	;
 		{ TypeBody = uu_type(_) },
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.96
diff -u -r1.96 private_builtin.m
--- library/private_builtin.m	5 Feb 2002 16:30:06 -0000	1.96
+++ library/private_builtin.m	12 Feb 2002 11:29:31 -0000
@@ -1430,6 +1430,9 @@
 
 	% N.B. interface continued below.
 
+:- pred nyi_foreign_type_unify(T::in, T::in) is semidet.
+:- pred nyi_foreign_type_compare(comparison_result::uo, T::in, T::in) is det.
+
 :- implementation.
 
 % unsafe_type_cast is a builtin; the compiler generates inline code for it
@@ -1440,6 +1443,20 @@
 	;
 		% the following is never executed
 		true
+	).
+
+nyi_foreign_type_unify(_, _) :-
+	( semidet_succeed ->
+		sorry("unify for foreign types")
+	;
+		semidet_succeed
+	).
+
+nyi_foreign_type_compare(Result, _, _) :-
+	( semidet_succeed ->
+		sorry("compare for foreign types")
+	;
+		Result = (=)
 	).
 
 %-----------------------------------------------------------------------------%

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