1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 2004 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. *)(* *)(**************************************************************************)typeshape=|Function|Lazy|Class|Moduleofshapearray|ValueofObj.tletoverwriteon=assert(Obj.sizeo>=Obj.sizen);fori=0toObj.sizen-1doObj.set_fieldoi(Obj.fieldni)doneletrecinit_modlocshape=matchshapewith|Function->(* Two code pointer words (curried and full application), arity
and eight environment entries makes 11 words. *)letclosure=Obj.new_blockObj.closure_tag11inlettemplate=Obj.repr(fun_->raise(Undefined_recursive_moduleloc))inoverwriteclosuretemplate;closure|Lazy->Obj.repr(lazy(raise(Undefined_recursive_moduleloc)))|Class->Obj.repr(CamlinternalOO.dummy_classloc)|Modulecomps->Obj.repr(Array.map(init_modloc)comps)|Valuev->vletrecupdate_modshapeon=matchshapewith|Function->ifObj.tagn=Obj.closure_tag&&Obj.sizen<=Obj.sizeothenbeginoverwriteon;Obj.truncateo(Obj.sizen)(* PR#4008 *)endelseoverwriteo(Obj.repr(funx->(Obj.objn:_->_)x))|Lazy->ifObj.tagn=Obj.lazy_tagthenObj.set_fieldo0(Obj.fieldn0)elseifObj.tagn=Obj.forward_tagthenbegin(* PR#4316 *)Obj.set_tagoObj.forward_tag;Obj.set_fieldo0(Obj.fieldn0)endelsebegin(* forwarding pointer was shortcut by GC *)Obj.set_tagoObj.forward_tag;Obj.set_fieldo0nend|Class->assert(Obj.tagn=0&&Obj.sizen=4);overwriteon|Modulecomps->assert(Obj.tagn=0&&Obj.sizen>=Array.lengthcomps);fori=0toArray.lengthcomps-1doupdate_modcomps.(i)(Obj.fieldoi)(Obj.fieldni)done|Value_->()(* the value is already there *)