[m-dev.] diff: add cons_id_maybe_arity

Peter Ross peter.ross at miscrit.be
Thu Mar 1 23:53:29 AEDT 2001


Hi,


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


Estimated hours taken: 0.1
Branches: main

Merge changes from reuse branch to main branch.

compiler/hlds_data.m:
    Add the predicate cons_id_maybe_arity.


Index: hlds_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_data.m,v
retrieving revision 1.52
diff -u -r1.52 hlds_data.m
--- hlds_data.m	2000/12/06 06:05:00	1.52
+++ hlds_data.m	2001/03/01 12:50:17
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1996-2000 The University of Melbourne.
+% Copyright (C) 1996-2001 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -123,6 +123,12 @@
 :- pred cons_id_arity(cons_id, arity).
 :- mode cons_id_arity(in, out) is det.
 
+	% Get the arity of a cons_id. Return a `no' on those cons_ids
+	% where cons_id_arity/2 would normally abort. 
+
+:- pred cons_id_maybe_arity(cons_id, maybe(arity)).
+:- mode cons_id_maybe_arity(in, out) is det.
+
 	% The reverse conversion - make a cons_id for a functor.
 	% Given a const and an arity for the functor, create a cons_id.
 
@@ -181,6 +187,16 @@
 	error("cons_id_arity: can't get arity of base_typeclass_info_const").
 cons_id_arity(tabling_pointer_const(_, _), _) :-
 	error("cons_id_arity: can't get arity of tabling_pointer_const").
+
+cons_id_maybe_arity(cons(_, Arity), yes(Arity)).
+cons_id_maybe_arity(int_const(_), yes(0)).
+cons_id_maybe_arity(string_const(_), yes(0)).
+cons_id_maybe_arity(float_const(_), yes(0)).
+cons_id_maybe_arity(pred_const(_, _, _), no) .
+cons_id_maybe_arity(code_addr_const(_, _), no).
+cons_id_maybe_arity(type_ctor_info_const(_, _, _), no) .
+cons_id_maybe_arity(base_typeclass_info_const(_, _, _, _), no).
+cons_id_maybe_arity(tabling_pointer_const(_, _), no).
 
 make_functor_cons_id(term__atom(Name), Arity,
 		cons(unqualified(Name), Arity)).

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