[m-rev.] enable handling noncanonical types for rtti_implementation.

Peter Ross peter.ross at miscrit.be
Sat Nov 30 19:04:14 AEDT 2002


Hi,


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


Estimated hours taken: 1
Branches: main

library/rtti_implementation.m:
library/deconstruct.m:
	Add the ability to handle noncanonical types.

library/deconstruct.m:
	Note that the cc_nondet modes of limited_deconstruct_idcc of
	univ_arg_idcc are incorrect.  These two predicates need to be
	altered so that they return maybe(result) so that we can make
	them cc_multi.

Index: library/deconstruct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/deconstruct.m,v
retrieving revision 1.14
diff -u -r1.14 deconstruct.m
--- library/deconstruct.m	2 Sep 2002 05:48:05 -0000	1.14
+++ library/deconstruct.m	30 Nov 2002 07:57:55 -0000
@@ -408,16 +408,15 @@
 #undef	NONCANON
 }").
 
-functor_dna(_Term::in, _Functor::out, _Arity::out) :-
-	% This version is only used for back-ends for which there is no
-	% matching foreign_proc version.
-	private_builtin__sorry("deconstruct__functor_dna/3").
+functor_dna(Term::in, Functor::out, Arity::out) :-
+	rtti_implementation__deconstruct(Term,
+			do_not_allow, Functor, Arity, _Arguments).
 functor_can(Term::in, Functor::out, Arity::out) :-
-	rtti_implementation__deconstruct(Term, Functor, Arity, _Arguments).
-functor_idcc(_Term::in, _Functor::out, _Arity::out) :-
-	% This version is only used for back-ends for which there is no
-	% matching foreign_proc version.
-	private_builtin__sorry("deconstruct__functor_idcc/3").
+	rtti_implementation__deconstruct(Term,
+			canonicalize, Functor, Arity, _Arguments).
+functor_idcc(Term::in, Functor::out, Arity::out) :-
+	rtti_implementation__deconstruct(Term,
+			include_details_cc, Functor, Arity, _Arguments).
 
 %-----------------------------------------------------------------------------%
 
@@ -553,17 +552,18 @@
 #undef	SELECT_BY_NAME
 }").
 
-univ_arg_dna(_Term::in, _Index::in, _Arg::out) :-
-	% This version is only used for back-ends for which there is no
-	% matching foreign_proc version.
-	private_builtin__sorry("deconstruct__univ_arg_dna/3").
+univ_arg_dna(Term::in, Index::in, Arg::out) :-
+	rtti_implementation__deconstruct(Term,
+			do_not_allow, _Functor, _Arity, Arguments),
+	list__index0(Arguments, Index, Arg).
 univ_arg_can(Term::in, Index::in, Arg::out) :-
-	rtti_implementation__deconstruct(Term, _Functor, _Arity, Arguments),
+	rtti_implementation__deconstruct(Term,
+			canonicalize, _Functor, _Arity, Arguments),
 	list__index0(Arguments, Index, Arg).
 univ_arg_idcc(_Term::in, _Index::in, _Arg::out) :-
 	% This version is only used for back-ends for which there is no
 	% matching foreign_proc version.
-	private_builtin__sorry("deconstruct__univ_arg_idcc/3").
+	private_builtin__sorry("univ_arg_idcc/3").
 
 univ_named_arg_dna(_Term::in, _Name::in, _Arg::out) :-
 	% This version is only used for back-ends for which there is no
@@ -739,31 +739,31 @@
 #undef	NONCANON
 }").
 
-deconstruct_dna(_Term::in, _Functor::out, _Arity::out, _Arguments::out) :-
-	% This version is only used for back-ends for which there is no
-	% matching foreign_proc version.
-	private_builtin__sorry("deconstuct__deconstruct_dna/4").
+deconstruct_dna(Term::in, Functor::out, Arity::out, Arguments::out) :-
+	rtti_implementation__deconstruct(Term,
+			do_not_allow, Functor, Arity, Arguments).
 deconstruct_can(Term::in, Functor::out, Arity::out, Arguments::out) :-
