[m-dev.] [reuse] for review: compare and unify for univ
Peter Ross
Peter.Ross at cs.kuleuven.ac.be
Fri Oct 13 01:50:14 AEDT 2000
Hi,
For Fergus or Tyson to review.
I implemented these quickly, so that we can test out structure reuse on
the icfp 2000 entry.
The only issue I have is that I don't think that the arguments are boxed
correctly when calling the generic compare/unify predicates, but it
seems to work for the icfp 2000 entry. Anyway review away and I will
commit on the main branch if it is correct.
Pete
===================================================================
Estimated hours taken: 2
mercury.c:
Implement compare and unify for the univ type.
Index: mercury.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.c,v
retrieving revision 1.10.2.1
diff -u -r1.10.2.1 mercury.c
--- mercury.c 2000/09/25 17:08:53 1.10.2.1
+++ mercury.c 2000/10/12 14:44:17
@@ -442,7 +442,24 @@
bool
mercury__std_util____Unify____univ_0_0(MR_Univ x, MR_Univ y)
{
- SORRY("unify for univ");
+#ifdef MR_HIGHLEVEL_DATA
+ SORRY("unify for highlevel data univ");
+#else
+ MR_TypeInfo typeinfo_x, typeinfo_y;
+ MR_Word value_x, value_y;
+ int comp;
+
+ MR_unravel_univ(x, typeinfo_x, value_x);
+ MR_unravel_univ(y, typeinfo_y, value_y);
+
+ comp = MR_compare_type_info(typeinfo_x, typeinfo_y);
+
+ if (comp != MR_COMPARE_EQUAL) {
+ return FALSE;
+ }
+
+ return mercury__builtin__unify_2_p_0(typeinfo_x, value_x, value_y);
+#endif
}
bool
@@ -593,7 +610,25 @@
mercury__std_util____Compare____univ_0_0(MR_Comparison_Result *result,
MR_Univ x, MR_Univ y)
{
- SORRY("compare for univ");
+#ifdef MR_HIGHLEVEL_DATA
+ SORRY("compare for highlevel data univ");
+#else
+ MR_TypeInfo typeinfo_x, typeinfo_y;
+ MR_Word value_x, value_y;
+ int comp;
+
+ MR_unravel_univ(x, typeinfo_x, value_x);
+ MR_unravel_univ(y, typeinfo_y, value_y);
+
+ comp = MR_compare_type_info(typeinfo_x, typeinfo_y);
+
+ if (comp != MR_COMPARE_EQUAL) {
+ return comp;
+ }
+
+ return mercury__builtin__compare_3_p_0(typeinfo_x, result,
+ value_x, value_y);
+#endif
}
void
--------------------------------------------------------------------------
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