[m-rev.] diff: RTTI for erlang dummy types
Peter Ross
pro at missioncriticalit.com
Tue Jun 5 18:00:24 AEST 2007
Hi,
===================================================================
Estimated hours taken: main
Branches: 2
Handle dummy types in the RTTI.
compiler/erl_rtti.m:
Output the RTTI for dummy types.
compiler/erlang_rtti.m:
Add the dummy alternative.
library/erlang_rtti_implementation.m:
Handle dummy types in deconstruct.
Index: compiler/erl_rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/erl_rtti.m,v
retrieving revision 1.10
diff -u -r1.10 erl_rtti.m
--- compiler/erl_rtti.m 5 Jun 2007 04:55:46 -0000 1.10
+++ compiler/erl_rtti.m 5 Jun 2007 07:57:14 -0000
@@ -119,9 +119,16 @@
:- func erlang_type_ctor_details_2(type_ctor_details) =
erlang_type_ctor_details.
-erlang_type_ctor_details_2(enum(_, Functors, _, _, _IsDummy, _)) =
- % XXX Handle IsDummy
- erlang_du(list.map(convert_enum_functor, Functors)).
+erlang_type_ctor_details_2(enum(_, Functors, _, _, IsDummy, _)) =
+ ( IsDummy = yes ->
+ ( Functors = [F] ->
+ erlang_dummy(F ^ enum_name)
+ ;
+ unexpected(this_file, "dummy type with more than one functor")
+ )
+ ;
+ erlang_du(list.map(convert_enum_functor, Functors))
+ ).
erlang_type_ctor_details_2(du(_, Functors, _, _, _)) =
erlang_du(list.map(convert_du_functor, Functors)).
erlang_type_ctor_details_2(reserved(_, _, _, _, _, _)) =
@@ -557,6 +564,8 @@
erlang_type_ctor_rep(erlang_du(_)) =
elds_term(make_enum_alternative("etcr_du")).
+erlang_type_ctor_rep(erlang_dummy(_)) =
+ elds_term(make_enum_alternative("etcr_dummy")).
erlang_type_ctor_rep(erlang_list) =
elds_term(make_enum_alternative("etcr_list")).
erlang_type_ctor_rep(erlang_eqv(_)) =
@@ -698,6 +707,9 @@
(
Details = erlang_du(Functors),
rtti_to_elds_expr(ModuleInfo, Functors, Term, [], Defns)
+ ;
+ Details = erlang_dummy(DummyFunctorName),
+ rtti_to_elds_expr(ModuleInfo, DummyFunctorName, Term, [], Defns)
;
Details = erlang_eqv(MaybePseudoTypeInfo),
rtti_to_elds_expr(ModuleInfo, MaybePseudoTypeInfo, Term, [], Defns)
Index: compiler/erlang_rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/erlang_rtti.m,v
retrieving revision 1.3
diff -u -r1.3 erlang_rtti.m
--- compiler/erlang_rtti.m 4 Jun 2007 09:05:41 -0000 1.3
+++ compiler/erlang_rtti.m 5 Jun 2007 07:57:14 -0000
@@ -75,6 +75,10 @@
% The function symbols are listed in declaration order.
edu_functors :: list(erlang_du_functor)
)
+
+ ; erlang_dummy(
+ edummy_name :: string
+ )
% Mercury lists are represented as erlang lists
; erlang_list
Index: library/erlang_rtti_implementation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/erlang_rtti_implementation.m,v
retrieving revision 1.7
diff -u -r1.7 erlang_rtti_implementation.m
--- library/erlang_rtti_implementation.m 5 Jun 2007 04:55:46 -0000 1.7
+++ library/erlang_rtti_implementation.m 5 Jun 2007 07:57:14 -0000
@@ -86,6 +86,7 @@
%
:- type erlang_type_ctor_rep
---> etcr_du
+ ; etcr_dummy
; etcr_list
; etcr_eqv
; etcr_int
@@ -349,6 +350,11 @@
Arguments = list.map(
get_du_functor_arg(TypeInfo, FunctorRep, Term), 1 .. Arity)
;
+ TypeCtorRep = etcr_dummy,
+ Functor = TypeCtorInfo ^ type_ctor_dummy_functor_name,
+ Arity = 0,
+ Arguments = []
+ ;
TypeCtorRep = etcr_list,
ArgTypeInfo = TypeInfo ^ type_info_index(1),
( is_non_empty_list(TypeInfo, ArgTypeInfo, Term, H, T) ->
@@ -802,6 +809,18 @@
type_ctor_functors(_) = [] :-
det_unimplemented("type_ctor_functors").
+
+:- func type_ctor_dummy_functor_name(type_ctor_info) = string.
+
+:- pragma foreign_proc("Erlang",
+ type_ctor_dummy_functor_name(TypeCtorInfo::in) = (Functor::out),
+ [will_not_call_mercury, promise_pure, thread_safe],
+"
+ Functor = element(tci_details(), TypeCtorInfo)
+").
+
+type_ctor_dummy_functor_name(_) = "dummy value" :-
+ det_unimplemented("type_ctor_dummy_functor_name").
:- func type_ctor_eqv_type(type_ctor_info) = maybe_pseudo_type_info.
--------------------------------------------------------------------------
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