-	rtti_implementation__deconstruct(Term, Functor, Arity, Arguments).
-deconstruct_idcc(_Term::in, _Functor::out, _Arity::out, _Arguments::out) :-
-	% This version is only used for back-ends for which there is no
-	% matching foreign_proc version.
-	private_builtin__sorry("deconstuct__deconstruct_idcc/4").
+	rtti_implementation__deconstruct(Term,
+			canonicalize, Functor, Arity, Arguments).
+deconstruct_idcc(Term::in, Functor::out, Arity::out, Arguments::out) :-
+	rtti_implementation__deconstruct(Term,
+			include_details_cc, Functor, Arity, Arguments).
 
-limited_deconstruct_dna(_Term::in, _MaxArity::in,
-		_Functor::out, _Arity::out, _Arguments::out) :-
-	% This version is only used for back-ends for which there is no
-	% matching foreign_proc version.
-	private_builtin__sorry("deconstuct__limited_deconstruct_dna/5").
+limited_deconstruct_dna(Term::in, MaxArity::in,
+		Functor::out, Arity::out, Arguments::out) :-
+	rtti_implementation__deconstruct(Term,
+			do_not_allow, Functor, Arity, Arguments),
+	Arity =< MaxArity.
 limited_deconstruct_can(Term::in, MaxArity::in,
 		Functor::out, Arity::out, Arguments::out) :-
-	rtti_implementation__deconstruct(Term, Functor, Arity, Arguments),
+	rtti_implementation__deconstruct(Term,
+			canonicalize, Functor, Arity, Arguments),
 	Arity =< MaxArity.
 limited_deconstruct_idcc(_Term::in, _MaxArity::in,
 		_Functor::out, _Arity::out, _Arguments::out) :-
 	% This version is only used for back-ends for which there is no
 	% matching foreign_proc version.
-	private_builtin__sorry("deconstuct__limited_deconstruct_idcc/5").
+	private_builtin__sorry("limited_deconstruct_idcc/5").
 
 %-----------------------------------------------------------------------------%
 
Index: library/rtti_implementation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/rtti_implementation.m,v
retrieving revision 1.31
diff -u -r1.31 rtti_implementation.m
--- library/rtti_implementation.m	29 Nov 2002 16:30:57 -0000	1.31
+++ library/rtti_implementation.m	30 Nov 2002 07:57:55 -0000
@@ -29,7 +29,7 @@
 
 :- interface.
 
-:- import_module list.
+:- import_module deconstruct, list.
 
 :- use_module std_util.
 
@@ -54,8 +54,11 @@
 :- pred type_ctor_name_and_arity(type_ctor_info::in,
 		string::out, string::out, int::out) is det.
 
-:- pred deconstruct(T::in, string::out, int::out,
-		list(std_util__univ)::out) is det.
+:- pred deconstruct(T, noncanon_handling, string, int, list(std_util__univ)).
+:- mode deconstruct(in, in(do_not_allow), out, out, out) is det.
+:- mode deconstruct(in, in(canonicalize), out, out, out) is det.
+:- mode deconstruct(in, in(include_details_cc), out, out, out) is cc_multi.
+:- mode deconstruct(in, in, out, out, out) is cc_multi.
 
 	% This is useful in a few places, so we'd like to share the code, but
 	% it's better to put it into an implementation module such as this one.
@@ -66,7 +69,6 @@
 
 :- implementation.
 
-:- import_module deconstruct.
 :- import_module bool, require, string, int.
 
 	% std_util has a lot of types and functions with the same names,
@@ -626,12 +628,12 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
-deconstruct(Term, Functor, Arity, Arguments) :-
+deconstruct(Term, NonCanon, Functor, Arity, Arguments) :-
 	TypeInfo = get_type_info(Term),
 	TypeCtorInfo = get_type_ctor_info(TypeInfo),
 	TypeCtorRep = type_ctor_rep(TypeCtorInfo),
 	deconstruct(Term, TypeInfo, TypeCtorInfo, TypeCtorRep,
-			canonicalize, Functor, Arity, Arguments).
+			NonCanon, Functor, Arity, Arguments).
 
 :- pred deconstruct(T, type_info, type_ctor_info, type_ctor_rep,
 		noncanon_handling, string, int, list(std_util__univ)).

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