Skip to content

Commit 7a0da56

Browse files
Better compatibility with pull request AbsInt#222
In particular, use the name [AST.string_of_ident] and declare it in the same places, so that a merge would be straightforward.
1 parent 74bb7e0 commit 7a0da56

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

common/AST.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Definition ident := positive.
3131

3232
Definition ident_eq := peq.
3333

34+
Parameter string_of_ident: ident -> string.
35+
3436
(** The intermediate languages are weakly typed, using the following types: *)
3537

3638
Inductive typ : Type :=

common/BlockNames.v

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ Require Import AST.
44
Require Import Maps.
55
Require Import String.
66

7-
Axiom ident_to_string: ident -> string.
8-
Axiom pos_to_string: positive -> string.
9-
107
(** * Interface *)
118

129
(** This is the interface of the memory block namespace. There should
@@ -63,6 +60,11 @@ End BlockType.
6360

6461
(** * Implementation *)
6562

63+
(** We get some help from the Ocaml code to convert dynamic block
64+
identifiers into strings. *)
65+
66+
Parameter string_of_pos: positive -> string.
67+
6668
(** Block names are implemented as the disjoint union of [AST.ident]
6769
and dynamically allocated [positive]. *)
6870

@@ -218,8 +220,8 @@ Module Block : BlockType.
218220

219221
Definition to_string (b: t): string :=
220222
match b with
221-
| glob_def i => append "glob:" (ident_to_string i)
222-
| dyn b => append "dyn:" (pos_to_string b)
223+
| glob_def i => append "glob:" (string_of_ident i)
224+
| dyn b => append "dyn:" (string_of_pos b)
223225
end.
224226

225227
Lemma ident_of_glob i:

extraction/extraction.v

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ Require Parser.
3636
Require Initializers.
3737
Require Int31.
3838

39-
40-
Extract Inlined Constant BlockNames.ident_to_string =>
41-
"(fun i -> Camlcoq.coqstring_of_camlstring (Camlcoq.extern_atom i))".
42-
Extract Inlined Constant BlockNames.pos_to_string =>
43-
"(fun p -> Camlcoq.coqstring_of_camlstring (Printf.sprintf ""%ld"" (Camlcoq.P.to_int32 p)))".
44-
4539
(* Standard lib *)
4640
Require Import ExtrOcamlBasic.
4741
Require Import ExtrOcamlString.
@@ -68,6 +62,14 @@ Extraction NoInline Memory.Mem.valid_pointer.
6862
(* Errors *)
6963
Extraction Inline Errors.bind Errors.bind2.
7064

65+
(* AST *)
66+
Extract Inlined Constant AST.string_of_ident =>
67+
"(fun i -> Camlcoq.coqstring_of_camlstring (Camlcoq.extern_atom i))".
68+
69+
(* BlockNames *)
70+
Extract Inlined Constant BlockNames.string_of_pos =>
71+
"(fun p -> Camlcoq.coqstring_of_camlstring (Printf.sprintf ""%ld"" (Camlcoq.P.to_int32 p)))".
72+
7173
(* Iteration *)
7274

7375
Extract Constant Iteration.GenIter.iterate =>

0 commit comments

Comments
 (0)