@@ -102,6 +102,8 @@ let is_ct_enum = function CT_enum _ -> true | _ -> false
102
102
103
103
let iblock1 = function [instr] -> instr | instrs -> iblock instrs
104
104
105
+ type abstract_type_initialised = Initialised | Uninitialised
106
+
105
107
(* * The context type contains two type-checking environments. ctx.local_env contains the closest typechecking
106
108
environment, usually from the expression we are compiling, whereas ctx.tc_env is the global type checking
107
109
environment from type-checking the entire AST. We also keep track of local variables in ctx.locals, so we know when
@@ -111,7 +113,7 @@ type ctx = {
111
113
records : (kid list * ctyp Bindings .t ) Bindings .t ;
112
114
enums : IdSet .t Bindings .t ;
113
115
variants : (kid list * ctyp Bindings .t ) Bindings .t ;
114
- abstracts : ctyp Bindings .t ;
116
+ abstracts : ( ctyp * abstract_type_initialised ) Bindings .t ;
115
117
valspecs : (string option * ctyp list * ctyp * uannot ) Bindings .t ;
116
118
quants : ctyp KBindings .t ;
117
119
local_env : Env .t ;
@@ -132,7 +134,7 @@ let ctx_map_ctyps f ctx =
132
134
ctx with
133
135
records = Bindings. map (fun (params , fields ) -> (params, Bindings. map f fields)) ctx.records;
134
136
variants = Bindings. map (fun (params , fields ) -> (params, Bindings. map f fields)) ctx.variants;
135
- abstracts = Bindings. map f ctx.abstracts;
137
+ abstracts = Bindings. map ( fun ( ctyp , initialised ) -> (f ctyp, initialised)) ctx.abstracts;
136
138
valspecs =
137
139
Bindings. map
138
140
(fun (extern , param_ctyps , ret_ctyp , uannot ) -> (extern, List. map f param_ctyps, f ret_ctyp, uannot))
@@ -771,7 +773,7 @@ module Make (C : CONFIG) = struct
771
773
(mk_id " sail_config_bits_abstract_len" , [] )
772
774
[V_id (json, CT_json )];
773
775
]
774
- @ select_abstract l ctx abstract_name (fun id abstract_ctyp ->
776
+ @ select_abstract l ctx abstract_name (fun id ( abstract_ctyp , _ ) ->
775
777
match abstract_ctyp with
776
778
| CT_fint 64 ->
777
779
[
@@ -1808,14 +1810,19 @@ module Make (C : CONFIG) = struct
1808
1810
CTDI_instrs (setup @ [call (CL_id (Abstract id, ctyp))] @ cleanup)
1809
1811
| TDC_none -> CTDI_none
1810
1812
in
1813
+ let is_initialised = function CTDI_instrs _ -> Initialised | CTDI_none -> Uninitialised in
1811
1814
match kind with
1812
1815
| K_int ->
1813
1816
let ctyp = ctyp_of_typ ctx (atom_typ (nid id)) in
1814
1817
let inst = compile_inst ctyp inst in
1815
- (Some (CTD_abstract (id, ctyp, inst)), { ctx with abstracts = Bindings. add id ctyp ctx.abstracts })
1818
+ ( Some (CTD_abstract (id, ctyp, inst)),
1819
+ { ctx with abstracts = Bindings. add id (ctyp, is_initialised inst) ctx.abstracts }
1820
+ )
1816
1821
| K_bool ->
1817
1822
let inst = compile_inst CT_bool inst in
1818
- (Some (CTD_abstract (id, CT_bool , inst)), { ctx with abstracts = Bindings. add id CT_bool ctx.abstracts })
1823
+ ( Some (CTD_abstract (id, CT_bool , inst)),
1824
+ { ctx with abstracts = Bindings. add id (CT_bool , is_initialised inst) ctx.abstracts }
1825
+ )
1819
1826
| _ -> Reporting. unreachable l __POS__ " Found abstract type that was neither an integer nor a boolean"
1820
1827
)
1821
1828
(* Will be re-written before here, see bitfield.ml *)
0 commit comments