diff options
Diffstat (limited to '')
-rw-r--r-- | compiler/RegionsHierarchy.ml | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/compiler/RegionsHierarchy.ml b/compiler/RegionsHierarchy.ml index 0b589453..4ebdd01a 100644 --- a/compiler/RegionsHierarchy.ml +++ b/compiler/RegionsHierarchy.ml @@ -34,23 +34,24 @@ open LlbcAst open LlbcAstUtils open Assumed open SCC +open Errors module Subst = Substitute (** The local logger *) let log = Logging.regions_hierarchy_log -let compute_regions_hierarchy_for_sig (type_decls : type_decl TypeDeclId.Map.t) +let compute_regions_hierarchy_for_sig (meta : Meta.meta option) (type_decls : type_decl TypeDeclId.Map.t) (fun_decls : fun_decl FunDeclId.Map.t) (global_decls : global_decl GlobalDeclId.Map.t) (trait_decls : trait_decl TraitDeclId.Map.t) - (trait_impls : trait_impl TraitImplId.Map.t) (fun_name : string) + (trait_impls : trait_impl TraitImplId.Map.t) (* ?meta *) (fun_name : string) (sg : fun_sig) : region_var_groups = log#ldebug (lazy (__FUNCTION__ ^ ": " ^ fun_name)); (* Initialize a normalization context (we may need to normalize some associated types) *) let norm_ctx : AssociatedTypes.norm_ctx = let norm_trait_types = - AssociatedTypes.compute_norm_trait_types_from_preds + AssociatedTypes.compute_norm_trait_types_from_preds meta sg.preds.trait_type_constraints in { @@ -105,8 +106,8 @@ let compute_regions_hierarchy_for_sig (type_decls : type_decl TypeDeclId.Map.t) let add_edge ~(short : region) ~(long : region) = (* Sanity checks *) - assert (short <> RErased); - assert (long <> RErased); + cassert_opt_meta (short <> RErased) meta "TODO: Error message"; + cassert_opt_meta (long <> RErased) meta "TODO: Error message"; (* Ignore the locally bound regions (at the level of arrow types for instance *) match (short, long) with | RBVar _, _ | _, RBVar _ -> () @@ -172,13 +173,13 @@ let compute_regions_hierarchy_for_sig (type_decls : type_decl TypeDeclId.Map.t) | TTraitType (trait_ref, _) -> (* The trait should reference a clause, and not an implementation (otherwise it should have been normalized) *) - assert ( - AssociatedTypes.trait_instance_id_is_local_clause trait_ref.trait_id); + cassert_opt_meta ( + AssociatedTypes.trait_instance_id_is_local_clause trait_ref.trait_id) meta "The trait should reference a clause, and not an implementation (otherwise it should have been normalized)"; (* We have nothing to do *) () | TArrow (regions, inputs, output) -> (* TODO: *) - assert (regions = []); + cassert_opt_meta (regions = []) meta "Regions should be empty"; (* We can ignore the outer regions *) List.iter (explore_ty []) (output :: inputs) and explore_generics (outer : region list) (generics : generic_args) = @@ -221,7 +222,7 @@ let compute_regions_hierarchy_for_sig (type_decls : type_decl TypeDeclId.Map.t) (SccId.Map.bindings sccs.sccs) in (* The SCC should only contain the 'static *) - assert (static_scc = [ RStatic ]); + cassert_opt_meta (static_scc = [ RStatic ]) meta "The SCC should only contain the 'static"; (* Remove the group as well as references to this group from the other SCCs *) let { sccs; scc_deps } = sccs in @@ -277,7 +278,7 @@ let compute_regions_hierarchy_for_sig (type_decls : type_decl TypeDeclId.Map.t) (fun r -> match r with | RFVar rid -> RegionId.Map.find rid region_id_to_var_map - | _ -> raise (Failure "Unreachable")) + | _ -> craise (Option.get meta) "Unreachable") scc in @@ -317,19 +318,19 @@ let compute_regions_hierarchies (type_decls : type_decl TypeDeclId.Map.t) let regular = List.map (fun ((fid, d) : FunDeclId.id * fun_decl) -> - (FRegular fid, (Types.name_to_string env d.name, d.signature))) + (FRegular fid, (Types.name_to_string env d.name, d.signature, Some d.meta))) (FunDeclId.Map.bindings fun_decls) in let assumed = List.map (fun (info : assumed_fun_info) -> - (FAssumed info.fun_id, (info.name, info.fun_sig))) + (FAssumed info.fun_id, (info.name, info.fun_sig, None))) assumed_fun_infos in FunIdMap.of_list (List.map - (fun (fid, (name, sg)) -> + (fun (fid, (name, sg, meta)) -> ( fid, - compute_regions_hierarchy_for_sig type_decls fun_decls global_decls - trait_decls trait_impls name sg )) + compute_regions_hierarchy_for_sig meta type_decls fun_decls global_decls + trait_decls trait_impls name sg)) (regular @ assumed)) |