-let load_patterns32s = ref [];;
-
-let add_load_patterns32 f = load_patterns32s := f :: !load_patterns32s;;
-let fresh_id =
- fun () ->
- incr counter;
- !counter
-
-let add_interpretation dsc (symbol, args) appl_pattern =
- let id = fresh_id () in
- Hashtbl.add !level2_patterns32 id (dsc, symbol, args, appl_pattern);
- pattern32_matrix := (true, appl_pattern, id) :: !pattern32_matrix;
- List.iter (fun f -> f !pattern32_matrix) !load_patterns32s;
- (try
- let ids = Hashtbl.find !interpretations symbol in
- ids := id :: !ids
- with Not_found -> Hashtbl.add !interpretations symbol (ref [id]));
- id
-
-let get_all_interpretations () =
- List.map
- (function (_, _, id) ->
- let (dsc, _, _, _) =
- try
- Hashtbl.find !level2_patterns32 id
- with Not_found -> assert false
- in
- (id, dsc))
- !pattern32_matrix
-
-let get_active_interpretations () =
- HExtlib.filter_map (function (true, _, id) -> Some id | _ -> None)
- !pattern32_matrix
-
-let set_active_interpretations ids =
- let pattern32_matrix' =
- List.map
- (function
- | (_, ap, id) when List.mem id ids -> (true, ap, id)
- | (_, ap, id) -> (false, ap, id))
- !pattern32_matrix
+let fresh_id status =
+ let counter = status#interp_db.counter+1 in
+ status#set_interp_db ({ status#interp_db with counter = counter }), counter
+
+let add_interpretation (status : #status) dsc (symbol, args) appl_pattern =
+ let status,id = fresh_id status in
+ let ids =
+ try
+ StringMap.find symbol status#interp_db.interpretations
+ with Not_found -> [id] in
+ let status =
+ status#set_interp_db { status#interp_db with
+ level2_patterns32 =
+ IntMap.add id (dsc, symbol, args, appl_pattern)
+ status#interp_db.level2_patterns32;
+ pattern32_matrix = (true,appl_pattern,id)::status#interp_db.pattern32_matrix;
+ interpretations = StringMap.add symbol ids status#interp_db.interpretations
+ }