File: unbox_under_assign.ml

package info (click to toggle)
js-of-ocaml 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 37,932 kB
  • sloc: ml: 135,957; javascript: 58,364; ansic: 437; makefile: 422; sh: 12; perl: 4
file content (74 lines) | stat: -rw-r--r-- 1,455 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(* TEST *)

module Float = struct
  type _ t =
    | IO : int option t
    | F : float t

  let bar : type a. a t -> float -> int -> a =
    fun t f i ->
      match t with
      | IO -> Some i
      | F -> f
  [@@inline always]

  let foo (t : float t) f i =
    let r = ref 0. in
    r := bar t f i
end

(* These boxed integer cases were also fixed by GPR#2083, although
   current compiler code would not actually cause a failure even
   before that fix.  The tests here are given in case register
   typing is tightened up in future (e.g. GPR#1192). *)

module Int32 = struct
  type _ t =
    | IO : int option t
    | F : int32 t

  let bar : type a. a t -> int32 -> int -> a =
    fun t f i ->
      match t with
      | IO -> Some i
      | F -> f
  [@@inline always]

  let foo (t : int32 t) f i =
    let r = ref 0l in
    r := bar t f i
end

module Int64 = struct
  type _ t =
    | IO : int option t
    | F : int64 t

  let bar : type a. a t -> int64 -> int -> a =
    fun t f i ->
      match t with
      | IO -> Some i
      | F -> f
  [@@inline always]

  let foo (t : int64 t) f i =
    let r = ref 0L in
    r := bar t f i
end

module Nativeint = struct
  type _ t =
    | IO : int option t
    | F : nativeint t

  let bar : type a. a t -> nativeint -> int -> a =
    fun t f i ->
      match t with
      | IO -> Some i
      | F -> f
  [@@inline always]

  let foo (t : nativeint t) f i =
    let r = ref 0n in
    r := bar t f i
end