summaryrefslogtreecommitdiff
path: root/contrib/xml/unshare.ml
diff options
context:
space:
mode:
authorGravatar Stephane Glondu <steph@glondu.net>2010-07-21 09:46:51 +0200
committerGravatar Stephane Glondu <steph@glondu.net>2010-07-21 09:46:51 +0200
commit5b7eafd0f00a16d78f99a27f5c7d5a0de77dc7e6 (patch)
tree631ad791a7685edafeb1fb2e8faeedc8379318ae /contrib/xml/unshare.ml
parentda178a880e3ace820b41d38b191d3785b82991f5 (diff)
Imported Upstream snapshot 8.3~beta0+13298
Diffstat (limited to 'contrib/xml/unshare.ml')
-rw-r--r--contrib/xml/unshare.ml52
1 files changed, 0 insertions, 52 deletions
diff --git a/contrib/xml/unshare.ml b/contrib/xml/unshare.ml
deleted file mode 100644
index f30f8230..00000000
--- a/contrib/xml/unshare.ml
+++ /dev/null
@@ -1,52 +0,0 @@
-(************************************************************************)
-(* v * The Coq Proof Assistant / The Coq Development Team *)
-(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
-(* \VV/ **************************************************************)
-(* // * The HELM Project / The EU MoWGLI Project *)
-(* * University of Bologna *)
-(************************************************************************)
-(* This file is distributed under the terms of the *)
-(* GNU Lesser General Public License Version 2.1 *)
-(* *)
-(* Copyright (C) 2000-2004, HELM Team. *)
-(* http://helm.cs.unibo.it *)
-(************************************************************************)
-
-exception CanNotUnshare;;
-
-(* [unshare t] gives back a copy of t where all sharing has been removed *)
-(* Physical equality becomes meaningful on unshared terms. Hashtables that *)
-(* use physical equality can now be used to associate information to evey *)
-(* node of the term. *)
-let unshare ?(already_unshared = function _ -> false) t =
- let obj = Obj.repr t in
- let rec aux obj =
- if already_unshared (Obj.obj obj) then
- obj
- else
- (if Obj.is_int obj then
- obj
- else if Obj.is_block obj then
- begin
- let tag = Obj.tag obj in
- if tag < Obj.no_scan_tag then
- begin
- let size = Obj.size obj in
- let new_obj = Obj.new_block 0 size in
- Obj.set_tag new_obj tag ;
- for i = 0 to size - 1 do
- Obj.set_field new_obj i (aux (Obj.field obj i))
- done ;
- new_obj
- end
- else if tag = Obj.string_tag then
- obj
- else
- raise CanNotUnshare
- end
- else
- raise CanNotUnshare
- )
- in
- Obj.obj (aux obj)
-;;