123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(* Operations on internal representations of values *)typettyperaw_data=nativeintexternalrepr:'a->t="%identity"externalobj:t->'a="%identity"externalmagic:'a->'b="%identity"externalis_int:t->bool="%obj_is_int"let[@inlinealways]is_blocka=not(is_inta)externaltag:t->int="caml_obj_tag"[@@noalloc]externalsize:t->int="%obj_size"externalreachable_words:t->int="caml_obj_reachable_words"externalfield:t->int->t="%obj_field"externalset_field:t->int->t->unit="%obj_set_field"externalfloatarray_get:floatarray->int->float="caml_floatarray_get"externalfloatarray_set:floatarray->int->float->unit="caml_floatarray_set"let[@inlinealways]double_fieldxi=floatarray_get(objx:floatarray)ilet[@inlinealways]set_double_fieldxiv=floatarray_set(objx:floatarray)ivexternalraw_field:t->int->raw_data="caml_obj_raw_field"externalset_raw_field:t->int->raw_data->unit="caml_obj_set_raw_field"externalnew_block:int->int->t="caml_obj_block"externaldup:t->t="caml_obj_dup"externaladd_offset:t->Int32.t->t="caml_obj_add_offset"externalwith_tag:int->t->t="caml_obj_with_tag"letfirst_non_constant_constructor_tag=0letlast_non_constant_constructor_tag=243letforcing_tag=244letcont_tag=245letlazy_tag=246letclosure_tag=247letobject_tag=248letinfix_tag=249letforward_tag=250letno_scan_tag=251letabstract_tag=251letstring_tag=252letdouble_tag=253letdouble_array_tag=254letcustom_tag=255letint_tag=1000letout_of_heap_tag=1001letunaligned_tag=1002moduleExtension_constructor=structtypet=extension_constructorletof_valx=letx=reprxinletslot=if(is_blockx)&&(tagx)<>object_tag&&(sizex)>=1thenfieldx0elsexinletname=if(is_blockslot)&&(tagslot)=object_tagthenfieldslot0elseinvalid_arg"Obj.extension_constructor"inif(tagname)=string_tagthen(objslot:t)elseinvalid_arg"Obj.extension_constructor"let[@inlinealways]name(slot:t)=(obj(field(reprslot)0):string)let[@inlinealways]id(slot:t)=(obj(field(reprslot)1):int)endmoduleEphemeron=structtypeobj_t=ttypet(** ephemeron *)(** To change in sync with weak.h *)letadditional_values=2letmax_ephe_length=Sys.max_array_length-additional_valuesexternalcreate:int->t="caml_ephe_create"letcreatel=ifnot(0<=l&&l<=max_ephe_length)theninvalid_arg"Obj.Ephemeron.create";createlletlengthx=size(reprx)-additional_valuesletraise_if_invalid_offseteomsg=ifnot(0<=o&&o<lengthe)theninvalid_argmsgexternalget_key:t->int->obj_toption="caml_ephe_get_key"letget_keyeo=raise_if_invalid_offseteo"Obj.Ephemeron.get_key";get_keyeoexternalget_key_copy:t->int->obj_toption="caml_ephe_get_key_copy"letget_key_copyeo=raise_if_invalid_offseteo"Obj.Ephemeron.get_key_copy";get_key_copyeoexternalset_key:t->int->obj_t->unit="caml_ephe_set_key"letset_keyeox=raise_if_invalid_offseteo"Obj.Ephemeron.set_key";set_keyeoxexternalunset_key:t->int->unit="caml_ephe_unset_key"letunset_keyeo=raise_if_invalid_offseteo"Obj.Ephemeron.unset_key";unset_keyeoexternalcheck_key:t->int->bool="caml_ephe_check_key"letcheck_keyeo=raise_if_invalid_offseteo"Obj.Ephemeron.check_key";check_keyeoexternalblit_key:t->int->t->int->int->unit="caml_ephe_blit_key"letblit_keye1o1e2o2l=ifl<0||o1<0||o1>lengthe1-l||o2<0||o2>lengthe2-ltheninvalid_arg"Obj.Ephemeron.blit_key"elseifl<>0thenblit_keye1o1e2o2lexternalget_data:t->obj_toption="caml_ephe_get_data"externalget_data_copy:t->obj_toption="caml_ephe_get_data_copy"externalset_data:t->obj_t->unit="caml_ephe_set_data"externalunset_data:t->unit="caml_ephe_unset_data"externalcheck_data:t->bool="caml_ephe_check_data"externalblit_data:t->t->unit="caml_ephe_blit_data"end