/
flat_Shared.mli
84 lines (61 loc) · 2.22 KB
/
flat_Shared.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(**
Flat Compiler : Compile time sharing, and runtime sharing generation
@author Mathieu Barbin
*)
(**
Those function returns the identifier which will be generated in the generated code,
corresponding to the sharing version of the correspondant value.
During the compilation, at any moment, we can call these function for accessing
the identifier.
At the end, we reintroduce all the binding at the beginning of the generated code.
*)
(** {6 Shared identifiers} *)
type label = Flat_Common.label
(**
FIXME !
Ocaml Ast should distinguish between top level binding and expressions.
*)
type ocaml_val = Ocaml.expr
val field : label -> Ocaml.expr
val vtable : label list -> Ocaml.expr
val simple : label -> Ocaml.expr
(** {6 Caches} *)
val cache : unit -> Ocaml.expr
(** {6 Introduction of declaration in the generated code} *)
module Let :
sig
(**
For outputting the code, you can introduce them in any order
because the sharing is done at runtime (separated compilation)
[all] give all the declaration.
To avoid multiple declaration, the internal state is modified when
you get ocaml_val definitions.
*)
val fields : unit -> ocaml_val list
val vtables : unit -> ocaml_val list
val simples : unit -> ocaml_val list
val caches : unit -> ocaml_val list
val all : unit -> ocaml_val list
(**
Insert the definition before an existing list.
More efficient than a list concatenation.
*)
val insert : ocaml_val list -> ocaml_val list
end
(**
The module should be restarted before each compilation unit.
*)
val reset : unit -> unit