[m-rev.] For review: pretty print c_pointers as addresses
Ralph Becket
rafe at csse.unimelb.edu.au
Mon Aug 14 17:38:24 AEST 2006
Branches: main
Estimated hours taken: 0.2
library/pprint.m:
Pretty print c_pointers as "<<0xADDRESS>>" rather than just
"<<c_pointer>>". This allows us to distinguish between different
C pointers.
Index: library/pprint.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/pprint.m,v
retrieving revision 1.22
diff -u -r1.22 pprint.m
--- library/pprint.m 19 Apr 2006 05:17:54 -0000 1.22
+++ library/pprint.m 14 Aug 2006 07:32:48 -0000
@@ -806,7 +806,10 @@
then
- text(Name)
+ ( if Name = "<<c_pointer>>"
+ then text(string.format("<<0x%x>>", [i(c_pointer_addr(X))]))
+ else text(Name)
+ )
else
@@ -818,6 +821,18 @@
)
).
+
+% This really should be impure...
+%
+:- func c_pointer_addr(T) = int.
+
+:- pragma foreign_proc("C",
+ c_pointer_addr(X::in) = (Addr::out),
+ [promise_pure, will_not_call_mercury, will_not_modify_trail],
+"
+ Addr = (MR_Integer) X;
+").
+
%-----------------------------------------------------------------------------%
% We need to put parentheses around a subterm if its top-level
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list