Blob Blame History Raw
From c6a8f300e19485c8fd6542ed8978829c6cf53cb4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= <thevoodoos@gmail.com>
Date: Mon, 30 Aug 2021 19:49:14 +0200
Subject: [PATCH 41/75] Update primitive

---
 src/ocaml/typing/primitive.ml  | 24 ++++++++++++++++++++++++
 src/ocaml/typing/primitive.mli |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/src/ocaml/typing/primitive.ml b/src/ocaml/typing/primitive.ml
index 0c3372b9..bf4fe832 100644
--- a/src/ocaml/typing/primitive.ml
+++ b/src/ocaml/typing/primitive.ml
@@ -200,6 +200,30 @@ let native_name p =
 let byte_name p =
   p.prim_name
 
+let equal_boxed_integer bi1 bi2 =
+  match bi1, bi2 with
+  | Pnativeint, Pnativeint
+  | Pint32, Pint32
+  | Pint64, Pint64 ->
+    true
+  | (Pnativeint | Pint32 | Pint64), _ ->
+    false
+
+let equal_native_repr nr1 nr2 =
+  match nr1, nr2 with
+  | Same_as_ocaml_repr, Same_as_ocaml_repr -> true
+  | Same_as_ocaml_repr,
+    (Unboxed_float | Unboxed_integer _ | Untagged_int) -> false
+  | Unboxed_float, Unboxed_float -> true
+  | Unboxed_float,
+    (Same_as_ocaml_repr | Unboxed_integer _ | Untagged_int) -> false
+  | Unboxed_integer bi1, Unboxed_integer bi2 -> equal_boxed_integer bi1 bi2
+  | Unboxed_integer _,
+    (Same_as_ocaml_repr | Unboxed_float | Untagged_int) -> false
+  | Untagged_int, Untagged_int -> true
+  | Untagged_int,
+    (Same_as_ocaml_repr | Unboxed_float | Unboxed_integer _) -> false
+
 let native_name_is_external p =
   let nat_name = native_name p in
   nat_name <> "" && nat_name.[0] <> '%'
diff --git a/src/ocaml/typing/primitive.mli b/src/ocaml/typing/primitive.mli
index ddd39779..e8376ad5 100644
--- a/src/ocaml/typing/primitive.mli
+++ b/src/ocaml/typing/primitive.mli
@@ -63,6 +63,9 @@ val print
 val native_name: description -> string
 val byte_name: description -> string
 
+val equal_boxed_integer : boxed_integer -> boxed_integer -> bool
+val equal_native_repr : native_repr -> native_repr -> bool
+
 (** [native_name_is_externa] returns [true] iff the [native_name] for the
     given primitive identifies that the primitive is not implemented in the
     compiler itself. *)
-- 
2.32.0