|
22 | 22 | * along with this program; if not, write to the Free Software
|
23 | 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
|
24 | 24 |
|
25 |
| -let undefinedHeader = [| |] |
| 25 | +let%private undefinedHeader = [| |] |
| 26 | +type nest = (int array * int) |
| 27 | + |
26 | 28 |
|
27 | 29 | let some ( x : Obj.t) : Obj.t =
|
28 | 30 | if Obj.magic x = None then
|
29 | 31 | (let block = Obj.repr (undefinedHeader, 0) in
|
30 | 32 | Obj.set_tag block 256;
|
31 | 33 | block)
|
32 | 34 | else
|
33 |
| - if x != Obj.repr Js.null && match (Obj.magic x ) with (x,_) -> x == Obj.repr undefinedHeader then |
| 35 | + if x != Obj.repr Js.null && match (Obj.magic x :nest ) with (x,_) -> x == undefinedHeader then |
34 | 36 | (
|
35 |
| - let nid = match (Obj.magic x) with (_,x) -> x + 1 in |
| 37 | + let nid = match (Obj.magic x : nest) with (_,x) -> x + 1 in |
36 | 38 | let block = Obj.repr (undefinedHeader, nid) in
|
37 | 39 | Obj.set_tag block 256;
|
38 | 40 | block
|
@@ -60,9 +62,9 @@ let null_to_opt (type t ) ( x : t Js.null) : t option =
|
60 | 62 | (** The input is already of [Some] form, [x] is not None,
|
61 | 63 | make sure [x[0]] will not throw *)
|
62 | 64 | let valFromOption (x : Obj.t) : Obj.t =
|
63 |
| - if x != Obj.repr Js.null && match (Obj.magic x) with (x,_) -> x == Obj.repr undefinedHeader |
| 65 | + if x != Obj.repr Js.null && match (Obj.magic x : nest) with (x,_) -> x == undefinedHeader |
64 | 66 | then
|
65 |
| - (match (Obj.magic x) with (_, (depth : int)) -> |
| 67 | + (match (Obj.magic x : nest) with _, depth -> |
66 | 68 | if depth = 0 then Obj.magic None
|
67 | 69 | else Obj.magic (undefinedHeader, depth - 1))
|
68 | 70 | else Obj.magic x
|
|
0 commit comments