1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
2001-12-07 05:41:02 -08:00
|
|
|
(* under the terms of the GNU Library General Public License, with *)
|
|
|
|
(* the special exception on linking described in file ../LICENSE. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Operations on internal representations of values *)
|
|
|
|
|
|
|
|
type t
|
|
|
|
|
|
|
|
external repr : 'a -> t = "%identity"
|
1997-03-22 12:27:26 -08:00
|
|
|
external obj : t -> 'a = "%identity"
|
1995-05-04 03:15:53 -07:00
|
|
|
external magic : 'a -> 'b = "%identity"
|
2004-01-01 08:42:43 -08:00
|
|
|
external is_block : t -> bool = "caml_obj_is_block"
|
1999-12-12 08:29:31 -08:00
|
|
|
external is_int : t -> bool = "%obj_is_int"
|
2004-01-01 08:42:43 -08:00
|
|
|
external tag : t -> int = "caml_obj_tag"
|
|
|
|
external set_tag : t -> int -> unit = "caml_obj_set_tag"
|
1995-07-27 10:44:04 -07:00
|
|
|
external size : t -> int = "%obj_size"
|
|
|
|
external field : t -> int -> t = "%obj_field"
|
|
|
|
external set_field : t -> int -> t -> unit = "%obj_set_field"
|
2010-01-20 08:26:46 -08:00
|
|
|
let double_field x i = Array.get (obj x : float array) i
|
|
|
|
let set_double_field x i v = Array.set (obj x : float array) i v
|
2004-01-01 08:42:43 -08:00
|
|
|
external new_block : int -> int -> t = "caml_obj_block"
|
|
|
|
external dup : t -> t = "caml_obj_dup"
|
|
|
|
external truncate : t -> int -> unit = "caml_obj_truncate"
|
2010-01-25 03:55:30 -08:00
|
|
|
external add_offset : t -> Int32.t -> t = "caml_obj_add_offset"
|
1997-10-28 05:17:11 -08:00
|
|
|
|
1999-12-08 00:21:57 -08:00
|
|
|
let marshal (obj : t) =
|
1997-10-28 05:17:11 -08:00
|
|
|
Marshal.to_string obj []
|
|
|
|
let unmarshal str pos =
|
1997-11-21 05:47:38 -08:00
|
|
|
(Marshal.from_string str pos, pos + Marshal.total_size str pos)
|
1998-10-01 05:34:32 -07:00
|
|
|
|
2002-01-20 09:39:10 -08:00
|
|
|
let lazy_tag = 246
|
|
|
|
let closure_tag = 247
|
1998-10-01 05:34:32 -07:00
|
|
|
let object_tag = 248
|
2002-01-20 09:39:10 -08:00
|
|
|
let infix_tag = 249
|
|
|
|
let forward_tag = 250
|
2002-01-23 09:51:41 -08:00
|
|
|
|
2002-01-20 09:39:10 -08:00
|
|
|
let no_scan_tag = 251
|
2002-01-23 09:51:41 -08:00
|
|
|
|
1998-10-01 05:34:32 -07:00
|
|
|
let abstract_tag = 251
|
|
|
|
let string_tag = 252
|
|
|
|
let double_tag = 253
|
|
|
|
let double_array_tag = 254
|
2002-01-20 09:39:10 -08:00
|
|
|
let custom_tag = 255
|
2002-01-23 09:51:41 -08:00
|
|
|
let final_tag = custom_tag
|
2003-10-16 16:22:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
let int_tag = 1000
|
|
|
|
let out_of_heap_tag = 1001
|
2008-01-29 05:11:15 -08:00
|
|
|
let unaligned_tag = 1002
|