From cdcb658c29409c8aef94ca3e22c14a90b396aea0 Mon Sep 17 00:00:00 2001 From: xleroy Date: Tue, 18 Oct 2011 09:40:59 +0000 Subject: Extraction: map Coq pairs to Caml pairs and Coq chars (type ascii) to Caml chars git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1732 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- lib/Camlcoq.ml | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'lib') diff --git a/lib/Camlcoq.ml b/lib/Camlcoq.ml index 34aaa0f..cfbca6e 100644 --- a/lib/Camlcoq.ml +++ b/lib/Camlcoq.ml @@ -109,27 +109,11 @@ let extern_atom a = (* Strings *) -let char_of_ascii (Ascii.Ascii(a0, a1, a2, a3, a4, a5, a6, a7)) = - Char.chr( (if a0 then 1 else 0) - + (if a1 then 2 else 0) - + (if a2 then 4 else 0) - + (if a3 then 8 else 0) - + (if a4 then 16 else 0) - + (if a5 then 32 else 0) - + (if a6 then 64 else 0) - + (if a7 then 128 else 0)) - -let coqstring_length s = - let rec len accu = function - | String0.EmptyString -> accu - | String0.String(_, s) -> len (accu + 1) s - in len 0 s - -let camlstring_of_coqstring s = - let r = String.create (coqstring_length s) in +let camlstring_of_coqstring (s: char list) = + let r = String.create (List.length s) in let rec fill pos = function - | String0.EmptyString -> r - | String0.String(c, s) -> r.[pos] <- char_of_ascii c; fill (pos + 1) s + | [] -> r + | c :: s -> r.[pos] <- c; fill (pos + 1) s in fill 0 s (* Timing facility *) -- cgit v1.2.3