[m-rev.] diff: fix exported foreign type bug
Simon Taylor
stayl at cs.mu.OZ.AU
Tue May 13 16:20:16 AEST 2003
Estimated hours taken: 0.25
Branches: main
compiler/mercury_to_mercury.m:
Fix syntax errors in the `.int' files for foreign types
with user-defined equality.
tests/valid/Mmakefile:
tests/valid/exported_foreign_type{,2}.m:
Test case.
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.227
diff -u -u -r1.227 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m 15 Mar 2003 03:08:58 -0000 1.227
+++ compiler/mercury_to_mercury.m 13 May 2003 01:44:37 -0000
@@ -567,12 +567,6 @@
{ construct_qualified_term(MercuryTypeSymName,
MercuryTypeArgs, MercuryType) },
mercury_output_term(MercuryType, TVarSet, no),
- ( { MaybeEqCompare = yes(_) } ->
- io__write_string(" ")
- ;
- []
- ),
- mercury_output_equality_compare_preds(MaybeEqCompare),
io__write_string(", \""),
{ ForeignType = il(il(RefOrVal,
ForeignLocStr, ForeignTypeName)),
@@ -588,7 +582,14 @@
; ForeignType = java(java(ForeignTypeStr))
},
io__write_string(ForeignTypeStr),
- io__write_string("\").\n")
+ io__write_string("\")"),
+ ( { MaybeEqCompare = yes(_) } ->
+ io__write_string(" ")
+ ;
+ []
+ ),
+ mercury_output_equality_compare_preds(MaybeEqCompare),
+ io__write_string(".\n")
;
{ Pragma = import(Pred, PredOrFunc, ModeList, Attributes,
C_Function) },
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.127
diff -u -u -r1.127 Mmakefile
--- tests/valid/Mmakefile 13 Mar 2003 11:53:36 -0000 1.127
+++ tests/valid/Mmakefile 13 May 2003 01:47:28 -0000
@@ -73,6 +73,7 @@
error \
existential_cons \
explicit_quant \
+ exported_foreign_type \
fail_ite \
followcode_det_problem \
big_foreign_type \
Index: tests/valid/exported_foreign_type.m
===================================================================
RCS file: tests/valid/exported_foreign_type.m
diff -N tests/valid/exported_foreign_type.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/valid/exported_foreign_type.m 13 May 2003 01:48:06 -0000
@@ -0,0 +1,4 @@
+:- module exported_foreign_type.
+:- interface.
+:- import_module exported_foreign_type2.
+:- type t2 == t.
Index: tests/valid/exported_foreign_type2.m
===================================================================
RCS file: tests/valid/exported_foreign_type2.m
diff -N tests/valid/exported_foreign_type2.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/valid/exported_foreign_type2.m 13 May 2003 02:43:15 -0000
@@ -0,0 +1,24 @@
+:- module exported_foreign_type2.
+:- interface.
+
+:- type t ---> t(int).
+:- pragma foreign_type("C", t, "int") where equality is int_equals, comparison is int_compare.
+
+:- pred int_equals(t::in, t::in) is semidet.
+:- pred int_compare(comparison_result::uo, t::in, t::in) is det.
+
+:- implementation.
+:- import_module int.
+
+:- pragma foreign_proc("C", int_equals(T1::in, T2::in), [promise_pure],
+"SUCCESS_INDICATOR = (T1 == T2);").
+
+int_compare((Res < 0 -> (<) ; Res = 0 -> (=) ; (>)), T1, T2) :-
+ int_compare_2(Res, T1, T2).
+
+:- pred int_compare_2(int::out, t::in, t::in) is det.
+
+:- pragma foreign_proc("C",
+ int_compare_2(Result::out, T1::in, T2::in), [promise_pure],
+"Result = (T1 < T2) ? -1 : ((T1 == T2) ? 0 : 1);").
+
--------------------------------------------------------------------------
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