[m-rev.] diff 1/3: Move pointer_equals/2 into the private_builtin module.

Paul Bone paul at bone.id.au
Fri Jun 28 18:48:25 AEST 2013


My other two patches in this series are still okay, and the second one is
still waiting for review.

Move pointer_equals/2 into the private_builtin module.

library/version_hash_table.m:
library/private_builtin.m:
    As above.

library/private_builtin.m:
    Adjust a comment to say that some predicates are implemented in the
    normal way in this module.
---
 library/private_builtin.m    | 40 ++++++++++++++++++++++++++++++++++++++--
 library/version_hash_table.m | 30 +-----------------------------
 2 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/library/private_builtin.m b/library/private_builtin.m
index 1dd866d..cd3bffc 100644
--- a/library/private_builtin.m
+++ b/library/private_builtin.m
@@ -23,8 +23,9 @@
 % does not get included in the Mercury library reference manual.
 % 
 % Many of the predicates defined in this module are builtin - they do not have
-% definitions because the compiler generates code for them inline. Some others
-% are implemented in the runtime.
+% definitions because the compiler generates code for them inline. A second
+% group are implemented in the runtime.  Whilst a third group are
+% implemented normally in this module.
 % 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -118,6 +119,11 @@
     %
 :- pred typed_compare(comparison_result::uo, T1::in, T2::in) is det.
 
+    % True if the two objects have the same pointer value in the underlying
+    % implementation.
+    %
+:- pred pointer_equals(T::in, T::in) is semidet.
+
     % N.B. interface continued below.
 
 %-----------------------------------------------------------------------------%
@@ -337,6 +343,36 @@ typed_compare(R, X, Y) :-
     ).
 
 %-----------------------------------------------------------------------------%
+
+:- pragma inline(pointer_equals/2).
+
+:- pragma foreign_proc("C", pointer_equals(A::in, B::in),
+    [promise_pure, thread_safe, will_not_call_mercury,
+        will_not_throw_exception, terminates],
+"
+    SUCCESS_INDICATOR = (A == B);
+").
+
+:- pragma foreign_proc("Java", pointer_equals(A::in, B::in),
+    [promise_pure, thread_safe, will_not_call_mercury,
+        will_not_throw_exception, terminates],
+"
+    SUCCESS_INDICATOR = (A == B);
+").
+
+:- pragma foreign_proc("C#", pointer_equals(A::in, B::in),
+    [promise_pure, thread_safe, will_not_call_mercury,
+        will_not_throw_exception, terminates],
+"
+    SUCCESS_INDICATOR = System.Object.ReferenceEquals(A, B);
+").
+
+% Conservative default if a backend does not have pointer equality, such as
+% Erlang.  (Erlang does have erts_debug:same/1 but I don't know if we can
+% rely on that.)
+pointer_equals(_A, _B) :- semidet_false.
+
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- interface.
diff --git a/library/version_hash_table.m b/library/version_hash_table.m
index b2765c2..95c5ed5 100644
--- a/library/version_hash_table.m
+++ b/library/version_hash_table.m
@@ -234,6 +234,7 @@
 :- import_module int.
 :- import_module list.
 :- import_module pair.
+:- import_module private_builtin.
 :- import_module require.
 :- import_module string.
 :- import_module type_desc.
@@ -879,35 +880,6 @@ equals(A, B) :-
 compare_item(Table, K, V, unit, unit) :-
     search(Table, K, V).
 
-:- pred pointer_equals(T::in, T::in) is semidet.
-:- pragma inline(pointer_equals/2).
-
-:- pragma foreign_proc("C", pointer_equals(A::in, B::in),
-    [promise_pure, thread_safe, will_not_call_mercury,
-        will_not_throw_exception, terminates],
-"
-    SUCCESS_INDICATOR = (A == B);
-").
-
-:- pragma foreign_proc("Java", pointer_equals(A::in, B::in),
-    [promise_pure, thread_safe, will_not_call_mercury,
-        will_not_throw_exception, terminates],
-"
-    SUCCESS_INDICATOR = (A == B);
-").
-
-:- pragma foreign_proc("C#", pointer_equals(A::in, B::in),
-    [promise_pure, thread_safe, will_not_call_mercury,
-        will_not_throw_exception, terminates],
-"
-    SUCCESS_INDICATOR = System.Object.ReferenceEquals(A, B);
-").
-
-% Conservative default if a backend does not have pointer equality, such as
-% Erlang.  (Erlang does have erts_debug:same/1 but I don't know if we can
-% rely on that.)
-pointer_equals(_A, _B) :- semidet_false.
-
 %-----------------------------------------------------------------------------%
 :- end_module version_hash_table.
 %-----------------------------------------------------------------------------%
-- 
1.8.1.3




More information about the reviews mailing list