[m-rev.] For review: pretty print c_pointers as addresses

Ian MacLarty maclarty at csse.unimelb.edu.au
Tue Aug 15 10:44:13 AEST 2006


On Mon, Aug 14, 2006 at 05:38:24PM +1000, Ralph Becket wrote:
> 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;
> +").
> +

I think it should be a cc_multi predicate, not impure.

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