123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990(**************************************************************************)(* *)(* 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.tletrecinit_mod_fieldmoduilocshape=letinit=matchshapewith|Function->letrecfn(x:'a)=letfn':'a->'b=Obj.obj(Obj.fieldmodui)iniffn==fn'thenraise(Undefined_recursive_moduleloc)elsefn'xinObj.reprfn|Lazy->letrecl=lazy(letl'=Obj.obj(Obj.fieldmodui)inifl==l'thenraise(Undefined_recursive_moduleloc)elseLazy.forcel')inObj.reprl|Class->Obj.repr(CamlinternalOO.dummy_classloc)|Modulecomps->Obj.repr(init_mod_blockloccomps)|Valuev->vinObj.set_fieldmoduiinitandinit_mod_blockloccomps=letlength=Array.lengthcompsinletmodu=Obj.new_block0lengthinfori=0tolength-1doinit_mod_fieldmoduiloccomps.(i)done;moduletinit_modlocshape=matchshapewith|Modulecomps->Obj.repr(init_mod_blockloccomps)|_->failwith"CamlinternalMod.init_mod: not a module"letrecupdate_mod_fieldmoduishapen=matchshapewith|Function|Lazy->Obj.set_fieldmoduin|Value_->()(* the value is already there *)|Class->assert(Obj.tagn=0&&Obj.sizen=4);letcl=Obj.fieldmoduiinforj=0to3doObj.set_fieldclj(Obj.fieldnj)done|Modulecomps->update_mod_blockcomps(Obj.fieldmodui)nandupdate_mod_blockcompson=assert(Obj.tagn=0&&Obj.sizen>=Array.lengthcomps);fori=0toArray.lengthcomps-1doupdate_mod_fieldoicomps.(i)(Obj.fieldni)doneletupdate_modshapeon=matchshapewith|Modulecomps->update_mod_blockcompson|_->failwith"CamlinternalMod.update_mod: not a module"