diff options
Diffstat (limited to 'compiler/InterpreterBorrowsCore.ml')
-rw-r--r-- | compiler/InterpreterBorrowsCore.ml | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/compiler/InterpreterBorrowsCore.ml b/compiler/InterpreterBorrowsCore.ml index 54949d3f..6db23cc4 100644 --- a/compiler/InterpreterBorrowsCore.ml +++ b/compiler/InterpreterBorrowsCore.ml @@ -182,14 +182,29 @@ let projection_contains (ty1 : T.rty) (rset1 : T.RegionId.Set.t) (ty2 : T.rty) in compare_rtys default combine compare_regions ty1 ty2 -(** Compute the set of borrow ids, loan ids and abstraction ids in a context. *) -let compute_borrow_abs_ids_in_context (ctx : C.eval_ctx) : - V.BorrowId.Set.t * V.AbstractionId.Set.t = +(* TODO: there misses fields *) +type ctx_ids = { + aids : V.AbstractionId.Set.t; + bids : V.BorrowId.Set.t; + dids : C.DummyVarId.Set.t; +} + +(* TODO: move *) + +(** Compute the sets of ids found in a list of contexts. *) +let compute_contexts_ids (ctxl : C.eval_ctx list) : ctx_ids = let bids = ref V.BorrowId.Set.empty in let aids = ref V.AbstractionId.Set.empty in + let dids = ref C.DummyVarId.Set.empty in let obj = object inherit [_] C.iter_eval_ctx + + method! visit_binder _ bv = + match bv with + | VarBinder _ -> () + | DummyBinder bid -> dids := C.DummyVarId.Set.add bid !dids + method! visit_borrow_id _ id = bids := V.BorrowId.Set.add id !bids method! visit_loan_id _ id = @@ -201,8 +216,12 @@ let compute_borrow_abs_ids_in_context (ctx : C.eval_ctx) : aids := V.AbstractionId.Set.add id !aids end in - obj#visit_eval_ctx () ctx; - (!bids, !aids) + List.iter (obj#visit_eval_ctx ()) ctxl; + { aids = !aids; bids = !bids; dids = !dids } + +(** Compute the sets of ids found in a context. *) +let compute_context_ids (ctx : C.eval_ctx) : ctx_ids = + compute_contexts_ids [ ctx ] (** Lookup a loan content. |