[m-rev.] diff: use erlang macros in erlang_rtti_implementation.m
Peter Wang
wangp at students.csse.unimelb.edu.au
Tue Jun 26 12:11:07 AEST 2007
Unfortunately, I committed the diff in place of the log message again.
Estimated hours taken: 0.2
Branches: main
library/erlang_rtti_implementation.m:
Use Erlang macros for magic numbers which indicate the locations of
elements in type_infos and type_ctor_infos.
Index: library/erlang_rtti_implementation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/erlang_rtti_implementation.m,v
retrieving revision 1.9
diff -u -r1.9 erlang_rtti_implementation.m
--- library/erlang_rtti_implementation.m 7 Jun 2007 07:53:06 -0000 1.9
+++ library/erlang_rtti_implementation.m 26 Jun 2007 02:06:39 -0000
@@ -643,20 +643,22 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-:- pragma foreign_code("Erlang", "
- % Location of element in a type_info
- ti_type_ctor_info() -> 1.
- ti_var_arity() -> 2.
-
- % Location of elements in a type_ctor_info
- tci_arity() -> 1.
- tci_version() -> 2.
- tci_unify_pred() -> 3.
- tci_compare_pred() -> 4.
- tci_module_name() -> 5.
- tci_type_name() -> 6.
- tci_type_ctor_rep() -> 7.
- tci_details() -> 8.
+:- pragma foreign_decl("Erlang", "
+ % These are macros for efficiency.
+
+ % Location of element in a type_info
+ -define(ti_type_ctor_info, 1).
+ -define(ti_var_arity, 2).
+
+ % Location of elements in a type_ctor_info
+ -define(tci_arity, 1).
+ -define(tci_version, 2).
+ -define(tci_unify_pred, 3).
+ -define(tci_compare_pred, 4).
+ -define(tci_module_name, 5).
+ -define(tci_type_name, 6).
+ -define(tci_type_ctor_rep, 7).
+ -define(tci_details, 8).
").
%-----------------------------------------------------------------------------%
@@ -689,7 +691,7 @@
% The first field of a type_ctor_info is the integer
% zero in this case.
%
- FirstElement = element(ti_type_ctor_info(), TypeInfo),
+ FirstElement = element(?ti_type_ctor_info, TypeInfo),
if
% XXX is the test FirstElement =:= 0 better?
is_integer(FirstElement)
@@ -708,7 +710,7 @@
var_arity_type_info_arity(TypeInfo::in) = (TypeCtorInfo::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- TypeCtorInfo = element(ti_var_arity(), TypeInfo)
+ TypeCtorInfo = element(?ti_var_arity, TypeInfo)
").
var_arity_type_info_arity(_) = 0 :-
@@ -760,7 +762,7 @@
[will_not_call_mercury, promise_pure, thread_safe],
"
% io:format(""type_ctor_rep(~p)~n"", [TypeCtorInfo]),
- TypeCtorRep = element(tci_type_ctor_rep(), TypeCtorInfo),
+ TypeCtorRep = element(?tci_type_ctor_rep, TypeCtorInfo),
% io:format(""type_ctor_rep(~p) = ~p~n"", [TypeCtorInfo, TypeCtorRep]),
void
").
@@ -778,7 +780,7 @@
"
% The TypeInfo is never used so this is safe
TypeInfo_for_P = 0,
- UnifyPred = element(tci_unify_pred(), TypeCtorInfo)
+ UnifyPred = element(?tci_unify_pred, TypeCtorInfo)
").
type_ctor_unify_pred(_) = "dummy value" :-
@@ -792,7 +794,7 @@
"
% The TypeInfo is never used so this is safe
TypeInfo_for_P = 0,
- ComparePred = element(tci_compare_pred(), TypeCtorInfo)
+ ComparePred = element(?tci_compare_pred, TypeCtorInfo)
").
type_ctor_compare_pred(_) = "dummy value" :-
@@ -804,7 +806,7 @@
type_ctor_module_name(TypeCtorInfo::in) = (ModuleName::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- ModuleName = element(tci_module_name(), TypeCtorInfo)
+ ModuleName = element(?tci_module_name, TypeCtorInfo)
").
type_ctor_module_name(_) = "dummy value" :-
@@ -816,7 +818,7 @@
type_ctor_type_name(TypeCtorInfo::in) = (TypeName::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- TypeName = element(tci_type_name(), TypeCtorInfo)
+ TypeName = element(?tci_type_name, TypeCtorInfo)
").
type_ctor_type_name(_) = "dummy value" :-
@@ -828,7 +830,7 @@
type_ctor_arity(TypeCtorInfo::in) = (Arity::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- Arity = element(tci_arity(), TypeCtorInfo)
+ Arity = element(?tci_arity, TypeCtorInfo)
").
type_ctor_arity(_) = 0 :-
@@ -840,7 +842,7 @@
type_ctor_functors(TypeCtorInfo::in) = (Functors::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- Functors = element(tci_details(), TypeCtorInfo)
+ Functors = element(?tci_details, TypeCtorInfo)
").
type_ctor_functors(_) = [] :-
@@ -852,7 +854,7 @@
type_ctor_dummy_functor_name(TypeCtorInfo::in) = (Functor::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- Functor = element(tci_details(), TypeCtorInfo)
+ Functor = element(?tci_details, TypeCtorInfo)
").
type_ctor_dummy_functor_name(_) = "dummy value" :-
@@ -864,7 +866,7 @@
type_ctor_eqv_type(TypeCtorInfo::in) = (EqvType::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- EqvType = element(tci_details(), TypeCtorInfo)
+ EqvType = element(?tci_details, TypeCtorInfo)
").
type_ctor_eqv_type(_) = plain(type_info_thunk) :-
--------------------------------------------------------------------------
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