Debian Codegraph @

kernel/vmvalues.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Names
12
13 (** Values *)
14
15 type values
16 type structured_values
17 type vm_env
18 type vprod
19 type vfun
20 type vfix
21 type vcofix
22 type vblock
23 type arguments
24 type vstack = values array
25 type to_update
26
27 type tag = int
28
29 val type_atom_tag : tag
30 val max_atom_tag : tag
31 val proj_tag : tag
32 val fix_app_tag : tag
33 val switch_tag : tag
34 val cofix_tag : tag
35 val cofix_evaluated_tag : tag
36
37 type structured_constant =
38 | Const_sort of Sorts.t
39 | Const_ind of inductive
40 | Const_evar of Evar.t
41 | Const_b0 of tag
42 | Const_univ_instance of UVars.Instance.t
43 | Const_val of structured_values
44 | Const_uint of Uint63.t
45 | Const_float of Float64.t
46 | Const_string of Pstring.t
47
48 val pp_struct_const : structured_constant -> Pp.t
49
50 type reloc_table = (tag * int) array
51
52 type annot_switch =
53 { rtbl : reloc_table; tailcall : bool; max_stack_size : int }
54
55 val eq_structured_constant : structured_constant -> structured_constant -> bool
56 val hash_structured_constant : structured_constant -> int
57
58 val eq_annot_switch : annot_switch -> annot_switch -> bool
59 val hash_annot_switch : annot_switch -> int
60
61 val fun_val : vfun -> values
62 val fix_val : vfix -> values
63 val cofix_upd_val : to_update -> values
64
65 val inj_env : values array -> vm_env
66 val fun_env : vfun -> vm_env
67 val fix_env : vfix -> vm_env
68 val cofix_env : vcofix -> vm_env
69 val cofix_upd_env : to_update -> vm_env
70
71 (** Cast a value known to be a function, unsafe in general *)
72 val fun_of_val : values -> vfun
73
74 val crazy_val : values
75
76 (** Machine code *)
77
78 type tcode
79
80 type vswitch = {
81 sw_type_code : tcode;
82 sw_code : tcode;
83 sw_annot : annot_switch;
84 sw_stk : vstack;
85 sw_env : vm_env
86 }
87
88 external mkAccuCode : int -> tcode = "rocq_makeaccu"
89
90 val fun_code : vfun -> tcode
91 val fix_code : vfix -> tcode
92 val cofix_upd_code : to_update -> tcode
93
94 type id_key =
95 | ConstKey of Constant.t
96 | VarKey of Id.t
97 | RelKey of Int.t
98 | EvarKey of Evar.t
99
100 val eq_id_key : id_key -> id_key -> bool
101
102 type atom =
103 | Aid of id_key
104 | Aind of inductive
105 | Asort of Sorts.t
106
107 val get_atom_rel : unit -> atom array
108 (** Global table of rels *)
109
110 (** Zippers *)
111
112 type zipper =
113 | Zapp of arguments
114 | Zfix of vfix * arguments (** might be empty *)
115 | Zswitch of vswitch
116 | Zproj of int (* index of the projection as in Projection.Repr *)
117
118 type stack = zipper list
119
120 type accumulator = atom * stack
121
122 type kind = (values, accumulator, vfun, vprod, vfix * arguments option, vcofix * to_update * arguments option, vblock) Values.kind
123
124 (** For debugging purposes only *)
125
126 val pr_atom : atom -> Pp.t
127 val pr_kind : kind -> Pp.t
128 val pr_stack : stack -> Pp.t
129
130 (** Constructors *)
131
132 val val_of_str_const : structured_constant -> values
133 val val_of_rel : int -> values
134 val val_of_named : Id.t -> values
135 val val_of_constant : Constant.t -> values
136 val val_of_evar : Evar.t -> values
137 val val_of_proj : int -> values -> values
138 val val_of_atom : atom -> values
139 val val_of_int : int -> structured_values
140 val val_of_block : tag -> structured_values array -> structured_values
141 val val_of_uint : Uint63.t -> structured_values
142 val val_of_float : Float64.t -> structured_values
143 val val_of_string : Pstring.t -> structured_values
144
145 external val_of_annot_switch : annot_switch -> values = "%identity"
146
147 (** Destructors *)
148
149 val whd_val : values -> kind
150 val uni_instance : values -> UVars.Instance.t
151
152 (** Arguments *)
153
154 val nargs : arguments -> int
155 val arg : arguments -> int -> values
156
157 (** Product *)
158
159 val dom : vprod -> values
160 val codom : vprod -> vfun
161
162 (** Fun *)
163 external closure_arity : vfun -> int = "rocq_closure_arity"
164
165 (** Fix *)
166
167 val current_fix : vfix -> int
168 val check_fix : vfix -> vfix -> bool
169 val rec_args : vfix -> int array
170 val first_fix : vfix -> vfix
171 val fix_types : vfix -> tcode array
172 val cofix_types : vcofix -> tcode array
173 val mk_fix_body : int -> int -> vfix -> vfun array
174
175 (** CoFix *)
176
177 val current_cofix : vcofix -> int
178 val check_cofix : vcofix -> vcofix -> bool
179 val mk_cofix_body : (vfun -> vstack -> values) -> int -> int -> vcofix -> values array
180
181 (** Block *)
182
183 val btag : vblock -> int
184 val bsize : vblock -> int
185 val bfield : vblock -> int -> values
186
187 (** Switch *)
188
189 val check_switch : vswitch -> vswitch -> bool
190 val branch_arg : int -> tag * int -> values
191
192 (** Primitives implemented in OCaml, seen as values (to be used as globals) *)
193 val parray_make : values
194 val parray_get : values
195 val parray_get_default : values
196 val parray_set : values
197 val parray_copy : values
198 val parray_length : values
199
200 val pstring_make : values
201 val pstring_length : values
202 val pstring_get : values
203 val pstring_sub : values
204 val pstring_cat : values
205 val pstring_compare : values