summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSon HO2024-05-24 14:16:37 +0200
committerGitHub2024-05-24 14:16:37 +0200
commitc6c9e351546a723e62cc21579b2359dba3bfb56f (patch)
tree74ed652b8862d1dde24ccd65b6c29503ea3db35c
parente669de58b71fd68642cfacf1a2e3cbd1c5b2f4fe (diff)
parent69ff150ede10b7d24f9777298e8ca3de163c33e1 (diff)
Merge pull request #175 from AeneasVerif/afromher/meta
Rename meta into span
-rw-r--r--charon-pin2
-rw-r--r--compiler/AssociatedTypes.ml86
-rw-r--r--compiler/Contexts.ml72
-rw-r--r--compiler/Cps.ml10
-rw-r--r--compiler/Errors.ml74
-rw-r--r--compiler/Extract.ml440
-rw-r--r--compiler/ExtractBase.ml330
-rw-r--r--compiler/ExtractName.ml4
-rw-r--r--compiler/ExtractTypes.ml274
-rw-r--r--compiler/FunsAnalysis.ml6
-rw-r--r--compiler/Interpreter.ml74
-rw-r--r--compiler/InterpreterBorrows.ml620
-rw-r--r--compiler/InterpreterBorrows.mli28
-rw-r--r--compiler/InterpreterBorrowsCore.ml194
-rw-r--r--compiler/InterpreterExpansion.ml158
-rw-r--r--compiler/InterpreterExpansion.mli14
-rw-r--r--compiler/InterpreterExpressions.ml272
-rw-r--r--compiler/InterpreterExpressions.mli10
-rw-r--r--compiler/InterpreterLoops.ml72
-rw-r--r--compiler/InterpreterLoops.mli2
-rw-r--r--compiler/InterpreterLoopsCore.ml16
-rw-r--r--compiler/InterpreterLoopsFixedPoint.ml146
-rw-r--r--compiler/InterpreterLoopsFixedPoint.mli10
-rw-r--r--compiler/InterpreterLoopsJoinCtxs.ml140
-rw-r--r--compiler/InterpreterLoopsJoinCtxs.mli6
-rw-r--r--compiler/InterpreterLoopsMatchCtxs.ml326
-rw-r--r--compiler/InterpreterLoopsMatchCtxs.mli10
-rw-r--r--compiler/InterpreterPaths.ml190
-rw-r--r--compiler/InterpreterPaths.mli18
-rw-r--r--compiler/InterpreterProjectors.ml112
-rw-r--r--compiler/InterpreterProjectors.mli12
-rw-r--r--compiler/InterpreterStatements.ml430
-rw-r--r--compiler/InterpreterStatements.mli2
-rw-r--r--compiler/InterpreterUtils.ml56
-rw-r--r--compiler/Invariants.ml234
-rw-r--r--compiler/Main.ml2
-rw-r--r--compiler/PrePasses.ml18
-rw-r--r--compiler/Print.ml136
-rw-r--r--compiler/PrintPure.ml138
-rw-r--r--compiler/Pure.ml32
-rw-r--r--compiler/PureMicroPasses.ml106
-rw-r--r--compiler/PureTypeCheck.ml150
-rw-r--r--compiler/PureUtils.ml124
-rw-r--r--compiler/RegionsHierarchy.ml26
-rw-r--r--compiler/Substitute.ml32
-rw-r--r--compiler/SymbolicAst.ml16
-rw-r--r--compiler/SymbolicToPure.ml548
-rw-r--r--compiler/SynthesizeSymbolic.ml40
-rw-r--r--compiler/Translate.ml28
-rw-r--r--compiler/TypesAnalysis.ml2
-rw-r--r--compiler/Values.ml30
-rw-r--r--compiler/ValuesUtils.ml36
-rw-r--r--flake.lock6
53 files changed, 2962 insertions, 2958 deletions
diff --git a/charon-pin b/charon-pin
index 6568ef9b..d18033b9 100644
--- a/charon-pin
+++ b/charon-pin
@@ -1,2 +1,2 @@
# This is the commit from https://github.com/AeneasVerif/charon that should be used with this version of aeneas.
-7cb5b367aec5768bee003d395634b30e13638b7d
+a5fda598f359a2b85e044a884fd977d75f4578b4
diff --git a/compiler/AssociatedTypes.ml b/compiler/AssociatedTypes.ml
index c0c5399f..1c335d8d 100644
--- a/compiler/AssociatedTypes.ml
+++ b/compiler/AssociatedTypes.ml
@@ -34,7 +34,7 @@ end
module TyMap = Collections.MakeMap (TyOrd)
-let compute_norm_trait_types_from_preds (meta : Meta.meta option)
+let compute_norm_trait_types_from_preds (span : Meta.span option)
(trait_type_constraints : trait_type_constraint list) : ty TraitTypeRefMap.t
=
(* Compute a union-find structure by recursively exploring the predicates and clauses *)
@@ -51,9 +51,9 @@ let compute_norm_trait_types_from_preds (meta : Meta.meta option)
(* Sanity check: the type constraint can't make use of regions - Remark
that it would be enough to only visit the field [ty] of the trait type
constraint, but for safety we visit all the fields *)
- sanity_check_opt_meta __FILE__ __LINE__
+ sanity_check_opt_span __FILE__ __LINE__
(trait_type_constraint_no_regions c)
- meta;
+ span;
let { trait_ref; type_name; ty } : trait_type_constraint = c in
let trait_ty = TTraitType (trait_ref, type_name) in
let trait_ty_ref = get_ref trait_ty in
@@ -82,10 +82,10 @@ let compute_norm_trait_types_from_preds (meta : Meta.meta option)
in
TraitTypeRefMap.of_list rbindings
-let ctx_add_norm_trait_types_from_preds (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_add_norm_trait_types_from_preds (span : Meta.span) (ctx : eval_ctx)
(trait_type_constraints : trait_type_constraint list) : eval_ctx =
let norm_trait_types =
- compute_norm_trait_types_from_preds (Some meta) trait_type_constraints
+ compute_norm_trait_types_from_preds (Some span) trait_type_constraints
in
{ ctx with norm_trait_types }
@@ -104,7 +104,7 @@ let rec trait_instance_id_is_local_clause (id : trait_instance_id) : bool =
but they should be applied to types without regions.
*)
type norm_ctx = {
- meta : Meta.meta option;
+ span : Meta.span option;
norm_trait_types : ty TraitTypeRefMap.t;
type_decls : type_decl TypeDeclId.Map.t;
fun_decls : fun_decl FunDeclId.Map.t;
@@ -241,9 +241,9 @@ let rec norm_ctx_normalize_ty (ctx : norm_ctx) (ty : ty) : ty =
match trait_ref.trait_id with
| TraitRef { trait_id = TraitImpl impl_id; generics = ref_generics; _ }
->
- cassert_opt_meta __FILE__ __LINE__
+ cassert_opt_span __FILE__ __LINE__
(ref_generics = empty_generic_args)
- ctx.meta "Higher order trait types are not supported yet";
+ ctx.span "Higher order trait types are not supported yet";
log#ldebug
(lazy
("norm_ctx_normalize_ty: trait type: trait ref: "
@@ -283,9 +283,9 @@ let rec norm_ctx_normalize_ty (ctx : norm_ctx) (ty : ty) : ty =
^ trait_ref_to_string ctx trait_ref
^ "\n- raw trait ref:\n" ^ show_trait_ref trait_ref));
(* We can't project *)
- sanity_check_opt_meta __FILE__ __LINE__
+ sanity_check_opt_span __FILE__ __LINE__
(trait_instance_id_is_local_clause trait_ref.trait_id)
- ctx.meta;
+ ctx.span;
TTraitType (trait_ref, type_name)
in
let tr : trait_type_ref = { trait_ref; type_name } in
@@ -353,9 +353,9 @@ and norm_ctx_normalize_trait_instance_id (ctx : norm_ctx)
match impl with
| None ->
(* This is actually a local clause *)
- sanity_check_opt_meta __FILE__ __LINE__
+ sanity_check_opt_span __FILE__ __LINE__
(trait_instance_id_is_local_clause inst_id)
- ctx.meta;
+ ctx.span;
(ParentClause (inst_id, decl_id, clause_id), None)
| Some impl ->
(* We figure out the parent clause by doing the following:
@@ -386,9 +386,9 @@ and norm_ctx_normalize_trait_instance_id (ctx : norm_ctx)
match impl with
| None ->
(* This is actually a local clause *)
- sanity_check_opt_meta __FILE__ __LINE__
+ sanity_check_opt_span __FILE__ __LINE__
(trait_instance_id_is_local_clause inst_id)
- ctx.meta;
+ ctx.span;
(ItemClause (inst_id, decl_id, item_name, clause_id), None)
| Some impl ->
(* We figure out the item clause by doing the following:
@@ -428,12 +428,12 @@ and norm_ctx_normalize_trait_instance_id (ctx : norm_ctx)
| TraitRef trait_ref ->
(* The trait instance id necessarily refers to a local sub-clause. We
can't project over it and can only peel off the [TraitRef] wrapper *)
- sanity_check_opt_meta __FILE__ __LINE__
+ sanity_check_opt_span __FILE__ __LINE__
(trait_instance_id_is_local_clause trait_ref.trait_id)
- ctx.meta;
- sanity_check_opt_meta __FILE__ __LINE__
+ ctx.span;
+ sanity_check_opt_span __FILE__ __LINE__
(trait_ref.generics = empty_generic_args)
- ctx.meta;
+ ctx.span;
(trait_ref.trait_id, None)
| FnPointer ty ->
let ty = norm_ctx_normalize_ty ctx ty in
@@ -482,9 +482,9 @@ and norm_ctx_normalize_trait_ref (ctx : norm_ctx) (trait_ref : trait_ref) :
(lazy
("norm_ctx_normalize_trait_ref: normalized to: "
^ trait_ref_to_string ctx trait_ref));
- sanity_check_opt_meta __FILE__ __LINE__
+ sanity_check_opt_span __FILE__ __LINE__
(generics = empty_generic_args)
- ctx.meta;
+ ctx.span;
trait_ref
(* Not sure this one is really necessary *)
@@ -501,9 +501,9 @@ let norm_ctx_normalize_trait_type_constraint (ctx : norm_ctx)
let ty = norm_ctx_normalize_ty ctx ty in
{ trait_ref; type_name; ty }
-let mk_norm_ctx (meta : Meta.meta) (ctx : eval_ctx) : norm_ctx =
+let mk_norm_ctx (span : Meta.span) (ctx : eval_ctx) : norm_ctx =
{
- meta = Some meta;
+ span = Some span;
norm_trait_types = ctx.norm_trait_types;
type_decls = ctx.type_ctx.type_decls;
fun_decls = ctx.fun_ctx.fun_decls;
@@ -514,20 +514,20 @@ let mk_norm_ctx (meta : Meta.meta) (ctx : eval_ctx) : norm_ctx =
const_generic_vars = ctx.const_generic_vars;
}
-let ctx_normalize_ty (meta : Meta.meta) (ctx : eval_ctx) (ty : ty) : ty =
- norm_ctx_normalize_ty (mk_norm_ctx meta ctx) ty
+let ctx_normalize_ty (span : Meta.span) (ctx : eval_ctx) (ty : ty) : ty =
+ norm_ctx_normalize_ty (mk_norm_ctx span ctx) ty
(** Normalize a type and erase the regions at the same time *)
-let ctx_normalize_erase_ty (meta : Meta.meta) (ctx : eval_ctx) (ty : ty) : ty =
- let ty = ctx_normalize_ty meta ctx ty in
+let ctx_normalize_erase_ty (span : Meta.span) (ctx : eval_ctx) (ty : ty) : ty =
+ let ty = ctx_normalize_ty span ctx ty in
Subst.erase_regions ty
-let ctx_normalize_trait_type_constraint (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_normalize_trait_type_constraint (span : Meta.span) (ctx : eval_ctx)
(ttc : trait_type_constraint) : trait_type_constraint =
- norm_ctx_normalize_trait_type_constraint (mk_norm_ctx meta ctx) ttc
+ norm_ctx_normalize_trait_type_constraint (mk_norm_ctx span ctx) ttc
(** Same as [type_decl_get_instantiated_variants_fields_types] but normalizes the types *)
-let type_decl_get_inst_norm_variants_fields_rtypes (meta : Meta.meta)
+let type_decl_get_inst_norm_variants_fields_rtypes (span : Meta.span)
(ctx : eval_ctx) (def : type_decl) (generics : generic_args) :
(VariantId.id option * ty list) list =
let res =
@@ -535,51 +535,51 @@ let type_decl_get_inst_norm_variants_fields_rtypes (meta : Meta.meta)
in
List.map
(fun (variant_id, types) ->
- (variant_id, List.map (ctx_normalize_ty meta ctx) types))
+ (variant_id, List.map (ctx_normalize_ty span ctx) types))
res
(** Same as [type_decl_get_instantiated_field_types] but normalizes the types *)
-let type_decl_get_inst_norm_field_rtypes (meta : Meta.meta) (ctx : eval_ctx)
+let type_decl_get_inst_norm_field_rtypes (span : Meta.span) (ctx : eval_ctx)
(def : type_decl) (opt_variant_id : VariantId.id option)
(generics : generic_args) : ty list =
let types =
Subst.type_decl_get_instantiated_field_types def opt_variant_id generics
in
- List.map (ctx_normalize_ty meta ctx) types
+ List.map (ctx_normalize_ty span ctx) types
(** Same as [ctx_adt_value_get_instantiated_field_rtypes] but normalizes the types *)
-let ctx_adt_value_get_inst_norm_field_rtypes (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_adt_value_get_inst_norm_field_rtypes (span : Meta.span) (ctx : eval_ctx)
(adt : adt_value) (id : type_id) (generics : generic_args) : ty list =
let types =
- Subst.ctx_adt_value_get_instantiated_field_types meta ctx adt id generics
+ Subst.ctx_adt_value_get_instantiated_field_types span ctx adt id generics
in
- List.map (ctx_normalize_ty meta ctx) types
+ List.map (ctx_normalize_ty span ctx) types
(** Same as [ctx_adt_value_get_instantiated_field_types] but normalizes the types
and erases the regions. *)
-let type_decl_get_inst_norm_field_etypes (meta : Meta.meta) (ctx : eval_ctx)
+let type_decl_get_inst_norm_field_etypes (span : Meta.span) (ctx : eval_ctx)
(def : type_decl) (opt_variant_id : VariantId.id option)
(generics : generic_args) : ty list =
let types =
Subst.type_decl_get_instantiated_field_types def opt_variant_id generics
in
- let types = List.map (ctx_normalize_ty meta ctx) types in
+ let types = List.map (ctx_normalize_ty span ctx) types in
List.map Subst.erase_regions types
(** Same as [ctx_adt_get_instantiated_field_types] but normalizes the types and
erases the regions. *)
-let ctx_adt_get_inst_norm_field_etypes (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_adt_get_inst_norm_field_etypes (span : Meta.span) (ctx : eval_ctx)
(def_id : TypeDeclId.id) (opt_variant_id : VariantId.id option)
(generics : generic_args) : ty list =
let types =
Subst.ctx_adt_get_instantiated_field_types ctx def_id opt_variant_id
generics
in
- let types = List.map (ctx_normalize_ty meta ctx) types in
+ let types = List.map (ctx_normalize_ty span ctx) types in
List.map Subst.erase_regions types
(** Same as [substitute_signature] but normalizes the types *)
-let ctx_subst_norm_signature (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_subst_norm_signature (span : Meta.span) (ctx : eval_ctx)
(asubst : RegionGroupId.id -> AbstractionId.id)
(r_subst : RegionVarId.id -> RegionId.id) (ty_subst : TypeVarId.id -> ty)
(cg_subst : ConstGenericVarId.id -> const_generic)
@@ -591,11 +591,11 @@ let ctx_subst_norm_signature (meta : Meta.meta) (ctx : eval_ctx)
sg regions_hierarchy
in
let { regions_hierarchy; inputs; output; trait_type_constraints } = sg in
- let inputs = List.map (ctx_normalize_ty meta ctx) inputs in
- let output = ctx_normalize_ty meta ctx output in
+ let inputs = List.map (ctx_normalize_ty span ctx) inputs in
+ let output = ctx_normalize_ty span ctx output in
let trait_type_constraints =
List.map
- (ctx_normalize_trait_type_constraint meta ctx)
+ (ctx_normalize_trait_type_constraint span ctx)
trait_type_constraints
in
{ regions_hierarchy; inputs; output; trait_type_constraints }
diff --git a/compiler/Contexts.ml b/compiler/Contexts.ml
index 0a62f5ef..745c22b6 100644
--- a/compiler/Contexts.ml
+++ b/compiler/Contexts.ml
@@ -286,7 +286,7 @@ let lookup_const_generic_var (ctx : eval_ctx) (vid : ConstGenericVarId.id) :
ConstGenericVarId.nth ctx.const_generic_vars vid
(** Lookup a variable in the current frame *)
-let env_lookup_var (meta : Meta.meta) (env : env) (vid : VarId.id) :
+let env_lookup_var (span : Meta.span) (env : env) (vid : VarId.id) :
var_binder * typed_value =
(* We take care to stop at the end of current frame: different variables
in different frames can have the same id!
@@ -298,13 +298,13 @@ let env_lookup_var (meta : Meta.meta) (env : env) (vid : VarId.id) :
| EBinding (BVar var, v) :: env' ->
if var.index = vid then (var, v) else lookup env'
| (EBinding (BDummy _, _) | EAbs _) :: env' -> lookup env'
- | EFrame :: _ -> craise __FILE__ __LINE__ meta "End of frame"
+ | EFrame :: _ -> craise __FILE__ __LINE__ span "End of frame"
in
lookup env
-let ctx_lookup_var_binder (meta : Meta.meta) (ctx : eval_ctx) (vid : VarId.id) :
+let ctx_lookup_var_binder (span : Meta.span) (ctx : eval_ctx) (vid : VarId.id) :
var_binder =
- fst (env_lookup_var meta ctx.env vid)
+ fst (env_lookup_var span ctx.env vid)
let ctx_lookup_type_decl (ctx : eval_ctx) (tid : TypeDeclId.id) : type_decl =
TypeDeclId.Map.find tid ctx.type_ctx.type_decls
@@ -323,14 +323,14 @@ let ctx_lookup_trait_impl (ctx : eval_ctx) (id : TraitImplId.id) : trait_impl =
TraitImplId.Map.find id ctx.trait_impls_ctx.trait_impls
(** Retrieve a variable's value in the current frame *)
-let env_lookup_var_value (meta : Meta.meta) (env : env) (vid : VarId.id) :
+let env_lookup_var_value (span : Meta.span) (env : env) (vid : VarId.id) :
typed_value =
- snd (env_lookup_var meta env vid)
+ snd (env_lookup_var span env vid)
(** Retrieve a variable's value in an evaluation context *)
-let ctx_lookup_var_value (meta : Meta.meta) (ctx : eval_ctx) (vid : VarId.id) :
+let ctx_lookup_var_value (span : Meta.span) (ctx : eval_ctx) (vid : VarId.id) :
typed_value =
- env_lookup_var_value meta ctx.env vid
+ env_lookup_var_value span ctx.env vid
(** Retrieve a const generic value in an evaluation context *)
let ctx_lookup_const_generic_value (ctx : eval_ctx) (vid : ConstGenericVarId.id)
@@ -342,19 +342,19 @@ let ctx_lookup_const_generic_value (ctx : eval_ctx) (vid : ConstGenericVarId.id)
This is a helper function: it can break invariants and doesn't perform
any check.
*)
-let env_update_var_value (meta : Meta.meta) (env : env) (vid : VarId.id)
+let env_update_var_value (span : Meta.span) (env : env) (vid : VarId.id)
(nv : typed_value) : env =
(* We take care to stop at the end of current frame: different variables
in different frames can have the same id!
*)
let rec update env =
match env with
- | [] -> craise __FILE__ __LINE__ meta "Unexpected"
+ | [] -> craise __FILE__ __LINE__ span "Unexpected"
| EBinding ((BVar b as var), v) :: env' ->
if b.index = vid then EBinding (var, nv) :: env'
else EBinding (var, v) :: update env'
| ((EBinding (BDummy _, _) | EAbs _) as ee) :: env' -> ee :: update env'
- | EFrame :: _ -> craise __FILE__ __LINE__ meta "End of frame"
+ | EFrame :: _ -> craise __FILE__ __LINE__ span "End of frame"
in
update env
@@ -366,20 +366,20 @@ let var_to_binder (var : var) : var_binder =
This is a helper function: it can break invariants and doesn't perform
any check.
*)
-let ctx_update_var_value (meta : Meta.meta) (ctx : eval_ctx) (vid : VarId.id)
+let ctx_update_var_value (span : Meta.span) (ctx : eval_ctx) (vid : VarId.id)
(nv : typed_value) : eval_ctx =
- { ctx with env = env_update_var_value meta ctx.env vid nv }
+ { ctx with env = env_update_var_value span ctx.env vid nv }
(** Push a variable in the context's environment.
Checks that the pushed variable and its value have the same type (this
is important).
*)
-let ctx_push_var (meta : Meta.meta) (ctx : eval_ctx) (var : var)
+let ctx_push_var (span : Meta.span) (ctx : eval_ctx) (var : var)
(v : typed_value) : eval_ctx =
cassert __FILE__ __LINE__
(TypesUtils.ty_is_ety var.var_ty && var.var_ty = v.ty)
- meta "The pushed variables and their values do not have the same type";
+ span "The pushed variables and their values do not have the same type";
let bv = var_to_binder var in
{ ctx with env = EBinding (BVar bv, v) :: ctx.env }
@@ -388,7 +388,7 @@ let ctx_push_var (meta : Meta.meta) (ctx : eval_ctx) (var : var)
Checks that the pushed variables and their values have the same type (this
is important).
*)
-let ctx_push_vars (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_push_vars (span : Meta.span) (ctx : eval_ctx)
(vars : (var * typed_value) list) : eval_ctx =
log#ldebug
(lazy
@@ -404,7 +404,7 @@ let ctx_push_vars (meta : Meta.meta) (ctx : eval_ctx)
(fun (var, (value : typed_value)) ->
TypesUtils.ty_is_ety var.var_ty && var.var_ty = value.ty)
vars)
- meta "The pushed variables and their values do not have the same type";
+ span "The pushed variables and their values do not have the same type";
let vars =
List.map
(fun (var, value) -> EBinding (BVar (var_to_binder var), value))
@@ -426,11 +426,11 @@ let ctx_push_fresh_dummy_vars (ctx : eval_ctx) (vl : typed_value list) :
List.fold_left (fun ctx v -> ctx_push_fresh_dummy_var ctx v) ctx vl
(** Remove a dummy variable from a context's environment. *)
-let ctx_remove_dummy_var meta (ctx : eval_ctx) (vid : DummyVarId.id) :
+let ctx_remove_dummy_var span (ctx : eval_ctx) (vid : DummyVarId.id) :
eval_ctx * typed_value =
let rec remove_var (env : env) : env * typed_value =
match env with
- | [] -> craise __FILE__ __LINE__ meta "Could not lookup a dummy variable"
+ | [] -> craise __FILE__ __LINE__ span "Could not lookup a dummy variable"
| EBinding (BDummy vid', v) :: env when vid' = vid -> (env, v)
| ee :: env ->
let env, v = remove_var env in
@@ -440,11 +440,11 @@ let ctx_remove_dummy_var meta (ctx : eval_ctx) (vid : DummyVarId.id) :
({ ctx with env }, v)
(** Lookup a dummy variable in a context's environment. *)
-let ctx_lookup_dummy_var (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_lookup_dummy_var (span : Meta.span) (ctx : eval_ctx)
(vid : DummyVarId.id) : typed_value =
let rec lookup_var (env : env) : typed_value =
match env with
- | [] -> craise __FILE__ __LINE__ meta "Could not lookup a dummy variable"
+ | [] -> craise __FILE__ __LINE__ span "Could not lookup a dummy variable"
| EBinding (BDummy vid', v) :: _env when vid' = vid -> v
| _ :: env -> lookup_var env
in
@@ -460,17 +460,17 @@ let erase_regions (ty : ty) : ty =
v#visit_ty () ty
(** Push an uninitialized variable (which thus maps to {!constructor:Values.value.VBottom}) *)
-let ctx_push_uninitialized_var (meta : Meta.meta) (ctx : eval_ctx) (var : var) :
+let ctx_push_uninitialized_var (span : Meta.span) (ctx : eval_ctx) (var : var) :
eval_ctx =
- ctx_push_var meta ctx var (mk_bottom meta (erase_regions var.var_ty))
+ ctx_push_var span ctx var (mk_bottom span (erase_regions var.var_ty))
(** Push a list of uninitialized variables (which thus map to {!constructor:Values.value.VBottom}) *)
-let ctx_push_uninitialized_vars (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_push_uninitialized_vars (span : Meta.span) (ctx : eval_ctx)
(vars : var list) : eval_ctx =
let vars =
- List.map (fun v -> (v, mk_bottom meta (erase_regions v.var_ty))) vars
+ List.map (fun v -> (v, mk_bottom span (erase_regions v.var_ty))) vars
in
- ctx_push_vars meta ctx vars
+ ctx_push_vars span ctx vars
let env_find_abs (env : env) (pred : abs -> bool) : abs option =
let rec lookup env =
@@ -489,11 +489,11 @@ let env_lookup_abs_opt (env : env) (abs_id : AbstractionId.id) : abs option =
this abstraction (for instance, remove the abs id from all the parent sets
of all the other abstractions).
*)
-let env_remove_abs (meta : Meta.meta) (env : env) (abs_id : AbstractionId.id) :
+let env_remove_abs (span : Meta.span) (env : env) (abs_id : AbstractionId.id) :
env * abs option =
let rec remove (env : env) : env * abs option =
match env with
- | [] -> craise __FILE__ __LINE__ meta "Unreachable"
+ | [] -> craise __FILE__ __LINE__ span "Unreachable"
| EFrame :: _ -> (env, None)
| EBinding (bv, v) :: env ->
let env, abs_opt = remove env in
@@ -515,11 +515,11 @@ let env_remove_abs (meta : Meta.meta) (env : env) (abs_id : AbstractionId.id) :
we also substitute the abstraction id wherever it is used (i.e., in the
parent sets of the other abstractions).
*)
-let env_subst_abs (meta : Meta.meta) (env : env) (abs_id : AbstractionId.id)
+let env_subst_abs (span : Meta.span) (env : env) (abs_id : AbstractionId.id)
(nabs : abs) : env * abs option =
let rec update (env : env) : env * abs option =
match env with
- | [] -> craise __FILE__ __LINE__ meta "Unreachable"
+ | [] -> craise __FILE__ __LINE__ span "Unreachable"
| EFrame :: _ -> (* We're done *) (env, None)
| EBinding (bv, v) :: env ->
let env, opt_abs = update env in
@@ -551,22 +551,22 @@ let ctx_find_abs (ctx : eval_ctx) (p : abs -> bool) : abs option =
env_find_abs ctx.env p
(** See the comments for {!env_remove_abs} *)
-let ctx_remove_abs (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_remove_abs (span : Meta.span) (ctx : eval_ctx)
(abs_id : AbstractionId.id) : eval_ctx * abs option =
- let env, abs = env_remove_abs meta ctx.env abs_id in
+ let env, abs = env_remove_abs span ctx.env abs_id in
({ ctx with env }, abs)
(** See the comments for {!env_subst_abs} *)
-let ctx_subst_abs (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_subst_abs (span : Meta.span) (ctx : eval_ctx)
(abs_id : AbstractionId.id) (nabs : abs) : eval_ctx * abs option =
- let env, abs_opt = env_subst_abs meta ctx.env abs_id nabs in
+ let env, abs_opt = env_subst_abs span ctx.env abs_id nabs in
({ ctx with env }, abs_opt)
-let ctx_set_abs_can_end (meta : Meta.meta) (ctx : eval_ctx)
+let ctx_set_abs_can_end (span : Meta.span) (ctx : eval_ctx)
(abs_id : AbstractionId.id) (can_end : bool) : eval_ctx =
let abs = ctx_lookup_abs ctx abs_id in
let abs = { abs with can_end } in
- fst (ctx_subst_abs meta ctx abs_id abs)
+ fst (ctx_subst_abs span ctx abs_id abs)
let ctx_type_decl_is_rec (ctx : eval_ctx) (id : TypeDeclId.id) : bool =
let decl_group = TypeDeclId.Map.find id ctx.type_ctx.type_decls_groups in
diff --git a/compiler/Cps.ml b/compiler/Cps.ml
index 3f2e2eaa..142c2b08 100644
--- a/compiler/Cps.ml
+++ b/compiler/Cps.ml
@@ -100,10 +100,10 @@ let opt_list_to_list_opt (len : int) (el : 'a option list) : 'a list option =
let _ = assert (List.length expr_list = len) in
if Option.is_none (List.hd expr_list) then None else Some expr_list
-let cc_singleton file line meta cf el =
+let cc_singleton file line span cf el =
match el with
| Some [ e ] -> cf (Some e)
- | Some _ -> internal_error file line meta
+ | Some _ -> internal_error file line span
| _ -> None
(** It happens that we need to concatenate lists of results, for
@@ -112,7 +112,7 @@ let cc_singleton file line meta cf el =
to decompose the list of expressions we get to give it to the
individual continuations for the branches.
*)
-let comp_seqs (file : string) (line : int) (meta : Meta.meta)
+let comp_seqs (file : string) (line : int) (span : Meta.span)
(ls :
('a list
* (SymbolicAst.expression list option -> SymbolicAst.expression option))
@@ -126,7 +126,7 @@ let comp_seqs (file : string) (line : int) (meta : Meta.meta)
match ls with
| [] ->
(* End of the list of branches: there shouldn't be any expression remaining *)
- sanity_check file line (el = []) meta;
+ sanity_check file line (el = []) span;
[]
| (resl, cf) :: ls ->
(* Split the list of expressions between:
@@ -136,7 +136,7 @@ let comp_seqs (file : string) (line : int) (meta : Meta.meta)
(* Compute the expression for the current branch *)
let e0 = cf (Some el0) in
let e0 =
- match e0 with None -> internal_error file line meta | Some e -> e
+ match e0 with None -> internal_error file line span | Some e -> e
in
(* Compute the expressions for the remaining branches *)
let e = cc_aux ls el in
diff --git a/compiler/Errors.ml b/compiler/Errors.ml
index 30887593..6e2de7e1 100644
--- a/compiler/Errors.ml
+++ b/compiler/Errors.ml
@@ -1,70 +1,72 @@
let log = Logging.errors_log
-let meta_to_string (meta : Meta.meta) =
- let span = meta.span in
- let file = match span.file with Virtual s | Local s -> s in
+let span_to_string (span : Meta.span) =
+ let raw_span = span.span in
+ let file = match raw_span.file with Virtual s | Local s -> s in
let loc_to_string (l : Meta.loc) : string =
string_of_int l.line ^ ":" ^ string_of_int l.col
in
- "Source: '" ^ file ^ "', lines " ^ loc_to_string span.beg_loc ^ "-"
- ^ loc_to_string span.end_loc
+ "Source: '" ^ file ^ "', lines "
+ ^ loc_to_string raw_span.beg_loc
+ ^ "-"
+ ^ loc_to_string raw_span.end_loc
-let format_error_message (meta : Meta.meta option) (msg : string) =
- let meta =
- match meta with None -> "" | Some meta -> "\n" ^ meta_to_string meta
+let format_error_message (span : Meta.span option) (msg : string) =
+ let span =
+ match span with None -> "" | Some span -> "\n" ^ span_to_string span
in
- msg ^ meta
+ msg ^ span
let format_error_message_with_file_line (file : string) (line : int)
- (meta : Meta.meta option) (msg : string) =
+ (span : Meta.span option) (msg : string) =
"In file " ^ file ^ ", line " ^ string_of_int line ^ ":\n"
- ^ format_error_message meta msg
+ ^ format_error_message span msg
-exception CFailure of (Meta.meta option * string)
+exception CFailure of (Meta.span option * string)
-let error_list : (Meta.meta option * string) list ref = ref []
+let error_list : (Meta.span option * string) list ref = ref []
-let push_error (meta : Meta.meta option) (msg : string) =
- error_list := (meta, msg) :: !error_list
+let push_error (span : Meta.span option) (msg : string) =
+ error_list := (span, msg) :: !error_list
(** Register an error, and throw an exception if [throw] is true *)
let save_error (file : string) (line : int) ?(throw : bool = false)
- (meta : Meta.meta option) (msg : string) =
- push_error meta msg;
+ (span : Meta.span option) (msg : string) =
+ push_error span msg;
if !Config.fail_hard && throw then (
- let msg = format_error_message_with_file_line file line meta msg in
+ let msg = format_error_message_with_file_line file line span msg in
log#serror (msg ^ "\n");
raise (Failure msg))
-let craise_opt_meta (file : string) (line : int) (meta : Meta.meta option)
+let craise_opt_span (file : string) (line : int) (span : Meta.span option)
(msg : string) =
if !Config.fail_hard then (
- let msg = format_error_message_with_file_line file line meta msg in
+ let msg = format_error_message_with_file_line file line span msg in
log#serror (msg ^ "\n");
- raise (Failure (format_error_message_with_file_line file line meta msg)))
+ raise (Failure (format_error_message_with_file_line file line span msg)))
else
- let () = push_error meta msg in
- raise (CFailure (meta, msg))
+ let () = push_error span msg in
+ raise (CFailure (span, msg))
-let craise (file : string) (line : int) (meta : Meta.meta) (msg : string) =
- craise_opt_meta file line (Some meta) msg
+let craise (file : string) (line : int) (span : Meta.span) (msg : string) =
+ craise_opt_span file line (Some span) msg
-let cassert_opt_meta (file : string) (line : int) (b : bool)
- (meta : Meta.meta option) (msg : string) =
- if not b then craise_opt_meta file line meta msg
+let cassert_opt_span (file : string) (line : int) (b : bool)
+ (span : Meta.span option) (msg : string) =
+ if not b then craise_opt_span file line span msg
-let cassert (file : string) (line : int) (b : bool) (meta : Meta.meta)
+let cassert (file : string) (line : int) (b : bool) (span : Meta.span)
(msg : string) =
- cassert_opt_meta file line b (Some meta) msg
+ cassert_opt_span file line b (Some span) msg
-let sanity_check (file : string) (line : int) b meta =
- cassert file line b meta "Internal error, please file an issue"
+let sanity_check (file : string) (line : int) b span =
+ cassert file line b span "Internal error, please file an issue"
-let sanity_check_opt_meta (file : string) (line : int) b meta =
- cassert_opt_meta file line b meta "Internal error, please file an issue"
+let sanity_check_opt_span (file : string) (line : int) b span =
+ cassert_opt_span file line b span "Internal error, please file an issue"
-let internal_error (file : string) (line : int) meta =
- craise file line meta "Internal error, please file an issue"
+let internal_error (file : string) (line : int) span =
+ craise file line span "Internal error, please file an issue"
let exec_raise = craise
let exec_assert = cassert
diff --git a/compiler/Extract.ml b/compiler/Extract.ml
index 8efb59fb..035ea8fe 100644
--- a/compiler/Extract.ml
+++ b/compiler/Extract.ml
@@ -46,7 +46,7 @@ let extract_fun_decl_register_names (ctx : extraction_ctx)
let f = def.f in
let open ExtractBuiltin in
let fun_id = (Pure.FunId (FRegular f.def_id), f.loop_id) in
- ctx_add f.meta (FunId (FromLlbc fun_id)) fun_info.extract_name ctx
+ ctx_add f.span (FunId (FromLlbc fun_id)) fun_info.extract_name ctx
| None ->
(* Not builtin *)
(* If this is a trait method implementation, we prefix the name with the
@@ -60,7 +60,7 @@ let extract_fun_decl_register_names (ctx : extraction_ctx)
(* Add the decreases proof for Lean only *)
match !Config.backend with
| Coq | FStar -> ctx
- | HOL4 -> craise __FILE__ __LINE__ def.meta "Unexpected"
+ | HOL4 -> craise __FILE__ __LINE__ def.span "Unexpected"
| Lean -> ctx_add_decreases_proof def ctx
else ctx
in
@@ -90,7 +90,7 @@ let extract_global_decl_register_names (ctx : extraction_ctx)
TODO: we don't need something very generic anymore (some definitions used
to be polymorphic).
*)
-let extract_adt_g_value (meta : Meta.meta)
+let extract_adt_g_value (span : Meta.span)
(extract_value : extraction_ctx -> bool -> 'v -> extraction_ctx)
(fmt : F.formatter) (ctx : extraction_ctx) (is_single_pat : bool)
(inside : bool) (variant_id : VariantId.id option) (field_values : 'v list)
@@ -130,10 +130,10 @@ let extract_adt_g_value (meta : Meta.meta)
(* For now, we only support fully applied tuple constructors *)
cassert __FILE__ __LINE__
(List.length generics.types = List.length field_values)
- meta "Only fully applied tuple constructors are currently supported";
+ span "Only fully applied tuple constructors are currently supported";
cassert __FILE__ __LINE__
(generics.const_generics = [] && generics.trait_refs = [])
- meta "Only fully applied tuple constructors are currently supported";
+ span "Only fully applied tuple constructors are currently supported";
extract_as_tuple ()
| TAdt (adt_id, _) ->
(* "Regular" ADT *)
@@ -172,8 +172,8 @@ let extract_adt_g_value (meta : Meta.meta)
*)
let cons =
match variant_id with
- | Some vid -> ctx_get_variant meta adt_id vid ctx
- | None -> ctx_get_struct meta adt_id ctx
+ | Some vid -> ctx_get_variant span adt_id vid ctx
+ | None -> ctx_get_struct span adt_id ctx
in
let use_parentheses = inside && field_values <> [] in
if use_parentheses then F.pp_print_string fmt "(";
@@ -187,18 +187,18 @@ let extract_adt_g_value (meta : Meta.meta)
in
if use_parentheses then F.pp_print_string fmt ")";
ctx
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent typed value"
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent typed value"
(* Extract globals in the same way as variables *)
-let extract_global (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
+let extract_global (span : Meta.span) (ctx : extraction_ctx) (fmt : F.formatter)
(inside : bool) (id : A.GlobalDeclId.id) (generics : generic_args) : unit =
let use_brackets = inside && generics <> empty_generic_args in
F.pp_open_hvbox fmt ctx.indent_incr;
if use_brackets then F.pp_print_string fmt "(";
(* Extract the global name *)
- F.pp_print_string fmt (ctx_get_global meta id ctx);
+ F.pp_print_string fmt (ctx_get_global span id ctx);
(* Extract the generics *)
- extract_generic_args meta ctx fmt TypeDeclId.Set.empty generics;
+ extract_generic_args span ctx fmt TypeDeclId.Set.empty generics;
if use_brackets then F.pp_print_string fmt ")";
F.pp_close_box fmt ()
@@ -236,7 +236,7 @@ let fun_builtin_filter_types (id : FunDeclId.id) (types : 'a list)
As a pattern can introduce new variables, we return an extraction context
updated with new bindings.
*)
-let rec extract_typed_pattern (meta : Meta.meta) (ctx : extraction_ctx)
+let rec extract_typed_pattern (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (is_let : bool) (inside : bool) ?(with_type = false)
(v : typed_pattern) : extraction_ctx =
if with_type then F.pp_print_string fmt "(";
@@ -244,11 +244,11 @@ let rec extract_typed_pattern (meta : Meta.meta) (ctx : extraction_ctx)
let ctx =
match v.value with
| PatConstant cv ->
- extract_literal meta fmt inside cv;
+ extract_literal span fmt inside cv;
ctx
| PatVar (v, _) ->
- let vname = ctx_compute_var_basename meta ctx v.basename v.ty in
- let ctx, vname = ctx_add_var meta vname v.id ctx in
+ let vname = ctx_compute_var_basename span ctx v.basename v.ty in
+ let ctx, vname = ctx_add_var span vname v.id ctx in
F.pp_print_string fmt vname;
ctx
| PatDummy ->
@@ -256,22 +256,22 @@ let rec extract_typed_pattern (meta : Meta.meta) (ctx : extraction_ctx)
ctx
| PatAdt av ->
let extract_value ctx inside v =
- extract_typed_pattern meta ctx fmt is_let inside v
+ extract_typed_pattern span ctx fmt is_let inside v
in
- extract_adt_g_value meta extract_value fmt ctx is_let inside
+ extract_adt_g_value span extract_value fmt ctx is_let inside
av.variant_id av.field_values v.ty
in
if with_type then (
F.pp_print_space fmt ();
F.pp_print_string fmt ":";
F.pp_print_space fmt ();
- extract_ty meta ctx fmt TypeDeclId.Set.empty false v.ty;
+ extract_ty span ctx fmt TypeDeclId.Set.empty false v.ty;
F.pp_print_string fmt ")");
ctx
(** Return true if we need to wrap a succession of let-bindings in a [do ...]
block (because some of them are monadic) *)
-let lets_require_wrap_in_do (meta : Meta.meta)
+let lets_require_wrap_in_do (span : Meta.span)
(lets : (bool * typed_pattern * texpression) list) : bool =
match !backend with
| Lean ->
@@ -283,7 +283,7 @@ let lets_require_wrap_in_do (meta : Meta.meta)
if wrap_in_do then
sanity_check __FILE__ __LINE__
(List.for_all (fun (m, _, _) -> m) lets)
- meta;
+ span;
wrap_in_do
| FStar | Coq -> false
@@ -304,38 +304,38 @@ let extract_texpression_errors (fmt : F.formatter) =
| Lean -> F.pp_print_string fmt "sorry"
| HOL4 -> F.pp_print_string fmt "(* ERROR: could not generate the code *)"
-let rec extract_texpression (meta : Meta.meta) (ctx : extraction_ctx)
+let rec extract_texpression (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (inside : bool) (e : texpression) : unit =
match e.e with
| Var var_id ->
- let var_name = ctx_get_var meta var_id ctx in
+ let var_name = ctx_get_var span var_id ctx in
F.pp_print_string fmt var_name
| CVar var_id ->
- let var_name = ctx_get_const_generic_var meta var_id ctx in
+ let var_name = ctx_get_const_generic_var span var_id ctx in
F.pp_print_string fmt var_name
- | Const cv -> extract_literal meta fmt inside cv
+ | Const cv -> extract_literal span fmt inside cv
| App _ ->
let app, args = destruct_apps e in
- extract_App meta ctx fmt inside app args
+ extract_App span ctx fmt inside app args
| Lambda _ ->
let xl, e = destruct_lambdas e in
- extract_Lambda (meta : Meta.meta) ctx fmt inside xl e
+ extract_Lambda (span : Meta.span) ctx fmt inside xl e
| Qualif _ ->
(* We use the app case *)
- extract_App meta ctx fmt inside e []
- | Let (_, _, _, _) -> extract_lets meta ctx fmt inside e
- | Switch (scrut, body) -> extract_Switch meta ctx fmt inside scrut body
- | Meta (_, e) -> extract_texpression meta ctx fmt inside e
- | StructUpdate supd -> extract_StructUpdate meta ctx fmt inside e.ty supd
+ extract_App span ctx fmt inside e []
+ | Let (_, _, _, _) -> extract_lets span ctx fmt inside e
+ | Switch (scrut, body) -> extract_Switch span ctx fmt inside scrut body
+ | Meta (_, e) -> extract_texpression span ctx fmt inside e
+ | StructUpdate supd -> extract_StructUpdate span ctx fmt inside e.ty supd
| Loop _ ->
(* The loop nodes should have been eliminated in {!PureMicroPasses} *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| EError (_, _) -> extract_texpression_errors fmt
(* Extract an application *or* a top-level qualif (function extraction has
* to handle top-level qualifiers, so it seemed more natural to merge the
* two cases) *)
-and extract_App (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
+and extract_App (span : Meta.span) (ctx : extraction_ctx) (fmt : F.formatter)
(inside : bool) (app : texpression) (args : texpression list) : unit =
(* We don't do the same thing if the app is a top-level identifier (function,
* ADT constructor...) or a "regular" expression *)
@@ -344,19 +344,19 @@ and extract_App (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(* Top-level qualifier *)
match qualif.id with
| FunOrOp fun_id ->
- extract_function_call meta ctx fmt inside fun_id qualif.generics args
+ extract_function_call span ctx fmt inside fun_id qualif.generics args
| Global global_id ->
assert (args = []);
- extract_global meta ctx fmt inside global_id qualif.generics
+ extract_global span ctx fmt inside global_id qualif.generics
| AdtCons adt_cons_id ->
- extract_adt_cons meta ctx fmt inside adt_cons_id qualif.generics args
+ extract_adt_cons span ctx fmt inside adt_cons_id qualif.generics args
| Proj proj ->
- extract_field_projector meta ctx fmt inside app proj qualif.generics
+ extract_field_projector span ctx fmt inside app proj qualif.generics
args
| TraitConst (trait_ref, const_name) ->
- extract_trait_ref meta ctx fmt TypeDeclId.Set.empty true trait_ref;
+ extract_trait_ref span ctx fmt TypeDeclId.Set.empty true trait_ref;
let name =
- ctx_get_trait_const meta trait_ref.trait_decl_ref.trait_decl_id
+ ctx_get_trait_const span trait_ref.trait_decl_ref.trait_decl_id
const_name ctx
in
let add_brackets (s : string) =
@@ -371,12 +371,12 @@ and extract_App (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Print the app expression *)
let app_inside = (inside && args = []) || args <> [] in
- extract_texpression meta ctx fmt app_inside app;
+ extract_texpression span ctx fmt app_inside app;
(* Print the arguments *)
List.iter
(fun ve ->
F.pp_print_space fmt ();
- extract_texpression meta ctx fmt true ve)
+ extract_texpression span ctx fmt true ve)
args;
(* Close the box for the application *)
F.pp_close_box fmt ();
@@ -384,7 +384,7 @@ and extract_App (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
if inside then F.pp_print_string fmt ")"
(** Subcase of the app case: function call *)
-and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_function_call (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (inside : bool) (fid : fun_or_op_id)
(generics : generic_args) (args : texpression list) : unit =
match (fid, args) with
@@ -393,11 +393,11 @@ and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
* Note that the way we generate the translation, we shouldn't get the
* case where we have no argument (all functions are fully instantiated,
* and no AST transformation introduces partial calls). *)
- extract_unop meta (extract_texpression meta ctx fmt) fmt inside unop arg
+ extract_unop span (extract_texpression span ctx fmt) fmt inside unop arg
| Binop (binop, int_ty), [ arg0; arg1 ] ->
(* Number of arguments: similar to unop *)
- extract_binop meta
- (extract_texpression meta ctx fmt)
+ extract_binop span
+ (extract_texpression span ctx fmt)
fmt inside binop int_ty arg0 arg1
| Fun fun_id, _ ->
if inside then F.pp_print_string fmt "(";
@@ -464,11 +464,11 @@ and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
if not method_id.is_provided then (
(* Required method *)
- sanity_check __FILE__ __LINE__ (lp_id = None) trait_decl.meta;
- extract_trait_ref trait_decl.meta ctx fmt TypeDeclId.Set.empty true
+ sanity_check __FILE__ __LINE__ (lp_id = None) trait_decl.span;
+ extract_trait_ref trait_decl.span ctx fmt TypeDeclId.Set.empty true
trait_ref;
let fun_name =
- ctx_get_trait_method meta trait_ref.trait_decl_ref.trait_decl_id
+ ctx_get_trait_method span trait_ref.trait_decl_ref.trait_decl_id
method_name ctx
in
let add_brackets (s : string) =
@@ -479,7 +479,7 @@ and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
(* Provided method: we see it as a regular function call, and use
the function name *)
let fun_id = FromLlbc (FunId (FRegular method_id.id), lp_id) in
- let fun_name = ctx_get_function trait_decl.meta fun_id ctx in
+ let fun_name = ctx_get_function trait_decl.span fun_id ctx in
F.pp_print_string fmt fun_name;
(* Note that we do not need to print the generics for the trait
@@ -488,16 +488,16 @@ and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
Print the trait ref (to instantate the self clause) *)
F.pp_print_space fmt ();
- extract_trait_ref trait_decl.meta ctx fmt TypeDeclId.Set.empty true
+ extract_trait_ref trait_decl.span ctx fmt TypeDeclId.Set.empty true
trait_ref
| _ ->
- let fun_name = ctx_get_function meta fun_id ctx in
+ let fun_name = ctx_get_function span fun_id ctx in
F.pp_print_string fmt fun_name);
(* Sanity check: HOL4 doesn't support const generics *)
sanity_check __FILE__ __LINE__
(generics.const_generics = [] || !backend <> HOL4)
- meta;
+ span;
(* Print the generics.
We might need to filter some of the type arguments, if the type
@@ -512,12 +512,12 @@ and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
in
(match types with
| Ok types ->
- extract_generic_args meta ctx fmt TypeDeclId.Set.empty
+ extract_generic_args span ctx fmt TypeDeclId.Set.empty
{ generics with types }
| Error (types, err) ->
- extract_generic_args meta ctx fmt TypeDeclId.Set.empty
+ extract_generic_args span ctx fmt TypeDeclId.Set.empty
{ generics with types };
- save_error __FILE__ __LINE__ (Some meta) err;
+ save_error __FILE__ __LINE__ (Some span) err;
F.pp_print_string fmt
"(\"ERROR: ill-formed builtin: invalid number of filtering \
arguments\")");
@@ -525,14 +525,14 @@ and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
List.iter
(fun ve ->
F.pp_print_space fmt ();
- extract_texpression meta ctx fmt true ve)
+ extract_texpression span ctx fmt true ve)
args;
(* Close the box for the function call *)
F.pp_close_box fmt ();
(* Return *)
if inside then F.pp_print_string fmt ")"
| (Unop _ | Binop _), _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Unreachable:\n" ^ "Function: " ^ show_fun_or_op_id fid
^ ",\nNumber of arguments: "
^ string_of_int (List.length args)
@@ -540,22 +540,22 @@ and extract_function_call (meta : Meta.meta) (ctx : extraction_ctx)
^ String.concat " " (List.map show_texpression args))
(** Subcase of the app case: ADT constructor *)
-and extract_adt_cons (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_adt_cons (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (inside : bool) (adt_cons : adt_cons_id)
(generics : generic_args) (args : texpression list) : unit =
let e_ty = TAdt (adt_cons.adt_id, generics) in
let is_single_pat = false in
let _ =
- extract_adt_g_value meta
+ extract_adt_g_value span
(fun ctx inside e ->
- extract_texpression meta ctx fmt inside e;
+ extract_texpression span ctx fmt inside e;
ctx)
fmt ctx is_single_pat inside adt_cons.variant_id args e_ty
in
()
(** Subcase of the app case: ADT field projector. *)
-and extract_field_projector (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_field_projector (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (inside : bool) (original_app : texpression)
(proj : projection) (_generics : generic_args) (args : texpression list) :
unit =
@@ -582,7 +582,7 @@ and extract_field_projector (meta : Meta.meta) (ctx : extraction_ctx)
match num_fields with Some len -> len = 1 | None -> false
in
if is_tuple_struct && has_one_field then
- extract_texpression meta ctx fmt inside arg
+ extract_texpression span ctx fmt inside arg
else
(* Exactly one argument: pretty-print *)
let field_name =
@@ -633,12 +633,12 @@ and extract_field_projector (meta : Meta.meta) (ctx : extraction_ctx)
if field_id + 1 = Option.get num_fields then twos_prefix
else twos_prefix ^ ".1"
else "#" ^ string_of_int field_id
- else ctx_get_field meta proj.adt_id proj.field_id ctx
+ else ctx_get_field span proj.adt_id proj.field_id ctx
in
(* Open a box *)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Extract the expression *)
- extract_texpression meta ctx fmt true arg;
+ extract_texpression span ctx fmt true arg;
(* We allow to break where the "." appears (except Lean, it's a syntax error) *)
if !backend <> Lean then F.pp_print_break fmt 0 0;
F.pp_print_string fmt ".";
@@ -651,26 +651,26 @@ and extract_field_projector (meta : Meta.meta) (ctx : extraction_ctx)
| arg :: args ->
(* Call extract_App again, but in such a way that the first argument is
* isolated *)
- extract_App meta ctx fmt inside (mk_app meta original_app arg) args
+ extract_App span ctx fmt inside (mk_app span original_app arg) args
| [] ->
(* No argument: shouldn't happen *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
-and extract_Lambda (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
+and extract_Lambda (span : Meta.span) (ctx : extraction_ctx) (fmt : F.formatter)
(inside : bool) (xl : typed_pattern list) (e : texpression) : unit =
(* Open a box for the abs expression *)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Open parentheses *)
if inside then F.pp_print_string fmt "(";
(* Print the lambda - note that there should always be at least one variable *)
- sanity_check __FILE__ __LINE__ (xl <> []) meta;
+ sanity_check __FILE__ __LINE__ (xl <> []) span;
F.pp_print_string fmt "fun";
let with_type = !backend = Coq in
let ctx =
List.fold_left
(fun ctx x ->
F.pp_print_space fmt ();
- extract_typed_pattern meta ctx fmt true true ~with_type x)
+ extract_typed_pattern span ctx fmt true true ~with_type x)
ctx xl
in
F.pp_print_space fmt ();
@@ -678,13 +678,13 @@ and extract_Lambda (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
else F.pp_print_string fmt "->";
F.pp_print_space fmt ();
(* Print the body *)
- extract_texpression meta ctx fmt false e;
+ extract_texpression span ctx fmt false e;
(* Close parentheses *)
if inside then F.pp_print_string fmt ")";
(* Close the box for the abs expression *)
F.pp_close_box fmt ()
-and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
+and extract_lets (span : Meta.span) (ctx : extraction_ctx) (fmt : F.formatter)
(inside : bool) (e : texpression) : unit =
(* Destruct the lets.
@@ -710,7 +710,7 @@ and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
*)
let lets, next_e =
match !backend with
- | HOL4 -> destruct_lets_no_interleave meta e
+ | HOL4 -> destruct_lets_no_interleave span e
| FStar | Coq | Lean -> destruct_lets e
in
(* Extract the let-bindings *)
@@ -731,16 +731,16 @@ and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
* TODO: cleanup
* *)
if monadic && (!backend = Coq || !backend = HOL4) then (
- let ctx = extract_typed_pattern meta ctx fmt true true lv in
+ let ctx = extract_typed_pattern span ctx fmt true true lv in
F.pp_print_space fmt ();
let arrow =
match !backend with
| Coq | HOL4 -> "<-"
- | FStar | Lean -> craise __FILE__ __LINE__ meta "impossible"
+ | FStar | Lean -> craise __FILE__ __LINE__ span "impossible"
in
F.pp_print_string fmt arrow;
F.pp_print_space fmt ();
- extract_texpression meta ctx fmt false re;
+ extract_texpression span ctx fmt false re;
F.pp_print_string fmt ";";
ctx)
else (
@@ -757,7 +757,7 @@ and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
else (
F.pp_print_string fmt "let";
F.pp_print_space fmt ());
- let ctx = extract_typed_pattern meta ctx fmt true true lv in
+ let ctx = extract_typed_pattern span ctx fmt true true lv in
F.pp_print_space fmt ();
let eq =
match !backend with
@@ -768,7 +768,7 @@ and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
in
F.pp_print_string fmt eq;
F.pp_print_space fmt ();
- extract_texpression meta ctx fmt false re;
+ extract_texpression span ctx fmt false re;
(* End the let-binding *)
(match !backend with
| Lean ->
@@ -796,7 +796,7 @@ and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
if inside && !backend <> Lean then F.pp_print_string fmt "(";
(* If Lean and HOL4, we rely on monadic blocks, so we insert a do and open a new box
immediately *)
- let wrap_in_do_od = lets_require_wrap_in_do meta lets in
+ let wrap_in_do_od = lets_require_wrap_in_do span lets in
if wrap_in_do_od then (
F.pp_print_string fmt "do";
F.pp_print_space fmt ());
@@ -808,7 +808,7 @@ and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(* Open a box for the next expression *)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Print the next expression *)
- extract_texpression meta ctx fmt false next_e;
+ extract_texpression span ctx fmt false next_e;
(* Close the box for the next expression *)
F.pp_close_box fmt ();
@@ -822,7 +822,7 @@ and extract_lets (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(* Close the box for the whole expression *)
F.pp_close_box fmt ()
-and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
+and extract_Switch (span : Meta.span) (ctx : extraction_ctx) (fmt : F.formatter)
(_inside : bool) (scrut : texpression) (body : switch_body) : unit =
(* Remark: we don't use the [inside] parameter because we extract matches in
a conservative manner: we always make sure they are parenthesized/delimited
@@ -842,9 +842,9 @@ and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
if !backend = Lean && ctx.use_dep_ite then F.pp_print_string fmt " h:";
F.pp_print_space fmt ();
let scrut_inside =
- PureUtils.texpression_requires_parentheses meta scrut
+ PureUtils.texpression_requires_parentheses span scrut
in
- extract_texpression meta ctx fmt scrut_inside scrut;
+ extract_texpression span ctx fmt scrut_inside scrut;
(* Close the box for the [if e] *)
F.pp_close_box fmt ();
@@ -858,7 +858,7 @@ and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
let then_or_else = if is_then then "then" else "else" in
F.pp_print_string fmt then_or_else;
let parenth =
- PureUtils.texpression_requires_parentheses meta e_branch
+ PureUtils.texpression_requires_parentheses span e_branch
in
(* Open the parenthesized expression *)
let print_space_after_parenth =
@@ -880,7 +880,7 @@ and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(* Open a box for the branch *)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Print the branch expression *)
- extract_texpression meta ctx fmt false e_branch;
+ extract_texpression span ctx fmt false e_branch;
(* Close the box for the branch *)
F.pp_close_box fmt ();
(* Close the parenthesized expression *)
@@ -912,9 +912,9 @@ and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_string fmt match_begin;
F.pp_print_space fmt ();
let scrut_inside =
- PureUtils.texpression_requires_parentheses meta scrut
+ PureUtils.texpression_requires_parentheses span scrut
in
- extract_texpression meta ctx fmt scrut_inside scrut;
+ extract_texpression span ctx fmt scrut_inside scrut;
F.pp_print_space fmt ();
let match_scrut_end =
match !backend with FStar | Coq | Lean -> "with" | HOL4 -> "of"
@@ -933,7 +933,7 @@ and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(* Print the pattern *)
F.pp_print_string fmt "|";
F.pp_print_space fmt ();
- let ctx = extract_typed_pattern meta ctx fmt false false br.pat in
+ let ctx = extract_typed_pattern span ctx fmt false false br.pat in
F.pp_print_space fmt ();
let arrow =
match !backend with FStar -> "->" | Coq | Lean | HOL4 -> "=>"
@@ -945,7 +945,7 @@ and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(* Open a box for the branch *)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Print the branch itself *)
- extract_texpression meta ctx fmt false br.branch;
+ extract_texpression span ctx fmt false br.branch;
(* Close the box for the branch *)
F.pp_close_box fmt ();
(* Close the box for the pattern+branch *)
@@ -964,12 +964,12 @@ and extract_Switch (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(* Close the box for the whole expression *)
F.pp_close_box fmt ()
-and extract_StructUpdate (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_StructUpdate (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (inside : bool) (e_ty : ty) (supd : struct_update) :
unit =
(* We can't update a subset of the fields in Coq (i.e., we can do
[{| x:= 3; y := 4 |}], but there is no syntax for [{| s with x := 3 |}]) *)
- sanity_check __FILE__ __LINE__ (!backend <> Coq || supd.init = None) meta;
+ sanity_check __FILE__ __LINE__ (!backend <> Coq || supd.init = None) span;
(* In the case of HOL4, records with no fields are not supported and are
thus extracted to unit. We need to check that by looking up the definition *)
let extract_as_unit =
@@ -1034,7 +1034,7 @@ and extract_StructUpdate (meta : Meta.meta) (ctx : extraction_ctx)
if need_paren then F.pp_print_string fmt "(";
F.pp_open_hvbox fmt ctx.indent_incr;
if supd.init <> None then (
- let var_name = ctx_get_var meta (Option.get supd.init) ctx in
+ let var_name = ctx_get_var span (Option.get supd.init) ctx in
F.pp_print_string fmt var_name;
F.pp_print_space fmt ();
F.pp_print_string fmt "with";
@@ -1053,12 +1053,12 @@ and extract_StructUpdate (meta : Meta.meta) (ctx : extraction_ctx)
F.pp_print_space fmt ())
(fun (fid, fe) ->
F.pp_open_hvbox fmt ctx.indent_incr;
- let f = ctx_get_field meta supd.struct_id fid ctx in
+ let f = ctx_get_field span supd.struct_id fid ctx in
F.pp_print_string fmt f;
F.pp_print_string fmt (" " ^ assign);
F.pp_print_space fmt ();
F.pp_open_hvbox fmt ctx.indent_incr;
- extract_texpression meta ctx fmt true fe;
+ extract_texpression span ctx fmt true fe;
F.pp_close_box fmt ();
F.pp_close_box fmt ())
supd.updates;
@@ -1077,16 +1077,16 @@ and extract_StructUpdate (meta : Meta.meta) (ctx : extraction_ctx)
(* Open the box for `Array.replicate T N [` *)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Print the array constructor *)
- let cs = ctx_get_struct meta (TAssumed TArray) ctx in
+ let cs = ctx_get_struct span (TAssumed TArray) ctx in
F.pp_print_string fmt cs;
(* Print the parameters *)
- let _, generics = ty_as_adt meta e_ty in
+ let _, generics = ty_as_adt span e_ty in
let ty = Collections.List.to_cons_nil generics.types in
F.pp_print_space fmt ();
- extract_ty meta ctx fmt TypeDeclId.Set.empty true ty;
+ extract_ty span ctx fmt TypeDeclId.Set.empty true ty;
let cg = Collections.List.to_cons_nil generics.const_generics in
F.pp_print_space fmt ();
- extract_const_generic meta ctx fmt true cg;
+ extract_const_generic span ctx fmt true cg;
F.pp_print_space fmt ();
F.pp_print_string fmt "[";
(* Close the box for `Array.mk T N [` *)
@@ -1101,7 +1101,7 @@ and extract_StructUpdate (meta : Meta.meta) (ctx : extraction_ctx)
(fun () ->
F.pp_print_string fmt delimiter;
F.pp_print_space fmt ())
- (fun (_, fe) -> extract_texpression meta ctx fmt false fe)
+ (fun (_, fe) -> extract_texpression span ctx fmt false fe)
supd.updates;
(* Close the boxes *)
F.pp_close_box fmt ();
@@ -1109,7 +1109,7 @@ and extract_StructUpdate (meta : Meta.meta) (ctx : extraction_ctx)
F.pp_print_string fmt "]";
if need_paren then F.pp_print_string fmt ")";
F.pp_close_box fmt ()
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
(** A small utility to print the parameters of a function signature.
@@ -1143,7 +1143,7 @@ let extract_fun_parameters (space : bool ref) (ctx : extraction_ctx)
match def.kind with
| TraitItemProvided (decl_id, _) ->
let trait_decl = T.TraitDeclId.Map.find decl_id ctx.trans_trait_decls in
- let ctx, _ = ctx_add_trait_self_clause def.meta ctx in
+ let ctx, _ = ctx_add_trait_self_clause def.span ctx in
let ctx = { ctx with is_provided_method = true } in
(ctx, Some trait_decl)
| _ -> (ctx, None)
@@ -1151,14 +1151,14 @@ let extract_fun_parameters (space : bool ref) (ctx : extraction_ctx)
(* Add the type parameters - note that we need those bindings only for the
* body translation (they are not top-level) *)
let ctx, type_params, cg_params, trait_clauses =
- ctx_add_generic_params def.meta def.llbc_name def.signature.llbc_generics
+ ctx_add_generic_params def.span def.llbc_name def.signature.llbc_generics
def.signature.generics ctx
in
(* Print the generics *)
(* Open a box for the generics *)
F.pp_open_hovbox fmt 0;
(let space = Some space in
- extract_generic_params def.meta ctx fmt TypeDeclId.Set.empty ~space
+ extract_generic_params def.span ctx fmt TypeDeclId.Set.empty ~space
~trait_decl def.signature.generics type_params cg_params trait_clauses);
(* Close the box for the generics *)
F.pp_close_box fmt ();
@@ -1173,11 +1173,11 @@ let extract_fun_parameters (space : bool ref) (ctx : extraction_ctx)
(* Open a box for the input parameter *)
F.pp_open_hovbox fmt 0;
F.pp_print_string fmt "(";
- let ctx = extract_typed_pattern def.meta ctx fmt true false lv in
+ let ctx = extract_typed_pattern def.span ctx fmt true false lv in
F.pp_print_space fmt ();
F.pp_print_string fmt ":";
F.pp_print_space fmt ();
- extract_ty def.meta ctx fmt TypeDeclId.Set.empty false lv.ty;
+ extract_ty def.span ctx fmt TypeDeclId.Set.empty false lv.ty;
F.pp_print_string fmt ")";
(* Close the box for the input parameters *)
F.pp_close_box fmt ();
@@ -1196,7 +1196,7 @@ let extract_fun_input_parameters_types (ctx : extraction_ctx)
(fmt : F.formatter) (def : fun_decl) : unit =
let extract_param (ty : ty) : unit =
let inside = false in
- extract_ty def.meta ctx fmt TypeDeclId.Set.empty inside ty;
+ extract_ty def.span ctx fmt TypeDeclId.Set.empty inside ty;
F.pp_print_space fmt ();
extract_arrow fmt ();
F.pp_print_space fmt ()
@@ -1206,13 +1206,13 @@ let extract_fun_input_parameters_types (ctx : extraction_ctx)
let extract_fun_inputs_output_parameters_types (ctx : extraction_ctx)
(fmt : F.formatter) (def : fun_decl) : unit =
extract_fun_input_parameters_types ctx fmt def;
- extract_ty def.meta ctx fmt TypeDeclId.Set.empty false def.signature.output
+ extract_ty def.span ctx fmt TypeDeclId.Set.empty false def.signature.output
-let assert_backend_supports_decreases_clauses (meta : Meta.meta) =
+let assert_backend_supports_decreases_clauses (span : Meta.span) =
match !backend with
| FStar | Lean -> ()
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Decreases clauses are only supported for the Lean and F* backends"
(** Extract a decreases clause function template body.
@@ -1233,13 +1233,13 @@ let assert_backend_supports_decreases_clauses (meta : Meta.meta) =
*)
let extract_template_fstar_decreases_clause (ctx : extraction_ctx)
(fmt : F.formatter) (def : fun_decl) : unit =
- cassert __FILE__ __LINE__ (!backend = FStar) def.meta
+ cassert __FILE__ __LINE__ (!backend = FStar) def.span
"The generation of template decrease clauses is only supported for the F* \
backend";
(* Retrieve the function name *)
let def_name =
- ctx_get_termination_measure def.meta def.def_id def.loop_id ctx
+ ctx_get_termination_measure def.span def.def_id def.loop_id ctx
in
(* Add a break before *)
F.pp_print_break fmt 0 0;
@@ -1249,9 +1249,9 @@ let extract_template_fstar_decreases_clause (ctx : extraction_ctx)
Some def.llbc_name
else None
in
- extract_comment_with_span ctx fmt
+ extract_comment_with_raw_span ctx fmt
[ "[" ^ name_to_string ctx def.llbc_name ^ "]: decreases clause" ]
- name def.meta.span);
+ name def.span.span);
F.pp_print_space fmt ();
(* Open a box for the definition, so that whenever possible it gets printed on
* one line *)
@@ -1302,7 +1302,7 @@ let extract_template_fstar_decreases_clause (ctx : extraction_ctx)
*)
let extract_template_lean_termination_and_decreasing (ctx : extraction_ctx)
(fmt : F.formatter) (def : fun_decl) : unit =
- cassert __FILE__ __LINE__ (!backend = Lean) def.meta
+ cassert __FILE__ __LINE__ (!backend = Lean) def.span
"The generation of template termination and decreasing clauses is only \
supported for the Lean backend";
(*
@@ -1310,15 +1310,15 @@ let extract_template_lean_termination_and_decreasing (ctx : extraction_ctx)
*)
(* Retrieve the function name *)
let def_name =
- ctx_get_termination_measure def.meta def.def_id def.loop_id ctx
+ ctx_get_termination_measure def.span def.def_id def.loop_id ctx
in
let def_body = Option.get def.body in
(* Add a break before *)
F.pp_print_break fmt 0 0;
(* Print a comment to link the extracted type to its original rust definition *)
- extract_comment_with_span ctx fmt
+ extract_comment_with_raw_span ctx fmt
[ "[" ^ name_to_string ctx def.llbc_name ^ "]: termination measure" ]
- None def.meta.span;
+ None def.span.span;
F.pp_print_space fmt ();
(* Open a box for the definition, so that whenever possible it gets printed on
* one line *)
@@ -1346,7 +1346,7 @@ let extract_template_lean_termination_and_decreasing (ctx : extraction_ctx)
let vars = List.map (fun (v : var) -> v.id) def_body.inputs in
if List.length vars = 1 then
- F.pp_print_string fmt (ctx_get_var def.meta (List.hd vars) ctx_body)
+ F.pp_print_string fmt (ctx_get_var def.span (List.hd vars) ctx_body)
else (
F.pp_open_hovbox fmt 0;
F.pp_print_string fmt "(";
@@ -1354,7 +1354,7 @@ let extract_template_lean_termination_and_decreasing (ctx : extraction_ctx)
(fun () ->
F.pp_print_string fmt ",";
F.pp_print_space fmt ())
- (fun v -> F.pp_print_string fmt (ctx_get_var def.meta v ctx_body))
+ (fun v -> F.pp_print_string fmt (ctx_get_var def.span v ctx_body))
vars;
F.pp_print_string fmt ")";
F.pp_close_box fmt ());
@@ -1368,12 +1368,12 @@ let extract_template_lean_termination_and_decreasing (ctx : extraction_ctx)
(*
* Extract a template for the decreases proof
*)
- let def_name = ctx_get_decreases_proof def.meta def.def_id def.loop_id ctx in
+ let def_name = ctx_get_decreases_proof def.span def.def_id def.loop_id ctx in
(* syntax <def_name> term ... term : tactic *)
F.pp_print_break fmt 0 0;
- extract_comment_with_span ctx fmt
+ extract_comment_with_raw_span ctx fmt
[ "[" ^ name_to_string ctx def.llbc_name ^ "]: decreases_by tactic" ]
- None def.meta.span;
+ None def.span.span;
F.pp_print_space fmt ();
F.pp_open_hvbox fmt 0;
F.pp_print_string fmt "syntax \"";
@@ -1391,7 +1391,7 @@ let extract_template_lean_termination_and_decreasing (ctx : extraction_ctx)
(fun v ->
F.pp_print_space fmt ();
F.pp_print_string fmt "$";
- F.pp_print_string fmt (ctx_get_var def.meta v ctx_body))
+ F.pp_print_string fmt (ctx_get_var def.span v ctx_body))
vars;
F.pp_print_string fmt ") =>";
F.pp_close_box fmt ();
@@ -1418,7 +1418,7 @@ let extract_fun_comment (ctx : extraction_ctx) (fmt : F.formatter)
Some def.llbc_name
else None
in
- extract_comment_with_span ctx fmt comment name def.meta.span
+ extract_comment_with_raw_span ctx fmt comment name def.span.span
(** Extract a function declaration.
@@ -1429,9 +1429,9 @@ let extract_fun_comment (ctx : extraction_ctx) (fmt : F.formatter)
*)
let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
(kind : decl_kind) (has_decreases_clause : bool) (def : fun_decl) : unit =
- sanity_check __FILE__ __LINE__ (not def.is_global_decl_body) def.meta;
+ sanity_check __FILE__ __LINE__ (not def.is_global_decl_body) def.span;
(* Retrieve the function name *)
- let def_name = ctx_get_local_function def.meta def.def_id def.loop_id ctx in
+ let def_name = ctx_get_local_function def.span def.def_id def.loop_id ctx in
(* Add a break before *)
if !backend <> HOL4 || not (decl_is_first_from_group kind) then
F.pp_print_break fmt 0 0;
@@ -1501,18 +1501,18 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
if is_opaque then extract_fun_input_parameters_types ctx fmt def;
(* [Tot] *)
if has_decreases_clause then (
- assert_backend_supports_decreases_clauses def.meta;
+ assert_backend_supports_decreases_clauses def.span;
if !backend = FStar then (
F.pp_print_string fmt "Tot";
F.pp_print_space fmt ()));
- extract_ty def.meta ctx fmt TypeDeclId.Set.empty has_decreases_clause
+ extract_ty def.span ctx fmt TypeDeclId.Set.empty has_decreases_clause
def.signature.output;
(* Close the box for the return type *)
F.pp_close_box fmt ();
(* Print the decrease clause - rk.: a function with a decreases clause
* is necessarily a transparent function *)
if has_decreases_clause && !backend = FStar then (
- assert_backend_supports_decreases_clauses def.meta;
+ assert_backend_supports_decreases_clauses def.span;
F.pp_print_space fmt ();
(* Open a box for the decreases clause *)
F.pp_open_hovbox fmt ctx.indent_incr;
@@ -1523,7 +1523,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_open_hovbox fmt ctx.indent_incr;
(* The name of the decrease clause *)
let decr_name =
- ctx_get_termination_measure def.meta def.def_id def.loop_id ctx
+ ctx_get_termination_measure def.span def.def_id def.loop_id ctx
in
F.pp_print_string fmt decr_name;
(* Print the generic parameters - TODO: we do this many
@@ -1554,7 +1554,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
List.fold_left
(fun ctx (lv : typed_pattern) ->
F.pp_print_space fmt ();
- let ctx = extract_typed_pattern def.meta ctx fmt true false lv in
+ let ctx = extract_typed_pattern def.span ctx fmt true false lv in
ctx)
ctx inputs_lvs
in
@@ -1581,7 +1581,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_open_hvbox fmt 0;
(* Extract the body *)
let _ =
- extract_texpression def.meta ctx_body fmt false (Option.get def.body).body
+ extract_texpression def.span ctx_body fmt false (Option.get def.body).body
in
(* Close the box for the body *)
F.pp_close_box fmt ());
@@ -1598,7 +1598,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
(* termination_by *)
let terminates_name =
- ctx_get_termination_measure def.meta def.def_id def.loop_id ctx
+ ctx_get_termination_measure def.span def.def_id def.loop_id ctx
in
F.pp_print_break fmt 0 0;
(* Open a box for the whole [termination_by CALL => DECREASES] *)
@@ -1611,7 +1611,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
List.iter
(fun v ->
F.pp_print_space fmt ();
- F.pp_print_string fmt (ctx_get_var def.meta v ctx_body))
+ F.pp_print_string fmt (ctx_get_var def.span v ctx_body))
all_vars;
F.pp_print_space fmt ();
F.pp_print_string fmt "=>";
@@ -1631,7 +1631,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
List.iter
(fun v ->
F.pp_print_space fmt ();
- F.pp_print_string fmt (ctx_get_var def.meta v ctx_body))
+ F.pp_print_string fmt (ctx_get_var def.span v ctx_body))
vars;
(* Close the box for [DECREASES] *)
F.pp_close_box fmt ();
@@ -1642,7 +1642,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
(* Open a box for the [decreasing by ...] *)
F.pp_open_hvbox fmt ctx.indent_incr;
let decreases_name =
- ctx_get_decreases_proof def.meta def.def_id def.loop_id ctx
+ ctx_get_decreases_proof def.span def.def_id def.loop_id ctx
in
F.pp_print_string fmt "decreasing_by";
F.pp_print_space fmt ();
@@ -1651,7 +1651,7 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
List.iter
(fun v ->
F.pp_print_space fmt ();
- F.pp_print_string fmt (ctx_get_var def.meta v ctx_body))
+ F.pp_print_string fmt (ctx_get_var def.span v ctx_body))
vars;
F.pp_close_box fmt ();
(* Close the box for the [decreasing by ...] *)
@@ -1681,15 +1681,15 @@ let extract_fun_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
let extract_fun_decl_hol4_opaque (ctx : extraction_ctx) (fmt : F.formatter)
(def : fun_decl) : unit =
(* Retrieve the definition name *)
- let def_name = ctx_get_local_function def.meta def.def_id def.loop_id ctx in
+ let def_name = ctx_get_local_function def.span def.def_id def.loop_id ctx in
cassert __FILE__ __LINE__
(def.signature.generics.const_generics = [])
- def.meta
+ def.span
"Constant generics are not supported yet when generating code for HOL4";
(* Add the type/const gen parameters - note that we need those bindings
only for the generation of the type (they are not top-level) *)
let ctx, _, _, _ =
- ctx_add_generic_params def.meta def.llbc_name def.signature.llbc_generics
+ ctx_add_generic_params def.span def.llbc_name def.signature.llbc_generics
def.signature.generics ctx
in
(* Add breaks to insert new lines between definitions *)
@@ -1706,7 +1706,7 @@ let extract_fun_decl_hol4_opaque (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_string fmt "“:";
(* Generate the type *)
extract_fun_input_parameters_types ctx fmt def;
- extract_ty def.meta ctx fmt TypeDeclId.Set.empty false def.signature.output;
+ extract_ty def.span ctx fmt TypeDeclId.Set.empty false def.signature.output;
(* Close the box for the type *)
F.pp_print_string fmt "”";
F.pp_close_box fmt ();
@@ -1731,7 +1731,7 @@ let extract_fun_decl_hol4_opaque (ctx : extraction_ctx) (fmt : F.formatter)
*)
let extract_fun_decl (ctx : extraction_ctx) (fmt : F.formatter)
(kind : decl_kind) (has_decreases_clause : bool) (def : fun_decl) : unit =
- sanity_check __FILE__ __LINE__ (not def.is_global_decl_body) def.meta;
+ sanity_check __FILE__ __LINE__ (not def.is_global_decl_body) def.span;
(* We treat HOL4 opaque functions in a specific manner *)
if !backend = HOL4 && Option.is_none def.body then
extract_fun_decl_hol4_opaque ctx fmt def
@@ -1744,7 +1744,7 @@ let extract_fun_decl (ctx : extraction_ctx) (fmt : F.formatter)
extracted to two declarations, and we can actually factor out the generation
of those declarations. See {!extract_global_decl} for more explanations.
*)
-let extract_global_decl_body_gen (meta : Meta.meta) (ctx : extraction_ctx)
+let extract_global_decl_body_gen (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (kind : decl_kind) (name : string)
(generics : generic_params) (type_params : string list)
(cg_params : string list) (trait_clauses : string list) (ty : ty)
@@ -1777,7 +1777,7 @@ let extract_global_decl_body_gen (meta : Meta.meta) (ctx : extraction_ctx)
(* Extract the generic parameters *)
let space = ref true in
- extract_generic_params meta ctx fmt TypeDeclId.Set.empty ~space:(Some space)
+ extract_generic_params span ctx fmt TypeDeclId.Set.empty ~space:(Some space)
generics type_params cg_params trait_clauses;
if not !space then F.pp_print_space fmt ();
@@ -1790,7 +1790,7 @@ let extract_global_decl_body_gen (meta : Meta.meta) (ctx : extraction_ctx)
(* Open "TYPE" box (depth=3) *)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Print "TYPE" *)
- extract_ty meta ctx fmt TypeDeclId.Set.empty false ty;
+ extract_ty span ctx fmt TypeDeclId.Set.empty false ty;
(* Close "TYPE" box (depth=3) *)
F.pp_close_box fmt ();
@@ -1836,7 +1836,7 @@ let extract_global_decl_body_gen (meta : Meta.meta) (ctx : extraction_ctx)
Remark (SH): having to treat this specific case separately is very annoying,
but I could not find a better way.
*)
-let extract_global_decl_hol4_opaque (meta : Meta.meta) (ctx : extraction_ctx)
+let extract_global_decl_hol4_opaque (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (name : string) (generics : generic_params) (ty : ty) :
unit =
(* TODO: non-empty generics *)
@@ -1850,7 +1850,7 @@ let extract_global_decl_hol4_opaque (meta : Meta.meta) (ctx : extraction_ctx)
F.pp_close_box fmt ();
(* Print the type *)
F.pp_open_hovbox fmt 0;
- extract_ty meta ctx fmt TypeDeclId.Set.empty false ty;
+ extract_ty span ctx fmt TypeDeclId.Set.empty false ty;
(* Close the definition *)
F.pp_print_string fmt ")";
F.pp_close_box fmt ();
@@ -1881,9 +1881,9 @@ let extract_global_decl_hol4_opaque (meta : Meta.meta) (ctx : extraction_ctx)
*)
let extract_global_decl_aux (ctx : extraction_ctx) (fmt : F.formatter)
(global : global_decl) (body : fun_decl) (interface : bool) : unit =
- let meta = body.meta in
- sanity_check __FILE__ __LINE__ body.is_global_decl_body meta;
- sanity_check __FILE__ __LINE__ (body.signature.inputs = []) meta;
+ let span = body.span in
+ sanity_check __FILE__ __LINE__ body.is_global_decl_body span;
+ sanity_check __FILE__ __LINE__ (body.signature.inputs = []) span;
(* Add a break then the name of the corresponding LLBC declaration *)
F.pp_print_break fmt 0 0;
@@ -1892,26 +1892,26 @@ let extract_global_decl_aux (ctx : extraction_ctx) (fmt : F.formatter)
Some global.llbc_name
else None
in
- extract_comment_with_span ctx fmt
+ extract_comment_with_raw_span ctx fmt
[ "[" ^ name_to_string ctx global.llbc_name ^ "]" ]
- name global.meta.span;
+ name global.span.span;
F.pp_print_space fmt ();
- let decl_name = ctx_get_global meta global.def_id ctx in
+ let decl_name = ctx_get_global span global.def_id ctx in
let body_name =
- ctx_get_function meta
+ ctx_get_function span
(FromLlbc (Pure.FunId (FRegular global.body_id), None))
ctx
in
let decl_ty, body_ty =
let ty = body.signature.output in
if body.signature.fwd_info.effect_info.can_fail then
- (unwrap_result_ty meta ty, ty)
+ (unwrap_result_ty span ty, ty)
else (ty, mk_result_ty ty)
in
(* Add the type parameters *)
let ctx, type_params, cg_params, trait_clauses =
- ctx_add_generic_params meta global.llbc_name global.llbc_generics
+ ctx_add_generic_params span global.llbc_name global.llbc_generics
global.generics ctx
in
match body.body with
@@ -1919,20 +1919,20 @@ let extract_global_decl_aux (ctx : extraction_ctx) (fmt : F.formatter)
(* No body: only generate a [val x_c : u32] declaration *)
let kind = if interface then Declared else Assumed in
if !backend = HOL4 then
- extract_global_decl_hol4_opaque meta ctx fmt decl_name global.generics
+ extract_global_decl_hol4_opaque span ctx fmt decl_name global.generics
decl_ty
else
- extract_global_decl_body_gen meta ctx fmt kind decl_name global.generics
+ extract_global_decl_body_gen span ctx fmt kind decl_name global.generics
type_params cg_params trait_clauses decl_ty None
| Some body ->
(* There is a body *)
(* Generate: [let x_body : result u32 = Return 3] *)
- extract_global_decl_body_gen meta ctx fmt SingleNonRec body_name
+ extract_global_decl_body_gen span ctx fmt SingleNonRec body_name
global.generics type_params cg_params trait_clauses body_ty
- (Some (fun fmt -> extract_texpression meta ctx fmt false body.body));
+ (Some (fun fmt -> extract_texpression span ctx fmt false body.body));
F.pp_print_break fmt 0 0;
(* Generate: [let x_c : u32 = eval_global x_body] *)
- extract_global_decl_body_gen meta ctx fmt SingleNonRec decl_name
+ extract_global_decl_body_gen span ctx fmt SingleNonRec decl_name
global.generics type_params cg_params trait_clauses decl_ty
(Some
(fun fmt ->
@@ -2007,7 +2007,7 @@ let extract_trait_decl_register_parent_clause_names (ctx : extraction_ctx)
(* Register the names *)
List.fold_left
(fun ctx (cid, cname) ->
- ctx_add trait_decl.meta
+ ctx_add trait_decl.span
(TraitParentClauseId (trait_decl.def_id, cid))
cname ctx)
ctx clause_names
@@ -2042,7 +2042,7 @@ let extract_trait_decl_register_constant_names (ctx : extraction_ctx)
(* Register the names *)
List.fold_left
(fun ctx (item_name, name) ->
- ctx_add trait_decl.meta
+ ctx_add trait_decl.span
(TraitItemId (trait_decl.def_id, item_name))
name ctx)
ctx constant_names
@@ -2103,13 +2103,13 @@ let extract_trait_decl_type_names (ctx : extraction_ctx)
List.fold_left
(fun ctx (item_name, (type_name, clauses)) ->
let ctx =
- ctx_add trait_decl.meta
+ ctx_add trait_decl.span
(TraitItemId (trait_decl.def_id, item_name))
type_name ctx
in
List.fold_left
(fun ctx (clause_id, clause_name) ->
- ctx_add trait_decl.meta
+ ctx_add trait_decl.span
(TraitItemClauseId (trait_decl.def_id, item_name, clause_id))
clause_name ctx)
ctx clauses)
@@ -2161,7 +2161,7 @@ let extract_trait_decl_method_names (ctx : extraction_ctx)
(* Register the names *)
List.fold_left
(fun ctx (item_name, fun_name) ->
- ctx_add trait_decl.meta
+ ctx_add trait_decl.span
(TraitMethodId (trait_decl.def_id, item_name))
fun_name ctx)
ctx method_names
@@ -2184,9 +2184,9 @@ let extract_trait_decl_register_names (ctx : extraction_ctx)
| Some info -> (info.extract_name, info.constructor)
in
let ctx =
- ctx_add trait_decl.meta (TraitDeclId trait_decl.def_id) trait_name ctx
+ ctx_add trait_decl.span (TraitDeclId trait_decl.def_id) trait_name ctx
in
- ctx_add trait_decl.meta (TraitDeclConstructorId trait_decl.def_id)
+ ctx_add trait_decl.span (TraitDeclConstructorId trait_decl.def_id)
trait_constructor ctx
in
(* Parent clauses *)
@@ -2243,7 +2243,7 @@ let extract_trait_impl_register_names (ctx : extraction_ctx)
(* For now we do not support overriding provided methods *)
cassert __FILE__ __LINE__
(trait_impl.provided_methods = [])
- trait_impl.meta
+ trait_impl.span
("Overriding trait provided methods in trait implementations is not \
supported yet (overriden methods: "
^ String.concat ", " (List.map fst trait_impl.provided_methods)
@@ -2256,7 +2256,7 @@ let extract_trait_impl_register_names (ctx : extraction_ctx)
| None -> ctx_compute_trait_impl_name ctx trait_decl trait_impl
| Some name -> name
in
- ctx_add trait_decl.meta (TraitImplId trait_impl.def_id) name ctx
+ ctx_add trait_decl.span (TraitImplId trait_impl.def_id) name ctx
(** Small helper.
@@ -2305,7 +2305,7 @@ let extract_trait_decl_method_items (ctx : extraction_ctx) (fmt : F.formatter)
let trans = A.FunDeclId.Map.find id ctx.trans_funs in
(* Extract the items *)
let f = trans.f in
- let fun_name = ctx_get_trait_method decl.meta decl.def_id item_name ctx in
+ let fun_name = ctx_get_trait_method decl.span decl.def_id item_name ctx in
let ty () =
(* Extract the generics *)
(* We need to add the generics specific to the method, by removing those
@@ -2321,7 +2321,7 @@ let extract_trait_decl_method_items (ctx : extraction_ctx) (fmt : F.formatter)
- we only generate trait clauses for the clauses we find in the
pure generics *)
let ctx, type_params, cg_params, trait_clauses =
- ctx_add_generic_params decl.meta f.llbc_name f.signature.llbc_generics
+ ctx_add_generic_params decl.span f.llbc_name f.signature.llbc_generics
generics ctx
in
let backend_uses_forall =
@@ -2331,7 +2331,7 @@ let extract_trait_decl_method_items (ctx : extraction_ctx) (fmt : F.formatter)
let use_forall = generics_not_empty && backend_uses_forall in
let use_arrows = generics_not_empty && not backend_uses_forall in
let use_forall_use_sep = false in
- extract_generic_params decl.meta ctx fmt TypeDeclId.Set.empty ~use_forall
+ extract_generic_params decl.span ctx fmt TypeDeclId.Set.empty ~use_forall
~use_forall_use_sep ~use_arrows generics type_params cg_params
trait_clauses;
if use_forall then F.pp_print_string fmt ",";
@@ -2345,7 +2345,7 @@ let extract_trait_decl_method_items (ctx : extraction_ctx) (fmt : F.formatter)
let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
(decl : trait_decl) : unit =
(* Retrieve the trait name *)
- let decl_name = ctx_get_trait_decl decl.meta decl.def_id ctx in
+ let decl_name = ctx_get_trait_decl decl.span decl.def_id ctx in
(* Add a break before *)
F.pp_print_break fmt 0 0;
(* Print a comment to link the extracted type to its original rust definition *)
@@ -2354,9 +2354,9 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
Some decl.llbc_name
else None
in
- extract_comment_with_span ctx fmt
+ extract_comment_with_raw_span ctx fmt
[ "Trait declaration: [" ^ name_to_string ctx decl.llbc_name ^ "]" ]
- name decl.meta.span);
+ name decl.span.span);
F.pp_print_break fmt 0 0;
(* Open two outer boxes for the definition, so that whenever possible it gets printed on
one line and indents are correct.
@@ -2373,7 +2373,7 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
(* Open the box for the name + generics *)
F.pp_open_hovbox fmt ctx.indent_incr;
let qualif =
- Option.get (type_decl_kind_to_qualif decl.meta SingleNonRec (Some Struct))
+ Option.get (type_decl_kind_to_qualif decl.span SingleNonRec (Some Struct))
in
(* When checking if the trait declaration is empty: we ignore the provided
methods, because for now they are extracted separately *)
@@ -2389,10 +2389,10 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
(* Add the type and const generic params - note that we need those bindings only for the
* body translation (they are not top-level) *)
let ctx, type_params, cg_params, trait_clauses =
- ctx_add_generic_params decl.meta decl.llbc_name decl.llbc_generics generics
+ ctx_add_generic_params decl.span decl.llbc_name decl.llbc_generics generics
ctx
in
- extract_generic_params decl.meta ctx fmt TypeDeclId.Set.empty generics
+ extract_generic_params decl.span ctx fmt TypeDeclId.Set.empty generics
type_params cg_params trait_clauses;
F.pp_print_space fmt ();
@@ -2402,7 +2402,7 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_close_box fmt ())
else if is_empty && !backend = Coq then (
(* Coq is not very good at infering constructors *)
- let cons = ctx_get_trait_constructor decl.meta decl.def_id ctx in
+ let cons = ctx_get_trait_constructor decl.span decl.def_id ctx in
F.pp_print_string fmt (":= " ^ cons ^ "{}.");
(* Outer box *)
F.pp_close_box fmt ())
@@ -2411,7 +2411,7 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
| Lean -> F.pp_print_string fmt "where"
| FStar -> F.pp_print_string fmt "= {"
| Coq ->
- let cons = ctx_get_trait_constructor decl.meta decl.def_id ctx in
+ let cons = ctx_get_trait_constructor decl.span decl.def_id ctx in
F.pp_print_string fmt (":= " ^ cons ^ " {")
| _ -> F.pp_print_string fmt "{");
@@ -2425,11 +2425,11 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
(* The constants *)
List.iter
(fun (name, (ty, _)) ->
- let item_name = ctx_get_trait_const decl.meta decl.def_id name ctx in
+ let item_name = ctx_get_trait_const decl.span decl.def_id name ctx in
let ty () =
let inside = false in
F.pp_print_space fmt ();
- extract_ty decl.meta ctx fmt TypeDeclId.Set.empty inside ty
+ extract_ty decl.span ctx fmt TypeDeclId.Set.empty inside ty
in
extract_trait_decl_item ctx fmt item_name ty)
decl.consts;
@@ -2438,22 +2438,22 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
List.iter
(fun (name, (clauses, _)) ->
(* Extract the type *)
- let item_name = ctx_get_trait_type decl.meta decl.def_id name ctx in
+ let item_name = ctx_get_trait_type decl.span decl.def_id name ctx in
let ty () =
F.pp_print_space fmt ();
- F.pp_print_string fmt (type_keyword decl.meta)
+ F.pp_print_string fmt (type_keyword decl.span)
in
extract_trait_decl_item ctx fmt item_name ty;
(* Extract the clauses *)
List.iter
(fun clause ->
let item_name =
- ctx_get_trait_item_clause decl.meta decl.def_id name
+ ctx_get_trait_item_clause decl.span decl.def_id name
clause.clause_id ctx
in
let ty () =
F.pp_print_space fmt ();
- extract_trait_clause_type decl.meta ctx fmt TypeDeclId.Set.empty
+ extract_trait_clause_type decl.span ctx fmt TypeDeclId.Set.empty
clause
in
extract_trait_decl_item ctx fmt item_name ty)
@@ -2465,11 +2465,11 @@ let extract_trait_decl (ctx : extraction_ctx) (fmt : F.formatter)
List.iter
(fun clause ->
let item_name =
- ctx_get_trait_parent_clause decl.meta decl.def_id clause.clause_id ctx
+ ctx_get_trait_parent_clause decl.span decl.def_id clause.clause_id ctx
in
let ty () =
F.pp_print_space fmt ();
- extract_trait_clause_type decl.meta ctx fmt TypeDeclId.Set.empty
+ extract_trait_clause_type decl.span ctx fmt TypeDeclId.Set.empty
clause
in
extract_trait_decl_item ctx fmt item_name ty)
@@ -2507,25 +2507,25 @@ let extract_trait_decl_coq_arguments (ctx : extraction_ctx) (fmt : F.formatter)
in
if num_params > 0 then (
(* The constructor *)
- let cons_name = ctx_get_trait_constructor decl.meta decl.def_id ctx in
+ let cons_name = ctx_get_trait_constructor decl.span decl.def_id ctx in
extract_coq_arguments_instruction ctx fmt cons_name num_params;
(* The constants *)
List.iter
(fun (name, _) ->
- let item_name = ctx_get_trait_const decl.meta decl.def_id name ctx in
+ let item_name = ctx_get_trait_const decl.span decl.def_id name ctx in
extract_coq_arguments_instruction ctx fmt item_name num_params)
decl.consts;
(* The types *)
List.iter
(fun (name, (clauses, _)) ->
(* The type *)
- let item_name = ctx_get_trait_type decl.meta decl.def_id name ctx in
+ let item_name = ctx_get_trait_type decl.span decl.def_id name ctx in
extract_coq_arguments_instruction ctx fmt item_name num_params;
(* The type clauses *)
List.iter
(fun clause ->
let item_name =
- ctx_get_trait_item_clause decl.meta decl.def_id name
+ ctx_get_trait_item_clause decl.span decl.def_id name
clause.clause_id ctx
in
extract_coq_arguments_instruction ctx fmt item_name num_params)
@@ -2535,7 +2535,7 @@ let extract_trait_decl_coq_arguments (ctx : extraction_ctx) (fmt : F.formatter)
List.iter
(fun clause ->
let item_name =
- ctx_get_trait_parent_clause decl.meta decl.def_id clause.clause_id ctx
+ ctx_get_trait_parent_clause decl.span decl.def_id clause.clause_id ctx
in
extract_coq_arguments_instruction ctx fmt item_name num_params)
decl.parent_clauses;
@@ -2544,7 +2544,7 @@ let extract_trait_decl_coq_arguments (ctx : extraction_ctx) (fmt : F.formatter)
(fun (item_name, _) ->
(* Extract the items *)
let item_name =
- ctx_get_trait_method decl.meta decl.def_id item_name ctx
+ ctx_get_trait_method decl.span decl.def_id item_name ctx
in
extract_coq_arguments_instruction ctx fmt item_name num_params)
decl.required_methods;
@@ -2570,7 +2570,7 @@ let extract_trait_impl_method_items (ctx : extraction_ctx) (fmt : F.formatter)
let trans = A.FunDeclId.Map.find id ctx.trans_funs in
(* Extract the items *)
let f = trans.f in
- let fun_name = ctx_get_trait_method impl.meta trait_decl_id item_name ctx in
+ let fun_name = ctx_get_trait_method impl.span trait_decl_id item_name ctx in
let ty () =
(* Filter the generics if the method is a builtin *)
let i_tys, _, _ = impl_generics in
@@ -2610,16 +2610,16 @@ let extract_trait_impl_method_items (ctx : extraction_ctx) (fmt : F.formatter)
- we only generate trait clauses for the clauses we find in the
pure generics *)
let ctx, f_tys, f_cgs, f_tcs =
- ctx_add_generic_params impl.meta f.llbc_name f.signature.llbc_generics
+ ctx_add_generic_params impl.span f.llbc_name f.signature.llbc_generics
f_generics ctx
in
let use_forall = f_generics <> empty_generic_params in
- extract_generic_params impl.meta ctx fmt TypeDeclId.Set.empty ~use_forall
+ extract_generic_params impl.span ctx fmt TypeDeclId.Set.empty ~use_forall
f_generics f_tys f_cgs f_tcs;
if use_forall then F.pp_print_string fmt ",";
(* Extract the function call *)
F.pp_print_space fmt ();
- let fun_name = ctx_get_local_function impl.meta f.def_id None ctx in
+ let fun_name = ctx_get_local_function impl.span f.def_id None ctx in
F.pp_print_string fmt fun_name;
let all_generics =
let _, i_cgs, i_tcs = impl_generics in
@@ -2640,7 +2640,7 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
(impl : trait_impl) : unit =
log#ldebug (lazy ("extract_trait_impl: " ^ name_to_string ctx impl.llbc_name));
(* Retrieve the impl name *)
- let impl_name = ctx_get_trait_impl impl.meta impl.def_id ctx in
+ let impl_name = ctx_get_trait_impl impl.span impl.def_id ctx in
(* Add a break before *)
F.pp_print_break fmt 0 0;
(* Print a comment to link the extracted type to its original rust definition *)
@@ -2653,10 +2653,10 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
Some (trait_decl.llbc_generics, decl_ref.decl_generics) )
else (None, None)
in
- extract_comment_with_span ctx fmt
+ extract_comment_with_raw_span ctx fmt
[ "Trait implementation: [" ^ name_to_string ctx impl.llbc_name ^ "]" ]
(* TODO: why option option for the generics? Looks like a bug in OCaml!? *)
- name ?generics:(Some generics) impl.meta.span);
+ name ?generics:(Some generics) impl.span.span);
F.pp_print_break fmt 0 0;
(* Open two outer boxes for the definition, so that whenever possible it gets printed on
@@ -2686,18 +2686,18 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
(* Add the type and const generic params - note that we need those bindings only for the
* body translation (they are not top-level) *)
let ctx, type_params, cg_params, trait_clauses =
- ctx_add_generic_params impl.meta impl.llbc_name impl.llbc_generics
+ ctx_add_generic_params impl.span impl.llbc_name impl.llbc_generics
impl.generics ctx
in
let all_generics = (type_params, cg_params, trait_clauses) in
- extract_generic_params impl.meta ctx fmt TypeDeclId.Set.empty impl.generics
+ extract_generic_params impl.span ctx fmt TypeDeclId.Set.empty impl.generics
type_params cg_params trait_clauses;
(* Print the type *)
F.pp_print_space fmt ();
F.pp_print_string fmt ":";
F.pp_print_space fmt ();
- extract_trait_decl_ref impl.meta ctx fmt TypeDeclId.Set.empty false
+ extract_trait_decl_ref impl.span ctx fmt TypeDeclId.Set.empty false
impl.impl_trait;
(* When checking if the trait impl is empty: we ignore the provided
@@ -2712,7 +2712,7 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
else if is_empty && !Config.backend = Coq then (
(* Coq is not very good at infering constructors *)
let cons =
- ctx_get_trait_constructor impl.meta impl.impl_trait.trait_decl_id ctx
+ ctx_get_trait_constructor impl.span impl.impl_trait.trait_decl_id ctx
in
F.pp_print_string fmt (":= " ^ cons ^ ".");
(* Outer box *)
@@ -2737,12 +2737,12 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
(* The constants *)
List.iter
(fun (provided_id, (name, (_, id))) ->
- let item_name = ctx_get_trait_const impl.meta trait_decl_id name ctx in
+ let item_name = ctx_get_trait_const impl.span trait_decl_id name ctx in
(* The parameters are not the same depending on whether the constant
is a provided constant or not *)
let print_params () =
if provided_id = Some id then
- extract_generic_args impl.meta ctx fmt TypeDeclId.Set.empty
+ extract_generic_args impl.span ctx fmt TypeDeclId.Set.empty
impl.impl_trait.decl_generics
else
let all_params =
@@ -2756,7 +2756,7 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
in
let ty () =
F.pp_print_space fmt ();
- F.pp_print_string fmt (ctx_get_global impl.meta id ctx);
+ F.pp_print_string fmt (ctx_get_global impl.span id ctx);
print_params ()
in
@@ -2767,22 +2767,22 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
List.iter
(fun (name, (trait_refs, ty)) ->
(* Extract the type *)
- let item_name = ctx_get_trait_type impl.meta trait_decl_id name ctx in
+ let item_name = ctx_get_trait_type impl.span trait_decl_id name ctx in
let ty () =
F.pp_print_space fmt ();
- extract_ty impl.meta ctx fmt TypeDeclId.Set.empty false ty
+ extract_ty impl.span ctx fmt TypeDeclId.Set.empty false ty
in
extract_trait_impl_item ctx fmt item_name ty;
(* Extract the clauses *)
TraitClauseId.iteri
(fun clause_id trait_ref ->
let item_name =
- ctx_get_trait_item_clause impl.meta trait_decl_id name clause_id
+ ctx_get_trait_item_clause impl.span trait_decl_id name clause_id
ctx
in
let ty () =
F.pp_print_space fmt ();
- extract_trait_ref impl.meta ctx fmt TypeDeclId.Set.empty false
+ extract_trait_ref impl.span ctx fmt TypeDeclId.Set.empty false
trait_ref
in
extract_trait_impl_item ctx fmt item_name ty)
@@ -2793,11 +2793,11 @@ let extract_trait_impl (ctx : extraction_ctx) (fmt : F.formatter)
TraitClauseId.iteri
(fun clause_id trait_ref ->
let item_name =
- ctx_get_trait_parent_clause impl.meta trait_decl_id clause_id ctx
+ ctx_get_trait_parent_clause impl.span trait_decl_id clause_id ctx
in
let ty () =
F.pp_print_space fmt ();
- extract_trait_ref impl.meta ctx fmt TypeDeclId.Set.empty false
+ extract_trait_ref impl.span ctx fmt TypeDeclId.Set.empty false
trait_ref
in
extract_trait_impl_item ctx fmt item_name ty)
@@ -2862,7 +2862,7 @@ let extract_unit_test_if_unit_fun (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_space fmt ();
F.pp_print_string fmt "(";
let fun_name =
- ctx_get_local_function def.meta def.def_id def.loop_id ctx
+ ctx_get_local_function def.span def.def_id def.loop_id ctx
in
F.pp_print_string fmt fun_name;
if sg.inputs <> [] then (
@@ -2872,7 +2872,7 @@ let extract_unit_test_if_unit_fun (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_string fmt "=";
F.pp_print_space fmt ();
let success =
- ctx_get_variant def.meta (TAssumed TResult) result_ok_id ctx
+ ctx_get_variant def.span (TAssumed TResult) result_ok_id ctx
in
F.pp_print_string fmt (success ^ " ())")
| Coq ->
@@ -2880,7 +2880,7 @@ let extract_unit_test_if_unit_fun (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_space fmt ();
F.pp_print_string fmt "(";
let fun_name =
- ctx_get_local_function def.meta def.def_id def.loop_id ctx
+ ctx_get_local_function def.span def.def_id def.loop_id ctx
in
F.pp_print_string fmt fun_name;
if sg.inputs <> [] then (
@@ -2893,7 +2893,7 @@ let extract_unit_test_if_unit_fun (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_space fmt ();
F.pp_print_string fmt "(";
let fun_name =
- ctx_get_local_function def.meta def.def_id def.loop_id ctx
+ ctx_get_local_function def.span def.def_id def.loop_id ctx
in
F.pp_print_string fmt fun_name;
if sg.inputs <> [] then (
@@ -2903,14 +2903,14 @@ let extract_unit_test_if_unit_fun (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_string fmt "==";
F.pp_print_space fmt ();
let success =
- ctx_get_variant def.meta (TAssumed TResult) result_ok_id ctx
+ ctx_get_variant def.span (TAssumed TResult) result_ok_id ctx
in
F.pp_print_string fmt (success ^ " ())")
| HOL4 ->
F.pp_print_string fmt "val _ = assert_ok (";
F.pp_print_string fmt "“";
let fun_name =
- ctx_get_local_function def.meta def.def_id def.loop_id ctx
+ ctx_get_local_function def.span def.def_id def.loop_id ctx
in
F.pp_print_string fmt fun_name;
if sg.inputs <> [] then (
diff --git a/compiler/ExtractBase.ml b/compiler/ExtractBase.ml
index f2686cc6..ab7eb50c 100644
--- a/compiler/ExtractBase.ml
+++ b/compiler/ExtractBase.ml
@@ -237,7 +237,7 @@ module IdSet = Collections.MakeSet (IdOrderedType)
*)
type names_map = {
id_to_name : string IdMap.t;
- name_to_id : (id * Meta.meta option) StringMap.t;
+ name_to_id : (id * Meta.span option) StringMap.t;
(** The name to id map is used to look for name clashes, and generate nice
debugging messages: if there is a name clash, it is useful to know
precisely which identifiers are mapped to the same name...
@@ -254,15 +254,15 @@ let empty_names_map : names_map =
(** Small helper to report name collision *)
let report_name_collision (id_to_string : id -> string)
- ((id1, meta1) : id * Meta.meta option) (id2 : id) (meta2 : Meta.meta option)
+ ((id1, span1) : id * Meta.span option) (id2 : id) (span2 : Meta.span option)
(name : string) : unit =
- let meta_to_string (meta : Meta.meta option) =
- match meta with
+ let span_to_string (span : Meta.span option) =
+ match span with
| None -> ""
- | Some meta -> "\n " ^ Errors.meta_to_string meta
+ | Some span -> "\n " ^ Errors.span_to_string span
in
- let id1 = "\n- " ^ id_to_string id1 ^ meta_to_string meta1 in
- let id2 = "\n- " ^ id_to_string id2 ^ meta_to_string meta2 in
+ let id1 = "\n- " ^ id_to_string id1 ^ span_to_string span1 in
+ let id2 = "\n- " ^ id_to_string id2 ^ span_to_string span2 in
let err =
"Name clash detected: the following identifiers are bound to the same name \
\"" ^ name ^ "\":" ^ id1 ^ id2
@@ -270,36 +270,36 @@ let report_name_collision (id_to_string : id -> string)
in
(* Register the error.
- We don't link this error to any meta information because we already put
+ We don't link this error to any span information because we already put
the span information about the two problematic definitions in the error
message above. *)
save_error __FILE__ __LINE__ None err
let names_map_get_id_from_name (name : string) (nm : names_map) :
- (id * Meta.meta option) option =
+ (id * Meta.span option) option =
StringMap.find_opt name nm.name_to_id
let names_map_check_collision (id_to_string : id -> string) (id : id)
- (meta : Meta.meta option) (name : string) (nm : names_map) : unit =
+ (span : Meta.span option) (name : string) (nm : names_map) : unit =
match names_map_get_id_from_name name nm with
| None -> () (* Ok *)
| Some clash ->
(* There is a clash: print a nice debugging message for the user *)
- report_name_collision id_to_string clash id meta name
+ report_name_collision id_to_string clash id span name
(** Insert bindings in a names map without checking for collisions *)
-let names_map_add_unchecked ((id, meta) : id * Meta.meta option) (name : string)
+let names_map_add_unchecked ((id, span) : id * Meta.span option) (name : string)
(nm : names_map) : names_map =
(* Insert *)
let id_to_name = IdMap.add id name nm.id_to_name in
- let name_to_id = StringMap.add name (id, meta) nm.name_to_id in
+ let name_to_id = StringMap.add name (id, span) nm.name_to_id in
let names_set = StringSet.add name nm.names_set in
{ id_to_name; name_to_id; names_set }
-let names_map_add (id_to_string : id -> string) ((id, meta) : id * meta option)
+let names_map_add (id_to_string : id -> string) ((id, span) : id * span option)
(name : string) (nm : names_map) : names_map =
(* Check if there is a clash *)
- names_map_check_collision id_to_string id meta name nm;
+ names_map_check_collision id_to_string id span name nm;
(* Sanity check *)
(if StringSet.mem name nm.names_set then
let err =
@@ -307,9 +307,9 @@ let names_map_add (id_to_string : id -> string) ((id, meta) : id * meta option)
^ ":\nThe chosen name is already in the names set: " ^ name
in
(* If we fail hard on errors, raise an exception *)
- save_error __FILE__ __LINE__ meta err);
+ save_error __FILE__ __LINE__ span err);
(* Insert *)
- names_map_add_unchecked (id, meta) name nm
+ names_map_add_unchecked (id, span) name nm
(** The unsafe names map stores mappings from identifiers to names which might
collide. For some backends and some names, it might be acceptable to have
@@ -396,7 +396,7 @@ let allow_collisions (id : id) : bool =
(** The [id_to_string] function to print nice debugging messages if there are
collisions *)
let names_maps_add (id_to_string : id -> string) (id : id)
- (meta : Meta.meta option) (name : string) (nm : names_maps) : names_maps =
+ (span : Meta.span option) (name : string) (nm : names_maps) : names_maps =
(* We do not use the same name map if we allow/disallow collisions.
We notably use it for field names: some backends like Lean can use the
type information to disambiguate field projections.
@@ -411,7 +411,7 @@ let names_maps_add (id_to_string : id -> string) (id : id)
*)
if allow_collisions id then (
(* Check with the ids which are considered to be strict on collisions *)
- names_map_check_collision id_to_string id meta name nm.strict_names_map;
+ names_map_check_collision id_to_string id span name nm.strict_names_map;
{
nm with
unsafe_names_map = unsafe_names_map_add id name nm.unsafe_names_map;
@@ -426,15 +426,15 @@ let names_maps_add (id_to_string : id -> string) (id : id)
*)
let strict_names_map =
if strict_collisions id then
- names_map_add id_to_string (id, meta) name nm.strict_names_map
+ names_map_add id_to_string (id, span) name nm.strict_names_map
else nm.strict_names_map
in
- let names_map = names_map_add id_to_string (id, meta) name nm.names_map in
+ let names_map = names_map_add id_to_string (id, span) name nm.names_map in
{ nm with strict_names_map; names_map }
(** The [id_to_string] function to print nice debugging messages if there are
collisions *)
-let names_maps_get (meta : Meta.meta option) (id_to_string : id -> string)
+let names_maps_get (span : Meta.span option) (id_to_string : id -> string)
(id : id) (nm : names_maps) : string =
(* We do not use the same name map if we allow/disallow collisions *)
let map_to_string (m : string IdMap.t) : string =
@@ -454,7 +454,7 @@ let names_maps_get (meta : Meta.meta option) (id_to_string : id -> string)
"Could not find: " ^ id_to_string id ^ "\nNames map:\n"
^ map_to_string m
in
- save_error __FILE__ __LINE__ meta err;
+ save_error __FILE__ __LINE__ span err;
"(%%%ERROR: unknown identifier\": " ^ id_to_string id ^ "\"%%%)")
else
let m = nm.names_map.id_to_name in
@@ -465,7 +465,7 @@ let names_maps_get (meta : Meta.meta option) (id_to_string : id -> string)
"Could not find: " ^ id_to_string id ^ "\nNames map:\n"
^ map_to_string m
in
- save_error __FILE__ __LINE__ meta err;
+ save_error __FILE__ __LINE__ span err;
"(ERROR: \"" ^ id_to_string id ^ "\")"
type names_map_init = {
@@ -491,9 +491,9 @@ let names_maps_add_assumed_variant (id_to_string : id -> string)
names_maps_add id_to_string (VariantId (TAssumed id, variant_id)) None name nm
let names_maps_add_function (id_to_string : id -> string)
- ((fid, meta) : fun_id * meta option) (name : string) (nm : names_maps) :
+ ((fid, span) : fun_id * span option) (name : string) (nm : names_maps) :
names_maps =
- names_maps_add id_to_string (FunId fid) meta name nm
+ names_maps_add id_to_string (FunId fid) span name nm
let bool_name () = if !backend = Lean then "Bool" else "bool"
let char_name () = if !backend = Lean then "Char" else "char"
@@ -537,7 +537,7 @@ let scalar_name (ty : literal_type) : string =
functions, etc.
*)
type extraction_ctx = {
- (* mutable _meta : Meta.meta; *)
+ (* mutable _span : Meta.span; *)
crate : A.crate;
trans_ctx : trans_ctx;
names_maps : names_maps;
@@ -599,17 +599,17 @@ let llbc_fun_id_to_string (ctx : extraction_ctx) =
let fun_id_to_string (ctx : extraction_ctx) =
PrintPure.regular_fun_id_to_string (extraction_ctx_to_fmt_env ctx)
-let adt_variant_to_string (meta : Meta.meta option) (ctx : extraction_ctx) =
- PrintPure.adt_variant_to_string ~meta (extraction_ctx_to_fmt_env ctx)
+let adt_variant_to_string (span : Meta.span option) (ctx : extraction_ctx) =
+ PrintPure.adt_variant_to_string ~span (extraction_ctx_to_fmt_env ctx)
-let adt_field_to_string (meta : Meta.meta option) (ctx : extraction_ctx) =
- PrintPure.adt_field_to_string ~meta (extraction_ctx_to_fmt_env ctx)
+let adt_field_to_string (span : Meta.span option) (ctx : extraction_ctx) =
+ PrintPure.adt_field_to_string ~span (extraction_ctx_to_fmt_env ctx)
(** Debugging function, used when communicating name collisions to the user,
and also to print ids for internal debugging (in case of lookup miss for
instance).
*)
-let id_to_string (meta : Meta.meta option) (id : id) (ctx : extraction_ctx) :
+let id_to_string (span : Meta.span option) (id : id) (ctx : extraction_ctx) :
string =
let trait_decl_id_to_string (id : A.TraitDeclId.id) : string =
let trait_name = trait_decl_id_to_string ctx id in
@@ -638,11 +638,11 @@ let id_to_string (meta : Meta.meta option) (id : id) (ctx : extraction_ctx) :
| StructId id -> "struct constructor of: " ^ type_id_to_string ctx id
| VariantId (id, variant_id) ->
let type_name = type_id_to_string ctx id in
- let variant_name = adt_variant_to_string meta ctx id (Some variant_id) in
+ let variant_name = adt_variant_to_string span ctx id (Some variant_id) in
"type name: " ^ type_name ^ ", variant name: " ^ variant_name
| FieldId (id, field_id) ->
let type_name = type_id_to_string ctx id in
- let field_name = adt_field_to_string meta ctx id field_id in
+ let field_name = adt_field_to_string span ctx id field_id in
"type name: " ^ type_name ^ ", field name: " ^ field_name
| UnknownId -> "keyword"
| TypeVarId id -> "type_var_id: " ^ TypeVarId.to_string id
@@ -668,119 +668,119 @@ let id_to_string (meta : Meta.meta option) (id : id) (ctx : extraction_ctx) :
trait_decl_id_to_string trait_decl_id ^ ", method name: " ^ fun_name
| TraitSelfClauseId -> "trait_self_clause"
-let ctx_add (meta : Meta.meta) (id : id) (name : string) (ctx : extraction_ctx)
+let ctx_add (span : Meta.span) (id : id) (name : string) (ctx : extraction_ctx)
: extraction_ctx =
- let id_to_string (id : id) : string = id_to_string (Some meta) id ctx in
+ let id_to_string (id : id) : string = id_to_string (Some span) id ctx in
let names_maps =
- names_maps_add id_to_string id (Some meta) name ctx.names_maps
+ names_maps_add id_to_string id (Some span) name ctx.names_maps
in
{ ctx with names_maps }
-let ctx_get (meta : Meta.meta option) (id : id) (ctx : extraction_ctx) : string
+let ctx_get (span : Meta.span option) (id : id) (ctx : extraction_ctx) : string
=
- let id_to_string (id : id) : string = id_to_string meta id ctx in
- names_maps_get meta id_to_string id ctx.names_maps
+ let id_to_string (id : id) : string = id_to_string span id ctx in
+ names_maps_get span id_to_string id ctx.names_maps
-let ctx_get_global (meta : Meta.meta) (id : A.GlobalDeclId.id)
+let ctx_get_global (span : Meta.span) (id : A.GlobalDeclId.id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (GlobalId id) ctx
+ ctx_get (Some span) (GlobalId id) ctx
-let ctx_get_function (meta : Meta.meta) (id : fun_id) (ctx : extraction_ctx) :
+let ctx_get_function (span : Meta.span) (id : fun_id) (ctx : extraction_ctx) :
string =
- ctx_get (Some meta) (FunId id) ctx
+ ctx_get (Some span) (FunId id) ctx
-let ctx_get_local_function (meta : Meta.meta) (id : A.FunDeclId.id)
+let ctx_get_local_function (span : Meta.span) (id : A.FunDeclId.id)
(lp : LoopId.id option) (ctx : extraction_ctx) : string =
- ctx_get_function meta (FromLlbc (FunId (FRegular id), lp)) ctx
+ ctx_get_function span (FromLlbc (FunId (FRegular id), lp)) ctx
-let ctx_get_type (meta : Meta.meta option) (id : type_id) (ctx : extraction_ctx)
+let ctx_get_type (span : Meta.span option) (id : type_id) (ctx : extraction_ctx)
: string =
- sanity_check_opt_meta __FILE__ __LINE__ (id <> TTuple) meta;
- ctx_get meta (TypeId id) ctx
+ sanity_check_opt_span __FILE__ __LINE__ (id <> TTuple) span;
+ ctx_get span (TypeId id) ctx
-let ctx_get_local_type (meta : Meta.meta) (id : TypeDeclId.id)
+let ctx_get_local_type (span : Meta.span) (id : TypeDeclId.id)
(ctx : extraction_ctx) : string =
- ctx_get_type (Some meta) (TAdtId id) ctx
+ ctx_get_type (Some span) (TAdtId id) ctx
-let ctx_get_assumed_type (meta : Meta.meta option) (id : assumed_ty)
+let ctx_get_assumed_type (span : Meta.span option) (id : assumed_ty)
(ctx : extraction_ctx) : string =
- ctx_get_type meta (TAssumed id) ctx
+ ctx_get_type span (TAssumed id) ctx
-let ctx_get_trait_constructor (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_constructor (span : Meta.span) (id : trait_decl_id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TraitDeclConstructorId id) ctx
+ ctx_get (Some span) (TraitDeclConstructorId id) ctx
-let ctx_get_trait_self_clause (meta : Meta.meta) (ctx : extraction_ctx) : string
+let ctx_get_trait_self_clause (span : Meta.span) (ctx : extraction_ctx) : string
=
- ctx_get (Some meta) TraitSelfClauseId ctx
+ ctx_get (Some span) TraitSelfClauseId ctx
-let ctx_get_trait_decl (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_decl (span : Meta.span) (id : trait_decl_id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TraitDeclId id) ctx
+ ctx_get (Some span) (TraitDeclId id) ctx
-let ctx_get_trait_impl (meta : Meta.meta) (id : trait_impl_id)
+let ctx_get_trait_impl (span : Meta.span) (id : trait_impl_id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TraitImplId id) ctx
+ ctx_get (Some span) (TraitImplId id) ctx
-let ctx_get_trait_item (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_item (span : Meta.span) (id : trait_decl_id)
(item_name : string) (ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TraitItemId (id, item_name)) ctx
+ ctx_get (Some span) (TraitItemId (id, item_name)) ctx
-let ctx_get_trait_const (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_const (span : Meta.span) (id : trait_decl_id)
(item_name : string) (ctx : extraction_ctx) : string =
- ctx_get_trait_item meta id item_name ctx
+ ctx_get_trait_item span id item_name ctx
-let ctx_get_trait_type (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_type (span : Meta.span) (id : trait_decl_id)
(item_name : string) (ctx : extraction_ctx) : string =
- ctx_get_trait_item meta id item_name ctx
+ ctx_get_trait_item span id item_name ctx
-let ctx_get_trait_method (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_method (span : Meta.span) (id : trait_decl_id)
(item_name : string) (ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TraitMethodId (id, item_name)) ctx
+ ctx_get (Some span) (TraitMethodId (id, item_name)) ctx
-let ctx_get_trait_parent_clause (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_parent_clause (span : Meta.span) (id : trait_decl_id)
(clause : trait_clause_id) (ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TraitParentClauseId (id, clause)) ctx
+ ctx_get (Some span) (TraitParentClauseId (id, clause)) ctx
-let ctx_get_trait_item_clause (meta : Meta.meta) (id : trait_decl_id)
+let ctx_get_trait_item_clause (span : Meta.span) (id : trait_decl_id)
(item : string) (clause : trait_clause_id) (ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TraitItemClauseId (id, item, clause)) ctx
+ ctx_get (Some span) (TraitItemClauseId (id, item, clause)) ctx
-let ctx_get_var (meta : Meta.meta) (id : VarId.id) (ctx : extraction_ctx) :
+let ctx_get_var (span : Meta.span) (id : VarId.id) (ctx : extraction_ctx) :
string =
- ctx_get (Some meta) (VarId id) ctx
+ ctx_get (Some span) (VarId id) ctx
-let ctx_get_type_var (meta : Meta.meta) (id : TypeVarId.id)
+let ctx_get_type_var (span : Meta.span) (id : TypeVarId.id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TypeVarId id) ctx
+ ctx_get (Some span) (TypeVarId id) ctx
-let ctx_get_const_generic_var (meta : Meta.meta) (id : ConstGenericVarId.id)
+let ctx_get_const_generic_var (span : Meta.span) (id : ConstGenericVarId.id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (ConstGenericVarId id) ctx
+ ctx_get (Some span) (ConstGenericVarId id) ctx
-let ctx_get_local_trait_clause (meta : Meta.meta) (id : TraitClauseId.id)
+let ctx_get_local_trait_clause (span : Meta.span) (id : TraitClauseId.id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (LocalTraitClauseId id) ctx
+ ctx_get (Some span) (LocalTraitClauseId id) ctx
-let ctx_get_field (meta : Meta.meta) (type_id : type_id) (field_id : FieldId.id)
+let ctx_get_field (span : Meta.span) (type_id : type_id) (field_id : FieldId.id)
(ctx : extraction_ctx) : string =
- ctx_get (Some meta) (FieldId (type_id, field_id)) ctx
+ ctx_get (Some span) (FieldId (type_id, field_id)) ctx
-let ctx_get_struct (meta : Meta.meta) (def_id : type_id) (ctx : extraction_ctx)
+let ctx_get_struct (span : Meta.span) (def_id : type_id) (ctx : extraction_ctx)
: string =
- ctx_get (Some meta) (StructId def_id) ctx
+ ctx_get (Some span) (StructId def_id) ctx
-let ctx_get_variant (meta : Meta.meta) (def_id : type_id)
+let ctx_get_variant (span : Meta.span) (def_id : type_id)
(variant_id : VariantId.id) (ctx : extraction_ctx) : string =
- ctx_get (Some meta) (VariantId (def_id, variant_id)) ctx
+ ctx_get (Some span) (VariantId (def_id, variant_id)) ctx
-let ctx_get_decreases_proof (meta : Meta.meta) (def_id : A.FunDeclId.id)
+let ctx_get_decreases_proof (span : Meta.span) (def_id : A.FunDeclId.id)
(loop_id : LoopId.id option) (ctx : extraction_ctx) : string =
- ctx_get (Some meta) (DecreasesProofId (FRegular def_id, loop_id)) ctx
+ ctx_get (Some span) (DecreasesProofId (FRegular def_id, loop_id)) ctx
-let ctx_get_termination_measure (meta : Meta.meta) (def_id : A.FunDeclId.id)
+let ctx_get_termination_measure (span : Meta.span) (def_id : A.FunDeclId.id)
(loop_id : LoopId.id option) (ctx : extraction_ctx) : string =
- ctx_get (Some meta) (TerminationMeasureId (FRegular def_id, loop_id)) ctx
+ ctx_get (Some span) (TerminationMeasureId (FRegular def_id, loop_id)) ctx
(** Small helper to compute the name of a unary operation *)
let unop_name (unop : unop) : string =
@@ -1256,7 +1256,7 @@ let initialize_names_maps () : names_maps =
Remark: can return [None] for some backends like HOL4.
*)
-let type_decl_kind_to_qualif (meta : Meta.meta) (kind : decl_kind)
+let type_decl_kind_to_qualif (span : Meta.span) (kind : decl_kind)
(type_kind : type_decl_kind option) : string option =
match !backend with
| FStar -> (
@@ -1284,7 +1284,7 @@ let type_decl_kind_to_qualif (meta : Meta.meta) (kind : decl_kind)
(* This is for traits *)
Some "Record"
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Unexpected: (" ^ show_decl_kind kind ^ ", "
^ Print.option_to_string show_type_decl_kind type_kind
^ ")"))
@@ -1341,17 +1341,17 @@ let fun_decl_kind_to_qualif (kind : decl_kind) : string option =
TODO: move inside the formatter?
*)
-let type_keyword (meta : Meta.meta) =
+let type_keyword (span : Meta.span) =
match !backend with
| FStar -> "Type0"
| Coq | Lean -> "Type"
- | HOL4 -> craise __FILE__ __LINE__ meta "Unexpected"
+ | HOL4 -> craise __FILE__ __LINE__ span "Unexpected"
(** Helper *)
-let name_last_elem_as_ident (meta : Meta.meta) (n : llbc_name) : string =
+let name_last_elem_as_ident (span : Meta.span) (n : llbc_name) : string =
match Collections.List.last n with
| PeIdent (s, _) -> s
- | PeImpl _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | PeImpl _ -> craise __FILE__ __LINE__ span "Unexpected"
(** Helper
@@ -1360,22 +1360,22 @@ let name_last_elem_as_ident (meta : Meta.meta) (n : llbc_name) : string =
we remove it. We ignore disambiguators (there may be collisions, but we
check if there are).
*)
-let ctx_prepare_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_prepare_name (span : Meta.span) (ctx : extraction_ctx)
(name : llbc_name) : llbc_name =
(* Rmk.: initially we only filtered the disambiguators equal to 0 *)
match name with
| (PeIdent (crate, _) as id) :: name ->
if crate = ctx.crate.name then name else id :: name
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Unexpected name shape: "
^ TranslateCore.name_to_string ctx.trans_ctx name)
(** Helper *)
-let ctx_compute_simple_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_simple_name (span : Meta.span) (ctx : extraction_ctx)
(name : llbc_name) : string list =
(* Rmk.: initially we only filtered the disambiguators equal to 0 *)
- let name = ctx_prepare_name meta ctx name in
+ let name = ctx_prepare_name span ctx name in
name_to_simple_name ctx.trans_ctx name
(** Helper *)
@@ -1383,14 +1383,14 @@ let ctx_compute_simple_type_name = ctx_compute_simple_name
(** Helper *)
-let ctx_compute_type_name_no_suffix (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_type_name_no_suffix (span : Meta.span) (ctx : extraction_ctx)
(name : llbc_name) : string =
- flatten_name (ctx_compute_simple_type_name meta ctx name)
+ flatten_name (ctx_compute_simple_type_name span ctx name)
(** Provided a basename, compute a type name. *)
-let ctx_compute_type_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_type_name (span : Meta.span) (ctx : extraction_ctx)
(name : llbc_name) =
- let name = ctx_compute_type_name_no_suffix meta ctx name in
+ let name = ctx_compute_type_name_no_suffix span ctx name in
match !backend with
| FStar -> StringUtils.lowercase_first_letter (name ^ "_t")
| Coq | HOL4 -> name ^ "_t"
@@ -1407,7 +1407,7 @@ let ctx_compute_type_name (meta : Meta.meta) (ctx : extraction_ctx)
access then causes trouble because not all provers accept syntax like
[x.3] where [x] is a tuple.
*)
-let ctx_compute_field_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_field_name (span : Meta.span) (ctx : extraction_ctx)
(def_name : llbc_name) (field_id : FieldId.id) (field_name : string option)
: string =
let field_name_s =
@@ -1423,7 +1423,7 @@ let ctx_compute_field_name (meta : Meta.meta) (ctx : extraction_ctx)
else field_name_s
else
let def_name =
- ctx_compute_type_name_no_suffix meta ctx def_name ^ "_" ^ field_name_s
+ ctx_compute_type_name_no_suffix span ctx def_name ^ "_" ^ field_name_s
in
match !backend with
| Lean | HOL4 -> def_name
@@ -1433,14 +1433,14 @@ let ctx_compute_field_name (meta : Meta.meta) (ctx : extraction_ctx)
- type name
- variant name
*)
-let ctx_compute_variant_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_variant_name (span : Meta.span) (ctx : extraction_ctx)
(def_name : llbc_name) (variant : string) : string =
match !backend with
| FStar | Coq | HOL4 ->
let variant = to_camel_case variant in
if !variant_concatenate_type_name then
StringUtils.capitalize_first_letter
- (ctx_compute_type_name_no_suffix meta ctx def_name ^ "_" ^ variant)
+ (ctx_compute_type_name_no_suffix span ctx def_name ^ "_" ^ variant)
else variant
| Lean -> variant
@@ -1455,14 +1455,14 @@ let ctx_compute_variant_name (meta : Meta.meta) (ctx : extraction_ctx)
Inputs:
- type name
*)
-let ctx_compute_struct_constructor (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_struct_constructor (span : Meta.span) (ctx : extraction_ctx)
(basename : llbc_name) : string =
- let tname = ctx_compute_type_name meta ctx basename in
+ let tname = ctx_compute_type_name span ctx basename in
ExtractBuiltin.mk_struct_constructor tname
-let ctx_compute_fun_name_no_suffix (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_fun_name_no_suffix (span : Meta.span) (ctx : extraction_ctx)
(fname : llbc_name) : string =
- let fname = ctx_compute_simple_name meta ctx fname in
+ let fname = ctx_compute_simple_name span ctx fname in
(* TODO: don't convert to snake case for Coq, HOL4, F* *)
let fname = flatten_name fname in
match !backend with
@@ -1470,15 +1470,15 @@ let ctx_compute_fun_name_no_suffix (meta : Meta.meta) (ctx : extraction_ctx)
| Lean -> fname
(** Provided a basename, compute the name of a global declaration. *)
-let ctx_compute_global_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_global_name (span : Meta.span) (ctx : extraction_ctx)
(name : llbc_name) : string =
match !Config.backend with
| Coq | FStar | HOL4 ->
let parts =
- List.map to_snake_case (ctx_compute_simple_name meta ctx name)
+ List.map to_snake_case (ctx_compute_simple_name span ctx name)
in
String.concat "_" parts
- | Lean -> flatten_name (ctx_compute_simple_name meta ctx name)
+ | Lean -> flatten_name (ctx_compute_simple_name span ctx name)
(** Helper function: generate a suffix for a function name, i.e., generates
a suffix like "_loop", "loop1", etc. to append to a function name.
@@ -1509,10 +1509,10 @@ let default_fun_suffix (num_loops : int) (loop_id : LoopId.id option) : string =
- loop id (if pertinent)
TODO: use the fun id for the assumed functions.
*)
-let ctx_compute_fun_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_fun_name (span : Meta.span) (ctx : extraction_ctx)
(fname : llbc_name) (num_loops : int) (loop_id : LoopId.id option) : string
=
- let fname = ctx_compute_fun_name_no_suffix meta ctx fname in
+ let fname = ctx_compute_fun_name_no_suffix span ctx fname in
(* Compute the suffix *)
let suffix = default_fun_suffix num_loops loop_id in
(* Concatenate *)
@@ -1520,7 +1520,7 @@ let ctx_compute_fun_name (meta : Meta.meta) (ctx : extraction_ctx)
let ctx_compute_trait_decl_name (ctx : extraction_ctx) (trait_decl : trait_decl)
: string =
- ctx_compute_type_name trait_decl.meta ctx trait_decl.llbc_name
+ ctx_compute_type_name trait_decl.span ctx trait_decl.llbc_name
let ctx_compute_trait_impl_name (ctx : extraction_ctx) (trait_decl : trait_decl)
(trait_impl : trait_impl) : string =
@@ -1533,7 +1533,7 @@ let ctx_compute_trait_impl_name (ctx : extraction_ctx) (trait_decl : trait_decl)
let name =
let params = trait_impl.llbc_generics in
let args = trait_impl.llbc_impl_trait.decl_generics in
- let name = ctx_prepare_name trait_impl.meta ctx trait_decl.llbc_name in
+ let name = ctx_prepare_name trait_impl.span ctx trait_decl.llbc_name in
trait_name_with_generics_to_simple_name ctx.trans_ctx name params args
in
let name = flatten_name name in
@@ -1670,17 +1670,17 @@ let ctx_compute_trait_type_clause_name (ctx : extraction_ctx)
the same purpose as in [llbc_name].
- loop identifier, if this is for a loop
*)
-let ctx_compute_termination_measure_name (meta : Meta.meta)
+let ctx_compute_termination_measure_name (span : Meta.span)
(ctx : extraction_ctx) (_fid : A.FunDeclId.id) (fname : llbc_name)
(num_loops : int) (loop_id : LoopId.id option) : string =
- let fname = ctx_compute_fun_name_no_suffix meta ctx fname in
+ let fname = ctx_compute_fun_name_no_suffix span ctx fname in
let lp_suffix = default_fun_loop_suffix num_loops loop_id in
(* Compute the suffix *)
let suffix =
match !Config.backend with
| FStar -> "_decreases"
| Lean -> "_terminates"
- | Coq | HOL4 -> craise __FILE__ __LINE__ meta "Unexpected"
+ | Coq | HOL4 -> craise __FILE__ __LINE__ span "Unexpected"
in
(* Concatenate *)
fname ^ lp_suffix ^ suffix
@@ -1699,16 +1699,16 @@ let ctx_compute_termination_measure_name (meta : Meta.meta)
the same purpose as in [llbc_name].
- loop identifier, if this is for a loop
*)
-let ctx_compute_decreases_proof_name (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_decreases_proof_name (span : Meta.span) (ctx : extraction_ctx)
(_fid : A.FunDeclId.id) (fname : llbc_name) (num_loops : int)
(loop_id : LoopId.id option) : string =
- let fname = ctx_compute_fun_name_no_suffix meta ctx fname in
+ let fname = ctx_compute_fun_name_no_suffix span ctx fname in
let lp_suffix = default_fun_loop_suffix num_loops loop_id in
(* Compute the suffix *)
let suffix =
match !Config.backend with
| Lean -> "_decreases"
- | FStar | Coq | HOL4 -> craise __FILE__ __LINE__ meta "Unexpected"
+ | FStar | Coq | HOL4 -> craise __FILE__ __LINE__ span "Unexpected"
in
(* Concatenate *)
fname ^ lp_suffix ^ suffix
@@ -1726,7 +1726,7 @@ let ctx_compute_decreases_proof_name (meta : Meta.meta) (ctx : extraction_ctx)
if necessary to prevent name clashes: the burden of name clashes checks
is thus on the caller's side.
*)
-let ctx_compute_var_basename (meta : Meta.meta) (ctx : extraction_ctx)
+let ctx_compute_var_basename (span : Meta.span) (ctx : extraction_ctx)
(basename : string option) (ty : ty) : string =
(* Small helper to derive var names from ADT type names.
@@ -1739,7 +1739,7 @@ let ctx_compute_var_basename (meta : Meta.meta) (ctx : extraction_ctx)
let cl = to_snake_case name in
let cl = String.split_on_char '_' cl in
let cl = List.filter (fun s -> String.length s > 0) cl in
- sanity_check __FILE__ __LINE__ (List.length cl > 0) meta;
+ sanity_check __FILE__ __LINE__ (List.length cl > 0) span;
let cl = List.map (fun s -> s.[0]) cl in
StringUtils.string_of_chars cl
in
@@ -1842,85 +1842,85 @@ let name_append_index (basename : string) (i : int) : string =
basename ^ string_of_int i
(** Generate a unique type variable name and add it to the context *)
-let ctx_add_type_var (meta : Meta.meta) (basename : string) (id : TypeVarId.id)
+let ctx_add_type_var (span : Meta.span) (basename : string) (id : TypeVarId.id)
(ctx : extraction_ctx) : extraction_ctx * string =
let name = ctx_compute_type_var_basename ctx basename in
let name =
basename_to_unique ctx.names_maps.names_map.names_set name_append_index name
in
- let ctx = ctx_add meta (TypeVarId id) name ctx in
+ let ctx = ctx_add span (TypeVarId id) name ctx in
(ctx, name)
(** Generate a unique const generic variable name and add it to the context *)
-let ctx_add_const_generic_var (meta : Meta.meta) (basename : string)
+let ctx_add_const_generic_var (span : Meta.span) (basename : string)
(id : ConstGenericVarId.id) (ctx : extraction_ctx) : extraction_ctx * string
=
let name = ctx_compute_const_generic_var_basename ctx basename in
let name =
basename_to_unique ctx.names_maps.names_map.names_set name_append_index name
in
- let ctx = ctx_add meta (ConstGenericVarId id) name ctx in
+ let ctx = ctx_add span (ConstGenericVarId id) name ctx in
(ctx, name)
(** See {!ctx_add_type_var} *)
-let ctx_add_type_vars (meta : Meta.meta) (vars : (string * TypeVarId.id) list)
+let ctx_add_type_vars (span : Meta.span) (vars : (string * TypeVarId.id) list)
(ctx : extraction_ctx) : extraction_ctx * string list =
List.fold_left_map
- (fun ctx (name, id) -> ctx_add_type_var meta name id ctx)
+ (fun ctx (name, id) -> ctx_add_type_var span name id ctx)
ctx vars
(** Generate a unique variable name and add it to the context *)
-let ctx_add_var (meta : Meta.meta) (basename : string) (id : VarId.id)
+let ctx_add_var (span : Meta.span) (basename : string) (id : VarId.id)
(ctx : extraction_ctx) : extraction_ctx * string =
let name =
basename_to_unique ctx.names_maps.names_map.names_set name_append_index
basename
in
- let ctx = ctx_add meta (VarId id) name ctx in
+ let ctx = ctx_add span (VarId id) name ctx in
(ctx, name)
(** Generate a unique variable name for the trait self clause and add it to the context *)
-let ctx_add_trait_self_clause (meta : Meta.meta) (ctx : extraction_ctx) :
+let ctx_add_trait_self_clause (span : Meta.span) (ctx : extraction_ctx) :
extraction_ctx * string =
let basename = trait_self_clause_basename in
let name =
basename_to_unique ctx.names_maps.names_map.names_set name_append_index
basename
in
- let ctx = ctx_add meta TraitSelfClauseId name ctx in
+ let ctx = ctx_add span TraitSelfClauseId name ctx in
(ctx, name)
(** Generate a unique trait clause name and add it to the context *)
-let ctx_add_local_trait_clause (meta : Meta.meta) (basename : string)
+let ctx_add_local_trait_clause (span : Meta.span) (basename : string)
(id : TraitClauseId.id) (ctx : extraction_ctx) : extraction_ctx * string =
let name =
basename_to_unique ctx.names_maps.names_map.names_set name_append_index
basename
in
- let ctx = ctx_add meta (LocalTraitClauseId id) name ctx in
+ let ctx = ctx_add span (LocalTraitClauseId id) name ctx in
(ctx, name)
(** See {!ctx_add_var} *)
-let ctx_add_vars (meta : Meta.meta) (vars : var list) (ctx : extraction_ctx) :
+let ctx_add_vars (span : Meta.span) (vars : var list) (ctx : extraction_ctx) :
extraction_ctx * string list =
List.fold_left_map
(fun ctx (v : var) ->
- let name = ctx_compute_var_basename meta ctx v.basename v.ty in
- ctx_add_var meta name v.id ctx)
+ let name = ctx_compute_var_basename span ctx v.basename v.ty in
+ ctx_add_var span name v.id ctx)
ctx vars
-let ctx_add_type_params (meta : Meta.meta) (vars : type_var list)
+let ctx_add_type_params (span : Meta.span) (vars : type_var list)
(ctx : extraction_ctx) : extraction_ctx * string list =
List.fold_left_map
- (fun ctx (var : type_var) -> ctx_add_type_var meta var.name var.index ctx)
+ (fun ctx (var : type_var) -> ctx_add_type_var span var.name var.index ctx)
ctx vars
-let ctx_add_const_generic_params (meta : Meta.meta)
+let ctx_add_const_generic_params (span : Meta.span)
(vars : const_generic_var list) (ctx : extraction_ctx) :
extraction_ctx * string list =
List.fold_left_map
(fun ctx (var : const_generic_var) ->
- ctx_add_const_generic_var meta var.name var.index ctx)
+ ctx_add_const_generic_var span var.name var.index ctx)
ctx vars
(** Returns the lists of names for:
@@ -1932,7 +1932,7 @@ let ctx_add_const_generic_params (meta : Meta.meta)
pretty names for the trait clauses. See {!ctx_compute_trait_clause_name}
for additional information.
*)
-let ctx_add_local_trait_clauses (meta : Meta.meta)
+let ctx_add_local_trait_clauses (span : Meta.span)
(current_def_name : Types.name) (llbc_generics : Types.generic_params)
(clauses : trait_clause list) (ctx : extraction_ctx) :
extraction_ctx * string list =
@@ -1942,7 +1942,7 @@ let ctx_add_local_trait_clauses (meta : Meta.meta)
ctx_compute_trait_clause_basename ctx current_def_name llbc_generics
c.clause_id
in
- ctx_add_local_trait_clause meta basename c.clause_id ctx)
+ ctx_add_local_trait_clause span basename c.clause_id ctx)
ctx clauses
(** Returns the lists of names for:
@@ -1954,15 +1954,15 @@ let ctx_add_local_trait_clauses (meta : Meta.meta)
pretty names for the trait clauses. See {!ctx_compute_trait_clause_name}
for additional information.
*)
-let ctx_add_generic_params (meta : Meta.meta) (current_def_name : Types.name)
+let ctx_add_generic_params (span : Meta.span) (current_def_name : Types.name)
(llbc_generics : Types.generic_params) (generics : generic_params)
(ctx : extraction_ctx) :
extraction_ctx * string list * string list * string list =
let { types; const_generics; trait_clauses } = generics in
- let ctx, tys = ctx_add_type_params meta types ctx in
- let ctx, cgs = ctx_add_const_generic_params meta const_generics ctx in
+ let ctx, tys = ctx_add_type_params span types ctx in
+ let ctx, cgs = ctx_add_const_generic_params span const_generics ctx in
let ctx, tcs =
- ctx_add_local_trait_clauses meta current_def_name llbc_generics
+ ctx_add_local_trait_clauses span current_def_name llbc_generics
trait_clauses ctx
in
(ctx, tys, cgs, tcs)
@@ -1970,20 +1970,20 @@ let ctx_add_generic_params (meta : Meta.meta) (current_def_name : Types.name)
let ctx_add_decreases_proof (def : fun_decl) (ctx : extraction_ctx) :
extraction_ctx =
let name =
- ctx_compute_decreases_proof_name def.meta ctx def.def_id def.llbc_name
+ ctx_compute_decreases_proof_name def.span ctx def.def_id def.llbc_name
def.num_loops def.loop_id
in
- ctx_add def.meta
+ ctx_add def.span
(DecreasesProofId (FRegular def.def_id, def.loop_id))
name ctx
let ctx_add_termination_measure (def : fun_decl) (ctx : extraction_ctx) :
extraction_ctx =
let name =
- ctx_compute_termination_measure_name def.meta ctx def.def_id def.llbc_name
+ ctx_compute_termination_measure_name def.span ctx def.def_id def.llbc_name
def.num_loops def.loop_id
in
- ctx_add def.meta
+ ctx_add def.span
(TerminationMeasureId (FRegular def.def_id, def.loop_id))
name ctx
@@ -1998,10 +1998,10 @@ let ctx_add_global_decl_and_body (def : A.global_decl) (ctx : extraction_ctx) :
match match_name_find_opt ctx.trans_ctx def.name builtin_globals_map with
| Some name ->
(* Yes: register the custom binding *)
- ctx_add def.item_meta.meta decl name ctx
+ ctx_add def.item_meta.span decl name ctx
| None ->
(* Not the case: "standard" registration *)
- let name = ctx_compute_global_name def.item_meta.meta ctx def.name in
+ let name = ctx_compute_global_name def.item_meta.span ctx def.name in
let body = FunId (FromLlbc (FunId (FRegular def.body), None)) in
(* If this is a provided constant (i.e., the default value for a constant
@@ -2011,26 +2011,26 @@ let ctx_add_global_decl_and_body (def : A.global_decl) (ctx : extraction_ctx) :
let suffix =
match def.kind with TraitItemProvided _ -> "_default" | _ -> ""
in
- let ctx = ctx_add def.item_meta.meta decl (name ^ suffix) ctx in
- let ctx = ctx_add def.item_meta.meta body (name ^ suffix ^ "_body") ctx in
+ let ctx = ctx_add def.item_meta.span decl (name ^ suffix) ctx in
+ let ctx = ctx_add def.item_meta.span body (name ^ suffix ^ "_body") ctx in
ctx
let ctx_compute_fun_name (def : fun_decl) (ctx : extraction_ctx) : string =
(* Add the function name *)
- ctx_compute_fun_name def.meta ctx def.llbc_name def.num_loops def.loop_id
+ ctx_compute_fun_name def.span ctx def.llbc_name def.num_loops def.loop_id
(* TODO: move to Extract *)
let ctx_add_fun_decl (def : fun_decl) (ctx : extraction_ctx) : extraction_ctx =
(* Sanity check: the function should not be a global body - those are handled
* separately *)
- sanity_check __FILE__ __LINE__ (not def.is_global_decl_body) def.meta;
+ sanity_check __FILE__ __LINE__ (not def.is_global_decl_body) def.span;
(* Lookup the LLBC def to compute the region group information *)
let def_id = def.def_id in
(* Add the function name *)
let def_name = ctx_compute_fun_name def ctx in
let fun_id = (Pure.FunId (FRegular def_id), def.loop_id) in
- ctx_add def.meta (FunId (FromLlbc fun_id)) def_name ctx
+ ctx_add def.span (FunId (FromLlbc fun_id)) def_name ctx
let ctx_compute_type_decl_name (ctx : extraction_ctx) (def : type_decl) : string
=
- ctx_compute_type_name def.meta ctx def.llbc_name
+ ctx_compute_type_name def.span ctx def.llbc_name
diff --git a/compiler/ExtractName.ml b/compiler/ExtractName.ml
index 0573512d..81c35847 100644
--- a/compiler/ExtractName.ml
+++ b/compiler/ExtractName.ml
@@ -32,7 +32,7 @@ end
For impl blocks, we simply use the name of the type (without its arguments)
if all the arguments are variables.
*)
-let pattern_to_extract_name (meta : Meta.meta option) (name : pattern) :
+let pattern_to_extract_name (span : Meta.span option) (name : pattern) :
string list =
let c = { tgt = TkName } in
let all_vars =
@@ -73,7 +73,7 @@ let pattern_to_extract_name (meta : Meta.meta option) (name : pattern) :
let id = Collections.List.last id in
match id with
| PIdent (_, _) -> super#visit_PImpl () (EComp [ id ])
- | PImpl _ -> craise_opt_meta __FILE__ __LINE__ meta "Unreachable")
+ | PImpl _ -> craise_opt_span __FILE__ __LINE__ span "Unreachable")
| _ -> super#visit_PImpl () ty
method! visit_EPrimAdt _ adt g =
diff --git a/compiler/ExtractTypes.ml b/compiler/ExtractTypes.ml
index 6a6067de..a2d4758b 100644
--- a/compiler/ExtractTypes.ml
+++ b/compiler/ExtractTypes.ml
@@ -15,7 +15,7 @@ include ExtractBase
if it is made of an application (ex.: [U32 3])
- the constant value
*)
-let extract_literal (meta : Meta.meta) (fmt : F.formatter) (inside : bool)
+let extract_literal (span : Meta.span) (fmt : F.formatter) (inside : bool)
(cv : literal) : unit =
match cv with
| VScalar sv -> (
@@ -29,7 +29,7 @@ let extract_literal (meta : Meta.meta) (fmt : F.formatter) (inside : bool)
| HOL4 ->
F.pp_print_string fmt ("int_to_" ^ int_name sv.int_ty);
F.pp_print_space fmt ()
- | _ -> craise __FILE__ __LINE__ meta "Unreachable");
+ | _ -> craise __FILE__ __LINE__ span "Unreachable");
(* We need to add parentheses if the value is negative *)
if sv.value >= Z.of_int 0 then
F.pp_print_string fmt (Z.to_string sv.value)
@@ -42,7 +42,7 @@ let extract_literal (meta : Meta.meta) (fmt : F.formatter) (inside : bool)
let iname = String.lowercase_ascii (int_name sv.int_ty) in
F.pp_print_string fmt ("#" ^ iname)
| HOL4 -> ()
- | _ -> craise __FILE__ __LINE__ meta "Unreachable");
+ | _ -> craise __FILE__ __LINE__ span "Unreachable");
if print_brackets then F.pp_print_string fmt ")")
| VBool b ->
let b =
@@ -71,7 +71,7 @@ let extract_literal (meta : Meta.meta) (fmt : F.formatter) (inside : bool)
F.pp_print_string fmt c;
if inside then F.pp_print_string fmt ")")
| VStr _ | VByteStr _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"String and byte string literals are unsupported"
(** Format a unary operation
@@ -85,7 +85,7 @@ let extract_literal (meta : Meta.meta) (fmt : F.formatter) (inside : bool)
- unop
- argument
*)
-let extract_unop (meta : Meta.meta) (extract_expr : bool -> texpression -> unit)
+let extract_unop (span : Meta.span) (extract_expr : bool -> texpression -> unit)
(fmt : F.formatter) (inside : bool) (unop : unop) (arg : texpression) : unit
=
match unop with
@@ -132,7 +132,7 @@ let extract_unop (meta : Meta.meta) (extract_expr : bool -> texpression -> unit)
match !backend with
| Coq | FStar -> "scalar_cast"
| Lean -> "Scalar.cast"
- | HOL4 -> craise __FILE__ __LINE__ meta "Unreachable"
+ | HOL4 -> craise __FILE__ __LINE__ span "Unreachable"
in
let src =
if !backend <> Lean then Some (integer_type_to_string src)
@@ -145,21 +145,21 @@ let extract_unop (meta : Meta.meta) (extract_expr : bool -> texpression -> unit)
match !backend with
| Coq | FStar -> "scalar_cast_bool"
| Lean -> "Scalar.cast_bool"
- | HOL4 -> craise __FILE__ __LINE__ meta "Unreachable"
+ | HOL4 -> craise __FILE__ __LINE__ span "Unreachable"
in
let tgt = integer_type_to_string tgt in
(cast_str, None, Some tgt)
| TInteger _, TBool ->
(* This is not allowed by rustc: the way of doing it in Rust is: [x != 0] *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Unexpected cast: integer to bool"
| TBool, TBool ->
(* There shouldn't be any cast here. Note that if
one writes [b as bool] in Rust (where [b] is a
boolean), it gets compiled to [b] (i.e., no cast
is introduced). *)
- craise __FILE__ __LINE__ meta "Unexpected cast: bool to bool"
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unexpected cast: bool to bool"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
(* Print the name of the function *)
F.pp_print_string fmt cast_str;
@@ -192,7 +192,7 @@ let extract_unop (meta : Meta.meta) (extract_expr : bool -> texpression -> unit)
- argument 0
- argument 1
*)
-let extract_binop (meta : Meta.meta)
+let extract_binop (span : Meta.span)
(extract_expr : bool -> texpression -> unit) (fmt : F.formatter)
(inside : bool) (binop : E.binop) (int_ty : integer_type)
(arg0 : texpression) (arg1 : texpression) : unit =
@@ -216,7 +216,7 @@ let extract_binop (meta : Meta.meta)
| Sub -> "-"
| Mul -> "*"
| CheckedAdd | CheckedSub | CheckedMul ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Checked operations are not implemented"
| Shl -> "<<<"
| Shr -> ">>>"
@@ -241,7 +241,7 @@ let extract_binop (meta : Meta.meta)
constant we need to provide the second implicit type argument *)
if binop_is_shift && !backend = FStar && is_const arg1 then (
F.pp_print_space fmt ();
- let ty = ty_as_integer meta arg1.ty in
+ let ty = ty_as_integer span arg1.ty in
F.pp_print_string fmt
("#" ^ StringUtils.capitalize_first_letter (int_name ty)));
F.pp_print_space fmt ();
@@ -282,7 +282,7 @@ let start_fun_decl_group (ctx : extraction_ctx) (fmt : F.formatter)
if is_single_opaque_fun_decl_group dg then ()
else
let compute_fun_def_name (def : Pure.fun_decl) : string =
- ctx_get_local_function def.meta def.def_id def.loop_id ctx ^ "_def"
+ ctx_get_local_function def.span def.def_id def.loop_id ctx ^ "_def"
in
let names = List.map compute_fun_def_name dg in
(* Add a break before *)
@@ -296,7 +296,7 @@ let start_fun_decl_group (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_string fmt
("val [" ^ String.concat ", " names ^ "] = DefineDiv ‘")
else (
- sanity_check_opt_meta __FILE__ __LINE__ (List.length names = 1) None;
+ sanity_check_opt_span __FILE__ __LINE__ (List.length names = 1) None;
let name = List.hd names in
F.pp_print_string fmt ("val " ^ name ^ " = Define ‘"));
F.pp_print_cut fmt ()
@@ -401,15 +401,15 @@ let extract_arrow (fmt : F.formatter) () : unit =
if !Config.backend = Lean then F.pp_print_string fmt "→"
else F.pp_print_string fmt "->"
-let extract_const_generic (meta : Meta.meta) (ctx : extraction_ctx)
+let extract_const_generic (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (inside : bool) (cg : const_generic) : unit =
match cg with
| CgGlobal id ->
- let s = ctx_get_global meta id ctx in
+ let s = ctx_get_global span id ctx in
F.pp_print_string fmt s
- | CgValue v -> extract_literal meta fmt inside v
+ | CgValue v -> extract_literal span fmt inside v
| CgVar id ->
- let s = ctx_get_const_generic_var meta id ctx in
+ let s = ctx_get_const_generic_var span id ctx in
F.pp_print_string fmt s
let extract_literal_type (_ctx : extraction_ctx) (fmt : F.formatter)
@@ -446,9 +446,9 @@ let extract_ty_errors (fmt : F.formatter) : unit =
| Lean -> F.pp_print_string fmt "sorry"
| HOL4 -> F.pp_print_string fmt "(* ERROR: could not generate the code *)"
-let rec extract_ty (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
+let rec extract_ty (span : Meta.span) (ctx : extraction_ctx) (fmt : F.formatter)
(no_params_tys : TypeDeclId.Set.t) (inside : bool) (ty : ty) : unit =
- let extract_rec = extract_ty meta ctx fmt no_params_tys in
+ let extract_rec = extract_ty span ctx fmt no_params_tys in
match ty with
| TAdt (type_id, generics) -> (
let has_params = generics <> empty_generic_args in
@@ -486,7 +486,7 @@ let rec extract_ty (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
if print_paren then F.pp_print_string fmt "(";
(* TODO: for now, only the opaque *functions* are extracted in the
opaque module. The opaque *types* are assumed. *)
- F.pp_print_string fmt (ctx_get_type (Some meta) type_id ctx);
+ F.pp_print_string fmt (ctx_get_type (Some span) type_id ctx);
(* We might need to filter the type arguments, if the type
is builtin (for instance, we filter the global allocator type
argument for `Vec`). *)
@@ -507,19 +507,19 @@ let rec extract_ty (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
{ generics with types })
| _ -> generics
in
- extract_generic_args meta ctx fmt no_params_tys generics;
+ extract_generic_args span ctx fmt no_params_tys generics;
if print_paren then F.pp_print_string fmt ")"
| HOL4 ->
let { types; const_generics; trait_refs } = generics in
(* Const generics are not supported in HOL4 *)
- cassert __FILE__ __LINE__ (const_generics = []) meta
+ cassert __FILE__ __LINE__ (const_generics = []) span
"Constant generics are not supported yet when generating code \
for HOL4";
let print_tys =
match type_id with
| TAdtId id -> not (TypeDeclId.Set.mem id no_params_tys)
| TAssumed _ -> true
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
if types <> [] && print_tys then (
let print_paren = List.length types > 1 in
@@ -531,13 +531,13 @@ let rec extract_ty (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
(extract_rec true) types;
if print_paren then F.pp_print_string fmt ")";
F.pp_print_space fmt ());
- F.pp_print_string fmt (ctx_get_type (Some meta) type_id ctx);
+ F.pp_print_string fmt (ctx_get_type (Some span) type_id ctx);
if trait_refs <> [] then (
F.pp_print_space fmt ();
Collections.List.iter_link (F.pp_print_space fmt)
- (extract_trait_ref meta ctx fmt no_params_tys true)
+ (extract_trait_ref span ctx fmt no_params_tys true)
trait_refs)))
- | TVar vid -> F.pp_print_string fmt (ctx_get_type_var meta vid ctx)
+ | TVar vid -> F.pp_print_string fmt (ctx_get_type_var span vid ctx)
| TLiteral lty -> extract_literal_type ctx fmt lty
| TArrow (arg_ty, ret_ty) ->
if inside then F.pp_print_string fmt "(";
@@ -549,10 +549,10 @@ let rec extract_ty (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
if inside then F.pp_print_string fmt ")"
| TTraitType (trait_ref, type_name) -> (
if !parameterize_trait_types then
- craise __FILE__ __LINE__ meta "Unimplemented"
+ craise __FILE__ __LINE__ span "Unimplemented"
else
let type_name =
- ctx_get_trait_type meta trait_ref.trait_decl_ref.trait_decl_id
+ ctx_get_trait_type span trait_ref.trait_decl_ref.trait_decl_id
type_name ctx
in
let add_brackets (s : string) =
@@ -569,19 +569,19 @@ let rec extract_ty (meta : Meta.meta) (ctx : extraction_ctx) (fmt : F.formatter)
| Self ->
sanity_check __FILE__ __LINE__
(trait_ref.generics = empty_generic_args)
- meta;
- extract_trait_instance_id_with_dot meta ctx fmt no_params_tys false
+ span;
+ extract_trait_instance_id_with_dot span ctx fmt no_params_tys false
trait_ref.trait_id;
F.pp_print_string fmt type_name
| _ ->
(* HOL4 doesn't have 1st class types *)
- cassert __FILE__ __LINE__ (!backend <> HOL4) meta
+ cassert __FILE__ __LINE__ (!backend <> HOL4) span
"Trait types are not supported yet when generating code for HOL4";
- extract_trait_ref meta ctx fmt no_params_tys false trait_ref;
+ extract_trait_ref span ctx fmt no_params_tys false trait_ref;
F.pp_print_string fmt ("." ^ add_brackets type_name))
| Error -> extract_ty_errors fmt
-and extract_trait_ref (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_trait_ref (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (no_params_tys : TypeDeclId.Set.t) (inside : bool)
(tr : trait_ref) : unit =
let use_brackets = tr.generics <> empty_generic_args && inside in
@@ -603,24 +603,24 @@ and extract_trait_ref (meta : Meta.meta) (ctx : extraction_ctx)
{ tr.generics with types })
| _ -> tr.generics
in
- extract_trait_instance_id meta ctx fmt no_params_tys inside tr.trait_id;
- extract_generic_args meta ctx fmt no_params_tys generics;
+ extract_trait_instance_id span ctx fmt no_params_tys inside tr.trait_id;
+ extract_generic_args span ctx fmt no_params_tys generics;
if use_brackets then F.pp_print_string fmt ")"
-and extract_trait_decl_ref (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_trait_decl_ref (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (no_params_tys : TypeDeclId.Set.t) (inside : bool)
(tr : trait_decl_ref) : unit =
let use_brackets = tr.decl_generics <> empty_generic_args && inside in
- let name = ctx_get_trait_decl meta tr.trait_decl_id ctx in
+ let name = ctx_get_trait_decl span tr.trait_decl_id ctx in
if use_brackets then F.pp_print_string fmt "(";
F.pp_print_string fmt name;
(* There is something subtle here: the trait obligations for the implemented
trait are put inside the parent clauses, so we must ignore them here *)
let generics = { tr.decl_generics with trait_refs = [] } in
- extract_generic_args meta ctx fmt no_params_tys generics;
+ extract_generic_args span ctx fmt no_params_tys generics;
if use_brackets then F.pp_print_string fmt ")"
-and extract_generic_args (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_generic_args (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (no_params_tys : TypeDeclId.Set.t)
(generics : generic_args) : unit =
let { types; const_generics; trait_refs } = generics in
@@ -628,19 +628,19 @@ and extract_generic_args (meta : Meta.meta) (ctx : extraction_ctx)
if types <> [] then (
F.pp_print_space fmt ();
Collections.List.iter_link (F.pp_print_space fmt)
- (extract_ty meta ctx fmt no_params_tys true)
+ (extract_ty span ctx fmt no_params_tys true)
types);
if const_generics <> [] then (
- cassert __FILE__ __LINE__ (!backend <> HOL4) meta
+ cassert __FILE__ __LINE__ (!backend <> HOL4) span
"Constant generics are not supported yet when generating code for HOL4";
F.pp_print_space fmt ();
Collections.List.iter_link (F.pp_print_space fmt)
- (extract_const_generic meta ctx fmt true)
+ (extract_const_generic span ctx fmt true)
const_generics));
if trait_refs <> [] then (
F.pp_print_space fmt ();
Collections.List.iter_link (F.pp_print_space fmt)
- (extract_trait_ref meta ctx fmt no_params_tys true)
+ (extract_trait_ref span ctx fmt no_params_tys true)
trait_refs)
(** We sometimes need to ignore references to `Self` when generating the
@@ -649,7 +649,7 @@ and extract_generic_args (meta : Meta.meta) (ctx : extraction_ctx)
id (e.g., `<Self as Foo>::foo` - note that in the extracted code, the
projections are often written with a dot '.').
*)
-and extract_trait_instance_id_with_dot (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_trait_instance_id_with_dot (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (no_params_tys : TypeDeclId.Set.t) (inside : bool)
(id : trait_instance_id) : unit =
match id with
@@ -668,7 +668,7 @@ and extract_trait_instance_id_with_dot (meta : Meta.meta) (ctx : extraction_ctx)
*)
if ctx.is_provided_method then
(* Provided method: use the trait self clause *)
- let self_clause = ctx_get_trait_self_clause meta ctx in
+ let self_clause = ctx_get_trait_self_clause span ctx in
F.pp_print_string fmt (self_clause ^ ".")
else
(* Declaration: nothing to print, we will directly refer to
@@ -676,10 +676,10 @@ and extract_trait_instance_id_with_dot (meta : Meta.meta) (ctx : extraction_ctx)
()
| _ ->
(* Other cases *)
- extract_trait_instance_id meta ctx fmt no_params_tys inside id;
+ extract_trait_instance_id span ctx fmt no_params_tys inside id;
F.pp_print_string fmt "."
-and extract_trait_instance_id (meta : Meta.meta) (ctx : extraction_ctx)
+and extract_trait_instance_id (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (no_params_tys : TypeDeclId.Set.t) (inside : bool)
(id : trait_instance_id) : unit =
let add_brackets (s : string) = if !backend = Coq then "(" ^ s ^ ")" else s in
@@ -687,31 +687,31 @@ and extract_trait_instance_id (meta : Meta.meta) (ctx : extraction_ctx)
| Self ->
(* This has a specific treatment depending on the item we're extracting
(associated type, etc.). We should have caught this elsewhere. *)
- save_error __FILE__ __LINE__ (Some meta) "Unexpected occurrence of `Self`";
+ save_error __FILE__ __LINE__ (Some span) "Unexpected occurrence of `Self`";
F.pp_print_string fmt "ERROR(\"Unexpected Self\")"
| TraitImpl id ->
- let name = ctx_get_trait_impl meta id ctx in
+ let name = ctx_get_trait_impl span id ctx in
F.pp_print_string fmt name
| Clause id ->
- let name = ctx_get_local_trait_clause meta id ctx in
+ let name = ctx_get_local_trait_clause span id ctx in
F.pp_print_string fmt name
| ParentClause (inst_id, decl_id, clause_id) ->
(* Use the trait decl id to lookup the name *)
- let name = ctx_get_trait_parent_clause meta decl_id clause_id ctx in
- extract_trait_instance_id_with_dot meta ctx fmt no_params_tys true inst_id;
+ let name = ctx_get_trait_parent_clause span decl_id clause_id ctx in
+ extract_trait_instance_id_with_dot span ctx fmt no_params_tys true inst_id;
F.pp_print_string fmt (add_brackets name)
| ItemClause (inst_id, decl_id, item_name, clause_id) ->
(* Use the trait decl id to lookup the name *)
let name =
- ctx_get_trait_item_clause meta decl_id item_name clause_id ctx
+ ctx_get_trait_item_clause span decl_id item_name clause_id ctx
in
- extract_trait_instance_id_with_dot meta ctx fmt no_params_tys true inst_id;
+ extract_trait_instance_id_with_dot span ctx fmt no_params_tys true inst_id;
F.pp_print_string fmt (add_brackets name)
| TraitRef trait_ref ->
- extract_trait_ref meta ctx fmt no_params_tys inside trait_ref
+ extract_trait_ref span ctx fmt no_params_tys inside trait_ref
| UnknownTrait _ ->
(* This is an error case *)
- craise __FILE__ __LINE__ meta "Unexpected"
+ craise __FILE__ __LINE__ span "Unexpected"
(** Compute the names for all the top-level identifiers used in a type
definition (type name, variant names, field names, etc. but not type
@@ -741,10 +741,10 @@ let extract_type_decl_register_names (ctx : extraction_ctx) (def : type_decl) :
(* Compute and register the type def name *)
let def_name =
match info with
- | None -> ctx_compute_type_name def.meta ctx def.llbc_name
+ | None -> ctx_compute_type_name def.span ctx def.llbc_name
| Some info -> info.extract_name
in
- let ctx = ctx_add def.meta (TypeId (TAdtId def.def_id)) def_name ctx in
+ let ctx = ctx_add def.span (TypeId (TAdtId def.def_id)) def_name ctx in
(* Compute and register:
* - the variant names, if this is an enumeration
* - the field names, if this is a structure
@@ -766,12 +766,12 @@ let extract_type_decl_register_names (ctx : extraction_ctx) (def : type_decl) :
FieldId.mapi
(fun fid (field : field) ->
( fid,
- ctx_compute_field_name def.meta ctx def.llbc_name fid
+ ctx_compute_field_name def.span ctx def.llbc_name fid
field.field_name ))
fields
in
let cons_name =
- ctx_compute_struct_constructor def.meta ctx def.llbc_name
+ ctx_compute_struct_constructor def.span ctx def.llbc_name
in
(field_names, cons_name)
| Some { body_info = Some (Struct (cons_name, field_names)); _ } ->
@@ -788,18 +788,18 @@ let extract_type_decl_register_names (ctx : extraction_ctx) (def : type_decl) :
in
(field_names, cons_name)
| Some info ->
- craise __FILE__ __LINE__ def.meta
+ craise __FILE__ __LINE__ def.span
("Invalid builtin information: " ^ show_builtin_type_info info)
in
(* Add the fields *)
let ctx =
List.fold_left
(fun ctx (fid, name) ->
- ctx_add def.meta (FieldId (TAdtId def.def_id, fid)) name ctx)
+ ctx_add def.span (FieldId (TAdtId def.def_id, fid)) name ctx)
ctx field_names
in
(* Add the constructor name *)
- ctx_add def.meta (StructId (TAdtId def.def_id)) cons_name ctx
+ ctx_add def.span (StructId (TAdtId def.def_id)) cons_name ctx
| Enum variants ->
let variant_names =
match info with
@@ -807,14 +807,14 @@ let extract_type_decl_register_names (ctx : extraction_ctx) (def : type_decl) :
VariantId.mapi
(fun variant_id (variant : variant) ->
let name =
- ctx_compute_variant_name def.meta ctx def.llbc_name
+ ctx_compute_variant_name def.span ctx def.llbc_name
variant.variant_name
in
(* Add the type name prefix for Lean *)
let name =
if !Config.backend = Lean then
let type_name =
- ctx_compute_type_name def.meta ctx def.llbc_name
+ ctx_compute_type_name def.span ctx def.llbc_name
in
type_name ^ "." ^ name
else name
@@ -835,11 +835,11 @@ let extract_type_decl_register_names (ctx : extraction_ctx) (def : type_decl) :
(variant_id, StringMap.find variant.variant_name variant_map))
variants
| _ ->
- craise __FILE__ __LINE__ def.meta "Invalid builtin information"
+ craise __FILE__ __LINE__ def.span "Invalid builtin information"
in
List.fold_left
(fun ctx (vid, vname) ->
- ctx_add def.meta (VariantId (TAdtId def.def_id, vid)) vname ctx)
+ ctx_add def.span (VariantId (TAdtId def.def_id, vid)) vname ctx)
ctx variant_names
| Opaque ->
(* Nothing to do *)
@@ -849,7 +849,7 @@ let extract_type_decl_register_names (ctx : extraction_ctx) (def : type_decl) :
ctx
(** Print the variants *)
-let extract_type_decl_variant (meta : Meta.meta) (ctx : extraction_ctx)
+let extract_type_decl_variant (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (type_decl_group : TypeDeclId.Set.t)
(type_name : string) (type_params : string list) (cg_params : string list)
(cons_name : string) (fields : field list) : unit =
@@ -878,9 +878,9 @@ let extract_type_decl_variant (meta : Meta.meta) (ctx : extraction_ctx)
| Some field_name ->
let var_id = VarId.of_int (FieldId.to_int fid) in
let field_name =
- ctx_compute_var_basename meta ctx (Some field_name) f.field_ty
+ ctx_compute_var_basename span ctx (Some field_name) f.field_ty
in
- let ctx, field_name = ctx_add_var meta field_name var_id ctx in
+ let ctx, field_name = ctx_add_var span field_name var_id ctx in
F.pp_print_string fmt (field_name ^ " :");
F.pp_print_space fmt ();
ctx)
@@ -888,7 +888,7 @@ let extract_type_decl_variant (meta : Meta.meta) (ctx : extraction_ctx)
in
(* Print the field type *)
let inside = !backend = HOL4 in
- extract_ty meta ctx fmt type_decl_group inside f.field_ty;
+ extract_ty span ctx fmt type_decl_group inside f.field_ty;
(* Print the arrow [->] *)
if !backend <> HOL4 then (
F.pp_print_space fmt ();
@@ -904,7 +904,7 @@ let extract_type_decl_variant (meta : Meta.meta) (ctx : extraction_ctx)
List.fold_left (fun ctx (fid, f) -> print_field fid f ctx) ctx fields
in
(* Sanity check: HOL4 doesn't support const generics *)
- sanity_check __FILE__ __LINE__ (cg_params = [] || !backend <> HOL4) meta;
+ sanity_check __FILE__ __LINE__ (cg_params = [] || !backend <> HOL4) span;
(* Print the final type *)
if !backend <> HOL4 then (
F.pp_print_space fmt ();
@@ -960,10 +960,10 @@ let extract_type_decl_enum_body (ctx : extraction_ctx) (fmt : F.formatter)
(* We don't lookup the name, because it may have a prefix for the type
id (in the case of Lean) *)
let cons_name =
- ctx_compute_variant_name def.meta ctx def.llbc_name v.variant_name
+ ctx_compute_variant_name def.span ctx def.llbc_name v.variant_name
in
let fields = v.fields in
- extract_type_decl_variant def.meta ctx fmt type_decl_group def_name
+ extract_type_decl_variant def.span ctx fmt type_decl_group def_name
type_params cg_params cons_name fields
in
(* Print the variants *)
@@ -971,7 +971,7 @@ let extract_type_decl_enum_body (ctx : extraction_ctx) (fmt : F.formatter)
List.iter (fun (vid, v) -> print_variant vid v) variants
(** Extract a struct as a tuple *)
-let extract_type_decl_tuple_struct_body (meta : Meta.meta)
+let extract_type_decl_tuple_struct_body (span : Meta.span)
(ctx : extraction_ctx) (fmt : F.formatter) (fields : field list) : unit =
(* If the type is empty, we need to have a special treatment *)
if fields = [] then (
@@ -985,7 +985,7 @@ let extract_type_decl_tuple_struct_body (meta : Meta.meta)
F.pp_print_string fmt sep)
(fun (f : field) ->
F.pp_print_space fmt ();
- extract_ty meta ctx fmt TypeDeclId.Set.empty true f.field_ty)
+ extract_ty span ctx fmt TypeDeclId.Set.empty true f.field_ty)
fields
let extract_type_decl_struct_body (ctx : extraction_ctx) (fmt : F.formatter)
@@ -1061,7 +1061,7 @@ let extract_type_decl_struct_body (ctx : extraction_ctx) (fmt : F.formatter)
(* If Coq: print the constructor name *)
(* TODO: remove superfluous test not is_rec below *)
if !backend = Coq && not is_rec then (
- F.pp_print_string fmt (ctx_get_struct def.meta (TAdtId def.def_id) ctx);
+ F.pp_print_string fmt (ctx_get_struct def.span (TAdtId def.def_id) ctx);
F.pp_print_string fmt " ");
(match !backend with
| Lean -> ()
@@ -1076,7 +1076,7 @@ let extract_type_decl_struct_body (ctx : extraction_ctx) (fmt : F.formatter)
(* Print the fields *)
let print_field (field_id : FieldId.id) (f : field) : unit =
let field_name =
- ctx_get_field def.meta (TAdtId def.def_id) field_id ctx
+ ctx_get_field def.span (TAdtId def.def_id) field_id ctx
in
(* Open a box for the field *)
F.pp_open_box fmt ctx.indent_incr;
@@ -1084,7 +1084,7 @@ let extract_type_decl_struct_body (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_space fmt ();
F.pp_print_string fmt ":";
F.pp_print_space fmt ();
- extract_ty def.meta ctx fmt type_decl_group false f.field_ty;
+ extract_ty def.span ctx fmt type_decl_group false f.field_ty;
if !backend <> Lean then F.pp_print_string fmt ";";
(* Close the box for the field *)
F.pp_close_box fmt ()
@@ -1108,7 +1108,7 @@ let extract_type_decl_struct_body (ctx : extraction_ctx) (fmt : F.formatter)
a group of mutually recursive types: we extract it as an inductive type *)
cassert __FILE__ __LINE__
(is_rec && (!backend = Coq || !backend = Lean))
- def.meta
+ def.span
"Constant generics are not supported yet when generating code for HOL4";
(* Small trick: in Lean we use namespaces, meaning we don't need to prefix
the constructor name with the name of the type at definition site,
@@ -1116,10 +1116,10 @@ let extract_type_decl_struct_body (ctx : extraction_ctx) (fmt : F.formatter)
we generate `inductive Foo := | mk ... *)
let cons_name =
if !backend = Lean then "mk"
- else ctx_get_struct def.meta (TAdtId def.def_id) ctx
+ else ctx_get_struct def.span (TAdtId def.def_id) ctx
in
- let def_name = ctx_get_local_type def.meta def.def_id ctx in
- extract_type_decl_variant def.meta ctx fmt type_decl_group def_name
+ let def_name = ctx_get_local_type def.span def.def_id ctx in
+ extract_type_decl_variant def.span ctx fmt type_decl_group def_name
type_params cg_params cons_name fields)
in
()
@@ -1146,17 +1146,19 @@ let extract_comment (fmt : F.formatter) (sl : string list) : unit =
F.pp_print_string fmt rd;
F.pp_close_box fmt ()
-let extract_comment_with_span (ctx : extraction_ctx) (fmt : F.formatter)
+let extract_comment_with_raw_span (ctx : extraction_ctx) (fmt : F.formatter)
(sl : string list) (name : Types.name option)
?(generics : (Types.generic_params * Types.generic_args) option = None)
- (span : Meta.span) : unit =
- let file = match span.file with Virtual s | Local s -> s in
+ (raw_span : Meta.raw_span) : unit =
+ let file = match raw_span.file with Virtual s | Local s -> s in
let loc_to_string (l : Meta.loc) : string =
string_of_int l.line ^ ":" ^ string_of_int l.col
in
- let span =
- "Source: '" ^ file ^ "', lines " ^ loc_to_string span.beg_loc ^ "-"
- ^ loc_to_string span.end_loc
+ let raw_span =
+ "Source: '" ^ file ^ "', lines "
+ ^ loc_to_string raw_span.beg_loc
+ ^ "-"
+ ^ loc_to_string raw_span.end_loc
in
let name =
match (name, generics) with
@@ -1169,16 +1171,16 @@ let extract_comment_with_span (ctx : extraction_ctx) (fmt : F.formatter)
^ name_with_generics_to_pattern_string ctx.trans_ctx name params args;
]
in
- extract_comment fmt (sl @ [ span ] @ name)
+ extract_comment fmt (sl @ [ raw_span ] @ name)
-let extract_trait_clause_type (meta : Meta.meta) (ctx : extraction_ctx)
+let extract_trait_clause_type (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (no_params_tys : TypeDeclId.Set.t)
(clause : trait_clause) : unit =
- let trait_name = ctx_get_trait_decl meta clause.trait_id ctx in
+ let trait_name = ctx_get_trait_decl span clause.trait_id ctx in
F.pp_print_string fmt trait_name;
- (* let meta = (TraitDeclId.Map.find clause.trait_id ctx.trans_trait_decls).meta in
+ (* let span = (TraitDeclId.Map.find clause.trait_id ctx.trans_trait_decls).span in
*)
- extract_generic_args meta ctx fmt no_params_tys clause.generics
+ extract_generic_args span ctx fmt no_params_tys clause.generics
(** Insert a space, if necessary *)
let insert_req_space (fmt : F.formatter) (space : bool ref) : unit =
@@ -1193,12 +1195,12 @@ let extract_trait_self_clause (insert_req_space : unit -> unit)
(params : string list) : unit =
insert_req_space ();
F.pp_print_string fmt "(";
- let self_clause = ctx_get_trait_self_clause trait_decl.meta ctx in
+ let self_clause = ctx_get_trait_self_clause trait_decl.span ctx in
F.pp_print_string fmt self_clause;
F.pp_print_space fmt ();
F.pp_print_string fmt ":";
F.pp_print_space fmt ();
- let trait_id = ctx_get_trait_decl trait_decl.meta trait_decl.def_id ctx in
+ let trait_id = ctx_get_trait_decl trait_decl.span trait_decl.def_id ctx in
F.pp_print_string fmt trait_id;
List.iter
(fun p ->
@@ -1211,7 +1213,7 @@ let extract_trait_self_clause (insert_req_space : unit -> unit)
- [trait_decl]: if [Some], it means we are extracting the generics for a provided
method and need to insert a trait self clause (see {!TraitSelfClauseId}).
*)
-let extract_generic_params (meta : Meta.meta) (ctx : extraction_ctx)
+let extract_generic_params (span : Meta.span) (ctx : extraction_ctx)
(fmt : F.formatter) (no_params_tys : TypeDeclId.Set.t) ?(use_forall = false)
?(use_forall_use_sep = true) ?(use_arrows = false)
?(as_implicits : bool = false) ?(space : bool ref option = None)
@@ -1222,7 +1224,7 @@ let extract_generic_params (meta : Meta.meta) (ctx : extraction_ctx)
(* HOL4 doesn't support const generics *)
cassert __FILE__ __LINE__
(cg_params = [] || !backend <> HOL4)
- meta "Constant generics are not supported yet when generating code for HOL4";
+ span "Constant generics are not supported yet when generating code for HOL4";
let left_bracket (implicit : bool) =
if implicit && !backend <> FStar then F.pp_print_string fmt "{"
else F.pp_print_string fmt "("
@@ -1266,7 +1268,7 @@ let extract_generic_params (meta : Meta.meta) (ctx : extraction_ctx)
type_params;
F.pp_print_string fmt ":";
F.pp_print_space fmt ();
- F.pp_print_string fmt (type_keyword meta);
+ F.pp_print_string fmt (type_keyword span);
(* ) *)
right_bracket as_implicits;
if use_arrows then (
@@ -1278,7 +1280,7 @@ let extract_generic_params (meta : Meta.meta) (ctx : extraction_ctx)
insert_req_space ();
(* ( *)
left_bracket as_implicits;
- let n = ctx_get_const_generic_var meta var.index ctx in
+ let n = ctx_get_const_generic_var span var.index ctx in
print_implicit_symbol as_implicits;
F.pp_print_string fmt n;
F.pp_print_space fmt ();
@@ -1297,13 +1299,13 @@ let extract_generic_params (meta : Meta.meta) (ctx : extraction_ctx)
insert_req_space ();
(* ( *)
left_bracket as_implicits;
- let n = ctx_get_local_trait_clause meta clause.clause_id ctx in
+ let n = ctx_get_local_trait_clause span clause.clause_id ctx in
print_implicit_symbol as_implicits;
F.pp_print_string fmt n;
F.pp_print_space fmt ();
F.pp_print_string fmt ":";
F.pp_print_space fmt ();
- extract_trait_clause_type meta ctx fmt no_params_tys clause;
+ extract_trait_clause_type span ctx fmt no_params_tys clause;
(* ) *)
right_bracket as_implicits;
if use_arrows then (
@@ -1347,11 +1349,11 @@ let extract_generic_params (meta : Meta.meta) (ctx : extraction_ctx)
dtype_params;
map
(fun (cg : const_generic_var) ->
- ctx_get_const_generic_var trait_decl.meta cg.index ctx)
+ ctx_get_const_generic_var trait_decl.span cg.index ctx)
dcgs;
map
(fun c ->
- ctx_get_local_trait_clause trait_decl.meta c.clause_id ctx)
+ ctx_get_local_trait_clause trait_decl.span c.clause_id ctx)
dtrait_clauses;
]
in
@@ -1370,7 +1372,7 @@ let extract_type_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
(type_decl_group : TypeDeclId.Set.t) (kind : decl_kind) (def : type_decl)
(extract_body : bool) : unit =
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (extract_body || !backend <> HOL4) def.meta;
+ sanity_check __FILE__ __LINE__ (extract_body || !backend <> HOL4) def.span;
let is_tuple_struct =
TypesUtils.type_decl_from_decl_id_is_tuple_struct
ctx.trans_ctx.type_ctx.type_infos def.def_id
@@ -1398,11 +1400,11 @@ let extract_type_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
let is_opaque_coq = !backend = Coq && is_opaque in
let use_forall = is_opaque_coq && def.generics <> empty_generic_params in
(* Retrieve the definition name *)
- let def_name = ctx_get_local_type def.meta def.def_id ctx in
+ let def_name = ctx_get_local_type def.span def.def_id ctx in
(* Add the type and const generic params - note that we need those bindings only for the
* body translation (they are not top-level) *)
let ctx_body, type_params, cg_params, trait_clauses =
- ctx_add_generic_params def.meta def.llbc_name def.llbc_generics def.generics
+ ctx_add_generic_params def.span def.llbc_name def.llbc_generics def.generics
ctx
in
(* Add a break before *)
@@ -1414,9 +1416,9 @@ let extract_type_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
Some def.llbc_name
else None
in
- extract_comment_with_span ctx fmt
+ extract_comment_with_raw_span ctx fmt
[ "[" ^ name_to_string ctx def.llbc_name ^ "]" ]
- name def.meta.span);
+ name def.span.span);
F.pp_print_break fmt 0 0;
(* Open a box for the definition, so that whenever possible it gets printed on
* one line. Note however that in the case of Lean line breaks are important
@@ -1436,7 +1438,7 @@ let extract_type_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_space fmt ())
else ();
(* > "type TYPE_NAME" *)
- let qualif = type_decl_kind_to_qualif def.meta kind type_kind in
+ let qualif = type_decl_kind_to_qualif def.span kind type_kind in
(match qualif with
| Some qualif -> F.pp_print_string fmt (qualif ^ " " ^ def_name)
| None -> F.pp_print_string fmt def_name);
@@ -1444,11 +1446,11 @@ let extract_type_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
support trait clauses *)
cassert __FILE__ __LINE__
((cg_params = [] && trait_clauses = []) || !backend <> HOL4)
- def.meta
+ def.span
"Constant generics and type definitions with trait clauses are not \
supported yet when generating code for HOL4";
(* Print the generic parameters *)
- extract_generic_params def.meta ctx_body fmt type_decl_group ~use_forall
+ extract_generic_params def.span ctx_body fmt type_decl_group ~use_forall
def.generics type_params cg_params trait_clauses;
(* Print the "=" if we extract the body*)
if extract_body then (
@@ -1475,21 +1477,21 @@ let extract_type_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_print_space fmt ();
F.pp_print_string fmt ":");
F.pp_print_space fmt ();
- F.pp_print_string fmt (type_keyword def.meta));
+ F.pp_print_string fmt (type_keyword def.span));
(* Close the box for "type TYPE_NAME (TYPE_PARAMS) =" *)
F.pp_close_box fmt ();
(if extract_body then
match def.kind with
| Struct fields ->
if is_tuple_struct then
- extract_type_decl_tuple_struct_body def.meta ctx_body fmt fields
+ extract_type_decl_tuple_struct_body def.span ctx_body fmt fields
else
extract_type_decl_struct_body ctx_body fmt type_decl_group kind def
type_params cg_params fields
| Enum variants ->
extract_type_decl_enum_body ctx_body fmt type_decl_group def def_name
type_params cg_params variants
- | Opaque -> craise __FILE__ __LINE__ def.meta "Unreachable");
+ | Opaque -> craise __FILE__ __LINE__ def.span "Unreachable");
(* Add the definition end delimiter *)
if !backend = HOL4 && decl_is_not_last_from_group kind then (
F.pp_print_space fmt ();
@@ -1513,16 +1515,16 @@ let extract_type_decl_gen (ctx : extraction_ctx) (fmt : F.formatter)
let extract_type_decl_hol4_opaque (ctx : extraction_ctx) (fmt : F.formatter)
(def : type_decl) : unit =
(* Retrieve the definition name *)
- let def_name = ctx_get_local_type def.meta def.def_id ctx in
+ let def_name = ctx_get_local_type def.span def.def_id ctx in
(* Generic parameters are unsupported *)
cassert __FILE__ __LINE__
(def.generics.const_generics = [])
- def.meta
+ def.span
"Constant generics are not supported yet when generating code for HOL4";
(* Trait clauses on type definitions are unsupported *)
cassert __FILE__ __LINE__
(def.generics.trait_clauses = [])
- def.meta
+ def.span
"Types with trait clauses are not supported yet when generating code for \
HOL4";
(* Types *)
@@ -1545,9 +1547,9 @@ let extract_type_decl_hol4_opaque (ctx : extraction_ctx) (fmt : F.formatter)
let extract_type_decl_hol4_empty_record (ctx : extraction_ctx)
(fmt : F.formatter) (def : type_decl) : unit =
(* Retrieve the definition name *)
- let def_name = ctx_get_local_type def.meta def.def_id ctx in
+ let def_name = ctx_get_local_type def.span def.def_id ctx in
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (def.generics = empty_generic_params) def.meta;
+ sanity_check __FILE__ __LINE__ (def.generics = empty_generic_params) def.span;
(* Generate the declaration *)
F.pp_print_space fmt ();
F.pp_print_string fmt ("Type " ^ def_name ^ " = “: unit”");
@@ -1623,7 +1625,7 @@ let extract_coq_arguments_instruction (ctx : extraction_ctx) (fmt : F.formatter)
*)
let extract_type_decl_coq_arguments (ctx : extraction_ctx) (fmt : F.formatter)
(kind : decl_kind) (decl : type_decl) : unit =
- sanity_check __FILE__ __LINE__ (!backend = Coq) decl.meta;
+ sanity_check __FILE__ __LINE__ (!backend = Coq) decl.span;
(* Generating the [Arguments] instructions is useful only if there are parameters *)
let num_params =
List.length decl.generics.types
@@ -1638,14 +1640,14 @@ let extract_type_decl_coq_arguments (ctx : extraction_ctx) (fmt : F.formatter)
| Struct fields ->
let adt_id = TAdtId decl.def_id in
(* Generate the instruction for the record constructor *)
- let cons_name = ctx_get_struct decl.meta adt_id ctx in
+ let cons_name = ctx_get_struct decl.span adt_id ctx in
extract_coq_arguments_instruction ctx fmt cons_name num_params;
(* Generate the instruction for the record projectors, if there are *)
let is_rec = decl_is_from_rec_group kind in
if not is_rec then
FieldId.iteri
(fun fid _ ->
- let cons_name = ctx_get_field decl.meta adt_id fid ctx in
+ let cons_name = ctx_get_field decl.span adt_id fid ctx in
extract_coq_arguments_instruction ctx fmt cons_name num_params)
fields;
(* Add breaks to insert new lines between definitions *)
@@ -1655,7 +1657,7 @@ let extract_type_decl_coq_arguments (ctx : extraction_ctx) (fmt : F.formatter)
VariantId.iteri
(fun vid (_ : variant) ->
let cons_name =
- ctx_get_variant decl.meta (TAdtId decl.def_id) vid ctx
+ ctx_get_variant decl.span (TAdtId decl.def_id) vid ctx
in
extract_coq_arguments_instruction ctx fmt cons_name num_params)
variants;
@@ -1671,7 +1673,7 @@ let extract_type_decl_coq_arguments (ctx : extraction_ctx) (fmt : F.formatter)
*)
let extract_type_decl_record_field_projectors (ctx : extraction_ctx)
(fmt : F.formatter) (kind : decl_kind) (decl : type_decl) : unit =
- sanity_check __FILE__ __LINE__ (!backend = Coq) decl.meta;
+ sanity_check __FILE__ __LINE__ (!backend = Coq) decl.span;
match decl.kind with
| Opaque | Enum _ -> ()
| Struct fields ->
@@ -1680,13 +1682,13 @@ let extract_type_decl_record_field_projectors (ctx : extraction_ctx)
if is_rec then
(* Add the type params *)
let ctx, type_params, cg_params, trait_clauses =
- ctx_add_generic_params decl.meta decl.llbc_name decl.llbc_generics
+ ctx_add_generic_params decl.span decl.llbc_name decl.llbc_generics
decl.generics ctx
in
- let ctx, record_var = ctx_add_var decl.meta "x" (VarId.of_int 0) ctx in
- let ctx, field_var = ctx_add_var decl.meta "x" (VarId.of_int 1) ctx in
- let def_name = ctx_get_local_type decl.meta decl.def_id ctx in
- let cons_name = ctx_get_struct decl.meta (TAdtId decl.def_id) ctx in
+ let ctx, record_var = ctx_add_var decl.span "x" (VarId.of_int 0) ctx in
+ let ctx, field_var = ctx_add_var decl.span "x" (VarId.of_int 1) ctx in
+ let def_name = ctx_get_local_type decl.span decl.def_id ctx in
+ let cons_name = ctx_get_struct decl.span (TAdtId decl.def_id) ctx in
let extract_field_proj (field_id : FieldId.id) (_ : field) : unit =
F.pp_print_space fmt ();
(* Outer box for the projector definition *)
@@ -1698,12 +1700,12 @@ let extract_type_decl_record_field_projectors (ctx : extraction_ctx)
F.pp_print_string fmt "Definition";
F.pp_print_space fmt ();
let field_name =
- ctx_get_field decl.meta (TAdtId decl.def_id) field_id ctx
+ ctx_get_field decl.span (TAdtId decl.def_id) field_id ctx
in
F.pp_print_string fmt field_name;
(* Print the generics *)
let as_implicits = true in
- extract_generic_params decl.meta ctx fmt TypeDeclId.Set.empty
+ extract_generic_params decl.span ctx fmt TypeDeclId.Set.empty
~as_implicits decl.generics type_params cg_params trait_clauses;
(* Print the record parameter *)
F.pp_print_space fmt ();
@@ -1780,12 +1782,12 @@ let extract_type_decl_record_field_projectors (ctx : extraction_ctx)
(* Inner box for the projector definition *)
F.pp_open_hovbox fmt ctx.indent_incr;
let ctx, record_var =
- ctx_add_var decl.meta "x" (VarId.of_int 0) ctx
+ ctx_add_var decl.span "x" (VarId.of_int 0) ctx
in
F.pp_print_string fmt "Notation";
F.pp_print_space fmt ();
let field_name =
- ctx_get_field decl.meta (TAdtId decl.def_id) field_id ctx
+ ctx_get_field decl.span (TAdtId decl.def_id) field_id ctx
in
F.pp_print_string fmt ("\"" ^ record_var ^ " .(" ^ field_name ^ ")\"");
F.pp_print_space fmt ();
diff --git a/compiler/FunsAnalysis.ml b/compiler/FunsAnalysis.ml
index ddfbf312..a11eab87 100644
--- a/compiler/FunsAnalysis.ml
+++ b/compiler/FunsAnalysis.ml
@@ -147,7 +147,7 @@ let analyze_module (m : crate) (funs_map : fun_decl FunDeclId.Map.t)
(* Sanity check: global bodies don't contain stateful calls *)
cassert __FILE__ __LINE__
((not f.is_global_decl_body) || not !stateful)
- f.item_meta.meta
+ f.item_meta.span
"Global definition containing a stateful call in its body";
let builtin_info = get_builtin_info f in
let has_builtin_info = builtin_info <> None in
@@ -172,11 +172,11 @@ let analyze_module (m : crate) (funs_map : fun_decl FunDeclId.Map.t)
let is_global_decl_body = List.exists (fun f -> f.is_global_decl_body) d in
cassert __FILE__ __LINE__
((not is_global_decl_body) || List.length d = 1)
- (List.hd d).item_meta.meta
+ (List.hd d).item_meta.span
"This global definition is in a group of mutually recursive definitions";
cassert __FILE__ __LINE__
((not !group_has_builtin_info) || List.length d = 1)
- (List.hd d).item_meta.meta
+ (List.hd d).item_meta.span
"This builtin function belongs to a group of mutually recursive \
definitions";
(* We ignore on purpose functions that cannot fail and consider they *can*
diff --git a/compiler/Interpreter.ml b/compiler/Interpreter.ml
index aa54ec6c..94158979 100644
--- a/compiler/Interpreter.ml
+++ b/compiler/Interpreter.ml
@@ -49,12 +49,12 @@ let compute_contexts (m : crate) : decls_ctx =
to compute a normalization map (for the associated types) and that we added
it in the context.
*)
-let normalize_inst_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
+let normalize_inst_fun_sig (span : Meta.span) (ctx : eval_ctx)
(sg : inst_fun_sig) : inst_fun_sig =
let { regions_hierarchy = _; trait_type_constraints = _; inputs; output } =
sg
in
- let norm = AssociatedTypes.ctx_normalize_ty meta ctx in
+ let norm = AssociatedTypes.ctx_normalize_ty span ctx in
let inputs = List.map norm inputs in
let output = norm output in
{ sg with inputs; output }
@@ -69,7 +69,7 @@ let normalize_inst_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
clauses (we are not considering a function call, so we don't need to
normalize because a trait clause was instantiated with a specific trait ref).
*)
-let symbolic_instantiate_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
+let symbolic_instantiate_fun_sig (span : Meta.span) (ctx : eval_ctx)
(sg : fun_sig) (regions_hierarchy : region_var_groups) (kind : item_kind) :
eval_ctx * inst_fun_sig =
let tr_self =
@@ -85,7 +85,7 @@ let symbolic_instantiate_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
List.map (fun (v : const_generic_var) -> CgVar v.index) const_generics
in
(* Annoying that we have to generate this substitution here *)
- let r_subst _ = craise __FILE__ __LINE__ meta "Unexpected region" in
+ let r_subst _ = craise __FILE__ __LINE__ span "Unexpected region" in
let ty_subst =
Substitute.make_type_subst_from_vars sg.generics.types types
in
@@ -123,7 +123,7 @@ let symbolic_instantiate_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
trait_instance_id =
match TraitClauseId.Map.find_opt clause_id tr_map with
| Some tr -> tr
- | None -> craise __FILE__ __LINE__ meta "Local trait clause not found"
+ | None -> craise __FILE__ __LINE__ span "Local trait clause not found"
in
let mk_subst tr_map =
let tr_subst = mk_tr_subst tr_map in
@@ -152,15 +152,15 @@ let symbolic_instantiate_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
{ regions; types; const_generics; trait_refs }
in
let inst_sg =
- instantiate_fun_sig meta ctx generics tr_self sg regions_hierarchy
+ instantiate_fun_sig span ctx generics tr_self sg regions_hierarchy
in
(* Compute the normalization maps *)
let ctx =
- AssociatedTypes.ctx_add_norm_trait_types_from_preds meta ctx
+ AssociatedTypes.ctx_add_norm_trait_types_from_preds span ctx
inst_sg.trait_type_constraints
in
(* Normalize the signature *)
- let inst_sg = normalize_inst_fun_sig meta ctx inst_sg in
+ let inst_sg = normalize_inst_fun_sig span ctx inst_sg in
(* Return *)
(ctx, inst_sg)
@@ -196,12 +196,12 @@ let initialize_symbolic_context_for_fun (ctx : decls_ctx) (fdef : fun_decl) :
(List.for_all
(fun ty -> not (ty_has_nested_borrows ctx.type_ctx.type_infos ty))
(sg.output :: sg.inputs))
- fdef.item_meta.meta "Nested borrows are not supported yet";
+ fdef.item_meta.span "Nested borrows are not supported yet";
cassert __FILE__ __LINE__
(List.for_all
(fun ty -> not (ty_has_adt_with_borrows ctx.type_ctx.type_infos ty))
(sg.output :: sg.inputs))
- fdef.item_meta.meta "ADTs containing borrows are not supported yet";
+ fdef.item_meta.span "ADTs containing borrows are not supported yet";
(* Create the context *)
let regions_hierarchy =
@@ -211,25 +211,25 @@ let initialize_symbolic_context_for_fun (ctx : decls_ctx) (fdef : fun_decl) :
List.map (fun (g : region_var_group) -> g.id) regions_hierarchy
in
let ctx =
- initialize_eval_ctx fdef.item_meta.meta ctx region_groups sg.generics.types
+ initialize_eval_ctx fdef.item_meta.span ctx region_groups sg.generics.types
sg.generics.const_generics
in
(* Instantiate the signature. This updates the context because we compute
at the same time the normalization map for the associated types.
*)
let ctx, inst_sg =
- symbolic_instantiate_fun_sig fdef.item_meta.meta ctx fdef.signature
+ symbolic_instantiate_fun_sig fdef.item_meta.span ctx fdef.signature
regions_hierarchy fdef.kind
in
(* Create fresh symbolic values for the inputs *)
let input_svs =
List.map
- (fun ty -> mk_fresh_symbolic_value fdef.item_meta.meta ty)
+ (fun ty -> mk_fresh_symbolic_value fdef.item_meta.span ty)
inst_sg.inputs
in
(* Initialize the abstractions as empty (i.e., with no avalues) abstractions *)
let call_id = fresh_fun_call_id () in
- sanity_check __FILE__ __LINE__ (call_id = FunCallId.zero) fdef.item_meta.meta;
+ sanity_check __FILE__ __LINE__ (call_id = FunCallId.zero) fdef.item_meta.span;
let compute_abs_avalues (abs : abs) (ctx : eval_ctx) :
eval_ctx * typed_avalue list =
(* Project over the values - we use *loan* projectors, as explained above *)
@@ -251,14 +251,14 @@ let initialize_symbolic_context_for_fun (ctx : decls_ctx) (fdef : fun_decl) :
Collections.List.split_at (List.tl body.locals) body.arg_count
in
(* Push the return variable (initialized with ⊥) *)
- let ctx = ctx_push_uninitialized_var fdef.item_meta.meta ctx ret_var in
+ let ctx = ctx_push_uninitialized_var fdef.item_meta.span ctx ret_var in
(* Push the input variables (initialized with symbolic values) *)
let input_values = List.map mk_typed_value_from_symbolic_value input_svs in
let ctx =
- ctx_push_vars fdef.item_meta.meta ctx (List.combine input_vars input_values)
+ ctx_push_vars fdef.item_meta.span ctx (List.combine input_vars input_values)
in
(* Push the remaining local variables (initialized with ⊥) *)
- let ctx = ctx_push_uninitialized_vars fdef.item_meta.meta ctx local_vars in
+ let ctx = ctx_push_uninitialized_vars fdef.item_meta.span ctx local_vars in
(* Return *)
(ctx, input_svs, inst_sg)
@@ -292,7 +292,7 @@ let evaluate_function_symbolic_synthesize_backward_from_return (config : config)
^ "\n- inside_loop: "
^ Print.bool_to_string inside_loop
^ "\n- ctx:\n"
- ^ Print.Contexts.eval_ctx_to_string ~meta:(Some fdef.item_meta.meta) ctx));
+ ^ Print.Contexts.eval_ctx_to_string ~span:(Some fdef.item_meta.span) ctx));
(* We need to instantiate the function signature - to retrieve
* the return type. Note that it is important to re-generate
* an instantiation of the signature, so that we use fresh
@@ -301,14 +301,14 @@ let evaluate_function_symbolic_synthesize_backward_from_return (config : config)
FunIdMap.find (FRegular fdef.def_id) ctx.fun_ctx.regions_hierarchies
in
let _, ret_inst_sg =
- symbolic_instantiate_fun_sig fdef.item_meta.meta ctx fdef.signature
+ symbolic_instantiate_fun_sig fdef.item_meta.span ctx fdef.signature
regions_hierarchy fdef.kind
in
let ret_rty = ret_inst_sg.output in
(* Move the return value out of the return variable *)
let pop_return_value = is_regular_return in
let ret_value, ctx, cc =
- pop_frame config fdef.item_meta.meta pop_return_value ctx
+ pop_frame config fdef.item_meta.span pop_return_value ctx
in
(* We need to find the parents regions/abstractions of the region we
@@ -336,7 +336,7 @@ let evaluate_function_symbolic_synthesize_backward_from_return (config : config)
let compute_abs_avalues (abs : abs) (ctx : eval_ctx) :
eval_ctx * typed_avalue list =
let ctx, avalue =
- apply_proj_borrows_on_input_value config fdef.item_meta.meta ctx
+ apply_proj_borrows_on_input_value config fdef.item_meta.span ctx
abs.regions abs.ancestors_regions ret_value ret_rty
in
(ctx, [ avalue ])
@@ -353,7 +353,7 @@ let evaluate_function_symbolic_synthesize_backward_from_return (config : config)
RegionGroupId.Set.mem rid parent_and_current_rgs
in
sanity_check __FILE__ __LINE__ (region_can_end back_id)
- fdef.item_meta.meta;
+ fdef.item_meta.span;
let ctx =
create_push_abstractions_from_abs_region_groups
(fun rg_id -> SynthRet rg_id)
@@ -441,7 +441,7 @@ let evaluate_function_symbolic_synthesize_backward_from_return (config : config)
sanity_check __FILE__ __LINE__
(if Option.is_some loop_id then loop_id = Some loop_id'
else true)
- fdef.item_meta.meta;
+ fdef.item_meta.span;
(* Loop abstractions *)
let rg_id' = Option.get rg_id' in
if rg_id' = back_id && inside_loop then
@@ -450,7 +450,7 @@ let evaluate_function_symbolic_synthesize_backward_from_return (config : config)
| Loop (loop_id', _, LoopCall) ->
(* We can end all the loop call abstractions *)
sanity_check __FILE__ __LINE__ (loop_id = Some loop_id')
- fdef.item_meta.meta;
+ fdef.item_meta.span;
{ abs with can_end = true }
| SynthInput rg_id' ->
if rg_id' = back_id && end_fun_synth_input then
@@ -471,7 +471,7 @@ let evaluate_function_symbolic_synthesize_backward_from_return (config : config)
let ctx, cc =
comp cc
(fold_left_apply_continuation
- (fun id ctx -> end_abstraction config fdef.item_meta.meta id ctx)
+ (fun id ctx -> end_abstraction config fdef.item_meta.span id ctx)
target_abs_ids ctx)
in
(* Generate the Return node *)
@@ -535,7 +535,7 @@ let evaluate_function_symbolic (synthesize : bool) (ctx : decls_ctx)
(* Pop the frame and retrieve the returned value at the same time *)
let pop_return_value = true in
let ret_value, ctx, cc_pop =
- pop_frame config fdef.item_meta.meta pop_return_value ctx
+ pop_frame config fdef.item_meta.span pop_return_value ctx
in
(* Generate the Return node *)
cc_pop (Some (SA.Return (ctx, ret_value)))
@@ -549,7 +549,7 @@ let evaluate_function_symbolic (synthesize : bool) (ctx : decls_ctx)
match res with
| Return -> None
| LoopReturn loop_id -> Some loop_id
- | _ -> craise __FILE__ __LINE__ fdef.item_meta.meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ fdef.item_meta.span "Unreachable"
in
let is_regular_return = true in
let inside_loop = Option.is_some loop_id in
@@ -575,7 +575,7 @@ let evaluate_function_symbolic (synthesize : bool) (ctx : decls_ctx)
match res with
| EndEnterLoop _ -> false
| EndContinue _ -> true
- | _ -> craise __FILE__ __LINE__ fdef.item_meta.meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ fdef.item_meta.span "Unreachable"
in
(* Forward translation *)
let fwd_e =
@@ -583,7 +583,7 @@ let evaluate_function_symbolic (synthesize : bool) (ctx : decls_ctx)
translation we will simply call the loop function *)
let pop_return_value = false in
let _ret_value, _ctx, cc_pop =
- pop_frame config fdef.item_meta.meta pop_return_value ctx
+ pop_frame config fdef.item_meta.span pop_return_value ctx
in
(* Generate the Return node *)
cc_pop (Some (SA.ReturnWithLoop (loop_id, inside_loop)))
@@ -614,7 +614,7 @@ let evaluate_function_symbolic (synthesize : bool) (ctx : decls_ctx)
* the executions can lead to a panic *)
if synthesize then Some SA.Panic else None
| Unit | Break _ | Continue _ ->
- craise __FILE__ __LINE__ fdef.item_meta.meta
+ craise __FILE__ __LINE__ fdef.item_meta.span
("evaluate_function_symbolic failed on: " ^ name_to_string ())
in
@@ -629,7 +629,7 @@ let evaluate_function_symbolic (synthesize : bool) (ctx : decls_ctx)
(List.map (fun (ctx, res) -> finish res ctx) ctx_resl)
in
cc (Some el)
- with CFailure (meta, msg) -> Some (Error (meta, msg))
+ with CFailure (span, msg) -> Some (Error (span, msg))
in
(* Return *)
(input_svs, symbolic)
@@ -655,14 +655,14 @@ module Test = struct
(* Sanity check - *)
sanity_check __FILE__ __LINE__
(fdef.signature.generics = empty_generic_params)
- fdef.item_meta.meta;
- sanity_check __FILE__ __LINE__ (body.arg_count = 0) fdef.item_meta.meta;
+ fdef.item_meta.span;
+ sanity_check __FILE__ __LINE__ (body.arg_count = 0) fdef.item_meta.span;
(* Create the evaluation context *)
- let ctx = initialize_eval_ctx fdef.item_meta.meta decls_ctx [] [] [] in
+ let ctx = initialize_eval_ctx fdef.item_meta.span decls_ctx [] [] [] in
(* Insert the (uninitialized) local variables *)
- let ctx = ctx_push_uninitialized_vars fdef.item_meta.meta ctx body.locals in
+ let ctx = ctx_push_uninitialized_vars fdef.item_meta.span ctx body.locals in
(* Create the continuation to check the function's result *)
let config = mk_config ConcreteMode in
@@ -671,9 +671,9 @@ module Test = struct
| Return ->
(* Ok: drop the local variables and finish *)
let pop_return_value = true in
- pop_frame config fdef.item_meta.meta pop_return_value ctx
+ pop_frame config fdef.item_meta.span pop_return_value ctx
| _ ->
- craise __FILE__ __LINE__ fdef.item_meta.meta
+ craise __FILE__ __LINE__ fdef.item_meta.span
("Unit test failed (concrete execution) on: "
^ Print.Types.name_to_string
(Print.Contexts.decls_ctx_to_fmt_env decls_ctx)
diff --git a/compiler/InterpreterBorrows.ml b/compiler/InterpreterBorrows.ml
index f49d39d0..ef958d2c 100644
--- a/compiler/InterpreterBorrows.ml
+++ b/compiler/InterpreterBorrows.ml
@@ -30,7 +30,7 @@ let log = Logging.borrows_log
loans. This is used to merge borrows with abstractions, to compute loop
fixed points for instance.
*)
-let end_borrow_get_borrow (meta : Meta.meta)
+let end_borrow_get_borrow (span : Meta.span)
(allowed_abs : AbstractionId.id option) (allow_inner_loans : bool)
(l : BorrowId.id) (ctx : eval_ctx) :
( eval_ctx * (AbstractionId.id option * g_borrow_content) option,
@@ -43,7 +43,7 @@ let end_borrow_get_borrow (meta : Meta.meta)
in
let set_replaced_bc (abs_id : AbstractionId.id option) (bc : g_borrow_content)
=
- sanity_check __FILE__ __LINE__ (Option.is_none !replaced_bc) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none !replaced_bc) span;
replaced_bc := Some (abs_id, bc)
in
(* Raise an exception if:
@@ -146,12 +146,12 @@ let end_borrow_get_borrow (meta : Meta.meta)
let av = super#visit_typed_avalue outer av in
(* Reconstruct *)
ALoan (ASharedLoan (bids, v, av))
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan _
(* The loan has ended, so no need to update the outer borrows *)
| AIgnoredMutLoan _ (* Nothing special to do *)
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
(* Nothing special to do *)
| AIgnoredSharedLoan _ ->
(* Nothing special to do *)
@@ -182,7 +182,7 @@ let end_borrow_get_borrow (meta : Meta.meta)
* Also note that, as we are moving the borrowed value inside the
* abstraction (and not really giving the value back to the context)
* we do not insert {!AEndedMutBorrow} but rather {!ABottom} *)
- craise __FILE__ __LINE__ meta "Unimplemented"
+ craise __FILE__ __LINE__ span "Unimplemented"
(* ABottom *))
else
(* Update the outer borrows before diving into the child avalue *)
@@ -203,7 +203,7 @@ let end_borrow_get_borrow (meta : Meta.meta)
| AIgnoredMutBorrow (_, _)
| AEndedMutBorrow _
| AEndedIgnoredMutBorrow
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AEndedSharedBorrow ->
(* Nothing special to do *)
super#visit_ABorrow outer bc
@@ -217,7 +217,7 @@ let end_borrow_get_borrow (meta : Meta.meta)
set_replaced_bc (fst outer) (Abstract bc);
(* Update the value - note that we are necessarily in the second
* of the two cases described above *)
- let asb = remove_borrow_from_asb meta l asb in
+ let asb = remove_borrow_from_asb span l asb in
ABorrow (AProjSharedBorrow asb))
else (* Nothing special to do *)
super#visit_ABorrow outer bc
@@ -225,8 +225,8 @@ let end_borrow_get_borrow (meta : Meta.meta)
method! visit_abs outer abs =
(* Update the outer abs *)
let outer_abs, outer_borrows = outer in
- sanity_check __FILE__ __LINE__ (Option.is_none outer_abs) meta;
- sanity_check __FILE__ __LINE__ (Option.is_none outer_borrows) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none outer_abs) span;
+ sanity_check __FILE__ __LINE__ (Option.is_none outer_borrows) span;
let outer = (Some abs.abs_id, None) in
super#visit_abs outer abs
end
@@ -246,27 +246,27 @@ let end_borrow_get_borrow (meta : Meta.meta)
give the value back.
TODO: this was not the case before, so some sanity checks are not useful anymore.
*)
-let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
+let give_back_value (config : config) (span : Meta.span) (bid : BorrowId.id)
(nv : typed_value) (ctx : eval_ctx) : eval_ctx =
(* Sanity check *)
exec_assert __FILE__ __LINE__
(not (loans_in_value nv))
- meta "Can not end a borrow because the value to give back contains bottom";
+ span "Can not end a borrow because the value to give back contains bottom";
exec_assert __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions nv))
- meta "Can not end a borrow because the value to give back contains bottom";
+ span "Can not end a borrow because the value to give back contains bottom";
(* Debug *)
log#ldebug
(lazy
("give_back_value:\n- bid: " ^ BorrowId.to_string bid ^ "\n- value: "
- ^ typed_value_to_string ~meta:(Some meta) ctx nv
+ ^ typed_value_to_string ~span:(Some span) ctx nv
^ "\n- context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n"));
(* We use a reference to check that we updated exactly one loan *)
let replaced : bool ref = ref false in
let set_replaced () =
- sanity_check __FILE__ __LINE__ (not !replaced) meta;
+ sanity_check __FILE__ __LINE__ (not !replaced) span;
replaced := true
in
(* Whenever giving back symbolic values, they shouldn't contain already ended regions *)
@@ -274,7 +274,7 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
(* We sometimes need to reborrow values while giving a value back due: prepare that *)
let allow_reborrows = true in
let fresh_reborrow, apply_registered_reborrows =
- prepare_reborrows config meta allow_reborrows
+ prepare_reborrows config span allow_reborrows
in
(* The visitor to give back the values *)
let obj =
@@ -304,7 +304,7 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
(* Sanity check *)
let expected_ty = ty in
if nv.ty <> expected_ty then
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Value given back doesn't have the proper type:\n\
- expected: " ^ ty_to_string ctx ty ^ "\n- received: "
^ ty_to_string ctx nv.ty);
@@ -338,10 +338,10 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
match nv.value with
| VSymbolic sv ->
let abs = Option.get opt_abs in
- (* Remember the given back value as a meta-value
+ (* Remember the given back value as a span-value
* TODO: it is a bit annoying to have to deconstruct
* the value... Think about a more elegant way. *)
- let given_back_meta = as_symbolic meta nv.value in
+ let given_back_span = as_symbolic span nv.value in
(* The loan projector *)
let given_back =
mk_aproj_loans_value_from_symbolic_value abs.regions sv
@@ -351,8 +351,8 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
(* Return *)
ABorrow
(AEndedIgnoredMutBorrow
- { given_back; child; given_back_meta })
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ { given_back; child; given_back_span })
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
else
(* Continue exploring *)
ABorrow (super#visit_AIgnoredMutBorrow opt_abs bid' child)
@@ -367,7 +367,7 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
(* Preparing a bit *)
let regions, ancestors_regions =
match opt_abs with
- | None -> craise __FILE__ __LINE__ meta "Unreachable"
+ | None -> craise __FILE__ __LINE__ span "Unreachable"
| Some abs -> (abs.regions, abs.ancestors_regions)
in
(* Rk.: there is a small issue with the types of the aloan values.
@@ -384,23 +384,23 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
* an ended loan *)
(* Register the insertion *)
set_replaced ();
- (* Remember the given back value as a meta-value *)
- let given_back_meta = nv in
+ (* Remember the given back value as a span-value *)
+ let given_back_span = nv in
(* Apply the projection *)
let given_back =
- apply_proj_borrows meta check_symbolic_no_ended ctx
+ apply_proj_borrows span check_symbolic_no_ended ctx
fresh_reborrow regions ancestors_regions nv borrowed_value_aty
in
(* Continue giving back in the child value *)
let child = super#visit_typed_avalue opt_abs child in
(* Return the new value *)
- ALoan (AEndedMutLoan { child; given_back; given_back_meta }))
+ ALoan (AEndedMutLoan { child; given_back; given_back_span }))
else (* Continue exploring *)
super#visit_ALoan opt_abs lc
| ASharedLoan (_, _, _) ->
(* We are giving back a value to a *mutable* loan: nothing special to do *)
super#visit_ALoan opt_abs lc
- | AEndedMutLoan { child = _; given_back = _; given_back_meta = _ }
+ | AEndedMutLoan { child = _; given_back = _; given_back_span = _ }
| AEndedSharedLoan (_, _) ->
(* Nothing special to do *)
super#visit_ALoan opt_abs lc
@@ -408,23 +408,23 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
(* This loan is ignored, but we may have to project on a subvalue
* of the value which is given back *)
if opt_bid = Some bid then
- (* Remember the given back value as a meta-value *)
- let given_back_meta = nv in
+ (* Remember the given back value as a span-value *)
+ let given_back_span = nv in
(* Note that we replace the ignored mut loan by an *ended* ignored
* mut loan. Also, this is not the loan we are looking for *per se*:
* we don't register the fact that we inserted the value somewhere
* (i.e., we don't call {!set_replaced}) *)
let given_back =
- apply_proj_borrows meta check_symbolic_no_ended ctx
+ apply_proj_borrows span check_symbolic_no_ended ctx
fresh_reborrow regions ancestors_regions nv borrowed_value_aty
in
(* Continue giving back in the child value *)
let child = super#visit_typed_avalue opt_abs child in
ALoan
- (AEndedIgnoredMutLoan { given_back; child; given_back_meta })
+ (AEndedIgnoredMutLoan { given_back; child; given_back_span })
else super#visit_ALoan opt_abs lc
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AIgnoredSharedLoan _ ->
(* Nothing special to do *)
super#visit_ALoan opt_abs lc
@@ -433,7 +433,7 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
(* We remember in which abstraction we are before diving -
* this is necessary for projecting values: we need to know
* over which regions to project *)
- sanity_check __FILE__ __LINE__ (Option.is_none opt_abs) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none opt_abs) span;
super#visit_EAbs (Some abs) abs
end
in
@@ -441,19 +441,19 @@ let give_back_value (config : config) (meta : Meta.meta) (bid : BorrowId.id)
(* Explore the environment *)
let ctx = obj#visit_eval_ctx None ctx in
(* Check we gave back to exactly one loan *)
- cassert __FILE__ __LINE__ !replaced meta "No loan updated";
+ cassert __FILE__ __LINE__ !replaced span "No loan updated";
(* Apply the reborrows *)
apply_registered_reborrows ctx
(** Give back a *modified* symbolic value. *)
-let give_back_symbolic_value (_config : config) (meta : Meta.meta)
+let give_back_symbolic_value (_config : config) (span : Meta.span)
(proj_regions : RegionId.Set.t) (proj_ty : rty) (sv : symbolic_value)
(nsv : symbolic_value) (ctx : eval_ctx) : eval_ctx =
(* Sanity checks *)
sanity_check __FILE__ __LINE__
(sv.sv_id <> nsv.sv_id && ty_is_rty proj_ty)
- meta;
- (* Store the given-back value as a meta-value for synthesis purposes *)
+ span;
+ (* Store the given-back value as a span-value for synthesis purposes *)
let mv = nsv in
(* Substitution function, to replace the borrow projectors over symbolic values *)
let subst (_abs : abs) local_given_back =
@@ -474,11 +474,11 @@ let give_back_symbolic_value (_config : config) (meta : Meta.meta)
type [T]! We thus *mustn't* introduce a projector here.
*)
(* AProjBorrows (nsv, sv.sv_ty) *)
- internal_error __FILE__ __LINE__ meta
+ internal_error __FILE__ __LINE__ span
in
AProjLoans (sv, (mv, child_proj) :: local_given_back)
in
- update_intersecting_aproj_loans meta proj_regions proj_ty sv subst ctx
+ update_intersecting_aproj_loans span proj_regions proj_ty sv subst ctx
(** Auxiliary function to end borrows. See {!give_back}.
@@ -493,13 +493,13 @@ let give_back_symbolic_value (_config : config) (meta : Meta.meta)
end abstraction when ending this abstraction. When doing this, we need
to convert the {!avalue} to a {!type:value} by introducing the proper symbolic values.
*)
-let give_back_avalue_to_same_abstraction (_config : config) (meta : Meta.meta)
+let give_back_avalue_to_same_abstraction (_config : config) (span : Meta.span)
(bid : BorrowId.id) (nv : typed_avalue) (nsv : typed_value) (ctx : eval_ctx)
: eval_ctx =
(* We use a reference to check that we updated exactly one loan *)
let replaced : bool ref = ref false in
let set_replaced () =
- cassert __FILE__ __LINE__ (not !replaced) meta
+ cassert __FILE__ __LINE__ (not !replaced) span
"Exacly one loan should be updated";
replaced := true
in
@@ -539,7 +539,7 @@ let give_back_avalue_to_same_abstraction (_config : config) (meta : Meta.meta)
* {!typed_avalue} *)
let _, expected_ty, _ = ty_get_ref ty in
if nv.ty <> expected_ty then
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Value given back doesn't have the proper type:\n\
- expected: " ^ ty_to_string ctx ty ^ "\n- received: "
^ ty_to_string ctx nv.ty);
@@ -550,12 +550,12 @@ let give_back_avalue_to_same_abstraction (_config : config) (meta : Meta.meta)
set_replaced ();
(* Return the new value *)
ALoan
- (AEndedMutLoan { given_back = nv; child; given_back_meta = nsv }))
+ (AEndedMutLoan { given_back = nv; child; given_back_span = nsv }))
else (* Continue exploring *)
super#visit_ALoan opt_abs lc
| ASharedLoan (_, _, _)
(* We are giving back a value to a *mutable* loan: nothing special to do *)
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan (_, _) ->
(* Nothing special to do *)
super#visit_ALoan opt_abs lc
@@ -568,13 +568,13 @@ let give_back_avalue_to_same_abstraction (_config : config) (meta : Meta.meta)
* we don't register the fact that we inserted the value somewhere
* (i.e., we don't call {!set_replaced}) *)
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (nv.ty = ty) meta;
+ sanity_check __FILE__ __LINE__ (nv.ty = ty) span;
ALoan
(AEndedIgnoredMutLoan
- { given_back = nv; child; given_back_meta = nsv }))
+ { given_back = nv; child; given_back_span = nsv }))
else super#visit_ALoan opt_abs lc
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AIgnoredSharedLoan _ ->
(* Nothing special to do *)
super#visit_ALoan opt_abs lc
@@ -584,7 +584,7 @@ let give_back_avalue_to_same_abstraction (_config : config) (meta : Meta.meta)
(* Explore the environment *)
let ctx = obj#visit_eval_ctx None ctx in
(* Check we gave back to exactly one loan *)
- cassert __FILE__ __LINE__ !replaced meta "No loan updated";
+ cassert __FILE__ __LINE__ !replaced span "No loan updated";
(* Return *)
ctx
@@ -597,12 +597,12 @@ let give_back_avalue_to_same_abstraction (_config : config) (meta : Meta.meta)
we update.
TODO: this was not the case before, so some sanity checks are not useful anymore.
*)
-let give_back_shared _config (meta : Meta.meta) (bid : BorrowId.id)
+let give_back_shared _config (span : Meta.span) (bid : BorrowId.id)
(ctx : eval_ctx) : eval_ctx =
(* We use a reference to check that we updated exactly one loan *)
let replaced : bool ref = ref false in
let set_replaced () =
- cassert __FILE__ __LINE__ (not !replaced) meta
+ cassert __FILE__ __LINE__ (not !replaced) span
"Exactly one loan should be updated";
replaced := true
in
@@ -650,14 +650,14 @@ let give_back_shared _config (meta : Meta.meta) (bid : BorrowId.id)
else
(* Not the loan we are looking for: continue exploring *)
super#visit_ALoan opt_abs lc
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
(* Nothing special to do (the loan has ended) *)
| AEndedSharedLoan (_, _)
(* Nothing special to do (the loan has ended) *)
| AIgnoredMutLoan (_, _)
(* Nothing special to do (we are giving back a *shared* borrow) *)
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
(* Nothing special to do *)
| AIgnoredSharedLoan _ ->
(* Nothing special to do *)
@@ -668,7 +668,7 @@ let give_back_shared _config (meta : Meta.meta) (bid : BorrowId.id)
(* Explore the environment *)
let ctx = obj#visit_eval_ctx None ctx in
(* Check we gave back to exactly one loan *)
- cassert __FILE__ __LINE__ !replaced meta "No loan updated";
+ cassert __FILE__ __LINE__ !replaced span "No loan updated";
(* Return *)
ctx
@@ -677,12 +677,12 @@ let give_back_shared _config (meta : Meta.meta) (bid : BorrowId.id)
to an environment by inserting a new borrow id in the set of borrows tracked
by a shared value, referenced by the [original_bid] argument.
*)
-let reborrow_shared (meta : Meta.meta) (original_bid : BorrowId.id)
+let reborrow_shared (span : Meta.span) (original_bid : BorrowId.id)
(new_bid : BorrowId.id) (ctx : eval_ctx) : eval_ctx =
(* Keep track of changes *)
let r = ref false in
let set_ref () =
- sanity_check __FILE__ __LINE__ (not !r) meta;
+ sanity_check __FILE__ __LINE__ (not !r) span;
r := true
in
@@ -712,7 +712,7 @@ let reborrow_shared (meta : Meta.meta) (original_bid : BorrowId.id)
let env = obj#visit_env () ctx.env in
(* Check that we reborrowed once *)
- sanity_check __FILE__ __LINE__ !r meta;
+ sanity_check __FILE__ __LINE__ !r span;
{ ctx with env }
(** Convert an {!type:avalue} to a {!type:value}.
@@ -731,9 +731,9 @@ let reborrow_shared (meta : Meta.meta) (original_bid : BorrowId.id)
be expanded (because expanding this symbolic value would require expanding
a reference whose region has already ended).
*)
-let convert_avalue_to_given_back_value (meta : Meta.meta) (av : typed_avalue) :
+let convert_avalue_to_given_back_value (span : Meta.span) (av : typed_avalue) :
symbolic_value =
- mk_fresh_symbolic_value meta av.ty
+ mk_fresh_symbolic_value span av.ty
(** Auxiliary function: see {!end_borrow_aux}.
@@ -751,19 +751,19 @@ let convert_avalue_to_given_back_value (meta : Meta.meta) (av : typed_avalue) :
borrows. This kind of internal reshuffling. should be similar to ending
abstractions (it is tantamount to ending *sub*-abstractions).
*)
-let give_back (config : config) (meta : Meta.meta) (l : BorrowId.id)
+let give_back (config : config) (span : Meta.span) (l : BorrowId.id)
(bc : g_borrow_content) (ctx : eval_ctx) : eval_ctx =
(* Debug *)
log#ldebug
(lazy
(let bc =
match bc with
- | Concrete bc -> borrow_content_to_string ~meta:(Some meta) ctx bc
- | Abstract bc -> aborrow_content_to_string ~meta:(Some meta) ctx bc
+ | Concrete bc -> borrow_content_to_string ~span:(Some span) ctx bc
+ | Abstract bc -> aborrow_content_to_string ~span:(Some span) ctx bc
in
"give_back:\n- bid: " ^ BorrowId.to_string l ^ "\n- content: " ^ bc
^ "\n- context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n"));
(* This is used for sanity checks *)
let sanity_ek =
@@ -772,60 +772,60 @@ let give_back (config : config) (meta : Meta.meta) (l : BorrowId.id)
match bc with
| Concrete (VMutBorrow (l', tv)) ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (l' = l) meta;
- sanity_check __FILE__ __LINE__ (not (loans_in_value tv)) meta;
+ sanity_check __FILE__ __LINE__ (l' = l) span;
+ sanity_check __FILE__ __LINE__ (not (loans_in_value tv)) span;
(* Check that the corresponding loan is somewhere - purely a sanity check *)
sanity_check __FILE__ __LINE__
- (Option.is_some (lookup_loan_opt meta sanity_ek l ctx))
- meta;
+ (Option.is_some (lookup_loan_opt span sanity_ek l ctx))
+ span;
(* Update the context *)
- give_back_value config meta l tv ctx
+ give_back_value config span l tv ctx
| Concrete (VSharedBorrow l' | VReservedMutBorrow l') ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (l' = l) meta;
+ sanity_check __FILE__ __LINE__ (l' = l) span;
(* Check that the borrow is somewhere - purely a sanity check *)
sanity_check __FILE__ __LINE__
- (Option.is_some (lookup_loan_opt meta sanity_ek l ctx))
- meta;
+ (Option.is_some (lookup_loan_opt span sanity_ek l ctx))
+ span;
(* Update the context *)
- give_back_shared config meta l ctx
+ give_back_shared config span l ctx
| Abstract (AMutBorrow (l', av)) ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (l' = l) meta;
+ sanity_check __FILE__ __LINE__ (l' = l) span;
(* Check that the corresponding loan is somewhere - purely a sanity check *)
sanity_check __FILE__ __LINE__
- (Option.is_some (lookup_loan_opt meta sanity_ek l ctx))
- meta;
+ (Option.is_some (lookup_loan_opt span sanity_ek l ctx))
+ span;
(* Convert the avalue to a (fresh symbolic) value.
Rem.: we shouldn't do this here. We should do this in a function
which takes care of ending *sub*-abstractions.
*)
- let sv = convert_avalue_to_given_back_value meta av in
+ let sv = convert_avalue_to_given_back_value span av in
(* Update the context *)
- give_back_avalue_to_same_abstraction config meta l av
+ give_back_avalue_to_same_abstraction config span l av
(mk_typed_value_from_symbolic_value sv)
ctx
| Abstract (ASharedBorrow l') ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (l' = l) meta;
+ sanity_check __FILE__ __LINE__ (l' = l) span;
(* Check that the borrow is somewhere - purely a sanity check *)
sanity_check __FILE__ __LINE__
- (Option.is_some (lookup_loan_opt meta sanity_ek l ctx))
- meta;
+ (Option.is_some (lookup_loan_opt span sanity_ek l ctx))
+ span;
(* Update the context *)
- give_back_shared config meta l ctx
+ give_back_shared config span l ctx
| Abstract (AProjSharedBorrow asb) ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (borrow_in_asb l asb) meta;
+ sanity_check __FILE__ __LINE__ (borrow_in_asb l asb) span;
(* Update the context *)
- give_back_shared config meta l ctx
+ give_back_shared config span l ctx
| Abstract
( AEndedMutBorrow _ | AIgnoredMutBorrow _ | AEndedIgnoredMutBorrow _
| AEndedSharedBorrow ) ->
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
-let check_borrow_disappeared (meta : Meta.meta) (fun_name : string)
+let check_borrow_disappeared (span : Meta.span) (fun_name : string)
(l : BorrowId.id) (ctx0 : eval_ctx) (ctx : eval_ctx) : unit =
(match lookup_borrow_opt ek_all l ctx with
| None -> () (* Ok *)
@@ -834,21 +834,21 @@ let check_borrow_disappeared (meta : Meta.meta) (fun_name : string)
(lazy
(fun_name ^ ": " ^ BorrowId.to_string l
^ ": borrow didn't disappear:\n- original context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string ~span:(Some span) ctx0
^ "\n\n- new context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
- internal_error __FILE__ __LINE__ meta);
- match lookup_loan_opt meta ek_all l ctx with
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
+ internal_error __FILE__ __LINE__ span);
+ match lookup_loan_opt span ek_all l ctx with
| None -> () (* Ok *)
| Some _ ->
log#ltrace
(lazy
(fun_name ^ ": " ^ BorrowId.to_string l
^ ": loan didn't disappear:\n- original context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string ~span:(Some span) ctx0
^ "\n\n- new context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
- internal_error __FILE__ __LINE__ meta
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
+ internal_error __FILE__ __LINE__ span
(** End a borrow identified by its borrow id in a context.
@@ -871,27 +871,27 @@ let check_borrow_disappeared (meta : Meta.meta) (fun_name : string)
perform anything smart and is trusted, and another function for the
book-keeping.
*)
-let rec end_borrow_aux (config : config) (meta : Meta.meta)
+let rec end_borrow_aux (config : config) (span : Meta.span)
(chain : borrow_or_abs_ids) (allowed_abs : AbstractionId.id option)
(l : BorrowId.id) : cm_fun =
fun ctx ->
(* Check that we don't loop *)
let chain0 = chain in
let chain =
- add_borrow_or_abs_id_to_chain meta "end_borrow_aux: " (BorrowId l) chain
+ add_borrow_or_abs_id_to_chain span "end_borrow_aux: " (BorrowId l) chain
in
log#ldebug
(lazy
("end borrow: " ^ BorrowId.to_string l ^ ":\n- original context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Utility function for the sanity checks: check that the borrow disappeared
* from the context *)
let ctx0 = ctx in
- let check = check_borrow_disappeared meta "end borrow" l ctx0 in
+ let check = check_borrow_disappeared span "end borrow" l ctx0 in
(* Start by ending the borrow itself (we lookup it up and replace it with [Bottom] *)
let allow_inner_loans = false in
- match end_borrow_get_borrow meta allowed_abs allow_inner_loans l ctx with
+ match end_borrow_get_borrow span allowed_abs allow_inner_loans l ctx with
(* Two cases:
- error: we found outer borrows (the borrow is inside a borrowed value) or
inner loans (the borrow contains loans)
@@ -921,11 +921,11 @@ let rec end_borrow_aux (config : config) (meta : Meta.meta)
let allowed_abs' = None in
(* End the outer borrows *)
let ctx, cc =
- end_borrows_aux config meta chain allowed_abs' bids ctx
+ end_borrows_aux config span chain allowed_abs' bids ctx
in
(* Retry to end the borrow *)
let ctx, cc =
- comp cc (end_borrow_aux config meta chain0 allowed_abs l ctx)
+ comp cc (end_borrow_aux config span chain0 allowed_abs l ctx)
in
(* Check and continue *)
check ctx;
@@ -933,17 +933,17 @@ let rec end_borrow_aux (config : config) (meta : Meta.meta)
| OuterBorrows (Borrow bid) | InnerLoans (Borrow bid) ->
let allowed_abs' = None in
(* End the outer borrow *)
- let ctx, cc = end_borrow_aux config meta chain allowed_abs' bid ctx in
+ let ctx, cc = end_borrow_aux config span chain allowed_abs' bid ctx in
(* Retry to end the borrow *)
let ctx, cc =
- comp cc (end_borrow_aux config meta chain0 allowed_abs l ctx)
+ comp cc (end_borrow_aux config span chain0 allowed_abs l ctx)
in
(* Check and continue *)
check ctx;
(ctx, cc)
| OuterAbs abs_id ->
(* The borrow is inside an abstraction: end the whole abstraction *)
- let ctx, end_abs = end_abstraction_aux config meta chain abs_id ctx in
+ let ctx, end_abs = end_abstraction_aux config span chain abs_id ctx in
(* Sanity check *)
check ctx;
(ctx, end_abs))
@@ -951,7 +951,7 @@ let rec end_borrow_aux (config : config) (meta : Meta.meta)
log#ldebug (lazy "End borrow: borrow not found");
(* It is possible that we can't find a borrow in symbolic mode (ending
* an abstraction may end several borrows at once *)
- sanity_check __FILE__ __LINE__ (config.mode = SymbolicMode) meta;
+ sanity_check __FILE__ __LINE__ (config.mode = SymbolicMode) span;
(* Do a sanity check and continue *)
check ctx;
(ctx, fun e -> e)
@@ -963,10 +963,10 @@ let rec end_borrow_aux (config : config) (meta : Meta.meta)
| Concrete (VMutBorrow (_, bv)) ->
sanity_check __FILE__ __LINE__
(Option.is_none (get_first_loan_in_value bv))
- meta
+ span
| _ -> ());
(* Give back the value *)
- let ctx = give_back config meta l bc ctx in
+ let ctx = give_back config span l bc ctx in
(* Do a sanity check and continue *)
check ctx;
(* Save a snapshot of the environment for the name generation *)
@@ -974,7 +974,7 @@ let rec end_borrow_aux (config : config) (meta : Meta.meta)
(* Compose *)
(ctx, cc)
-and end_borrows_aux (config : config) (meta : Meta.meta)
+and end_borrows_aux (config : config) (span : Meta.span)
(chain : borrow_or_abs_ids) (allowed_abs : AbstractionId.id option)
(lset : BorrowId.Set.t) : cm_fun =
fun ctx ->
@@ -983,15 +983,15 @@ and end_borrows_aux (config : config) (meta : Meta.meta)
a matter of taste, and may make debugging easier *)
let ids = BorrowId.Set.fold (fun id ids -> id :: ids) lset [] in
fold_left_apply_continuation
- (fun id ctx -> end_borrow_aux config meta chain allowed_abs id ctx)
+ (fun id ctx -> end_borrow_aux config span chain allowed_abs id ctx)
ids ctx
-and end_abstraction_aux (config : config) (meta : Meta.meta)
+and end_abstraction_aux (config : config) (span : Meta.span)
(chain : borrow_or_abs_ids) (abs_id : AbstractionId.id) : cm_fun =
fun ctx ->
(* Check that we don't loop *)
let chain =
- add_borrow_or_abs_id_to_chain meta "end_abstraction_aux: " (AbsId abs_id)
+ add_borrow_or_abs_id_to_chain span "end_abstraction_aux: " (AbsId abs_id)
chain
in
(* Remember the original context for printing purposes *)
@@ -1001,7 +1001,7 @@ and end_abstraction_aux (config : config) (meta : Meta.meta)
("end_abstraction_aux: "
^ AbstractionId.to_string abs_id
^ "\n- original context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx0));
+ ^ eval_ctx_to_string ~span:(Some span) ctx0));
(* Lookup the abstraction - note that if we end a list of abstractions,
ending one abstraction may lead to the current abstraction having
@@ -1019,34 +1019,34 @@ and end_abstraction_aux (config : config) (meta : Meta.meta)
(* Check that we can end the abstraction *)
if abs.can_end then ()
else
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Can't end abstraction "
^ AbstractionId.to_string abs.abs_id
^ " as it is set as non-endable");
(* End the parent abstractions first *)
- let ctx, cc = end_abstractions_aux config meta chain abs.parents ctx in
+ let ctx, cc = end_abstractions_aux config span chain abs.parents ctx in
log#ldebug
(lazy
("end_abstraction_aux: "
^ AbstractionId.to_string abs_id
^ "\n- context after parent abstractions ended:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* End the loans inside the abstraction *)
let ctx, cc =
- comp cc (end_abstraction_loans config meta chain abs_id ctx)
+ comp cc (end_abstraction_loans config span chain abs_id ctx)
in
log#ldebug
(lazy
("end_abstraction_aux: "
^ AbstractionId.to_string abs_id
^ "\n- context after loans ended:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* End the abstraction itself by redistributing the borrows it contains *)
let ctx, cc =
- comp cc (end_abstraction_borrows config meta chain abs_id ctx)
+ comp cc (end_abstraction_borrows config span chain abs_id ctx)
in
(* End the regions owned by the abstraction - note that we don't need to
@@ -1061,7 +1061,7 @@ and end_abstraction_aux (config : config) (meta : Meta.meta)
the abstraction itself.
**Rk.**: this is where we synthesize the updated symbolic AST *)
let ctx, cc =
- comp cc (end_abstraction_remove_from_context config meta abs_id ctx)
+ comp cc (end_abstraction_remove_from_context config span abs_id ctx)
in
(* Debugging *)
@@ -1070,12 +1070,12 @@ and end_abstraction_aux (config : config) (meta : Meta.meta)
("end_abstraction_aux: "
^ AbstractionId.to_string abs_id
^ "\n- original context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string ~span:(Some span) ctx0
^ "\n\n- new context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Sanity check: ending an abstraction must preserve the invariants *)
- Invariants.check_invariants meta ctx;
+ Invariants.check_invariants span ctx;
(* Save a snapshot of the environment for the name generation *)
let cc = cc_comp cc (SynthesizeSymbolic.save_snapshot ctx) in
@@ -1083,7 +1083,7 @@ and end_abstraction_aux (config : config) (meta : Meta.meta)
(* Return *)
(ctx, cc)
-and end_abstractions_aux (config : config) (meta : Meta.meta)
+and end_abstractions_aux (config : config) (span : Meta.span)
(chain : borrow_or_abs_ids) (abs_ids : AbstractionId.Set.t) : cm_fun =
fun ctx ->
(* This is not necessary, but we prefer to reorder the abstraction ids,
@@ -1091,10 +1091,10 @@ and end_abstractions_aux (config : config) (meta : Meta.meta)
* a matter of taste, and may make debugging easier *)
let abs_ids = AbstractionId.Set.fold (fun id ids -> id :: ids) abs_ids [] in
fold_left_apply_continuation
- (fun id ctx -> end_abstraction_aux config meta chain id ctx)
+ (fun id ctx -> end_abstraction_aux config span chain id ctx)
abs_ids ctx
-and end_abstraction_loans (config : config) (meta : Meta.meta)
+and end_abstraction_loans (config : config) (span : Meta.span)
(chain : borrow_or_abs_ids) (abs_id : AbstractionId.id) : cm_fun =
fun ctx ->
(* Lookup the abstraction *)
@@ -1103,7 +1103,7 @@ and end_abstraction_loans (config : config) (meta : Meta.meta)
*
* We ignore the "ignored mut/shared loans": as we should have already ended
* the parent abstractions, they necessarily come from children. *)
- let opt_loan = get_first_non_ignored_aloan_in_abstraction meta abs in
+ let opt_loan = get_first_non_ignored_aloan_in_abstraction span abs in
match opt_loan with
| None ->
(* No loans: nothing to update *)
@@ -1112,21 +1112,21 @@ and end_abstraction_loans (config : config) (meta : Meta.meta)
(* There are loans: end the corresponding borrows, then recheck *)
let ctx, cc =
match bids with
- | Borrow bid -> end_borrow_aux config meta chain None bid ctx
- | Borrows bids -> end_borrows_aux config meta chain None bids ctx
+ | Borrow bid -> end_borrow_aux config span chain None bid ctx
+ | Borrows bids -> end_borrows_aux config span chain None bids ctx
in
(* Reexplore, looking for loans *)
- comp cc (end_abstraction_loans config meta chain abs_id ctx)
+ comp cc (end_abstraction_loans config span chain abs_id ctx)
| Some (SymbolicValue sv) ->
(* There is a proj_loans over a symbolic value: end the proj_borrows
which intersect this proj_loans, then end the proj_loans itself *)
let ctx, cc =
- end_proj_loans_symbolic config meta chain abs_id abs.regions sv ctx
+ end_proj_loans_symbolic config span chain abs_id abs.regions sv ctx
in
(* Reexplore, looking for loans *)
- comp cc (end_abstraction_loans config meta chain abs_id ctx)
+ comp cc (end_abstraction_loans config span chain abs_id ctx)
-and end_abstraction_borrows (config : config) (meta : Meta.meta)
+and end_abstraction_borrows (config : config) (span : Meta.span)
(chain : borrow_or_abs_ids) (abs_id : AbstractionId.id) : cm_fun =
fun ctx ->
log#ldebug
@@ -1177,7 +1177,7 @@ and end_abstraction_borrows (config : config) (meta : Meta.meta)
method! visit_aproj env sproj =
(match sproj with
- | AProjLoans _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | AProjLoans _ -> craise __FILE__ __LINE__ span "Unexpected"
| AProjBorrows (sv, proj_ty) -> raise (FoundAProjBorrows (sv, proj_ty))
| AEndedProjLoans _ | AEndedProjBorrows _ | AIgnoredProjBorrows -> ());
super#visit_aproj env sproj
@@ -1186,7 +1186,7 @@ and end_abstraction_borrows (config : config) (meta : Meta.meta)
method! visit_borrow_content _ bc =
match bc with
| VSharedBorrow _ | VMutBorrow (_, _) -> raise (FoundBorrowContent bc)
- | VReservedMutBorrow _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | VReservedMutBorrow _ -> craise __FILE__ __LINE__ span "Unreachable"
end
in
(* Lookup the abstraction *)
@@ -1202,25 +1202,25 @@ and end_abstraction_borrows (config : config) (meta : Meta.meta)
log#ldebug
(lazy
("end_abstraction_borrows: found aborrow content: "
- ^ aborrow_content_to_string ~meta:(Some meta) ctx bc));
+ ^ aborrow_content_to_string ~span:(Some span) ctx bc));
let ctx =
match bc with
| AMutBorrow (bid, av) ->
(* First, convert the avalue to a (fresh symbolic) value *)
- let sv = convert_avalue_to_given_back_value meta av in
+ let sv = convert_avalue_to_given_back_value span av in
(* Replace the mut borrow to register the fact that we ended
* it and store with it the freshly generated given back value *)
let ended_borrow = ABorrow (AEndedMutBorrow (sv, av)) in
- let ctx = update_aborrow meta ek_all bid ended_borrow ctx in
+ let ctx = update_aborrow span ek_all bid ended_borrow ctx in
(* Give the value back *)
let sv = mk_typed_value_from_symbolic_value sv in
- give_back_value config meta bid sv ctx
+ give_back_value config span bid sv ctx
| ASharedBorrow bid ->
(* Replace the shared borrow to account for the fact it ended *)
let ended_borrow = ABorrow AEndedSharedBorrow in
- let ctx = update_aborrow meta ek_all bid ended_borrow ctx in
+ let ctx = update_aborrow span ek_all bid ended_borrow ctx in
(* Give back *)
- give_back_shared config meta bid ctx
+ give_back_shared config span bid ctx
| AProjSharedBorrow asb ->
(* Retrieve the borrow ids *)
let bids =
@@ -1235,21 +1235,21 @@ and end_abstraction_borrows (config : config) (meta : Meta.meta)
* can use to identify the whole set *)
let repr_bid = List.hd bids in
(* Replace the shared borrow with Bottom *)
- let ctx = update_aborrow meta ek_all repr_bid ABottom ctx in
+ let ctx = update_aborrow span ek_all repr_bid ABottom ctx in
(* Give back the shared borrows *)
let ctx =
List.fold_left
- (fun ctx bid -> give_back_shared config meta bid ctx)
+ (fun ctx bid -> give_back_shared config span bid ctx)
ctx bids
in
(* Continue *)
ctx
| AEndedMutBorrow _ | AIgnoredMutBorrow _ | AEndedIgnoredMutBorrow _
| AEndedSharedBorrow ->
- craise __FILE__ __LINE__ meta "Unexpected"
+ craise __FILE__ __LINE__ span "Unexpected"
in
(* Reexplore *)
- end_abstraction_borrows config meta chain abs_id ctx
+ end_abstraction_borrows config span chain abs_id ctx
(* There are symbolic borrows: end them, then reexplore *)
| FoundAProjBorrows (sv, proj_ty) ->
log#ldebug
@@ -1257,55 +1257,55 @@ and end_abstraction_borrows (config : config) (meta : Meta.meta)
("end_abstraction_borrows: found aproj borrows: "
^ aproj_to_string ctx (AProjBorrows (sv, proj_ty))));
(* Generate a fresh symbolic value *)
- let nsv = mk_fresh_symbolic_value meta proj_ty in
+ let nsv = mk_fresh_symbolic_value span proj_ty in
(* Replace the proj_borrows - there should be exactly one *)
let ended_borrow = AEndedProjBorrows nsv in
- let ctx = update_aproj_borrows meta abs.abs_id sv ended_borrow ctx in
+ let ctx = update_aproj_borrows span abs.abs_id sv ended_borrow ctx in
(* Give back the symbolic value *)
let ctx =
- give_back_symbolic_value config meta abs.regions proj_ty sv nsv ctx
+ give_back_symbolic_value config span abs.regions proj_ty sv nsv ctx
in
(* Reexplore *)
- end_abstraction_borrows config meta chain abs_id ctx
+ end_abstraction_borrows config span chain abs_id ctx
(* There are concrete (i.e., not symbolic) borrows in shared values: end them, then reexplore *)
| FoundBorrowContent bc ->
log#ldebug
(lazy
("end_abstraction_borrows: found borrow content: "
- ^ borrow_content_to_string ~meta:(Some meta) ctx bc));
+ ^ borrow_content_to_string ~span:(Some span) ctx bc));
let ctx =
match bc with
| VSharedBorrow bid -> (
(* Replace the shared borrow with bottom *)
let allow_inner_loans = false in
match
- end_borrow_get_borrow meta (Some abs_id) allow_inner_loans bid ctx
+ end_borrow_get_borrow span (Some abs_id) allow_inner_loans bid ctx
with
- | Error _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Error _ -> craise __FILE__ __LINE__ span "Unreachable"
| Ok (ctx, _) ->
(* Give back *)
- give_back_shared config meta bid ctx)
+ give_back_shared config span bid ctx)
| VMutBorrow (bid, v) -> (
(* Replace the mut borrow with bottom *)
let allow_inner_loans = false in
match
- end_borrow_get_borrow meta (Some abs_id) allow_inner_loans bid ctx
+ end_borrow_get_borrow span (Some abs_id) allow_inner_loans bid ctx
with
- | Error _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Error _ -> craise __FILE__ __LINE__ span "Unreachable"
| Ok (ctx, _) ->
(* Give the value back - note that the mut borrow was below a
* shared borrow: the value is thus unchanged *)
- give_back_value config meta bid v ctx)
- | VReservedMutBorrow _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ give_back_value config span bid v ctx)
+ | VReservedMutBorrow _ -> craise __FILE__ __LINE__ span "Unreachable"
in
(* Reexplore *)
- end_abstraction_borrows config meta chain abs_id ctx
+ end_abstraction_borrows config span chain abs_id ctx
(** Remove an abstraction from the context, as well as all its references *)
-and end_abstraction_remove_from_context (_config : config) (meta : Meta.meta)
+and end_abstraction_remove_from_context (_config : config) (span : Meta.span)
(abs_id : AbstractionId.id) : cm_fun =
fun ctx ->
- let ctx, abs = ctx_remove_abs meta ctx abs_id in
+ let ctx, abs = ctx_remove_abs span ctx abs_id in
let abs = Option.get abs in
(* Synthesize the symbolic AST *)
(ctx, SynthesizeSymbolic.synthesize_end_abstraction ctx abs)
@@ -1324,23 +1324,23 @@ and end_abstraction_remove_from_context (_config : config) (meta : Meta.meta)
intersecting proj_borrows, either in the concrete context or in an
abstraction
*)
-and end_proj_loans_symbolic (config : config) (meta : Meta.meta)
+and end_proj_loans_symbolic (config : config) (span : Meta.span)
(chain : borrow_or_abs_ids) (abs_id : AbstractionId.id)
(regions : RegionId.Set.t) (sv : symbolic_value) : cm_fun =
fun ctx ->
(* Small helpers for sanity checks *)
- let check ctx = no_aproj_over_symbolic_in_context meta sv ctx in
+ let check ctx = no_aproj_over_symbolic_in_context span sv ctx in
(* Find the first proj_borrows which intersects the proj_loans *)
let explore_shared = true in
match
- lookup_intersecting_aproj_borrows_opt meta explore_shared regions sv ctx
+ lookup_intersecting_aproj_borrows_opt span explore_shared regions sv ctx
with
| None ->
(* We couldn't find any in the context: it means that the symbolic value
* is in the concrete environment (or that we dropped it, in which case
* it is completely absent). We thus simply need to replace the loans
* projector with an ended projector. *)
- let ctx = update_aproj_loans_to_ended meta abs_id sv ctx in
+ let ctx = update_aproj_loans_to_ended span abs_id sv ctx in
(* Sanity check *)
check ctx;
(* Continue *)
@@ -1383,16 +1383,16 @@ and end_proj_loans_symbolic (config : config) (meta : Meta.meta)
AbstractionId.Set.empty abs_ids
in
(* End the abstractions and continue *)
- end_abstractions_aux config meta chain abs_ids ctx
+ end_abstractions_aux config span chain abs_ids ctx
in
(* End the internal borrows projectors and the loans projector *)
let ctx =
(* All the proj_borrows are owned: simply erase them *)
let ctx =
- remove_intersecting_aproj_borrows_shared meta regions sv ctx
+ remove_intersecting_aproj_borrows_shared span regions sv ctx
in
(* End the loan itself *)
- update_aproj_loans_to_ended meta abs_id sv ctx
+ update_aproj_loans_to_ended span abs_id sv ctx
in
(* Sanity check *)
check ctx;
@@ -1420,50 +1420,50 @@ and end_proj_loans_symbolic (config : config) (meta : Meta.meta)
*)
(* End the projector of borrows - TODO: not completely sure what to
* replace it with... Maybe we should introduce an ABottomProj? *)
- let ctx = update_aproj_borrows meta abs_id sv AIgnoredProjBorrows ctx in
+ let ctx = update_aproj_borrows span abs_id sv AIgnoredProjBorrows ctx in
(* Sanity check: no other occurrence of an intersecting projector of borrows *)
sanity_check __FILE__ __LINE__
(Option.is_none
- (lookup_intersecting_aproj_borrows_opt meta explore_shared regions
+ (lookup_intersecting_aproj_borrows_opt span explore_shared regions
sv ctx))
- meta;
+ span;
(* End the projector of loans *)
- let ctx = update_aproj_loans_to_ended meta abs_id sv ctx in
+ let ctx = update_aproj_loans_to_ended span abs_id sv ctx in
(* Sanity check *)
check ctx;
(* Continue *)
(ctx, fun e -> e))
else
(* The borrows proj comes from a different abstraction: end it. *)
- let ctx, cc = end_abstraction_aux config meta chain abs_id' ctx in
+ let ctx, cc = end_abstraction_aux config span chain abs_id' ctx in
(* Retry ending the projector of loans *)
let ctx, cc =
comp cc
- (end_proj_loans_symbolic config meta chain abs_id regions sv ctx)
+ (end_proj_loans_symbolic config span chain abs_id regions sv ctx)
in
(* Sanity check *)
check ctx;
(* Return *)
(ctx, cc)
-let end_borrow config (meta : Meta.meta) : BorrowId.id -> cm_fun =
- end_borrow_aux config meta [] None
+let end_borrow config (span : Meta.span) : BorrowId.id -> cm_fun =
+ end_borrow_aux config span [] None
-let end_borrows config (meta : Meta.meta) : BorrowId.Set.t -> cm_fun =
- end_borrows_aux config meta [] None
+let end_borrows config (span : Meta.span) : BorrowId.Set.t -> cm_fun =
+ end_borrows_aux config span [] None
-let end_abstraction config meta = end_abstraction_aux config meta []
-let end_abstractions config meta = end_abstractions_aux config meta []
-let end_borrow_no_synth config meta id ctx = fst (end_borrow config meta id ctx)
+let end_abstraction config span = end_abstraction_aux config span []
+let end_abstractions config span = end_abstractions_aux config span []
+let end_borrow_no_synth config span id ctx = fst (end_borrow config span id ctx)
-let end_borrows_no_synth config meta ids ctx =
- fst (end_borrows config meta ids ctx)
+let end_borrows_no_synth config span ids ctx =
+ fst (end_borrows config span ids ctx)
-let end_abstraction_no_synth config meta id ctx =
- fst (end_abstraction config meta id ctx)
+let end_abstraction_no_synth config span id ctx =
+ fst (end_abstraction config span id ctx)
-let end_abstractions_no_synth config meta ids ctx =
- fst (end_abstractions config meta ids ctx)
+let end_abstractions_no_synth config span ids ctx =
+ fst (end_abstractions config span ids ctx)
(** Helper function: see {!activate_reserved_mut_borrow}.
@@ -1481,14 +1481,14 @@ let end_abstractions_no_synth config meta ids ctx =
The loan to update mustn't be a borrowed value.
*)
-let promote_shared_loan_to_mut_loan (meta : Meta.meta) (l : BorrowId.id)
+let promote_shared_loan_to_mut_loan (span : Meta.span) (l : BorrowId.id)
(ctx : eval_ctx) : typed_value * eval_ctx =
(* Debug *)
log#ldebug
(lazy
("promote_shared_loan_to_mut_loan:\n- loan: " ^ BorrowId.to_string l
^ "\n- context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n"));
(* Lookup the shared loan - note that we can't promote a shared loan
* in a shared value, but we can do it in a mutably borrowed value.
@@ -1497,34 +1497,34 @@ let promote_shared_loan_to_mut_loan (meta : Meta.meta) (l : BorrowId.id)
let ek =
{ enter_shared_loans = false; enter_mut_borrows = true; enter_abs = false }
in
- match lookup_loan meta ek l ctx with
+ match lookup_loan span ek l ctx with
| _, Concrete (VMutLoan _) ->
- craise __FILE__ __LINE__ meta "Expected a shared loan, found a mut loan"
+ craise __FILE__ __LINE__ span "Expected a shared loan, found a mut loan"
| _, Concrete (VSharedLoan (bids, sv)) ->
(* Check that there is only one borrow id (l) and update the loan *)
cassert __FILE__ __LINE__
(BorrowId.Set.mem l bids && BorrowId.Set.cardinal bids = 1)
- meta "There should only be one borrow id";
+ span "There should only be one borrow id";
(* We need to check that there aren't any loans in the value:
we should have gotten rid of those already, but it is better
to do a sanity check. *)
- sanity_check __FILE__ __LINE__ (not (loans_in_value sv)) meta;
+ sanity_check __FILE__ __LINE__ (not (loans_in_value sv)) span;
(* Check there isn't {!Bottom} (this is actually an invariant *)
cassert __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions sv))
- meta "There shouldn't be a bottom";
+ span "There shouldn't be a bottom";
(* Check there aren't reserved borrows *)
cassert __FILE__ __LINE__
(not (reserved_in_value sv))
- meta "There shouldn't be reserved borrows";
+ span "There shouldn't be reserved borrows";
(* Update the loan content *)
- let ctx = update_loan meta ek l (VMutLoan l) ctx in
+ let ctx = update_loan span ek l (VMutLoan l) ctx in
(* Return *)
(sv, ctx)
| _, Abstract _ ->
(* I don't think it is possible to have two-phase borrows involving borrows
returned by abstractions. I'm not sure how we could handle that anyway. *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Can't promote a shared loan to a mutable loan if the loan is inside a \
region abstraction"
@@ -1533,7 +1533,7 @@ let promote_shared_loan_to_mut_loan (meta : Meta.meta) (l : BorrowId.id)
This function updates a shared borrow to a mutable borrow (and that is
all: it doesn't touch the corresponding loan).
*)
-let replace_reserved_borrow_with_mut_borrow (meta : Meta.meta) (l : BorrowId.id)
+let replace_reserved_borrow_with_mut_borrow (span : Meta.span) (l : BorrowId.id)
(borrowed_value : typed_value) (ctx : eval_ctx) : eval_ctx =
(* Lookup the reserved borrow - note that we don't go inside borrows/loans:
there can't be reserved borrows inside other borrows/loans
@@ -1541,28 +1541,28 @@ let replace_reserved_borrow_with_mut_borrow (meta : Meta.meta) (l : BorrowId.id)
let ek =
{ enter_shared_loans = false; enter_mut_borrows = false; enter_abs = false }
in
- match lookup_borrow meta ek l ctx with
+ match lookup_borrow span ek l ctx with
| Concrete (VSharedBorrow _ | VMutBorrow (_, _)) ->
- craise __FILE__ __LINE__ meta "Expected a reserved mutable borrow"
+ craise __FILE__ __LINE__ span "Expected a reserved mutable borrow"
| Concrete (VReservedMutBorrow _) ->
(* Update it *)
- update_borrow meta ek l (VMutBorrow (l, borrowed_value)) ctx
+ update_borrow span ek l (VMutBorrow (l, borrowed_value)) ctx
| Abstract _ ->
(* This can't happen for sure *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Can't promote a shared borrow to a mutable borrow if the borrow is \
inside a region abstraction"
(** Promote a reserved mut borrow to a mut borrow. *)
-let rec promote_reserved_mut_borrow (config : config) (meta : Meta.meta)
+let rec promote_reserved_mut_borrow (config : config) (span : Meta.span)
(l : BorrowId.id) : cm_fun =
fun ctx ->
(* Lookup the value *)
let ek =
{ enter_shared_loans = false; enter_mut_borrows = true; enter_abs = false }
in
- match lookup_loan meta ek l ctx with
- | _, Concrete (VMutLoan _) -> craise __FILE__ __LINE__ meta "Unreachable"
+ match lookup_loan span ek l ctx with
+ | _, Concrete (VMutLoan _) -> craise __FILE__ __LINE__ span "Unreachable"
| _, Concrete (VSharedLoan (bids, sv)) -> (
(* If there are loans inside the value, end them. Note that there can't be
reserved borrows inside the value.
@@ -1572,46 +1572,46 @@ let rec promote_reserved_mut_borrow (config : config) (meta : Meta.meta)
(* End the loans *)
let ctx, cc =
match lc with
- | VSharedLoan (bids, _) -> end_borrows config meta bids ctx
- | VMutLoan bid -> end_borrow config meta bid ctx
+ | VSharedLoan (bids, _) -> end_borrows config span bids ctx
+ | VMutLoan bid -> end_borrow config span bid ctx
in
(* Recursive call *)
- comp cc (promote_reserved_mut_borrow config meta l ctx)
+ comp cc (promote_reserved_mut_borrow config span l ctx)
| None ->
(* No loan to end inside the value *)
(* Some sanity checks *)
log#ldebug
(lazy
("activate_reserved_mut_borrow: resulting value:\n"
- ^ typed_value_to_string ~meta:(Some meta) ctx sv));
- sanity_check __FILE__ __LINE__ (not (loans_in_value sv)) meta;
+ ^ typed_value_to_string ~span:(Some span) ctx sv));
+ sanity_check __FILE__ __LINE__ (not (loans_in_value sv)) span;
sanity_check __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions sv))
- meta;
- sanity_check __FILE__ __LINE__ (not (reserved_in_value sv)) meta;
+ span;
+ sanity_check __FILE__ __LINE__ (not (reserved_in_value sv)) span;
(* End the borrows which borrow from the value, at the exception of
the borrow we want to promote *)
let bids = BorrowId.Set.remove l bids in
- let ctx, cc = end_borrows config meta bids ctx in
+ let ctx, cc = end_borrows config span bids ctx in
(* Promote the loan - TODO: this will fail if the value contains
* any loans. In practice, it shouldn't, but we could also
* look for loans inside the value and end them before promoting
* the borrow. *)
- let v, ctx = promote_shared_loan_to_mut_loan meta l ctx in
+ let v, ctx = promote_shared_loan_to_mut_loan span l ctx in
(* Promote the borrow - the value should have been checked by
{!promote_shared_loan_to_mut_loan}
*)
- let ctx = replace_reserved_borrow_with_mut_borrow meta l v ctx in
+ let ctx = replace_reserved_borrow_with_mut_borrow span l v ctx in
(* Return *)
(ctx, cc))
| _, Abstract _ ->
(* I don't think it is possible to have two-phase borrows involving borrows
* returned by abstractions. I'm not sure how we could handle that anyway. *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Can't activate a reserved mutable borrow referencing a loan inside\n\
\ a region abstraction"
-let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
+let destructure_abs (span : Meta.span) (abs_kind : abs_kind) (can_end : bool)
(destructure_shared_values : bool) (ctx : eval_ctx) (abs0 : abs) : abs =
(* Accumulator to store the destructured values *)
let avalues = ref [] in
@@ -1624,7 +1624,7 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
ignore the children altogether. Instead, we explore them and make sure
we don't register values while doing so.
*)
- let push_fail _ = craise __FILE__ __LINE__ meta "Unreachable" in
+ let push_fail _ = craise __FILE__ __LINE__ span "Unreachable" in
(* Function to explore an avalue and destructure it *)
let rec list_avalues (allow_borrows : bool) (push : typed_avalue -> unit)
(av : typed_avalue) : unit =
@@ -1641,13 +1641,13 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
(* We don't support nested borrows for now *)
cassert __FILE__ __LINE__
(not (value_has_borrows ctx sv.value))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
(* Destructure the shared value *)
let avl, sv =
if destructure_shared_values then list_values sv else ([], sv)
in
(* Push a value *)
- let ignored = mk_aignored meta child_av.ty in
+ let ignored = mk_aignored span child_av.ty in
let value = ALoan (ASharedLoan (bids, sv, ignored)) in
push { value; ty };
(* Explore the child *)
@@ -1663,39 +1663,39 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
(* Explore the child *)
list_avalues false push_fail child_av;
(* Explore the whole loan *)
- let ignored = mk_aignored meta child_av.ty in
+ let ignored = mk_aignored span child_av.ty in
let value = ALoan (AMutLoan (bid, ignored)) in
push { value; ty }
| AIgnoredMutLoan (opt_bid, child_av) ->
(* We don't support nested borrows for now *)
cassert __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos child_av.ty))
- meta "Nested borrows are not supported yet";
- sanity_check __FILE__ __LINE__ (opt_bid = None) meta;
+ span "Nested borrows are not supported yet";
+ sanity_check __FILE__ __LINE__ (opt_bid = None) span;
(* Simply explore the child *)
list_avalues false push_fail child_av
| AEndedMutLoan
- { child = child_av; given_back = _; given_back_meta = _ }
+ { child = child_av; given_back = _; given_back_span = _ }
| AEndedSharedLoan (_, child_av)
| AEndedIgnoredMutLoan
- { child = child_av; given_back = _; given_back_meta = _ }
+ { child = child_av; given_back = _; given_back_span = _ }
| AIgnoredSharedLoan child_av ->
(* We don't support nested borrows for now *)
cassert __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos child_av.ty))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
(* Simply explore the child *)
list_avalues false push_fail child_av)
| ABorrow bc -> (
(* Sanity check - rem.: may be redundant with [push_fail] *)
- sanity_check __FILE__ __LINE__ allow_borrows meta;
+ sanity_check __FILE__ __LINE__ allow_borrows span;
(* Explore the borrow content *)
match bc with
| AMutBorrow (bid, child_av) ->
(* Explore the child *)
list_avalues false push_fail child_av;
(* Explore the borrow *)
- let ignored = mk_aignored meta child_av.ty in
+ let ignored = mk_aignored span child_av.ty in
let value = ABorrow (AMutBorrow (bid, ignored)) in
push { value; ty }
| ASharedBorrow _ ->
@@ -1705,21 +1705,21 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
(* We don't support nested borrows for now *)
cassert __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos child_av.ty))
- meta "Nested borrows are not supported yet";
- sanity_check __FILE__ __LINE__ (opt_bid = None) meta;
+ span "Nested borrows are not supported yet";
+ sanity_check __FILE__ __LINE__ (opt_bid = None) span;
(* Just explore the child *)
list_avalues false push_fail child_av
| AEndedIgnoredMutBorrow
- { child = child_av; given_back = _; given_back_meta = _ } ->
+ { child = child_av; given_back = _; given_back_span = _ } ->
(* We don't support nested borrows for now *)
cassert __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos child_av.ty))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
(* Just explore the child *)
list_avalues false push_fail child_av
| AProjSharedBorrow asb ->
(* We don't support nested borrows *)
- cassert __FILE__ __LINE__ (asb = []) meta
+ cassert __FILE__ __LINE__ (asb = []) span
"Nested borrows are not supported yet";
(* Nothing specific to do *)
()
@@ -1728,13 +1728,13 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
be in the context anymore (if we end *one* borrow in an abstraction,
we have to end them all and remove the abstraction from the context)
*)
- craise __FILE__ __LINE__ meta "Unreachable")
+ craise __FILE__ __LINE__ span "Unreachable")
| ASymbolic _ ->
(* For now, we fore all symbolic values containing borrows to be eagerly
expanded *)
sanity_check __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos ty))
- meta
+ span
and list_values (v : typed_value) : typed_avalue list * typed_value =
let ty = v.ty in
match v.value with
@@ -1746,22 +1746,22 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
let avl = List.concat avll in
let adt = { adt with field_values } in
(avl, { v with value = VAdt adt })
- | VBottom -> craise __FILE__ __LINE__ meta "Unreachable"
+ | VBottom -> craise __FILE__ __LINE__ span "Unreachable"
| VBorrow _ ->
(* We don't support nested borrows for now *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| VLoan lc -> (
match lc with
| VSharedLoan (bids, sv) ->
let avl, sv = list_values sv in
if destructure_shared_values then (
(* Rem.: the shared value can't contain loans nor borrows *)
- cassert __FILE__ __LINE__ (ty_no_regions ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions ty) span
"Nested borrows are not supported yet";
let av : typed_avalue =
sanity_check __FILE__ __LINE__
(not (value_has_loans_or_borrows ctx sv.value))
- meta;
+ span;
(* We introduce fresh ids for the symbolic values *)
let mk_value_with_fresh_sids (v : typed_value) : typed_value =
let visitor =
@@ -1777,20 +1777,20 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
let sv = mk_value_with_fresh_sids sv in
(* Create the new avalue *)
let value =
- ALoan (ASharedLoan (bids, sv, mk_aignored meta ty))
+ ALoan (ASharedLoan (bids, sv, mk_aignored span ty))
in
{ value; ty }
in
let avl = List.append [ av ] avl in
(avl, sv))
else (avl, { v with value = VLoan (VSharedLoan (bids, sv)) })
- | VMutLoan _ -> craise __FILE__ __LINE__ meta "Unreachable")
+ | VMutLoan _ -> craise __FILE__ __LINE__ span "Unreachable")
| VSymbolic _ ->
(* For now, we fore all symbolic values containing borrows to be eagerly
expanded *)
sanity_check __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos ty))
- meta;
+ span;
([], v)
in
@@ -1800,14 +1800,14 @@ let destructure_abs (meta : Meta.meta) (abs_kind : abs_kind) (can_end : bool)
(* Update *)
{ abs0 with avalues; kind = abs_kind; can_end }
-let abs_is_destructured (meta : Meta.meta) (destructure_shared_values : bool)
+let abs_is_destructured (span : Meta.span) (destructure_shared_values : bool)
(ctx : eval_ctx) (abs : abs) : bool =
let abs' =
- destructure_abs meta abs.kind abs.can_end destructure_shared_values ctx abs
+ destructure_abs span abs.kind abs.can_end destructure_shared_values ctx abs
in
abs = abs'
-let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
+let convert_value_to_abstractions (span : Meta.span) (abs_kind : abs_kind)
(can_end : bool) (destructure_shared_values : bool) (ctx : eval_ctx)
(v : typed_value) : abs list =
(* Convert the value to a list of avalues *)
@@ -1846,7 +1846,7 @@ let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
log#ldebug
(lazy
("convert_value_to_abstractions: to_avalues:\n- value: "
- ^ typed_value_to_string ~meta:(Some meta) ctx v));
+ ^ typed_value_to_string ~span:(Some span) ctx v));
let ty = v.ty in
match v.value with
@@ -1890,14 +1890,14 @@ let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
(avl, { v with value = VAdt adt })
| VBorrow bc -> (
let _, ref_ty, kind = ty_as_ref ty in
- cassert __FILE__ __LINE__ (ty_no_regions ref_ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions ref_ty) span
"Nested borrows are not supported yet";
(* Sanity check *)
- sanity_check __FILE__ __LINE__ allow_borrows meta;
+ sanity_check __FILE__ __LINE__ allow_borrows span;
(* Convert the borrow content *)
match bc with
| VSharedBorrow bid ->
- cassert __FILE__ __LINE__ (ty_no_regions ref_ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions ref_ty) span
"Nested borrows are not supported yet";
let ty = TRef (RFVar r_id, ref_ty, kind) in
let value = ABorrow (ASharedBorrow bid) in
@@ -1907,10 +1907,10 @@ let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
(* We don't support nested borrows for now *)
cassert __FILE__ __LINE__
(not (value_has_borrows ctx bv.value))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
(* Create an avalue to push - note that we use [AIgnore] for the inner avalue *)
let ty = TRef (RFVar r_id, ref_ty, kind) in
- let ignored = mk_aignored meta ref_ty in
+ let ignored = mk_aignored span ref_ty in
let av = ABorrow (AMutBorrow (bid, ignored)) in
let av = { value = av; ty } in
(* Continue exploring, looking for loans (and forbidding borrows,
@@ -1920,7 +1920,7 @@ let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
(av :: avl, value)
| VReservedMutBorrow _ ->
(* This borrow should have been activated *)
- craise __FILE__ __LINE__ meta "Unexpected")
+ craise __FILE__ __LINE__ span "Unexpected")
| VLoan lc -> (
match lc with
| VSharedLoan (bids, sv) ->
@@ -1928,13 +1928,13 @@ let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
(* We don't support nested borrows for now *)
cassert __FILE__ __LINE__
(not (value_has_borrows ctx sv.value))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
(* Push the avalue - note that we use [AIgnore] for the inner avalue *)
(* For avalues, a loan has the borrow type *)
- cassert __FILE__ __LINE__ (ty_no_regions ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions ty) span
"Nested borrows are not supported yet";
let ty = mk_ref_ty (RFVar r_id) ty RShared in
- let ignored = mk_aignored meta ty in
+ let ignored = mk_aignored span ty in
(* Rem.: the shared value might contain loans *)
let avl, sv = to_avalues false true true r_id sv in
let av = ALoan (ASharedLoan (bids, sv, ignored)) in
@@ -1950,10 +1950,10 @@ let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
| VMutLoan bid ->
(* Push the avalue - note that we use [AIgnore] for the inner avalue *)
(* For avalues, a loan has the borrow type *)
- cassert __FILE__ __LINE__ (ty_no_regions ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions ty) span
"Nested borrows are not supported yet";
let ty = mk_ref_ty (RFVar r_id) ty RMut in
- let ignored = mk_aignored meta ty in
+ let ignored = mk_aignored span ty in
let av = ALoan (AMutLoan (bid, ignored)) in
let av = { value = av; ty } in
([ av ], v))
@@ -1962,7 +1962,7 @@ let convert_value_to_abstractions (meta : Meta.meta) (abs_kind : abs_kind)
be eagerly expanded, and we don't support nested borrows *)
cassert __FILE__ __LINE__
(not (value_has_borrows ctx v.value))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
(* Return nothing *)
([], v)
in
@@ -2003,7 +2003,7 @@ type merge_abstraction_info = {
- all the borrows are destructured (for instance, shared loans can't
contain shared loans).
*)
-let compute_merge_abstraction_info (meta : Meta.meta) (ctx : eval_ctx)
+let compute_merge_abstraction_info (span : Meta.span) (ctx : eval_ctx)
(abs : abs) : merge_abstraction_info =
let loans : loan_id_set ref = ref BorrowId.Set.empty in
let borrows : borrow_id_set ref = ref BorrowId.Set.empty in
@@ -2016,32 +2016,32 @@ let compute_merge_abstraction_info (meta : Meta.meta) (ctx : eval_ctx)
in
let push_loans ids (lc : g_loan_content_with_ty) : unit =
- sanity_check __FILE__ __LINE__ (BorrowId.Set.disjoint !loans ids) meta;
+ sanity_check __FILE__ __LINE__ (BorrowId.Set.disjoint !loans ids) span;
loans := BorrowId.Set.union !loans ids;
BorrowId.Set.iter
(fun id ->
sanity_check __FILE__ __LINE__
(not (BorrowId.Map.mem id !loan_to_content))
- meta;
+ span;
loan_to_content := BorrowId.Map.add id lc !loan_to_content;
borrows_loans := LoanId id :: !borrows_loans)
ids
in
let push_loan id (lc : g_loan_content_with_ty) : unit =
- sanity_check __FILE__ __LINE__ (not (BorrowId.Set.mem id !loans)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Set.mem id !loans)) span;
loans := BorrowId.Set.add id !loans;
sanity_check __FILE__ __LINE__
(not (BorrowId.Map.mem id !loan_to_content))
- meta;
+ span;
loan_to_content := BorrowId.Map.add id lc !loan_to_content;
borrows_loans := LoanId id :: !borrows_loans
in
let push_borrow id (bc : g_borrow_content_with_ty) : unit =
- sanity_check __FILE__ __LINE__ (not (BorrowId.Set.mem id !borrows)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Set.mem id !borrows)) span;
borrows := BorrowId.Set.add id !borrows;
sanity_check __FILE__ __LINE__
(not (BorrowId.Map.mem id !borrow_to_content))
- meta;
+ span;
borrow_to_content := BorrowId.Map.add id bc !borrow_to_content;
borrows_loans := BorrowId id :: !borrows_loans
in
@@ -2064,23 +2064,23 @@ let compute_merge_abstraction_info (meta : Meta.meta) (ctx : eval_ctx)
let ty =
match Option.get env with
| Concrete ty -> ty
- | Abstract _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Abstract _ -> craise __FILE__ __LINE__ span "Unreachable"
in
(match lc with
| VSharedLoan (bids, _) -> push_loans bids (Concrete (ty, lc))
- | VMutLoan _ -> craise __FILE__ __LINE__ meta "Unreachable");
+ | VMutLoan _ -> craise __FILE__ __LINE__ span "Unreachable");
(* Continue *)
super#visit_loan_content env lc
method! visit_borrow_content _ _ =
(* Can happen if we explore shared values which contain borrows -
i.e., if we have nested borrows (we forbid this for now) *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
method! visit_aloan_content env lc =
let ty =
match Option.get env with
- | Concrete _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Concrete _ -> craise __FILE__ __LINE__ span "Unreachable"
| Abstract ty -> ty
in
(* Register the loans *)
@@ -2090,14 +2090,14 @@ let compute_merge_abstraction_info (meta : Meta.meta) (ctx : eval_ctx)
| AEndedMutLoan _ | AEndedSharedLoan _ | AIgnoredMutLoan _
| AEndedIgnoredMutLoan _ | AIgnoredSharedLoan _ ->
(* The abstraction has been destructured, so those shouldn't appear *)
- craise __FILE__ __LINE__ meta "Unreachable");
+ craise __FILE__ __LINE__ span "Unreachable");
(* Continue *)
super#visit_aloan_content env lc
method! visit_aborrow_content env bc =
let ty =
match Option.get env with
- | Concrete _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Concrete _ -> craise __FILE__ __LINE__ span "Unreachable"
| Abstract ty -> ty
in
(* Explore the borrow content *)
@@ -2111,20 +2111,20 @@ let compute_merge_abstraction_info (meta : Meta.meta) (ctx : eval_ctx)
| AsbProjReborrows _ ->
(* Can only happen if the symbolic value (potentially) contains
borrows - i.e., we have nested borrows *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
List.iter register asb
| AIgnoredMutBorrow _ | AEndedIgnoredMutBorrow _ | AEndedMutBorrow _
| AEndedSharedBorrow ->
(* The abstraction has been destructured, so those shouldn't appear *)
- craise __FILE__ __LINE__ meta "Unreachable");
+ craise __FILE__ __LINE__ span "Unreachable");
super#visit_aborrow_content env bc
method! visit_symbolic_value _ sv =
(* Sanity check: no borrows *)
sanity_check __FILE__ __LINE__
(not (symbolic_value_has_borrows ctx sv))
- meta
+ span
end
in
@@ -2191,25 +2191,25 @@ type merge_duplicates_funcs = {
Merge two abstractions into one, without updating the context.
*)
-let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
+let merge_into_abstraction_aux (span : Meta.span) (abs_kind : abs_kind)
(can_end : bool) (merge_funs : merge_duplicates_funcs option)
(ctx : eval_ctx) (abs0 : abs) (abs1 : abs) : abs =
log#ldebug
(lazy
("merge_into_abstraction_aux:\n- abs0:\n"
- ^ abs_to_string meta ctx abs0
+ ^ abs_to_string span ctx abs0
^ "\n\n- abs1:\n"
- ^ abs_to_string meta ctx abs1));
+ ^ abs_to_string span ctx abs1));
(* Check that the abstractions are destructured *)
if !Config.sanity_checks then (
let destructure_shared_values = true in
sanity_check __FILE__ __LINE__
- (abs_is_destructured meta destructure_shared_values ctx abs0)
- meta;
+ (abs_is_destructured span destructure_shared_values ctx abs0)
+ span;
sanity_check __FILE__ __LINE__
- (abs_is_destructured meta destructure_shared_values ctx abs1)
- meta);
+ (abs_is_destructured span destructure_shared_values ctx abs1)
+ span);
(* Compute the relevant information *)
let {
@@ -2219,7 +2219,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
loan_to_content = loan_to_content0;
borrow_to_content = borrow_to_content0;
} =
- compute_merge_abstraction_info meta ctx abs0
+ compute_merge_abstraction_info span ctx abs0
in
let {
@@ -2229,7 +2229,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
loan_to_content = loan_to_content1;
borrow_to_content = borrow_to_content1;
} =
- compute_merge_abstraction_info meta ctx abs1
+ compute_merge_abstraction_info span ctx abs1
in
(* Sanity check: there is no loan/borrows which appears in both abstractions,
@@ -2237,8 +2237,8 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
if merge_funs = None then (
sanity_check __FILE__ __LINE__
(BorrowId.Set.disjoint borrows0 borrows1)
- meta;
- sanity_check __FILE__ __LINE__ (BorrowId.Set.disjoint loans0 loans1) meta);
+ span;
+ sanity_check __FILE__ __LINE__ (BorrowId.Set.disjoint loans0 loans1) span);
(* Merge.
There are several cases:
@@ -2265,7 +2265,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
log#ldebug
(lazy
("merge_into_abstraction_aux: push_avalue: "
- ^ typed_avalue_to_string ~meta:(Some meta) ctx av));
+ ^ typed_avalue_to_string ~span:(Some span) ctx av));
avalues := av :: !avalues
in
let push_opt_avalue av =
@@ -2279,7 +2279,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
in
let filter_bids (bids : BorrowId.Set.t) : BorrowId.Set.t =
let bids = BorrowId.Set.diff bids intersect in
- sanity_check __FILE__ __LINE__ (not (BorrowId.Set.is_empty bids)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Set.is_empty bids)) span;
bids
in
let filter_bid (bid : BorrowId.id) : BorrowId.id option =
@@ -2307,11 +2307,11 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
(Option.get merge_funs).merge_ashared_borrows id ty0 ty1
| AProjSharedBorrow _, AProjSharedBorrow _ ->
(* Unreachable because requires nested borrows *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| _ ->
(* Unreachable because those cases are ignored (ended/ignored borrows)
or inconsistent *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
let merge_g_borrow_contents (bc0 : g_borrow_content_with_ty)
@@ -2319,12 +2319,12 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
match (bc0, bc1) with
| Concrete _, Concrete _ ->
(* This can happen only in case of nested borrows *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Abstract (ty0, bc0), Abstract (ty1, bc1) ->
merge_aborrow_contents ty0 bc0 ty1 bc1
| Concrete _, Abstract _ | Abstract _, Concrete _ ->
(* TODO: is it really unreachable? *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
let merge_aloan_contents (ty0 : rty) (lc0 : aloan_content) (ty1 : rty)
@@ -2342,7 +2342,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
(* Check that the sets of ids are the same - if it is not the case, it
means we actually need to merge more than 2 avalues: we ignore this
case for now *)
- sanity_check __FILE__ __LINE__ (BorrowId.Set.equal ids0 ids1) meta;
+ sanity_check __FILE__ __LINE__ (BorrowId.Set.equal ids0 ids1) span;
let ids = ids0 in
if BorrowId.Set.is_empty ids then (
(* If the set of ids is empty, we can eliminate this shared loan.
@@ -2356,12 +2356,12 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
*)
sanity_check __FILE__ __LINE__
(not (value_has_loans_or_borrows ctx sv0.value))
- meta;
+ span;
sanity_check __FILE__ __LINE__
(not (value_has_loans_or_borrows ctx sv0.value))
- meta;
- sanity_check __FILE__ __LINE__ (is_aignored child0.value) meta;
- sanity_check __FILE__ __LINE__ (is_aignored child1.value) meta;
+ span;
+ sanity_check __FILE__ __LINE__ (is_aignored child0.value) span;
+ sanity_check __FILE__ __LINE__ (is_aignored child1.value) span;
None)
else (
(* Register the loan ids *)
@@ -2373,7 +2373,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
| _ ->
(* Unreachable because those cases are ignored (ended/ignored borrows)
or inconsistent *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
(* Note that because we may filter ids from a set of id, this function has
@@ -2384,12 +2384,12 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
match (lc0, lc1) with
| Concrete _, Concrete _ ->
(* This can not happen: the values should have been destructured *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Abstract (ty0, lc0), Abstract (ty1, lc1) ->
merge_aloan_contents ty0 lc0 ty1 lc1
| Concrete _, Abstract _ | Abstract _, Concrete _ ->
(* TODO: is it really unreachable? *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
(* Note that we first explore the borrows/loans of [abs1], because we
@@ -2430,12 +2430,12 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
a concrete borrow can only happen inside a shared
loan
*)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Abstract (ty, bc) -> { value = ABorrow bc; ty })
| Some bc0, Some bc1 ->
- sanity_check __FILE__ __LINE__ (merge_funs <> None) meta;
+ sanity_check __FILE__ __LINE__ (merge_funs <> None) span;
merge_g_borrow_contents bc0 bc1
- | None, None -> craise __FILE__ __LINE__ meta "Unreachable"
+ | None, None -> craise __FILE__ __LINE__ span "Unreachable"
in
push_avalue av)
| LoanId bid ->
@@ -2468,19 +2468,19 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
| Concrete _ ->
(* This shouldn't happen because the avalues should
have been destructured. *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Abstract (ty, lc) -> (
match lc with
| ASharedLoan (bids, sv, child) ->
let bids = filter_bids bids in
sanity_check __FILE__ __LINE__
(not (BorrowId.Set.is_empty bids))
- meta;
+ span;
sanity_check __FILE__ __LINE__
- (is_aignored child.value) meta;
+ (is_aignored child.value) span;
sanity_check __FILE__ __LINE__
(not (value_has_loans_or_borrows ctx sv.value))
- meta;
+ span;
let lc = ASharedLoan (bids, sv, child) in
set_loans_as_merged bids;
Some { value = ALoan lc; ty }
@@ -2491,11 +2491,11 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
| AIgnoredMutLoan _ | AEndedIgnoredMutLoan _
| AIgnoredSharedLoan _ ->
(* The abstraction has been destructured, so those shouldn't appear *)
- craise __FILE__ __LINE__ meta "Unreachable"))
+ craise __FILE__ __LINE__ span "Unreachable"))
| Some lc0, Some lc1 ->
- sanity_check __FILE__ __LINE__ (merge_funs <> None) meta;
+ sanity_check __FILE__ __LINE__ (merge_funs <> None) span;
merge_g_loan_contents lc0 lc1
- | None, None -> craise __FILE__ __LINE__ meta "Unreachable"
+ | None, None -> craise __FILE__ __LINE__ span "Unreachable"
in
push_opt_avalue av))
borrows_loans;
@@ -2513,7 +2513,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
match av.value with
| ABorrow _ -> true
| ALoan _ -> false
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
let aborrows, aloans = List.partition is_borrow avalues in
List.append aborrows aloans
@@ -2548,7 +2548,7 @@ let merge_into_abstraction_aux (meta : Meta.meta) (abs_kind : abs_kind)
in
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (abs_is_destructured meta true ctx abs) meta;
+ sanity_check __FILE__ __LINE__ (abs_is_destructured span true ctx abs) span;
(* Return *)
abs
@@ -2559,7 +2559,7 @@ let ctx_merge_regions (ctx : eval_ctx) (rid : RegionId.id)
let env = Substitute.env_subst_rids rsubst ctx.env in
{ ctx with env }
-let merge_into_abstraction (meta : Meta.meta) (abs_kind : abs_kind)
+let merge_into_abstraction (span : Meta.span) (abs_kind : abs_kind)
(can_end : bool) (merge_funs : merge_duplicates_funcs option)
(ctx : eval_ctx) (abs_id0 : AbstractionId.id) (abs_id1 : AbstractionId.id) :
eval_ctx * AbstractionId.id =
@@ -2569,13 +2569,13 @@ let merge_into_abstraction (meta : Meta.meta) (abs_kind : abs_kind)
(* Merge them *)
let nabs =
- merge_into_abstraction_aux meta abs_kind can_end merge_funs ctx abs0 abs1
+ merge_into_abstraction_aux span abs_kind can_end merge_funs ctx abs0 abs1
in
(* Update the environment: replace the abstraction 1 with the result of the merge,
remove the abstraction 0 *)
- let ctx = fst (ctx_subst_abs meta ctx abs_id1 nabs) in
- let ctx = fst (ctx_remove_abs meta ctx abs_id0) in
+ let ctx = fst (ctx_subst_abs span ctx abs_id1 nabs) in
+ let ctx = fst (ctx_remove_abs span ctx abs_id0) in
(* Merge all the regions from the abstraction into one (the first - i.e., the
one with the smallest id). Note that we need to do this in the whole
diff --git a/compiler/InterpreterBorrows.mli b/compiler/InterpreterBorrows.mli
index 30b75790..56df9344 100644
--- a/compiler/InterpreterBorrows.mli
+++ b/compiler/InterpreterBorrows.mli
@@ -9,39 +9,39 @@ open Cps
the set of borrows tracked by a shared value, referenced by the
[original_bid] argument. *)
val reborrow_shared :
- Meta.meta -> BorrowId.id -> BorrowId.id -> eval_ctx -> eval_ctx
+ Meta.span -> BorrowId.id -> BorrowId.id -> eval_ctx -> eval_ctx
(** End a borrow identified by its id, while preserving the invariants.
If the borrow is inside another borrow/an abstraction or contains loans,
[end_borrow] will end those borrows/abstractions/loans first.
*)
-val end_borrow : config -> Meta.meta -> BorrowId.id -> cm_fun
+val end_borrow : config -> Meta.span -> BorrowId.id -> cm_fun
(** End a set of borrows identified by their ids, while preserving the invariants. *)
-val end_borrows : config -> Meta.meta -> BorrowId.Set.t -> cm_fun
+val end_borrows : config -> Meta.span -> BorrowId.Set.t -> cm_fun
(** End an abstraction while preserving the invariants. *)
-val end_abstraction : config -> Meta.meta -> AbstractionId.id -> cm_fun
+val end_abstraction : config -> Meta.span -> AbstractionId.id -> cm_fun
(** End a set of abstractions while preserving the invariants. *)
-val end_abstractions : config -> Meta.meta -> AbstractionId.Set.t -> cm_fun
+val end_abstractions : config -> Meta.span -> AbstractionId.Set.t -> cm_fun
(** End a borrow and return the resulting environment, ignoring synthesis *)
val end_borrow_no_synth :
- config -> Meta.meta -> BorrowId.id -> eval_ctx -> eval_ctx
+ config -> Meta.span -> BorrowId.id -> eval_ctx -> eval_ctx
(** End a set of borrows and return the resulting environment, ignoring synthesis *)
val end_borrows_no_synth :
- config -> Meta.meta -> BorrowId.Set.t -> eval_ctx -> eval_ctx
+ config -> Meta.span -> BorrowId.Set.t -> eval_ctx -> eval_ctx
(** End an abstraction and return the resulting environment, ignoring synthesis *)
val end_abstraction_no_synth :
- config -> Meta.meta -> AbstractionId.id -> eval_ctx -> eval_ctx
+ config -> Meta.span -> AbstractionId.id -> eval_ctx -> eval_ctx
(** End a set of abstractions and return the resulting environment, ignoring synthesis *)
val end_abstractions_no_synth :
- config -> Meta.meta -> AbstractionId.Set.t -> eval_ctx -> eval_ctx
+ config -> Meta.span -> AbstractionId.Set.t -> eval_ctx -> eval_ctx
(** Promote a reserved mut borrow to a mut borrow, while preserving the invariants.
@@ -52,7 +52,7 @@ val end_abstractions_no_synth :
the corresponding shared loan with a mutable loan (after having ended the
other shared borrows which point to this loan).
*)
-val promote_reserved_mut_borrow : config -> Meta.meta -> BorrowId.id -> cm_fun
+val promote_reserved_mut_borrow : config -> Meta.span -> BorrowId.id -> cm_fun
(** Transform an abstraction to an abstraction where the values are not
structured.
@@ -95,7 +95,7 @@ val promote_reserved_mut_borrow : config -> Meta.meta -> BorrowId.id -> cm_fun
- [abs]
*)
val destructure_abs :
- Meta.meta -> abs_kind -> bool -> bool -> eval_ctx -> abs -> abs
+ Meta.span -> abs_kind -> bool -> bool -> eval_ctx -> abs -> abs
(** Return [true] if the values in an abstraction are destructured.
@@ -103,7 +103,7 @@ val destructure_abs :
The input boolean is [destructure_shared_value]. See {!destructure_abs}.
*)
-val abs_is_destructured : Meta.meta -> bool -> eval_ctx -> abs -> bool
+val abs_is_destructured : Meta.span -> bool -> eval_ctx -> abs -> bool
(** Turn a value into a abstractions.
@@ -129,7 +129,7 @@ val abs_is_destructured : Meta.meta -> bool -> eval_ctx -> abs -> bool
- [v]
*)
val convert_value_to_abstractions :
- Meta.meta -> abs_kind -> bool -> bool -> eval_ctx -> typed_value -> abs list
+ Meta.span -> abs_kind -> bool -> bool -> eval_ctx -> typed_value -> abs list
(** See {!merge_into_abstraction}.
@@ -236,7 +236,7 @@ type merge_duplicates_funcs = {
results from the merge.
*)
val merge_into_abstraction :
- Meta.meta ->
+ Meta.span ->
abs_kind ->
bool ->
merge_duplicates_funcs option ->
diff --git a/compiler/InterpreterBorrowsCore.ml b/compiler/InterpreterBorrowsCore.ml
index a01be046..2628b26a 100644
--- a/compiler/InterpreterBorrowsCore.ml
+++ b/compiler/InterpreterBorrowsCore.ml
@@ -72,10 +72,10 @@ let borrow_or_abs_ids_chain_to_string (ids : borrow_or_abs_ids) : string =
String.concat " -> " ids
(** Add a borrow or abs id to a chain of ids, while checking that we don't loop *)
-let add_borrow_or_abs_id_to_chain (meta : Meta.meta) (msg : string)
+let add_borrow_or_abs_id_to_chain (span : Meta.span) (msg : string)
(id : borrow_or_abs_id) (ids : borrow_or_abs_ids) : borrow_or_abs_ids =
if List.mem id ids then
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
(msg ^ "detected a loop in the chain of ids: "
^ borrow_or_abs_ids_chain_to_string (id :: ids))
else id :: ids
@@ -94,25 +94,25 @@ let add_borrow_or_abs_id_to_chain (meta : Meta.meta) (msg : string)
TODO: is there a way of deriving such a comparison?
TODO: rename
*)
-let rec compare_rtys (meta : Meta.meta) (default : bool)
+let rec compare_rtys (span : Meta.span) (default : bool)
(combine : bool -> bool -> bool)
(compare_regions : region -> region -> bool) (ty1 : rty) (ty2 : rty) : bool
=
- let compare = compare_rtys meta default combine compare_regions in
+ let compare = compare_rtys span default combine compare_regions in
(* Sanity check - TODO: don't do this at every recursive call *)
- sanity_check __FILE__ __LINE__ (ty_is_rty ty1 && ty_is_rty ty2) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty1 && ty_is_rty ty2) span;
(* Normalize the associated types *)
match (ty1, ty2) with
| TLiteral lit1, TLiteral lit2 ->
- sanity_check __FILE__ __LINE__ (lit1 = lit2) meta;
+ sanity_check __FILE__ __LINE__ (lit1 = lit2) span;
default
| TAdt (id1, generics1), TAdt (id2, generics2) ->
- sanity_check __FILE__ __LINE__ (id1 = id2) meta;
+ sanity_check __FILE__ __LINE__ (id1 = id2) span;
(* There are no regions in the const generics, so we ignore them,
but we still check they are the same, for sanity *)
sanity_check __FILE__ __LINE__
(generics1.const_generics = generics2.const_generics)
- meta;
+ span;
(* We also ignore the trait refs *)
@@ -146,7 +146,7 @@ let rec compare_rtys (meta : Meta.meta) (default : bool)
combine params_b tys_b
| TRef (r1, ty1, kind1), TRef (r2, ty2, kind2) ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (kind1 = kind2) meta;
+ sanity_check __FILE__ __LINE__ (kind1 = kind2) span;
(* Explanation for the case where we check if projections intersect:
* the projections intersect if the borrows intersect or their contents
* intersect. *)
@@ -154,19 +154,19 @@ let rec compare_rtys (meta : Meta.meta) (default : bool)
let tys_b = compare ty1 ty2 in
combine regions_b tys_b
| TVar id1, TVar id2 ->
- sanity_check __FILE__ __LINE__ (id1 = id2) meta;
+ sanity_check __FILE__ __LINE__ (id1 = id2) span;
default
| TTraitType _, TTraitType _ ->
(* The types should have been normalized. If after normalization we
get trait types, we can consider them as variables *)
- sanity_check __FILE__ __LINE__ (ty1 = ty2) meta;
+ sanity_check __FILE__ __LINE__ (ty1 = ty2) span;
default
| _ ->
log#ltrace
(lazy
("compare_rtys: unexpected inputs:" ^ "\n- ty1: " ^ show_ty ty1
^ "\n- ty2: " ^ show_ty ty2));
- internal_error __FILE__ __LINE__ meta
+ internal_error __FILE__ __LINE__ span
(** Check if two different projections intersect. This is necessary when
giving a symbolic value to an abstraction: we need to check that
@@ -175,14 +175,14 @@ let rec compare_rtys (meta : Meta.meta) (default : bool)
Note that the two abstractions have different views (in terms of regions)
of the symbolic value (hence the two region types).
*)
-let projections_intersect (meta : Meta.meta) (ty1 : rty)
+let projections_intersect (span : Meta.span) (ty1 : rty)
(rset1 : RegionId.Set.t) (ty2 : rty) (rset2 : RegionId.Set.t) : bool =
let default = false in
let combine b1 b2 = b1 || b2 in
let compare_regions r1 r2 =
region_in_set r1 rset1 && region_in_set r2 rset2
in
- compare_rtys meta default combine compare_regions ty1 ty2
+ compare_rtys span default combine compare_regions ty1 ty2
(** Check if the first projection contains the second projection.
We use this function when checking invariants.
@@ -190,14 +190,14 @@ let projections_intersect (meta : Meta.meta) (ty1 : rty)
The regions in the types shouldn't be erased (this function will raise an exception
otherwise).
*)
-let projection_contains (meta : Meta.meta) (ty1 : rty) (rset1 : RegionId.Set.t)
+let projection_contains (span : Meta.span) (ty1 : rty) (rset1 : RegionId.Set.t)
(ty2 : rty) (rset2 : RegionId.Set.t) : bool =
let default = true in
let combine b1 b2 = b1 && b2 in
let compare_regions r1 r2 =
region_in_set r1 rset1 || not (region_in_set r2 rset2)
in
- compare_rtys meta default combine compare_regions ty1 ty2
+ compare_rtys span default combine compare_regions ty1 ty2
(** Lookup a loan content.
@@ -207,7 +207,7 @@ let projection_contains (meta : Meta.meta) (ty1 : rty) (rset1 : RegionId.Set.t)
the {!InterpreterUtils.abs_or_var_id} is not necessarily {!constructor:Aeneas.InterpreterUtils.abs_or_var_id.VarId} or
{!constructor:Aeneas.InterpreterUtils.abs_or_var_id.DummyVarId}: there can be concrete loans in abstractions (in the shared values).
*)
-let lookup_loan_opt (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
+let lookup_loan_opt (span : Meta.span) (ek : exploration_kind) (l : BorrowId.id)
(ctx : eval_ctx) : (abs_or_var_id * g_loan_content) option =
(* We store here whether we are inside an abstraction or a value - note that we
* could also track that with the environment, it would probably be more idiomatic
@@ -262,16 +262,16 @@ let lookup_loan_opt (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
if BorrowId.Set.mem l bids then
raise (FoundGLoanContent (Abstract lc))
else super#visit_ASharedLoan env bids v av
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan (_, _)
| AIgnoredMutLoan (_, _)
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AIgnoredSharedLoan _ ->
super#visit_aloan_content env lc
method! visit_EBinding env bv v =
- sanity_check __FILE__ __LINE__ (Option.is_none !abs_or_var) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none !abs_or_var) span;
abs_or_var :=
Some
(match bv with
@@ -281,7 +281,7 @@ let lookup_loan_opt (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
abs_or_var := None
method! visit_EAbs env abs =
- sanity_check __FILE__ __LINE__ (Option.is_none !abs_or_var) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none !abs_or_var) span;
if ek.enter_abs then (
abs_or_var := Some (AbsId abs.abs_id);
super#visit_EAbs env abs;
@@ -296,17 +296,17 @@ let lookup_loan_opt (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
with FoundGLoanContent lc -> (
match !abs_or_var with
| Some abs_or_var -> Some (abs_or_var, lc)
- | None -> craise __FILE__ __LINE__ meta "Inconsistent state")
+ | None -> craise __FILE__ __LINE__ span "Inconsistent state")
(** Lookup a loan content.
The loan is referred to by a borrow id.
Raises an exception if no loan was found.
*)
-let lookup_loan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
+let lookup_loan (span : Meta.span) (ek : exploration_kind) (l : BorrowId.id)
(ctx : eval_ctx) : abs_or_var_id * g_loan_content =
- match lookup_loan_opt meta ek l ctx with
- | None -> craise __FILE__ __LINE__ meta "Unreachable"
+ match lookup_loan_opt span ek l ctx with
+ | None -> craise __FILE__ __LINE__ span "Unreachable"
| Some res -> res
(** Update a loan content.
@@ -315,14 +315,14 @@ let lookup_loan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
This is a helper function: it might break invariants.
*)
-let update_loan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
+let update_loan (span : Meta.span) (ek : exploration_kind) (l : BorrowId.id)
(nlc : loan_content) (ctx : eval_ctx) : eval_ctx =
(* We use a reference to check that we update exactly one loan: when updating
* inside values, we check we don't update more than one loan. Then, upon
* returning we check that we updated at least once. *)
let r = ref false in
let update () : loan_content =
- sanity_check __FILE__ __LINE__ (not !r) meta;
+ sanity_check __FILE__ __LINE__ (not !r) span;
r := true;
nlc
in
@@ -369,7 +369,7 @@ let update_loan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
let ctx = obj#visit_eval_ctx () ctx in
(* Check that we updated at least one loan *)
- sanity_check __FILE__ __LINE__ !r meta;
+ sanity_check __FILE__ __LINE__ !r span;
ctx
(** Update a abstraction loan content.
@@ -378,14 +378,14 @@ let update_loan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
This is a helper function: it might break invariants.
*)
-let update_aloan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
+let update_aloan (span : Meta.span) (ek : exploration_kind) (l : BorrowId.id)
(nlc : aloan_content) (ctx : eval_ctx) : eval_ctx =
(* We use a reference to check that we update exactly one loan: when updating
* inside values, we check we don't update more than one loan. Then, upon
* returning we check that we updated at least once. *)
let r = ref false in
let update () : aloan_content =
- sanity_check __FILE__ __LINE__ (not !r) meta;
+ sanity_check __FILE__ __LINE__ (not !r) span;
r := true;
nlc
in
@@ -401,11 +401,11 @@ let update_aloan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
| ASharedLoan (bids, v, av) ->
if BorrowId.Set.mem l bids then update ()
else super#visit_ASharedLoan env bids v av
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan (_, _)
| AIgnoredMutLoan (_, _)
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AIgnoredSharedLoan _ ->
super#visit_aloan_content env lc
@@ -418,7 +418,7 @@ let update_aloan (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
let ctx = obj#visit_eval_ctx () ctx in
(* Check that we updated at least one loan *)
- sanity_check __FILE__ __LINE__ !r meta;
+ sanity_check __FILE__ __LINE__ !r span;
ctx
(** Lookup a borrow content from a borrow id. *)
@@ -462,7 +462,7 @@ let lookup_borrow_opt (ek : exploration_kind) (l : BorrowId.id) (ctx : eval_ctx)
| AIgnoredMutBorrow (_, _)
| AEndedMutBorrow _
| AEndedIgnoredMutBorrow
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AEndedSharedBorrow ->
super#visit_aborrow_content env bc
| AProjSharedBorrow asb ->
@@ -484,10 +484,10 @@ let lookup_borrow_opt (ek : exploration_kind) (l : BorrowId.id) (ctx : eval_ctx)
Raise an exception if no loan was found
*)
-let lookup_borrow (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
+let lookup_borrow (span : Meta.span) (ek : exploration_kind) (l : BorrowId.id)
(ctx : eval_ctx) : g_borrow_content =
match lookup_borrow_opt ek l ctx with
- | None -> craise __FILE__ __LINE__ meta "Unreachable"
+ | None -> craise __FILE__ __LINE__ span "Unreachable"
| Some lc -> lc
(** Update a borrow content.
@@ -496,14 +496,14 @@ let lookup_borrow (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
This is a helper function: it might break invariants.
*)
-let update_borrow (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
+let update_borrow (span : Meta.span) (ek : exploration_kind) (l : BorrowId.id)
(nbc : borrow_content) (ctx : eval_ctx) : eval_ctx =
(* We use a reference to check that we update exactly one borrow: when updating
* inside values, we check we don't update more than one borrow. Then, upon
* returning we check that we updated at least once. *)
let r = ref false in
let update () : borrow_content =
- sanity_check __FILE__ __LINE__ (not !r) meta;
+ sanity_check __FILE__ __LINE__ (not !r) span;
r := true;
nbc
in
@@ -544,7 +544,7 @@ let update_borrow (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
let ctx = obj#visit_eval_ctx () ctx in
(* Check that we updated at least one borrow *)
- sanity_check __FILE__ __LINE__ !r meta;
+ sanity_check __FILE__ __LINE__ !r span;
ctx
(** Update an abstraction borrow content.
@@ -553,14 +553,14 @@ let update_borrow (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
This is a helper function: it might break invariants.
*)
-let update_aborrow (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
+let update_aborrow (span : Meta.span) (ek : exploration_kind) (l : BorrowId.id)
(nv : avalue) (ctx : eval_ctx) : eval_ctx =
(* We use a reference to check that we update exactly one borrow: when updating
* inside values, we check we don't update more than one borrow. Then, upon
* returning we check that we updated at least once. *)
let r = ref false in
let update () : avalue =
- sanity_check __FILE__ __LINE__ (not !r) meta;
+ sanity_check __FILE__ __LINE__ (not !r) span;
r := true;
nv
in
@@ -591,7 +591,7 @@ let update_aborrow (meta : Meta.meta) (ek : exploration_kind) (l : BorrowId.id)
let ctx = obj#visit_eval_ctx () ctx in
(* Check that we updated at least one borrow *)
- cassert __FILE__ __LINE__ !r meta "No borrow was updated";
+ cassert __FILE__ __LINE__ !r span "No borrow was updated";
ctx
(** Auxiliary function: see its usage in [end_borrow_get_borrow_in_value] *)
@@ -669,13 +669,13 @@ let get_first_outer_loan_or_borrow_in_value (with_borrows : bool)
| FoundLoanContent lc -> Some (LoanContent lc)
| FoundBorrowContent bc -> Some (BorrowContent bc)
-let proj_borrows_intersects_proj_loans (meta : Meta.meta)
+let proj_borrows_intersects_proj_loans (span : Meta.span)
(proj_borrows : RegionId.Set.t * symbolic_value * rty)
(proj_loans : RegionId.Set.t * symbolic_value) : bool =
let b_regions, b_sv, b_ty = proj_borrows in
let l_regions, l_sv = proj_loans in
if same_symbolic_id b_sv l_sv then
- projections_intersect meta l_sv.sv_ty l_regions b_ty b_regions
+ projections_intersect span l_sv.sv_ty l_regions b_ty b_regions
else false
(** Result of looking up aproj_borrows which intersect a given aproj_loans in
@@ -703,24 +703,24 @@ type looked_up_aproj_borrows =
This is a helper function.
*)
-let lookup_intersecting_aproj_borrows_opt (meta : Meta.meta)
+let lookup_intersecting_aproj_borrows_opt (span : Meta.span)
(lookup_shared : bool) (regions : RegionId.Set.t) (sv : symbolic_value)
(ctx : eval_ctx) : looked_up_aproj_borrows option =
let found : looked_up_aproj_borrows option ref = ref None in
let set_non_shared ((id, ty) : AbstractionId.id * rty) : unit =
match !found with
| None -> found := Some (NonSharedProj (id, ty))
- | Some _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Some _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let add_shared (x : AbstractionId.id * rty) : unit =
match !found with
| None -> found := Some (SharedProjs [ x ])
| Some (SharedProjs pl) -> found := Some (SharedProjs (x :: pl))
- | Some (NonSharedProj _) -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Some (NonSharedProj _) -> craise __FILE__ __LINE__ span "Unreachable"
in
let check_add_proj_borrows (is_shared : bool) abs sv' proj_ty =
if
- proj_borrows_intersects_proj_loans meta
+ proj_borrows_intersects_proj_loans span
(abs.regions, sv', proj_ty)
(regions, sv)
then
@@ -736,7 +736,7 @@ let lookup_intersecting_aproj_borrows_opt (meta : Meta.meta)
method! visit_abstract_shared_borrow abs asb =
(* Sanity check *)
(match !found with
- | Some (NonSharedProj _) -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Some (NonSharedProj _) -> craise __FILE__ __LINE__ span "Unreachable"
| _ -> ());
(* Explore *)
if lookup_shared then
@@ -775,23 +775,23 @@ let lookup_intersecting_aproj_borrows_opt (meta : Meta.meta)
Returns the id of the owning abstraction, and the projection type used in
this abstraction.
*)
-let lookup_intersecting_aproj_borrows_not_shared_opt (meta : Meta.meta)
+let lookup_intersecting_aproj_borrows_not_shared_opt (span : Meta.span)
(regions : RegionId.Set.t) (sv : symbolic_value) (ctx : eval_ctx) :
(AbstractionId.id * rty) option =
let lookup_shared = false in
match
- lookup_intersecting_aproj_borrows_opt meta lookup_shared regions sv ctx
+ lookup_intersecting_aproj_borrows_opt span lookup_shared regions sv ctx
with
| None -> None
| Some (NonSharedProj (abs_id, rty)) -> Some (abs_id, rty)
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
(** Similar to {!lookup_intersecting_aproj_borrows_opt}, but updates the
values.
This is a helper function: it might break invariants.
*)
-let update_intersecting_aproj_borrows (meta : Meta.meta)
+let update_intersecting_aproj_borrows (span : Meta.span)
(can_update_shared : bool)
(update_shared : AbstractionId.id -> rty -> abstract_shared_borrows)
(update_non_shared : AbstractionId.id -> rty -> aproj)
@@ -802,18 +802,18 @@ let update_intersecting_aproj_borrows (meta : Meta.meta)
let add_shared () =
match !shared with
| None -> shared := Some true
- | Some b -> sanity_check __FILE__ __LINE__ b meta
+ | Some b -> sanity_check __FILE__ __LINE__ b span
in
let set_non_shared () =
match !shared with
| None -> shared := Some false
| Some _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Found unexpected intersecting proj_borrows"
in
let check_proj_borrows is_shared abs sv' proj_ty =
if
- proj_borrows_intersects_proj_loans meta
+ proj_borrows_intersects_proj_loans span
(abs.regions, sv', proj_ty)
(regions, sv)
then (
@@ -830,7 +830,7 @@ let update_intersecting_aproj_borrows (meta : Meta.meta)
method! visit_abstract_shared_borrows abs asb =
(* Sanity check *)
(match !shared with
- | Some b -> sanity_check __FILE__ __LINE__ b meta
+ | Some b -> sanity_check __FILE__ __LINE__ b span
| _ -> ());
(* Explore *)
if can_update_shared then
@@ -863,7 +863,7 @@ let update_intersecting_aproj_borrows (meta : Meta.meta)
(* Apply *)
let ctx = obj#visit_eval_ctx None ctx in
(* Check that we updated the context at least once *)
- cassert __FILE__ __LINE__ (Option.is_some !shared) meta
+ cassert __FILE__ __LINE__ (Option.is_some !shared) span
"Context was not updated";
(* Return *)
ctx
@@ -875,12 +875,12 @@ let update_intersecting_aproj_borrows (meta : Meta.meta)
This is a helper function: it might break invariants.
*)
-let update_intersecting_aproj_borrows_non_shared (meta : Meta.meta)
+let update_intersecting_aproj_borrows_non_shared (span : Meta.span)
(regions : RegionId.Set.t) (sv : symbolic_value) (nv : aproj)
(ctx : eval_ctx) : eval_ctx =
(* Small helpers *)
let can_update_shared = false in
- let update_shared _ _ = craise __FILE__ __LINE__ meta "Unexpected" in
+ let update_shared _ _ = craise __FILE__ __LINE__ span "Unexpected" in
let updated = ref false in
let update_non_shared _ _ =
(* We can update more than one borrow! *)
@@ -889,11 +889,11 @@ let update_intersecting_aproj_borrows_non_shared (meta : Meta.meta)
in
(* Update *)
let ctx =
- update_intersecting_aproj_borrows meta can_update_shared update_shared
+ update_intersecting_aproj_borrows span can_update_shared update_shared
update_non_shared regions sv ctx
in
(* Check that we updated at least once *)
- sanity_check __FILE__ __LINE__ !updated meta;
+ sanity_check __FILE__ __LINE__ !updated span;
(* Return *)
ctx
@@ -902,15 +902,15 @@ let update_intersecting_aproj_borrows_non_shared (meta : Meta.meta)
This is a helper function: it might break invariants.
*)
-let remove_intersecting_aproj_borrows_shared (meta : Meta.meta)
+let remove_intersecting_aproj_borrows_shared (span : Meta.span)
(regions : RegionId.Set.t) (sv : symbolic_value) (ctx : eval_ctx) : eval_ctx
=
(* Small helpers *)
let can_update_shared = true in
let update_shared _ _ = [] in
- let update_non_shared _ _ = craise __FILE__ __LINE__ meta "Unexpected" in
+ let update_non_shared _ _ = craise __FILE__ __LINE__ span "Unexpected" in
(* Update *)
- update_intersecting_aproj_borrows meta can_update_shared update_shared
+ update_intersecting_aproj_borrows span can_update_shared update_shared
update_non_shared regions sv ctx
(** Updates the proj_loans intersecting some projection.
@@ -944,12 +944,12 @@ let remove_intersecting_aproj_borrows_shared (meta : Meta.meta)
Note that the symbolic value at this place is necessarily equal to [sv],
which is why we don't give it as parameters.
*)
-let update_intersecting_aproj_loans (meta : Meta.meta)
+let update_intersecting_aproj_loans (span : Meta.span)
(proj_regions : RegionId.Set.t) (proj_ty : rty) (sv : symbolic_value)
(subst : abs -> (msymbolic_value * aproj) list -> aproj) (ctx : eval_ctx) :
eval_ctx =
(* *)
- sanity_check __FILE__ __LINE__ (ty_is_rty proj_ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty proj_ty) span;
(* Small helpers for sanity checks *)
let updated = ref false in
let update abs local_given_back : aproj =
@@ -971,9 +971,9 @@ let update_intersecting_aproj_loans (meta : Meta.meta)
| AProjLoans (sv', given_back) ->
let abs = Option.get abs in
if same_symbolic_id sv sv' then (
- sanity_check __FILE__ __LINE__ (sv.sv_ty = sv'.sv_ty) meta;
+ sanity_check __FILE__ __LINE__ (sv.sv_ty = sv'.sv_ty) span;
if
- projections_intersect meta proj_ty proj_regions sv'.sv_ty
+ projections_intersect span proj_ty proj_regions sv'.sv_ty
abs.regions
then update abs given_back
else super#visit_aproj (Some abs) sproj)
@@ -983,7 +983,7 @@ let update_intersecting_aproj_loans (meta : Meta.meta)
(* Apply *)
let ctx = obj#visit_eval_ctx None ctx in
(* Check that we updated the context at least once *)
- sanity_check __FILE__ __LINE__ !updated meta;
+ sanity_check __FILE__ __LINE__ !updated span;
(* Return *)
ctx
@@ -997,13 +997,13 @@ let update_intersecting_aproj_loans (meta : Meta.meta)
Sanity check: we check that there is exactly one projector which corresponds
to the couple (abstraction id, symbolic value).
*)
-let lookup_aproj_loans (meta : Meta.meta) (abs_id : AbstractionId.id)
+let lookup_aproj_loans (span : Meta.span) (abs_id : AbstractionId.id)
(sv : symbolic_value) (ctx : eval_ctx) : (msymbolic_value * aproj) list =
(* Small helpers for sanity checks *)
let found = ref None in
let set_found x =
(* There is at most one projector which corresponds to the description *)
- sanity_check __FILE__ __LINE__ (Option.is_none !found) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none !found) span;
found := Some x
in
(* The visitor *)
@@ -1021,9 +1021,9 @@ let lookup_aproj_loans (meta : Meta.meta) (abs_id : AbstractionId.id)
super#visit_aproj abs sproj
| AProjLoans (sv', given_back) ->
let abs = Option.get abs in
- sanity_check __FILE__ __LINE__ (abs.abs_id = abs_id) meta;
+ sanity_check __FILE__ __LINE__ (abs.abs_id = abs_id) span;
if sv'.sv_id = sv.sv_id then (
- sanity_check __FILE__ __LINE__ (sv' = sv) meta;
+ sanity_check __FILE__ __LINE__ (sv' = sv) span;
set_found given_back)
else ());
super#visit_aproj abs sproj
@@ -1042,13 +1042,13 @@ let lookup_aproj_loans (meta : Meta.meta) (abs_id : AbstractionId.id)
Sanity check: we check that there is exactly one projector which corresponds
to the couple (abstraction id, symbolic value).
*)
-let update_aproj_loans (meta : Meta.meta) (abs_id : AbstractionId.id)
+let update_aproj_loans (span : Meta.span) (abs_id : AbstractionId.id)
(sv : symbolic_value) (nproj : aproj) (ctx : eval_ctx) : eval_ctx =
(* Small helpers for sanity checks *)
let found = ref false in
let update () =
(* We update at most once *)
- sanity_check __FILE__ __LINE__ (not !found) meta;
+ sanity_check __FILE__ __LINE__ (not !found) span;
found := true;
nproj
in
@@ -1067,9 +1067,9 @@ let update_aproj_loans (meta : Meta.meta) (abs_id : AbstractionId.id)
super#visit_aproj abs sproj
| AProjLoans (sv', _) ->
let abs = Option.get abs in
- sanity_check __FILE__ __LINE__ (abs.abs_id = abs_id) meta;
+ sanity_check __FILE__ __LINE__ (abs.abs_id = abs_id) span;
if sv'.sv_id = sv.sv_id then (
- sanity_check __FILE__ __LINE__ (sv' = sv) meta;
+ sanity_check __FILE__ __LINE__ (sv' = sv) span;
update ())
else super#visit_aproj (Some abs) sproj
end
@@ -1077,7 +1077,7 @@ let update_aproj_loans (meta : Meta.meta) (abs_id : AbstractionId.id)
(* Apply *)
let ctx = obj#visit_eval_ctx None ctx in
(* Sanity check *)
- sanity_check __FILE__ __LINE__ !found meta;
+ sanity_check __FILE__ __LINE__ !found span;
(* Return *)
ctx
@@ -1091,13 +1091,13 @@ let update_aproj_loans (meta : Meta.meta) (abs_id : AbstractionId.id)
TODO: factorize with {!update_aproj_loans}?
*)
-let update_aproj_borrows (meta : Meta.meta) (abs_id : AbstractionId.id)
+let update_aproj_borrows (span : Meta.span) (abs_id : AbstractionId.id)
(sv : symbolic_value) (nproj : aproj) (ctx : eval_ctx) : eval_ctx =
(* Small helpers for sanity checks *)
let found = ref false in
let update () =
(* We update at most once *)
- sanity_check __FILE__ __LINE__ (not !found) meta;
+ sanity_check __FILE__ __LINE__ (not !found) span;
found := true;
nproj
in
@@ -1116,9 +1116,9 @@ let update_aproj_borrows (meta : Meta.meta) (abs_id : AbstractionId.id)
super#visit_aproj abs sproj
| AProjBorrows (sv', _proj_ty) ->
let abs = Option.get abs in
- sanity_check __FILE__ __LINE__ (abs.abs_id = abs_id) meta;
+ sanity_check __FILE__ __LINE__ (abs.abs_id = abs_id) span;
if sv'.sv_id = sv.sv_id then (
- sanity_check __FILE__ __LINE__ (sv' = sv) meta;
+ sanity_check __FILE__ __LINE__ (sv' = sv) span;
update ())
else super#visit_aproj (Some abs) sproj
end
@@ -1126,7 +1126,7 @@ let update_aproj_borrows (meta : Meta.meta) (abs_id : AbstractionId.id)
(* Apply *)
let ctx = obj#visit_eval_ctx None ctx in
(* Sanity check *)
- sanity_check __FILE__ __LINE__ !found meta;
+ sanity_check __FILE__ __LINE__ !found span;
(* Return *)
ctx
@@ -1135,18 +1135,18 @@ let update_aproj_borrows (meta : Meta.meta) (abs_id : AbstractionId.id)
Converts an {!Values.aproj.AProjLoans} to an {!Values.aproj.AEndedProjLoans}. The projector is identified
by a symbolic value and an abstraction id.
*)
-let update_aproj_loans_to_ended (meta : Meta.meta) (abs_id : AbstractionId.id)
+let update_aproj_loans_to_ended (span : Meta.span) (abs_id : AbstractionId.id)
(sv : symbolic_value) (ctx : eval_ctx) : eval_ctx =
(* Lookup the projector of loans *)
- let given_back = lookup_aproj_loans meta abs_id sv ctx in
+ let given_back = lookup_aproj_loans span abs_id sv ctx in
(* Create the new value for the projector *)
let nproj = AEndedProjLoans (sv, given_back) in
(* Insert it *)
- let ctx = update_aproj_loans meta abs_id sv nproj ctx in
+ let ctx = update_aproj_loans span abs_id sv nproj ctx in
(* Return *)
ctx
-let no_aproj_over_symbolic_in_context (meta : Meta.meta) (sv : symbolic_value)
+let no_aproj_over_symbolic_in_context (span : Meta.span) (sv : symbolic_value)
(ctx : eval_ctx) : unit =
(* The visitor *)
let obj =
@@ -1164,7 +1164,7 @@ let no_aproj_over_symbolic_in_context (meta : Meta.meta) (sv : symbolic_value)
(* Apply *)
try obj#visit_eval_ctx () ctx
with Found ->
- craise __FILE__ __LINE__ meta "update_aproj_loans_to_ended: failed"
+ craise __FILE__ __LINE__ span "update_aproj_loans_to_ended: failed"
(** Helper function
@@ -1173,7 +1173,7 @@ let no_aproj_over_symbolic_in_context (meta : Meta.meta) (sv : symbolic_value)
**Remark:** we don't take the *ignored* mut/shared loans into account.
*)
-let get_first_non_ignored_aloan_in_abstraction (meta : Meta.meta) (abs : abs) :
+let get_first_non_ignored_aloan_in_abstraction (span : Meta.span) (abs : abs) :
borrow_ids_or_symbolic_value option =
(* Explore to find a loan *)
let obj =
@@ -1184,14 +1184,14 @@ let get_first_non_ignored_aloan_in_abstraction (meta : Meta.meta) (abs : abs) :
match lc with
| AMutLoan (bid, _) -> raise (FoundBorrowIds (Borrow bid))
| ASharedLoan (bids, _, _) -> raise (FoundBorrowIds (Borrows bids))
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan (_, _) ->
super#visit_aloan_content env lc
| AIgnoredMutLoan (_, _) ->
(* Ignore *)
super#visit_aloan_content env lc
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AIgnoredSharedLoan _ ->
(* Ignore *)
super#visit_aloan_content env lc
@@ -1202,7 +1202,7 @@ let get_first_non_ignored_aloan_in_abstraction (meta : Meta.meta) (abs : abs) :
| VMutLoan _ ->
(* The mut loan linked to the mutable borrow present in a shared
* value in an abstraction should be in an AProjBorrows *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| VSharedLoan (bids, _) -> raise (FoundBorrowIds (Borrows bids))
method! visit_aproj env sproj =
@@ -1226,9 +1226,9 @@ let get_first_non_ignored_aloan_in_abstraction (meta : Meta.meta) (abs : abs) :
(* There are loan projections over symbolic values *)
Some (SymbolicValue sv)
-let lookup_shared_value_opt (meta : Meta.meta) (ctx : eval_ctx)
+let lookup_shared_value_opt (span : Meta.span) (ctx : eval_ctx)
(bid : BorrowId.id) : typed_value option =
- match lookup_loan_opt meta ek_all bid ctx with
+ match lookup_loan_opt span ek_all bid ctx with
| None -> None
| Some (_, lc) -> (
match lc with
@@ -1236,6 +1236,6 @@ let lookup_shared_value_opt (meta : Meta.meta) (ctx : eval_ctx)
Some sv
| _ -> None)
-let lookup_shared_value (meta : Meta.meta) (ctx : eval_ctx) (bid : BorrowId.id)
+let lookup_shared_value (span : Meta.span) (ctx : eval_ctx) (bid : BorrowId.id)
: typed_value =
- Option.get (lookup_shared_value_opt meta ctx bid)
+ Option.get (lookup_shared_value_opt span ctx bid)
diff --git a/compiler/InterpreterExpansion.ml b/compiler/InterpreterExpansion.ml
index 39c9bd4a..388d7382 100644
--- a/compiler/InterpreterExpansion.ml
+++ b/compiler/InterpreterExpansion.ml
@@ -49,14 +49,14 @@ type proj_kind = LoanProj | BorrowProj
it would make things clearer.
*)
let apply_symbolic_expansion_to_target_avalues (config : config)
- (meta : Meta.meta) (allow_reborrows : bool) (proj_kind : proj_kind)
+ (span : Meta.span) (allow_reborrows : bool) (proj_kind : proj_kind)
(original_sv : symbolic_value) (expansion : symbolic_expansion)
(ctx : eval_ctx) : eval_ctx =
(* Symbolic values contained in the expansion might contain already ended regions *)
let check_symbolic_no_ended = false in
(* Prepare reborrows registration *)
let fresh_reborrow, apply_registered_reborrows =
- prepare_reborrows config meta allow_reborrows
+ prepare_reborrows config span allow_reborrows
in
(* Visitor to apply the expansion *)
let obj =
@@ -66,7 +66,7 @@ let apply_symbolic_expansion_to_target_avalues (config : config)
(** When visiting an abstraction, we remember the regions it owns to be
able to properly reduce projectors when expanding symbolic values *)
method! visit_abs current_abs abs =
- sanity_check __FILE__ __LINE__ (Option.is_none current_abs) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none current_abs) span;
let current_abs = Some abs in
super#visit_abs current_abs abs
@@ -80,7 +80,7 @@ let apply_symbolic_expansion_to_target_avalues (config : config)
| AProjLoans (sv, _) | AProjBorrows (sv, _) ->
sanity_check __FILE__ __LINE__
(not (same_symbolic_id sv original_sv))
- meta
+ span
| AEndedProjLoans _ | AEndedProjBorrows _ | AIgnoredProjBorrows -> ());
super#visit_aproj current_abs aproj
@@ -100,10 +100,10 @@ let apply_symbolic_expansion_to_target_avalues (config : config)
(* Check if this is the symbolic value we are looking for *)
if same_symbolic_id sv original_sv then (
(* There mustn't be any given back values *)
- sanity_check __FILE__ __LINE__ (given_back = []) meta;
+ sanity_check __FILE__ __LINE__ (given_back = []) span;
(* Apply the projector *)
let projected_value =
- apply_proj_loans_on_symbolic_expansion meta proj_regions
+ apply_proj_loans_on_symbolic_expansion span proj_regions
ancestors_regions expansion original_sv.sv_ty
in
(* Replace *)
@@ -120,12 +120,12 @@ let apply_symbolic_expansion_to_target_avalues (config : config)
(* WARNING: we mustn't get there if the expansion is for a shared
* reference. *)
let expansion =
- symbolic_expansion_non_shared_borrow_to_value meta original_sv
+ symbolic_expansion_non_shared_borrow_to_value span original_sv
expansion
in
(* Apply the projector *)
let projected_value =
- apply_proj_borrows meta check_symbolic_no_ended ctx
+ apply_proj_borrows span check_symbolic_no_ended ctx
fresh_reborrow proj_regions ancestors_regions expansion
proj_ty
in
@@ -149,11 +149,11 @@ let apply_symbolic_expansion_to_target_avalues (config : config)
(** Auxiliary function.
Apply a symbolic expansion to avalues in a context.
*)
-let apply_symbolic_expansion_to_avalues (config : config) (meta : Meta.meta)
+let apply_symbolic_expansion_to_avalues (config : config) (span : Meta.span)
(allow_reborrows : bool) (original_sv : symbolic_value)
(expansion : symbolic_expansion) (ctx : eval_ctx) : eval_ctx =
let apply_expansion proj_kind ctx =
- apply_symbolic_expansion_to_target_avalues config meta allow_reborrows
+ apply_symbolic_expansion_to_target_avalues config span allow_reborrows
proj_kind original_sv expansion ctx
in
(* First target the loan projectors, then the borrow projectors *)
@@ -166,12 +166,12 @@ let apply_symbolic_expansion_to_avalues (config : config) (meta : Meta.meta)
Simply replace the symbolic values (*not avalues*) in the context with
a given value. Will break invariants if not used properly.
*)
-let replace_symbolic_values (meta : Meta.meta) (at_most_once : bool)
+let replace_symbolic_values (span : Meta.span) (at_most_once : bool)
(original_sv : symbolic_value) (nv : value) (ctx : eval_ctx) : eval_ctx =
(* Count *)
let replaced = ref false in
let replace () =
- if at_most_once then sanity_check __FILE__ __LINE__ (not !replaced) meta;
+ if at_most_once then sanity_check __FILE__ __LINE__ (not !replaced) span;
replaced := true;
nv
in
@@ -190,18 +190,18 @@ let replace_symbolic_values (meta : Meta.meta) (at_most_once : bool)
(* Return *)
ctx
-let apply_symbolic_expansion_non_borrow (config : config) (meta : Meta.meta)
+let apply_symbolic_expansion_non_borrow (config : config) (span : Meta.span)
(original_sv : symbolic_value) (ctx : eval_ctx)
(expansion : symbolic_expansion) : eval_ctx =
(* Apply the expansion to non-abstraction values *)
- let nv = symbolic_expansion_non_borrow_to_value meta original_sv expansion in
+ let nv = symbolic_expansion_non_borrow_to_value span original_sv expansion in
let at_most_once = false in
let ctx =
- replace_symbolic_values meta at_most_once original_sv nv.value ctx
+ replace_symbolic_values span at_most_once original_sv nv.value ctx
in
(* Apply the expansion to abstraction values *)
let allow_reborrows = false in
- apply_symbolic_expansion_to_avalues config meta allow_reborrows original_sv
+ apply_symbolic_expansion_to_avalues config span allow_reborrows original_sv
expansion ctx
(** Compute the expansion of a non-assumed (i.e.: not [Box], etc.)
@@ -214,7 +214,7 @@ let apply_symbolic_expansion_non_borrow (config : config) (meta : Meta.meta)
[expand_enumerations] controls the expansion of enumerations: if false, it
doesn't allow the expansion of enumerations *containing several variants*.
*)
-let compute_expanded_symbolic_non_assumed_adt_value (meta : Meta.meta)
+let compute_expanded_symbolic_non_assumed_adt_value (span : Meta.span)
(expand_enumerations : bool) (def_id : TypeDeclId.id)
(generics : generic_args) (ctx : eval_ctx) : symbolic_expansion list =
(* Lookup the definition and check if it is an enumeration with several
@@ -222,21 +222,21 @@ let compute_expanded_symbolic_non_assumed_adt_value (meta : Meta.meta)
let def = ctx_lookup_type_decl ctx def_id in
sanity_check __FILE__ __LINE__
(List.length generics.regions = List.length def.generics.regions)
- meta;
+ span;
(* Retrieve, for every variant, the list of its instantiated field types *)
let variants_fields_types =
- AssociatedTypes.type_decl_get_inst_norm_variants_fields_rtypes meta ctx def
+ AssociatedTypes.type_decl_get_inst_norm_variants_fields_rtypes span ctx def
generics
in
(* Check if there is strictly more than one variant *)
if List.length variants_fields_types > 1 && not expand_enumerations then
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Not allowed to expand enumerations with several variants";
(* Initialize the expanded value for a given variant *)
let initialize ((variant_id, field_types) : VariantId.id option * rty list) :
symbolic_expansion =
let field_values =
- List.map (fun (ty : rty) -> mk_fresh_symbolic_value meta ty) field_types
+ List.map (fun (ty : rty) -> mk_fresh_symbolic_value span ty) field_types
in
let see = SeAdt (variant_id, field_values) in
see
@@ -244,20 +244,20 @@ let compute_expanded_symbolic_non_assumed_adt_value (meta : Meta.meta)
(* Initialize all the expanded values of all the variants *)
List.map initialize variants_fields_types
-let compute_expanded_symbolic_tuple_value (meta : Meta.meta)
+let compute_expanded_symbolic_tuple_value (span : Meta.span)
(field_types : rty list) : symbolic_expansion =
(* Generate the field values *)
let field_values =
- List.map (fun sv_ty -> mk_fresh_symbolic_value meta sv_ty) field_types
+ List.map (fun sv_ty -> mk_fresh_symbolic_value span sv_ty) field_types
in
let variant_id = None in
let see = SeAdt (variant_id, field_values) in
see
-let compute_expanded_symbolic_box_value (meta : Meta.meta) (boxed_ty : rty) :
+let compute_expanded_symbolic_box_value (span : Meta.span) (boxed_ty : rty) :
symbolic_expansion =
(* Introduce a fresh symbolic value *)
- let boxed_value = mk_fresh_symbolic_value meta boxed_ty in
+ let boxed_value = mk_fresh_symbolic_value span boxed_ty in
let see = SeAdt (None, [ boxed_value ]) in
see
@@ -270,22 +270,22 @@ let compute_expanded_symbolic_box_value (meta : Meta.meta) (boxed_ty : rty) :
[expand_enumerations] controls the expansion of enumerations: if [false], it
doesn't allow the expansion of enumerations *containing several variants*.
*)
-let compute_expanded_symbolic_adt_value (meta : Meta.meta)
+let compute_expanded_symbolic_adt_value (span : Meta.span)
(expand_enumerations : bool) (adt_id : type_id) (generics : generic_args)
(ctx : eval_ctx) : symbolic_expansion list =
match (adt_id, generics.regions, generics.types) with
| TAdtId def_id, _, _ ->
- compute_expanded_symbolic_non_assumed_adt_value meta expand_enumerations
+ compute_expanded_symbolic_non_assumed_adt_value span expand_enumerations
def_id generics ctx
| TTuple, [], _ ->
- [ compute_expanded_symbolic_tuple_value meta generics.types ]
+ [ compute_expanded_symbolic_tuple_value span generics.types ]
| TAssumed TBox, [], [ boxed_ty ] ->
- [ compute_expanded_symbolic_box_value meta boxed_ty ]
+ [ compute_expanded_symbolic_box_value span boxed_ty ]
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"compute_expanded_symbolic_adt_value: unexpected combination"
-let expand_symbolic_value_shared_borrow (config : config) (meta : Meta.meta)
+let expand_symbolic_value_shared_borrow (config : config) (span : Meta.span)
(original_sv : symbolic_value) (original_sv_place : SA.mplace option)
(ref_ty : rty) : cm_fun =
fun ctx ->
@@ -318,11 +318,11 @@ let expand_symbolic_value_shared_borrow (config : config) (meta : Meta.meta)
Some [ AsbBorrow bid; shared_asb ]
else (* Not in the set: ignore *)
Some [ shared_asb ]
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
else None
in
(* The fresh symbolic value for the shared value *)
- let shared_sv = mk_fresh_symbolic_value meta ref_ty in
+ let shared_sv = mk_fresh_symbolic_value span ref_ty in
(* Visitor to replace the projectors on borrows *)
let obj =
object (self)
@@ -335,7 +335,7 @@ let expand_symbolic_value_shared_borrow (config : config) (meta : Meta.meta)
else super#visit_VSymbolic env sv
method! visit_EAbs proj_regions abs =
- sanity_check __FILE__ __LINE__ (Option.is_none proj_regions) meta;
+ sanity_check __FILE__ __LINE__ (Option.is_none proj_regions) span;
let proj_regions = Some abs.regions in
super#visit_EAbs proj_regions abs
@@ -362,7 +362,7 @@ let expand_symbolic_value_shared_borrow (config : config) (meta : Meta.meta)
| AProjLoans (sv, _) | AProjBorrows (sv, _) ->
sanity_check __FILE__ __LINE__
(not (same_symbolic_id sv original_sv))
- meta
+ span
| AEndedProjLoans _ | AEndedProjBorrows _ | AIgnoredProjBorrows -> ());
super#visit_aproj proj_regions aproj
@@ -388,62 +388,62 @@ let expand_symbolic_value_shared_borrow (config : config) (meta : Meta.meta)
let ctx = obj#visit_eval_ctx None ctx in
(* Finally, replace the projectors on loans *)
let bids = !borrows in
- sanity_check __FILE__ __LINE__ (not (BorrowId.Set.is_empty bids)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Set.is_empty bids)) span;
let see = SeSharedRef (bids, shared_sv) in
let allow_reborrows = true in
let ctx =
- apply_symbolic_expansion_to_avalues config meta allow_reborrows original_sv
+ apply_symbolic_expansion_to_avalues config span allow_reborrows original_sv
see ctx
in
( ctx,
(* Update the synthesized program *)
- S.synthesize_symbolic_expansion_no_branching meta original_sv
+ S.synthesize_symbolic_expansion_no_branching span original_sv
original_sv_place see )
(** TODO: simplify and merge with the other expansion function *)
-let expand_symbolic_value_borrow (config : config) (meta : Meta.meta)
+let expand_symbolic_value_borrow (config : config) (span : Meta.span)
(original_sv : symbolic_value) (original_sv_place : SA.mplace option)
(region : region) (ref_ty : rty) (rkind : ref_kind) : cm_fun =
fun ctx ->
- sanity_check __FILE__ __LINE__ (region <> RErased) meta;
+ sanity_check __FILE__ __LINE__ (region <> RErased) span;
(* Check that we are allowed to expand the reference *)
sanity_check __FILE__ __LINE__
(not (region_in_set region ctx.ended_regions))
- meta;
+ span;
(* Match on the reference kind *)
match rkind with
| RMut ->
(* Simple case: simply create a fresh symbolic value and a fresh
* borrow id *)
- let sv = mk_fresh_symbolic_value meta ref_ty in
+ let sv = mk_fresh_symbolic_value span ref_ty in
let bid = fresh_borrow_id () in
let see = SeMutRef (bid, sv) in
(* Expand the symbolic values - we simply perform a substitution (and
* check that we perform exactly one substitution) *)
let nv =
- symbolic_expansion_non_shared_borrow_to_value meta original_sv see
+ symbolic_expansion_non_shared_borrow_to_value span original_sv see
in
let at_most_once = true in
let ctx =
- replace_symbolic_values meta at_most_once original_sv nv.value ctx
+ replace_symbolic_values span at_most_once original_sv nv.value ctx
in
(* Expand the symbolic avalues *)
let allow_reborrows = true in
let ctx =
- apply_symbolic_expansion_to_avalues config meta allow_reborrows
+ apply_symbolic_expansion_to_avalues config span allow_reborrows
original_sv see ctx
in
(* Apply the continuation *)
( ctx,
fun e ->
(* Update the synthesized program *)
- S.synthesize_symbolic_expansion_no_branching meta original_sv
+ S.synthesize_symbolic_expansion_no_branching span original_sv
original_sv_place see e )
| RShared ->
- expand_symbolic_value_shared_borrow config meta original_sv
+ expand_symbolic_value_shared_borrow config span original_sv
original_sv_place ref_ty ctx
-let expand_symbolic_bool (config : config) (meta : Meta.meta)
+let expand_symbolic_bool (config : config) (span : Meta.span)
(sv : symbolic_value) (sv_place : SA.mplace option) :
eval_ctx ->
(eval_ctx * eval_ctx)
@@ -453,26 +453,26 @@ let expand_symbolic_bool (config : config) (meta : Meta.meta)
(* Compute the expanded value *)
let original_sv = sv in
let rty = original_sv.sv_ty in
- sanity_check __FILE__ __LINE__ (rty = TLiteral TBool) meta;
+ sanity_check __FILE__ __LINE__ (rty = TLiteral TBool) span;
(* Expand the symbolic value to true or false and continue execution *)
let see_true = SeLiteral (VBool true) in
let see_false = SeLiteral (VBool false) in
let seel = [ Some see_true; Some see_false ] in
(* Apply the symbolic expansion *)
let apply_expansion =
- apply_symbolic_expansion_non_borrow config meta sv ctx
+ apply_symbolic_expansion_non_borrow config span sv ctx
in
let ctx_true = apply_expansion see_true in
let ctx_false = apply_expansion see_false in
(* Compute the continuation to build the expression *)
let cf e =
let el = match e with Some (a, b) -> Some [ a; b ] | None -> None in
- S.synthesize_symbolic_expansion meta sv sv_place seel el
+ S.synthesize_symbolic_expansion span sv sv_place seel el
in
(* Return *)
((ctx_true, ctx_false), cf)
-let expand_symbolic_value_no_branching (config : config) (meta : Meta.meta)
+let expand_symbolic_value_no_branching (config : config) (span : Meta.span)
(sv : symbolic_value) (sv_place : SA.mplace option) : cm_fun =
fun ctx ->
(* Debug *)
@@ -493,26 +493,26 @@ let expand_symbolic_value_no_branching (config : config) (meta : Meta.meta)
(* Compute the expanded value *)
let allow_branching = false in
let seel =
- compute_expanded_symbolic_adt_value meta allow_branching adt_id
+ compute_expanded_symbolic_adt_value span allow_branching adt_id
generics ctx
in
(* There should be exacly one branch *)
let see = Collections.List.to_cons_nil seel in
(* Apply in the context *)
let ctx =
- apply_symbolic_expansion_non_borrow config meta original_sv ctx see
+ apply_symbolic_expansion_non_borrow config span original_sv ctx see
in
(* Return*)
( ctx,
(* Update the synthesized program *)
- S.synthesize_symbolic_expansion_no_branching meta original_sv
+ S.synthesize_symbolic_expansion_no_branching span original_sv
original_sv_place see )
(* Borrows *)
| TRef (region, ref_ty, rkind) ->
- expand_symbolic_value_borrow config meta original_sv original_sv_place
+ expand_symbolic_value_borrow config span original_sv original_sv_place
region ref_ty rkind ctx
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("expand_symbolic_value_no_branching: unexpected type: "
^ show_rty rty)
in
@@ -522,18 +522,18 @@ let expand_symbolic_value_no_branching (config : config) (meta : Meta.meta)
("expand_symbolic_value_no_branching: "
^ symbolic_value_to_string ctx0 sv
^ "\n\n- original context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string ~span:(Some span) ctx0
^ "\n\n- new context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n"));
(* Sanity check: the symbolic value has disappeared *)
sanity_check __FILE__ __LINE__
(not (symbolic_value_id_in_ctx original_sv.sv_id ctx))
- meta;
+ span;
(* Return *)
(ctx, cc)
-let expand_symbolic_adt (config : config) (meta : Meta.meta)
+let expand_symbolic_adt (config : config) (span : Meta.span)
(sv : symbolic_value) (sv_place : SA.mplace option) :
eval_ctx ->
eval_ctx list * (SymbolicAst.expression list option -> eval_result) =
@@ -552,21 +552,21 @@ let expand_symbolic_adt (config : config) (meta : Meta.meta)
let allow_branching = true in
(* Compute the expanded value *)
let seel =
- compute_expanded_symbolic_adt_value meta allow_branching adt_id generics
+ compute_expanded_symbolic_adt_value span allow_branching adt_id generics
ctx
in
(* Apply *)
let ctx_branches =
- List.map (apply_symbolic_expansion_non_borrow config meta sv ctx) seel
+ List.map (apply_symbolic_expansion_non_borrow config span sv ctx) seel
in
( ctx_branches,
- S.synthesize_symbolic_expansion meta sv original_sv_place
+ S.synthesize_symbolic_expansion span sv original_sv_place
(List.map (fun el -> Some el) seel) )
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("expand_symbolic_adt: unexpected type: " ^ show_rty rty)
-let expand_symbolic_int (config : config) (meta : Meta.meta)
+let expand_symbolic_int (config : config) (span : Meta.span)
(sv : symbolic_value) (sv_place : SA.mplace option)
(int_type : integer_type) (tgts : scalar_value list) :
eval_ctx ->
@@ -575,7 +575,7 @@ let expand_symbolic_int (config : config) (meta : Meta.meta)
eval_result) =
fun ctx ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (sv.sv_ty = TLiteral (TInteger int_type)) meta;
+ sanity_check __FILE__ __LINE__ (sv.sv_ty = TLiteral (TInteger int_type)) span;
(* For all the branches of the switch, we expand the symbolic value
* to the value given by the branch and execute the branch statement.
* For the otherwise branch, we leave the symbolic value as it is
@@ -585,7 +585,7 @@ let expand_symbolic_int (config : config) (meta : Meta.meta)
(* Substitute the symbolic values to generate the contexts in the branches *)
let seel = List.map (fun v -> SeLiteral (VScalar v)) tgts in
let ctx_branches =
- List.map (apply_symbolic_expansion_non_borrow config meta sv ctx) seel
+ List.map (apply_symbolic_expansion_non_borrow config span sv ctx) seel
in
let ctx_otherwise = ctx in
(* Update the symbolic ast *)
@@ -594,7 +594,7 @@ let expand_symbolic_int (config : config) (meta : Meta.meta)
| None -> None
| Some (el, e) ->
let seel = List.map (fun x -> Some x) seel in
- S.synthesize_symbolic_expansion meta sv sv_place (seel @ [ None ])
+ S.synthesize_symbolic_expansion span sv sv_place (seel @ [ None ])
(Some (el @ [ e ]))
in
((ctx_branches, ctx_otherwise), cf)
@@ -607,7 +607,7 @@ let expand_symbolic_int (config : config) (meta : Meta.meta)
an enumeration with strictly more than one variant, a slice, etc.) or if
we need to expand a recursive type (because this leads to looping).
*)
-let greedy_expand_symbolics_with_borrows (config : config) (meta : Meta.meta) :
+let greedy_expand_symbolics_with_borrows (config : config) (span : Meta.span) :
cm_fun =
fun ctx ->
(* The visitor object, to look for symbolic values in the concrete environment *)
@@ -649,30 +649,30 @@ let greedy_expand_symbolics_with_borrows (config : config) (meta : Meta.meta) :
(match def.kind with
| Struct _ | Enum ([] | [ _ ]) -> ()
| Enum (_ :: _) ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Attempted to greedily expand a symbolic enumeration with > \
1 variants (option [greedy_expand_symbolics_with_borrows] \
of [config]): "
^ name_to_string ctx def.name)
| Opaque ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Attempted to greedily expand an opaque type");
(* Also, we need to check if the definition is recursive *)
if ctx_type_decl_is_rec ctx def_id then
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Attempted to greedily expand a recursive definition (option \
[greedy_expand_symbolics_with_borrows] of [config]): "
^ name_to_string ctx def.name)
- else expand_symbolic_value_no_branching config meta sv None ctx
+ else expand_symbolic_value_no_branching config span sv None ctx
| TAdt ((TTuple | TAssumed TBox), _) | TRef (_, _, _) ->
(* Ok *)
- expand_symbolic_value_no_branching config meta sv None ctx
+ expand_symbolic_value_no_branching config span sv None ctx
| TAdt (TAssumed (TArray | TSlice | TStr), _) ->
(* We can't expand those *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Attempted to greedily expand an ADT which can't be expanded "
| TVar _ | TLiteral _ | TNever | TTraitType _ | TArrow _ | TRawPtr _ ->
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
(* Compose and continue *)
comp cc (expand ctx)
@@ -680,10 +680,10 @@ let greedy_expand_symbolics_with_borrows (config : config) (meta : Meta.meta) :
(* Apply *)
expand ctx
-let greedy_expand_symbolic_values (config : config) (meta : Meta.meta) : cm_fun
+let greedy_expand_symbolic_values (config : config) (span : Meta.span) : cm_fun
=
fun ctx ->
if Config.greedy_expand_symbolics_with_borrows then (
log#ldebug (lazy "greedy_expand_symbolic_values");
- greedy_expand_symbolics_with_borrows config meta ctx)
+ greedy_expand_symbolics_with_borrows config span ctx)
else (ctx, fun e -> e)
diff --git a/compiler/InterpreterExpansion.mli b/compiler/InterpreterExpansion.mli
index 7140d55f..7f8c3a0a 100644
--- a/compiler/InterpreterExpansion.mli
+++ b/compiler/InterpreterExpansion.mli
@@ -13,7 +13,7 @@ type proj_kind = LoanProj | BorrowProj
*)
val apply_symbolic_expansion_non_borrow :
config ->
- Meta.meta ->
+ Meta.span ->
symbolic_value ->
eval_ctx ->
symbolic_expansion ->
@@ -21,20 +21,20 @@ val apply_symbolic_expansion_non_borrow :
(** Expand a symhbolic value, without branching *)
val expand_symbolic_value_no_branching :
- config -> Meta.meta -> symbolic_value -> SA.mplace option -> cm_fun
+ config -> Meta.span -> symbolic_value -> SA.mplace option -> cm_fun
(** Expand a symbolic enumeration (leads to branching if the enumeration has
more than one variant).
Parameters:
- [config]
- - [meta]
+ - [span]
- [sv]
- [sv_place]
*)
val expand_symbolic_adt :
config ->
- Meta.meta ->
+ Meta.span ->
symbolic_value ->
SA.mplace option ->
eval_ctx ->
@@ -46,7 +46,7 @@ val expand_symbolic_adt :
*)
val expand_symbolic_bool :
config ->
- Meta.meta ->
+ Meta.span ->
symbolic_value ->
SA.mplace option ->
eval_ctx ->
@@ -69,7 +69,7 @@ val expand_symbolic_bool :
*)
val expand_symbolic_int :
config ->
- Meta.meta ->
+ Meta.span ->
symbolic_value ->
SA.mplace option ->
integer_type ->
@@ -82,4 +82,4 @@ val expand_symbolic_int :
(** If this mode is activated through the [config], greedily expand the symbolic
values which need to be expanded. See {!type:Contexts.config} for more information.
*)
-val greedy_expand_symbolic_values : config -> Meta.meta -> cm_fun
+val greedy_expand_symbolic_values : config -> Meta.span -> cm_fun
diff --git a/compiler/InterpreterExpressions.ml b/compiler/InterpreterExpressions.ml
index 5b05dce8..2223897c 100644
--- a/compiler/InterpreterExpressions.ml
+++ b/compiler/InterpreterExpressions.ml
@@ -24,21 +24,21 @@ let log = Logging.expressions_log
Note that the place should have been prepared so that there are no remaining
loans.
*)
-let expand_primitively_copyable_at_place (config : config) (meta : Meta.meta)
+let expand_primitively_copyable_at_place (config : config) (span : Meta.span)
(access : access_kind) (p : place) : cm_fun =
fun ctx ->
(* Small helper *)
let rec expand : cm_fun =
fun ctx ->
- let v = read_place meta access p ctx in
+ let v = read_place span access p ctx in
match
find_first_primitively_copyable_sv_with_borrows ctx.type_ctx.type_infos v
with
| None -> (ctx, fun e -> e)
| Some sv ->
let ctx, cc =
- expand_symbolic_value_no_branching config meta sv
- (Some (mk_mplace meta p ctx))
+ expand_symbolic_value_no_branching config span sv
+ (Some (mk_mplace span p ctx))
ctx
in
comp cc (expand ctx)
@@ -51,50 +51,50 @@ let expand_primitively_copyable_at_place (config : config) (meta : Meta.meta)
We check that the value *doesn't contain bottoms or reserved
borrows*.
*)
-let read_place_check (meta : Meta.meta) (access : access_kind) (p : place)
+let read_place_check (span : Meta.span) (access : access_kind) (p : place)
(ctx : eval_ctx) : typed_value =
- let v = read_place meta access p ctx in
+ let v = read_place span access p ctx in
(* Check that there are no bottoms in the value *)
cassert __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions v))
- meta "There should be no bottoms in the value";
+ span "There should be no bottoms in the value";
(* Check that there are no reserved borrows in the value *)
cassert __FILE__ __LINE__
(not (reserved_in_value v))
- meta "There should be no reserved borrows in the value";
+ span "There should be no reserved borrows in the value";
(* Return *)
v
-let access_rplace_reorganize_and_read (config : config) (meta : Meta.meta)
+let access_rplace_reorganize_and_read (config : config) (span : Meta.span)
(expand_prim_copy : bool) (access : access_kind) (p : place)
(ctx : eval_ctx) : typed_value * eval_ctx * (eval_result -> eval_result) =
(* Make sure we can evaluate the path *)
- let ctx, cc = update_ctx_along_read_place config meta access p ctx in
+ let ctx, cc = update_ctx_along_read_place config span access p ctx in
(* End the proper loans at the place itself *)
- let ctx, cc = comp cc (end_loans_at_place config meta access p ctx) in
+ let ctx, cc = comp cc (end_loans_at_place config span access p ctx) in
(* Expand the copyable values which contain borrows (which are necessarily shared
* borrows) *)
let ctx, cc =
comp cc
(if expand_prim_copy then
- expand_primitively_copyable_at_place config meta access p ctx
+ expand_primitively_copyable_at_place config span access p ctx
else (ctx, fun e -> e))
in
(* Read the place - note that this checks that the value doesn't contain bottoms *)
- let ty_value = read_place_check meta access p ctx in
+ let ty_value = read_place_check span access p ctx in
(* Compose *)
(ty_value, ctx, cc)
-let access_rplace_reorganize (config : config) (meta : Meta.meta)
+let access_rplace_reorganize (config : config) (span : Meta.span)
(expand_prim_copy : bool) (access : access_kind) (p : place) : cm_fun =
fun ctx ->
let _, ctx, f =
- access_rplace_reorganize_and_read config meta expand_prim_copy access p ctx
+ access_rplace_reorganize_and_read config span expand_prim_copy access p ctx
in
(ctx, f)
(** Convert an operand constant operand value to a typed value *)
-let literal_to_typed_value (meta : Meta.meta) (ty : literal_type) (cv : literal)
+let literal_to_typed_value (span : Meta.span) (ty : literal_type) (cv : literal)
: typed_value =
(* Check the type while converting - we actually need some information
* contained in the type *)
@@ -108,11 +108,11 @@ let literal_to_typed_value (meta : Meta.meta) (ty : literal_type) (cv : literal)
| TChar, VChar v -> { value = VLiteral (VChar v); ty = TLiteral ty }
| TInteger int_ty, VScalar v ->
(* Check the type and the ranges *)
- sanity_check __FILE__ __LINE__ (int_ty = v.int_ty) meta;
- sanity_check __FILE__ __LINE__ (check_scalar_value_in_range v) meta;
+ sanity_check __FILE__ __LINE__ (int_ty = v.int_ty) span;
+ sanity_check __FILE__ __LINE__ (check_scalar_value_in_range v) span;
{ value = VLiteral (VScalar v); ty = TLiteral ty }
(* Remaining cases (invalid) *)
- | _, _ -> craise __FILE__ __LINE__ meta "Improperly typed constant value"
+ | _, _ -> craise __FILE__ __LINE__ span "Improperly typed constant value"
(** Copy a value, and return the resulting value.
@@ -125,14 +125,14 @@ let literal_to_typed_value (meta : Meta.meta) (ty : literal_type) (cv : literal)
parameter to control this copy ([allow_adt_copy]). Note that here by ADT we
mean the user-defined ADTs (not tuples or assumed types).
*)
-let rec copy_value (meta : Meta.meta) (allow_adt_copy : bool) (config : config)
+let rec copy_value (span : Meta.span) (allow_adt_copy : bool) (config : config)
(ctx : eval_ctx) (v : typed_value) : eval_ctx * typed_value =
log#ldebug
(lazy
("copy_value: "
- ^ typed_value_to_string ~meta:(Some meta) ctx v
+ ^ typed_value_to_string ~span:(Some span) ctx v
^ "\n- context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Remark: at some point we rewrote this function to use iterators, but then
* we reverted the changes: the result was less clear actually. In particular,
* the fact that we have exhaustive matches below makes very obvious the cases
@@ -143,12 +143,12 @@ let rec copy_value (meta : Meta.meta) (allow_adt_copy : bool) (config : config)
(* Sanity check *)
(match v.ty with
| TAdt (TAssumed TBox, _) ->
- exec_raise __FILE__ __LINE__ meta
+ exec_raise __FILE__ __LINE__ span
"Can't copy an assumed value other than Option"
| TAdt (TAdtId _, _) as ty ->
sanity_check __FILE__ __LINE__
(allow_adt_copy || ty_is_copyable ty)
- meta
+ span
| TAdt (TTuple, _) -> () (* Ok *)
| TAdt
( TAssumed (TSlice | TArray),
@@ -158,16 +158,16 @@ let rec copy_value (meta : Meta.meta) (allow_adt_copy : bool) (config : config)
const_generics = [];
trait_refs = [];
} ) ->
- exec_assert __FILE__ __LINE__ (ty_is_copyable ty) meta
+ exec_assert __FILE__ __LINE__ (ty_is_copyable ty) span
"The type is not primitively copyable"
- | _ -> exec_raise __FILE__ __LINE__ meta "Unreachable");
+ | _ -> exec_raise __FILE__ __LINE__ span "Unreachable");
let ctx, fields =
List.fold_left_map
- (copy_value meta allow_adt_copy config)
+ (copy_value span allow_adt_copy config)
ctx av.field_values
in
(ctx, { v with value = VAdt { av with field_values = fields } })
- | VBottom -> exec_raise __FILE__ __LINE__ meta "Can't copy ⊥"
+ | VBottom -> exec_raise __FILE__ __LINE__ span "Can't copy ⊥"
| VBorrow bc -> (
(* We can only copy shared borrows *)
match bc with
@@ -175,20 +175,20 @@ let rec copy_value (meta : Meta.meta) (allow_adt_copy : bool) (config : config)
(* We need to create a new borrow id for the copied borrow, and
* update the context accordingly *)
let bid' = fresh_borrow_id () in
- let ctx = InterpreterBorrows.reborrow_shared meta bid bid' ctx in
+ let ctx = InterpreterBorrows.reborrow_shared span bid bid' ctx in
(ctx, { v with value = VBorrow (VSharedBorrow bid') })
| VMutBorrow (_, _) ->
- exec_raise __FILE__ __LINE__ meta "Can't copy a mutable borrow"
+ exec_raise __FILE__ __LINE__ span "Can't copy a mutable borrow"
| VReservedMutBorrow _ ->
- exec_raise __FILE__ __LINE__ meta "Can't copy a reserved mut borrow")
+ exec_raise __FILE__ __LINE__ span "Can't copy a reserved mut borrow")
| VLoan lc -> (
(* We can only copy shared loans *)
match lc with
| VMutLoan _ ->
- exec_raise __FILE__ __LINE__ meta "Can't copy a mutable loan"
+ exec_raise __FILE__ __LINE__ span "Can't copy a mutable loan"
| VSharedLoan (_, sv) ->
(* We don't copy the shared loan: only the shared value inside *)
- copy_value meta allow_adt_copy config ctx sv)
+ copy_value span allow_adt_copy config ctx sv)
| VSymbolic sp ->
(* We can copy only if the type is "primitively" copyable.
* Note that in the general case, copy is a trait: copying values
@@ -196,7 +196,7 @@ let rec copy_value (meta : Meta.meta) (allow_adt_copy : bool) (config : config)
* for very simple types such as integers, shared borrows, etc. *)
cassert __FILE__ __LINE__
(ty_is_copyable (Substitute.erase_regions sp.sv_ty))
- meta "Not primitively copyable";
+ span "Not primitively copyable";
(* If the type is copyable, we simply return the current value. Side
* remark: what is important to look at when copying symbolic values
* is symbolic expansion. The important subcase is the expansion of shared
@@ -242,7 +242,7 @@ let rec copy_value (meta : Meta.meta) (allow_adt_copy : bool) (config : config)
what we do in the formalization (because we don't enforce the same constraints
as MIR in the formalization).
*)
-let prepare_eval_operand_reorganize (config : config) (meta : Meta.meta)
+let prepare_eval_operand_reorganize (config : config) (span : Meta.span)
(op : operand) : cm_fun =
fun ctx ->
match op with
@@ -254,15 +254,15 @@ let prepare_eval_operand_reorganize (config : config) (meta : Meta.meta)
let access = Read in
(* Expand the symbolic values, if necessary *)
let expand_prim_copy = true in
- access_rplace_reorganize config meta expand_prim_copy access p ctx
+ access_rplace_reorganize config span expand_prim_copy access p ctx
| Move p ->
(* Access the value *)
let access = Move in
let expand_prim_copy = false in
- access_rplace_reorganize config meta expand_prim_copy access p ctx
+ access_rplace_reorganize config span expand_prim_copy access p ctx
(** Evaluate an operand, without reorganizing the context before *)
-let eval_operand_no_reorganize (config : config) (meta : Meta.meta)
+let eval_operand_no_reorganize (config : config) (span : Meta.span)
(op : operand) (ctx : eval_ctx) :
typed_value * eval_ctx * (eval_result -> eval_result) =
(* Debug *)
@@ -270,21 +270,21 @@ let eval_operand_no_reorganize (config : config) (meta : Meta.meta)
(lazy
("eval_operand_no_reorganize: op: " ^ operand_to_string ctx op
^ "\n- ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n"));
(* Evaluate *)
match op with
| Constant cv -> (
match cv.value with
| CLiteral lit ->
- ( literal_to_typed_value meta (ty_as_literal cv.ty) lit,
+ ( literal_to_typed_value span (ty_as_literal cv.ty) lit,
ctx,
fun e -> e )
| CTraitConst (trait_ref, const_name) ->
let ctx0 = ctx in
(* Simply introduce a fresh symbolic value *)
let ty = cv.ty in
- let v = mk_fresh_symbolic_typed_value meta ty in
+ let v = mk_fresh_symbolic_typed_value span ty in
(* Wrap the generated expression *)
let cf e =
match e with
@@ -294,7 +294,7 @@ let eval_operand_no_reorganize (config : config) (meta : Meta.meta)
(SymbolicAst.IntroSymbolic
( ctx0,
None,
- value_as_symbolic meta v.value,
+ value_as_symbolic span v.value,
SymbolicAst.VaTraitConstValue (trait_ref, const_name),
e ))
in
@@ -313,10 +313,10 @@ let eval_operand_no_reorganize (config : config) (meta : Meta.meta)
| ConcreteMode ->
(* Copy the value - this is more of a sanity check *)
let allow_adt_copy = false in
- copy_value meta allow_adt_copy config ctx cv
+ copy_value span allow_adt_copy config ctx cv
| SymbolicMode ->
(* We use the looked up value only for its type *)
- let v = mk_fresh_symbolic_typed_value meta cv.ty in
+ let v = mk_fresh_symbolic_typed_value span cv.ty in
(ctx, v)
in
(* We have to wrap the generated expression *)
@@ -326,96 +326,96 @@ let eval_operand_no_reorganize (config : config) (meta : Meta.meta)
| Some e ->
(* If we are synthesizing a symbolic AST, it means that we are in symbolic
mode: the value of the const generic is necessarily symbolic. *)
- sanity_check __FILE__ __LINE__ (is_symbolic cv.value) meta;
+ sanity_check __FILE__ __LINE__ (is_symbolic cv.value) span;
(* *)
Some
(SymbolicAst.IntroSymbolic
( ctx0,
None,
- value_as_symbolic meta cv.value,
+ value_as_symbolic span cv.value,
SymbolicAst.VaCgValue vid,
e ))
in
(cv, ctx, cf)
| CFnPtr _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Function pointers are not supported yet")
| Copy p ->
(* Access the value *)
let access = Read in
- let v = read_place_check meta access p ctx in
+ let v = read_place_check span access p ctx in
(* Sanity checks *)
exec_assert __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions v))
- meta "Can not copy a value containing bottom";
+ span "Can not copy a value containing bottom";
sanity_check __FILE__ __LINE__
(Option.is_none
(find_first_primitively_copyable_sv_with_borrows
ctx.type_ctx.type_infos v))
- meta;
+ span;
(* Copy the value *)
let allow_adt_copy = false in
- let ctx, v = copy_value meta allow_adt_copy config ctx v in
+ let ctx, v = copy_value span allow_adt_copy config ctx v in
(v, ctx, fun e -> e)
| Move p ->
(* Access the value *)
let access = Move in
- let v = read_place_check meta access p ctx in
+ let v = read_place_check span access p ctx in
(* Check that there are no bottoms in the value we are about to move *)
exec_assert __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions v))
- meta "There should be no bottoms in the value we are about to move";
+ span "There should be no bottoms in the value we are about to move";
(* Move the value *)
let bottom : typed_value = { value = VBottom; ty = v.ty } in
- let ctx = write_place meta access p bottom ctx in
+ let ctx = write_place span access p bottom ctx in
(v, ctx, fun e -> e)
-let eval_operand (config : config) (meta : Meta.meta) (op : operand)
+let eval_operand (config : config) (span : Meta.span) (op : operand)
(ctx : eval_ctx) : typed_value * eval_ctx * (eval_result -> eval_result) =
(* Debug *)
log#ldebug
(lazy
("eval_operand: op: " ^ operand_to_string ctx op ^ "\n- ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n"));
(* We reorganize the context, then evaluate the operand *)
- let ctx, cc = prepare_eval_operand_reorganize config meta op ctx in
- comp2 cc (eval_operand_no_reorganize config meta op ctx)
+ let ctx, cc = prepare_eval_operand_reorganize config span op ctx in
+ comp2 cc (eval_operand_no_reorganize config span op ctx)
(** Small utility.
See [prepare_eval_operand_reorganize].
*)
-let prepare_eval_operands_reorganize (config : config) (meta : Meta.meta)
+let prepare_eval_operands_reorganize (config : config) (span : Meta.span)
(ops : operand list) : cm_fun =
- fold_left_apply_continuation (prepare_eval_operand_reorganize config meta) ops
+ fold_left_apply_continuation (prepare_eval_operand_reorganize config span) ops
(** Evaluate several operands. *)
-let eval_operands (config : config) (meta : Meta.meta) (ops : operand list)
+let eval_operands (config : config) (span : Meta.span) (ops : operand list)
(ctx : eval_ctx) :
typed_value list * eval_ctx * (eval_result -> eval_result) =
(* Prepare the operands *)
- let ctx, cc = prepare_eval_operands_reorganize config meta ops ctx in
+ let ctx, cc = prepare_eval_operands_reorganize config span ops ctx in
(* Evaluate the operands *)
comp2 cc
- (map_apply_continuation (eval_operand_no_reorganize config meta) ops ctx)
+ (map_apply_continuation (eval_operand_no_reorganize config span) ops ctx)
-let eval_two_operands (config : config) (meta : Meta.meta) (op1 : operand)
+let eval_two_operands (config : config) (span : Meta.span) (op1 : operand)
(op2 : operand) (ctx : eval_ctx) :
(typed_value * typed_value) * eval_ctx * (eval_result -> eval_result) =
- let res, ctx, cc = eval_operands config meta [ op1; op2 ] ctx in
+ let res, ctx, cc = eval_operands config span [ op1; op2 ] ctx in
let res =
match res with
| [ v1; v2 ] -> (v1, v2)
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
(res, ctx, cc)
-let eval_unary_op_concrete (config : config) (meta : Meta.meta) (unop : unop)
+let eval_unary_op_concrete (config : config) (span : Meta.span) (unop : unop)
(op : operand) (ctx : eval_ctx) :
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result) =
(* Evaluate the operand *)
- let v, ctx, cc = eval_operand config meta op ctx in
+ let v, ctx, cc = eval_operand config span op ctx in
(* Apply the unop *)
let r =
match (unop, v.value) with
@@ -428,7 +428,7 @@ let eval_unary_op_concrete (config : config) (meta : Meta.meta) (unop : unop)
| ( Cast (CastScalar (TInteger src_ty, TInteger tgt_ty)),
VLiteral (VScalar sv) ) -> (
(* Cast between integers *)
- sanity_check __FILE__ __LINE__ (src_ty = sv.int_ty) meta;
+ sanity_check __FILE__ __LINE__ (src_ty = sv.int_ty) span;
let i = sv.value in
match mk_scalar tgt_ty i with
| Error _ -> Error EPanic
@@ -451,21 +451,21 @@ let eval_unary_op_concrete (config : config) (meta : Meta.meta) (unop : unop)
if Z.of_int 0 = sv.value then false
else if Z.of_int 1 = sv.value then true
else
- exec_raise __FILE__ __LINE__ meta
+ exec_raise __FILE__ __LINE__ span
"Conversion from int to bool: out of range"
in
let value = VLiteral (VBool b) in
let ty = TLiteral TBool in
Ok { ty; value }
- | _ -> exec_raise __FILE__ __LINE__ meta "Invalid input for unop"
+ | _ -> exec_raise __FILE__ __LINE__ span "Invalid input for unop"
in
(r, ctx, cc)
-let eval_unary_op_symbolic (config : config) (meta : Meta.meta) (unop : unop)
+let eval_unary_op_symbolic (config : config) (span : Meta.span) (unop : unop)
(op : operand) (ctx : eval_ctx) :
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result) =
(* Evaluate the operand *)
- let v, ctx, cc = eval_operand config meta op ctx in
+ let v, ctx, cc = eval_operand config span op ctx in
(* Generate a fresh symbolic value to store the result *)
let res_sv_id = fresh_symbolic_value_id () in
let res_sv_ty =
@@ -473,7 +473,7 @@ let eval_unary_op_symbolic (config : config) (meta : Meta.meta) (unop : unop)
| Not, (TLiteral TBool as lty) -> lty
| Neg, (TLiteral (TInteger _) as lty) -> lty
| Cast (CastScalar (_, tgt_ty)), _ -> TLiteral tgt_ty
- | _ -> exec_raise __FILE__ __LINE__ meta "Invalid input for unop"
+ | _ -> exec_raise __FILE__ __LINE__ span "Invalid input for unop"
in
let res_sv = { sv_id = res_sv_id; sv_ty = res_sv_ty } in
(* Compute the result *)
@@ -482,31 +482,31 @@ let eval_unary_op_symbolic (config : config) (meta : Meta.meta) (unop : unop)
let cc =
cc_comp cc
(synthesize_unary_op ctx unop v
- (mk_opt_place_from_op meta op ctx)
+ (mk_opt_place_from_op span op ctx)
res_sv None)
in
(res, ctx, cc)
-let eval_unary_op (config : config) (meta : Meta.meta) (unop : unop)
+let eval_unary_op (config : config) (span : Meta.span) (unop : unop)
(op : operand) (ctx : eval_ctx) :
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result) =
match config.mode with
- | ConcreteMode -> eval_unary_op_concrete config meta unop op ctx
- | SymbolicMode -> eval_unary_op_symbolic config meta unop op ctx
+ | ConcreteMode -> eval_unary_op_concrete config span unop op ctx
+ | SymbolicMode -> eval_unary_op_symbolic config span unop op ctx
(** Small helper for [eval_binary_op_concrete]: computes the result of applying
the binop *after* the operands have been successfully evaluated
*)
-let eval_binary_op_concrete_compute (meta : Meta.meta) (binop : binop)
+let eval_binary_op_concrete_compute (span : Meta.span) (binop : binop)
(v1 : typed_value) (v2 : typed_value) : (typed_value, eval_error) result =
(* Equality check binops (Eq, Ne) accept values from a wide variety of types.
* The remaining binops only operate on scalars. *)
if binop = Eq || binop = Ne then (
(* Equality operations *)
- exec_assert __FILE__ __LINE__ (v1.ty = v2.ty) meta
+ exec_assert __FILE__ __LINE__ (v1.ty = v2.ty) span
"The arguments given to the binop don't have the same type";
(* Equality/inequality check is primitive only for a subset of types *)
- exec_assert __FILE__ __LINE__ (ty_is_copyable v1.ty) meta
+ exec_assert __FILE__ __LINE__ (ty_is_copyable v1.ty) span
"Type is not primitively copyable";
let b = v1 = v2 in
Ok { value = VLiteral (VBool b); ty = TLiteral TBool })
@@ -522,7 +522,7 @@ let eval_binary_op_concrete_compute (meta : Meta.meta) (binop : binop)
match binop with
| Lt | Le | Ge | Gt ->
(* The two operands must have the same type and the result is a boolean *)
- sanity_check __FILE__ __LINE__ (sv1.int_ty = sv2.int_ty) meta;
+ sanity_check __FILE__ __LINE__ (sv1.int_ty = sv2.int_ty) span;
let b =
match binop with
| Lt -> Z.lt sv1.value sv2.value
@@ -531,14 +531,14 @@ let eval_binary_op_concrete_compute (meta : Meta.meta) (binop : binop)
| Gt -> Z.gt sv1.value sv2.value
| Div | Rem | Add | Sub | Mul | BitXor | BitAnd | BitOr | Shl
| Shr | Ne | Eq | CheckedAdd | CheckedSub | CheckedMul ->
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
Ok
({ value = VLiteral (VBool b); ty = TLiteral TBool }
: typed_value)
| Div | Rem | Add | Sub | Mul | BitXor | BitAnd | BitOr -> (
(* The two operands must have the same type and the result is an integer *)
- sanity_check __FILE__ __LINE__ (sv1.int_ty = sv2.int_ty) meta;
+ sanity_check __FILE__ __LINE__ (sv1.int_ty = sv2.int_ty) span;
let res =
match binop with
| Div ->
@@ -556,7 +556,7 @@ let eval_binary_op_concrete_compute (meta : Meta.meta) (binop : binop)
| BitOr -> raise Unimplemented
| Lt | Le | Ge | Gt | Shl | Shr | Ne | Eq | CheckedAdd
| CheckedSub | CheckedMul ->
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
match res with
| Error _ -> Error EPanic
@@ -567,33 +567,33 @@ let eval_binary_op_concrete_compute (meta : Meta.meta) (binop : binop)
ty = TLiteral (TInteger sv1.int_ty);
})
| Shl | Shr | CheckedAdd | CheckedSub | CheckedMul ->
- craise __FILE__ __LINE__ meta "Unimplemented binary operation"
- | Ne | Eq -> craise __FILE__ __LINE__ meta "Unreachable")
- | _ -> craise __FILE__ __LINE__ meta "Invalid inputs for binop"
+ craise __FILE__ __LINE__ span "Unimplemented binary operation"
+ | Ne | Eq -> craise __FILE__ __LINE__ span "Unreachable")
+ | _ -> craise __FILE__ __LINE__ span "Invalid inputs for binop"
-let eval_binary_op_concrete (config : config) (meta : Meta.meta) (binop : binop)
+let eval_binary_op_concrete (config : config) (span : Meta.span) (binop : binop)
(op1 : operand) (op2 : operand) (ctx : eval_ctx) :
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result) =
(* Evaluate the operands *)
- let (v1, v2), ctx, cc = eval_two_operands config meta op1 op2 ctx in
+ let (v1, v2), ctx, cc = eval_two_operands config span op1 op2 ctx in
(* Compute the result of the binop *)
- let r = eval_binary_op_concrete_compute meta binop v1 v2 in
+ let r = eval_binary_op_concrete_compute span binop v1 v2 in
(* Return *)
(r, ctx, cc)
-let eval_binary_op_symbolic (config : config) (meta : Meta.meta) (binop : binop)
+let eval_binary_op_symbolic (config : config) (span : Meta.span) (binop : binop)
(op1 : operand) (op2 : operand) (ctx : eval_ctx) :
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result) =
(* Evaluate the operands *)
- let (v1, v2), ctx, cc = eval_two_operands config meta op1 op2 ctx in
+ let (v1, v2), ctx, cc = eval_two_operands config span op1 op2 ctx in
(* Generate a fresh symbolic value to store the result *)
let res_sv_id = fresh_symbolic_value_id () in
let res_sv_ty =
if binop = Eq || binop = Ne then (
(* Equality operations *)
- sanity_check __FILE__ __LINE__ (v1.ty = v2.ty) meta;
+ sanity_check __FILE__ __LINE__ (v1.ty = v2.ty) span;
(* Equality/inequality check is primitive only for a subset of types *)
- exec_assert __FILE__ __LINE__ (ty_is_copyable v1.ty) meta
+ exec_assert __FILE__ __LINE__ (ty_is_copyable v1.ty) span
"The type is not primitively copyable";
TLiteral TBool)
else
@@ -602,43 +602,43 @@ let eval_binary_op_symbolic (config : config) (meta : Meta.meta) (binop : binop)
| TLiteral (TInteger int_ty1), TLiteral (TInteger int_ty2) -> (
match binop with
| Lt | Le | Ge | Gt ->
- sanity_check __FILE__ __LINE__ (int_ty1 = int_ty2) meta;
+ sanity_check __FILE__ __LINE__ (int_ty1 = int_ty2) span;
TLiteral TBool
| Div | Rem | Add | Sub | Mul | BitXor | BitAnd | BitOr ->
- sanity_check __FILE__ __LINE__ (int_ty1 = int_ty2) meta;
+ sanity_check __FILE__ __LINE__ (int_ty1 = int_ty2) span;
TLiteral (TInteger int_ty1)
(* These return `(int, bool)` which isn't a literal type *)
| CheckedAdd | CheckedSub | CheckedMul ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Checked operations are not implemented"
| Shl | Shr ->
(* The number of bits can be of a different integer type
than the operand *)
TLiteral (TInteger int_ty1)
- | Ne | Eq -> craise __FILE__ __LINE__ meta "Unreachable")
- | _ -> craise __FILE__ __LINE__ meta "Invalid inputs for binop"
+ | Ne | Eq -> craise __FILE__ __LINE__ span "Unreachable")
+ | _ -> craise __FILE__ __LINE__ span "Invalid inputs for binop"
in
let res_sv = { sv_id = res_sv_id; sv_ty = res_sv_ty } in
let v = mk_typed_value_from_symbolic_value res_sv in
(* Synthesize the symbolic AST *)
- let p1 = mk_opt_place_from_op meta op1 ctx in
- let p2 = mk_opt_place_from_op meta op2 ctx in
+ let p1 = mk_opt_place_from_op span op1 ctx in
+ let p2 = mk_opt_place_from_op span op2 ctx in
let cc =
cc_comp cc (synthesize_binary_op ctx binop v1 p1 v2 p2 res_sv None)
in
(* Compose and apply *)
(Ok v, ctx, cc)
-let eval_binary_op (config : config) (meta : Meta.meta) (binop : binop)
+let eval_binary_op (config : config) (span : Meta.span) (binop : binop)
(op1 : operand) (op2 : operand) (ctx : eval_ctx) :
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result) =
match config.mode with
- | ConcreteMode -> eval_binary_op_concrete config meta binop op1 op2 ctx
- | SymbolicMode -> eval_binary_op_symbolic config meta binop op1 op2 ctx
+ | ConcreteMode -> eval_binary_op_concrete config span binop op1 op2 ctx
+ | SymbolicMode -> eval_binary_op_symbolic config span binop op1 op2 ctx
(** Evaluate an rvalue which creates a reference (i.e., an rvalue which is
`&p` or `&mut p` or `&two-phase p`) *)
-let eval_rvalue_ref (config : config) (meta : Meta.meta) (p : place)
+let eval_rvalue_ref (config : config) (span : Meta.span) (p : place)
(bkind : borrow_kind) (ctx : eval_ctx) :
typed_value * eval_ctx * (eval_result -> eval_result) =
match bkind with
@@ -648,19 +648,19 @@ let eval_rvalue_ref (config : config) (meta : Meta.meta) (p : place)
forbid them and remove them in the prepasses (see the comments there
as to why this is sound).
*)
- sanity_check __FILE__ __LINE__ (bkind <> BShallow) meta;
+ sanity_check __FILE__ __LINE__ (bkind <> BShallow) span;
(* Access the value *)
let access =
match bkind with
| BShared | BShallow -> Read
| BTwoPhaseMut -> Write
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let expand_prim_copy = false in
let v, ctx, cc =
- access_rplace_reorganize_and_read config meta expand_prim_copy access p
+ access_rplace_reorganize_and_read config span expand_prim_copy access p
ctx
in
(* Generate the fresh borrow id *)
@@ -678,14 +678,14 @@ let eval_rvalue_ref (config : config) (meta : Meta.meta) (p : place)
{ v with value = v' }
in
(* Update the value in the context to replace it with the loan *)
- let ctx = write_place meta access p nv ctx in
+ let ctx = write_place span access p nv ctx in
(* Compute the rvalue - simply a shared borrow with the fresh id.
* Note that the reference is *mutable* if we do a two-phase borrow *)
let ref_kind =
match bkind with
| BShared | BShallow -> RShared
| BTwoPhaseMut -> RMut
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let rv_ty = TRef (RErased, v.ty, ref_kind) in
let bc =
@@ -695,7 +695,7 @@ let eval_rvalue_ref (config : config) (meta : Meta.meta) (p : place)
handle shallow borrows like shared borrows *)
VSharedBorrow bid
| BTwoPhaseMut -> VReservedMutBorrow bid
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let rv : typed_value = { value = VBorrow bc; ty = rv_ty } in
(* Return *)
@@ -705,7 +705,7 @@ let eval_rvalue_ref (config : config) (meta : Meta.meta) (p : place)
let access = Write in
let expand_prim_copy = false in
let v, ctx, cc =
- access_rplace_reorganize_and_read config meta expand_prim_copy access p
+ access_rplace_reorganize_and_read config span expand_prim_copy access p
ctx
in
(* Compute the rvalue - wrap the value in a mutable borrow with a fresh id *)
@@ -717,15 +717,15 @@ let eval_rvalue_ref (config : config) (meta : Meta.meta) (p : place)
(* Compute the loan value with which to replace the value at place p *)
let nv = { v with value = VLoan (VMutLoan bid) } in
(* Update the value in the context to replace it with the loan *)
- let ctx = write_place meta access p nv ctx in
+ let ctx = write_place span access p nv ctx in
(* Return *)
(rv, ctx, cc)
-let eval_rvalue_aggregate (config : config) (meta : Meta.meta)
+let eval_rvalue_aggregate (config : config) (span : Meta.span)
(aggregate_kind : aggregate_kind) (ops : operand list) (ctx : eval_ctx) :
typed_value * eval_ctx * (eval_result -> eval_result) =
(* Evaluate the operands *)
- let values, ctx, cc = eval_operands config meta ops ctx in
+ let values, ctx, cc = eval_operands config span ops ctx in
(* Compute the value *)
let v, cf_compute =
(* Match on the aggregate kind *)
@@ -745,15 +745,15 @@ let eval_rvalue_aggregate (config : config) (meta : Meta.meta)
sanity_check __FILE__ __LINE__
(List.length type_decl.generics.regions
= List.length generics.regions)
- meta;
+ span;
let expected_field_types =
- AssociatedTypes.ctx_adt_get_inst_norm_field_etypes meta ctx def_id
+ AssociatedTypes.ctx_adt_get_inst_norm_field_etypes span ctx def_id
opt_variant_id generics
in
sanity_check __FILE__ __LINE__
(expected_field_types
= List.map (fun (v : typed_value) -> v.ty) values)
- meta;
+ span;
(* Construct the value *)
let av : adt_value =
{ variant_id = opt_variant_id; field_values = values }
@@ -762,17 +762,17 @@ let eval_rvalue_aggregate (config : config) (meta : Meta.meta)
let aggregated : typed_value = { value = VAdt av; ty = aty } in
(* Call the continuation *)
(aggregated, fun e -> e)
- | TAssumed _ -> craise __FILE__ __LINE__ meta "Unreachable")
+ | TAssumed _ -> craise __FILE__ __LINE__ span "Unreachable")
| AggregatedArray (ety, cg) ->
(* Sanity check: all the values have the proper type *)
sanity_check __FILE__ __LINE__
(List.for_all (fun (v : typed_value) -> v.ty = ety) values)
- meta;
+ span;
(* Sanity check: the number of values is consistent with the length *)
let len = (literal_as_scalar (const_generic_as_literal cg)).value in
sanity_check __FILE__ __LINE__
(len = Z.of_int (List.length values))
- meta;
+ span;
let generics = TypesUtils.mk_generic_args [] [ ety ] [ cg ] [] in
let ty = TAdt (TAssumed TArray, generics) in
(* In order to generate a better AST, we introduce a symbolic
@@ -780,24 +780,24 @@ let eval_rvalue_aggregate (config : config) (meta : Meta.meta)
array we introduce here might be duplicated in the generated
code: by introducing a symbolic value we introduce a let-binding
in the generated code. *)
- let saggregated = mk_fresh_symbolic_typed_value meta ty in
+ let saggregated = mk_fresh_symbolic_typed_value span ty in
(* Update the symbolic ast *)
let cf e =
match e with
| None -> None
| Some e ->
(* Introduce the symbolic value in the AST *)
- let sv = ValuesUtils.value_as_symbolic meta saggregated.value in
+ let sv = ValuesUtils.value_as_symbolic span saggregated.value in
Some
(SymbolicAst.IntroSymbolic (ctx, None, sv, VaArray values, e))
in
(saggregated, cf)
| AggregatedClosure _ ->
- craise __FILE__ __LINE__ meta "Closures are not supported yet"
+ craise __FILE__ __LINE__ span "Closures are not supported yet"
in
(v, ctx, cc_comp cc cf_compute)
-let eval_rvalue_not_global (config : config) (meta : Meta.meta)
+let eval_rvalue_not_global (config : config) (span : Meta.span)
(rvalue : rvalue) (ctx : eval_ctx) :
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result) =
log#ldebug (lazy "eval_rvalue");
@@ -805,25 +805,25 @@ let eval_rvalue_not_global (config : config) (meta : Meta.meta)
let wrap_in_result (v, ctx, cc) = (Ok v, ctx, cc) in
(* Delegate to the proper auxiliary function *)
match rvalue with
- | Use op -> wrap_in_result (eval_operand config meta op ctx)
- | RvRef (p, bkind) -> wrap_in_result (eval_rvalue_ref config meta p bkind ctx)
- | UnaryOp (unop, op) -> eval_unary_op config meta unop op ctx
- | BinaryOp (binop, op1, op2) -> eval_binary_op config meta binop op1 op2 ctx
+ | Use op -> wrap_in_result (eval_operand config span op ctx)
+ | RvRef (p, bkind) -> wrap_in_result (eval_rvalue_ref config span p bkind ctx)
+ | UnaryOp (unop, op) -> eval_unary_op config span unop op ctx
+ | BinaryOp (binop, op1, op2) -> eval_binary_op config span binop op1 op2 ctx
| Aggregate (aggregate_kind, ops) ->
- wrap_in_result (eval_rvalue_aggregate config meta aggregate_kind ops ctx)
+ wrap_in_result (eval_rvalue_aggregate config span aggregate_kind ops ctx)
| Discriminant _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Unreachable: discriminant reads should have been eliminated from the \
AST"
- | Global _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Global _ -> craise __FILE__ __LINE__ span "Unreachable"
-let eval_fake_read (config : config) (meta : Meta.meta) (p : place) : cm_fun =
+let eval_fake_read (config : config) (span : Meta.span) (p : place) : cm_fun =
fun ctx ->
let expand_prim_copy = false in
let v, ctx, cc =
- access_rplace_reorganize_and_read config meta expand_prim_copy Read p ctx
+ access_rplace_reorganize_and_read config span expand_prim_copy Read p ctx
in
cassert __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions v))
- meta "Fake read: the value contains bottom";
+ span "Fake read: the value contains bottom";
(ctx, cc)
diff --git a/compiler/InterpreterExpressions.mli b/compiler/InterpreterExpressions.mli
index 049cee95..feb641d1 100644
--- a/compiler/InterpreterExpressions.mli
+++ b/compiler/InterpreterExpressions.mli
@@ -20,7 +20,7 @@ open InterpreterPaths
*)
val access_rplace_reorganize_and_read :
config ->
- Meta.meta ->
+ Meta.span ->
bool ->
access_kind ->
place ->
@@ -38,7 +38,7 @@ val access_rplace_reorganize_and_read :
*)
val eval_operand :
config ->
- Meta.meta ->
+ Meta.span ->
operand ->
eval_ctx ->
typed_value * eval_ctx * (eval_result -> eval_result)
@@ -46,7 +46,7 @@ val eval_operand :
(** Evaluate several operands at once. *)
val eval_operands :
config ->
- Meta.meta ->
+ Meta.span ->
operand list ->
eval_ctx ->
typed_value list * eval_ctx * (eval_result -> eval_result)
@@ -60,10 +60,10 @@ val eval_operands :
*)
val eval_rvalue_not_global :
config ->
- Meta.meta ->
+ Meta.span ->
rvalue ->
eval_ctx ->
(typed_value, eval_error) result * eval_ctx * (eval_result -> eval_result)
(** Evaluate a fake read (update the context so that we can read a place) *)
-val eval_fake_read : config -> Meta.meta -> place -> cm_fun
+val eval_fake_read : config -> Meta.span -> place -> cm_fun
diff --git a/compiler/InterpreterLoops.ml b/compiler/InterpreterLoops.ml
index 3264bd18..776cb6fa 100644
--- a/compiler/InterpreterLoops.ml
+++ b/compiler/InterpreterLoops.ml
@@ -15,7 +15,7 @@ open Errors
let log = Logging.loops_log
(** Evaluate a loop in concrete mode *)
-let eval_loop_concrete (meta : Meta.meta) (eval_loop_body : stl_cm_fun) :
+let eval_loop_concrete (span : Meta.span) (eval_loop_body : stl_cm_fun) :
stl_cm_fun =
fun ctx ->
(* We need a loop id for the [LoopReturn]. In practice it won't be used
@@ -54,10 +54,10 @@ let eval_loop_concrete (meta : Meta.meta) (eval_loop_body : stl_cm_fun) :
* {!Unit} would account for the first iteration of the loop.
* We prefer to write it this way for consistency and sanity,
* though. *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| LoopReturn _ | EndEnterLoop _ | EndContinue _ ->
(* We can't get there: this is only used in symbolic mode *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
(* Apply - for the first iteration, we use the result `Continue 0` to evaluate
@@ -65,20 +65,20 @@ let eval_loop_concrete (meta : Meta.meta) (eval_loop_body : stl_cm_fun) :
let ctx_resl = rec_eval_loop_body ctx (Continue 0) in
(* If we evaluate in concrete mode, we shouldn't have to generate any symbolic expression *)
let cf el =
- sanity_check __FILE__ __LINE__ (el = None) meta;
+ sanity_check __FILE__ __LINE__ (el = None) span;
None
in
(ctx_resl, cf)
(** Evaluate a loop in symbolic mode *)
-let eval_loop_symbolic (config : config) (meta : meta)
+let eval_loop_symbolic (config : config) (span : span)
(eval_loop_body : stl_cm_fun) : stl_cm_fun =
fun ctx ->
(* Debug *)
log#ldebug
(lazy
("eval_loop_symbolic:\nContext:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n\n"));
(* Generate a fresh loop id *)
@@ -86,20 +86,20 @@ let eval_loop_symbolic (config : config) (meta : meta)
(* Compute the fixed point at the loop entrance *)
let fp_ctx, fixed_ids, rg_to_abs =
- compute_loop_entry_fixed_point config meta loop_id eval_loop_body ctx
+ compute_loop_entry_fixed_point config span loop_id eval_loop_body ctx
in
(* Debug *)
log#ldebug
(lazy
("eval_loop_symbolic:\nInitial context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n\nFixed point:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) fp_ctx));
+ ^ eval_ctx_to_string ~span:(Some span) fp_ctx));
(* Compute the loop input parameters *)
let fresh_sids, input_svalues =
- compute_fp_ctx_symbolic_values meta ctx fp_ctx
+ compute_fp_ctx_symbolic_values span ctx fp_ctx
in
let fp_input_svalues = List.map (fun sv -> sv.sv_id) input_svalues in
@@ -119,7 +119,7 @@ let eval_loop_symbolic (config : config) (meta : meta)
- src ctx (fixed-point ctx):\n" ^ eval_ctx_to_string fp_ctx
^ "\n\n-tgt ctx (original context):\n" ^ eval_ctx_to_string ctx));
- prepare_match_ctx_with_target config meta loop_id fixed_ids fp_ctx ctx
+ prepare_match_ctx_with_target config span loop_id fixed_ids fp_ctx ctx
in
(* Actually match *)
@@ -132,23 +132,23 @@ let eval_loop_symbolic (config : config) (meta : meta)
(* Compute the id correspondance between the contexts *)
let fp_bl_corresp =
- compute_fixed_point_id_correspondance meta fixed_ids ctx fp_ctx
+ compute_fixed_point_id_correspondance span fixed_ids ctx fp_ctx
in
log#ldebug
(lazy
("eval_loop_symbolic: about to match the fixed-point context with the \
original context:\n\
- src ctx (fixed-point ctx)"
- ^ eval_ctx_to_string ~meta:(Some meta) fp_ctx
+ ^ eval_ctx_to_string ~span:(Some span) fp_ctx
^ "\n\n-tgt ctx (original context):\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Compute the end expression, that is the expresion corresponding to the
end of the functin where we call the loop (for now, when calling a loop
we never get out) *)
let res_fun_end =
comp cf_prepare
- (match_ctx_with_target config meta loop_id true fp_bl_corresp
+ (match_ctx_with_target config span loop_id true fp_bl_corresp
fp_input_svalues fixed_ids fp_ctx ctx)
in
(res_fun_end, fp_bl_corresp)
@@ -177,26 +177,26 @@ let eval_loop_symbolic (config : config) (meta : meta)
| Panic -> ((ctx, res), fun e -> e)
| Break _ ->
(* Breaks should have been eliminated in the prepasses *)
- craise __FILE__ __LINE__ meta "Unexpected break"
+ craise __FILE__ __LINE__ span "Unexpected break"
| Continue i ->
(* We don't support nested loops for now *)
- cassert __FILE__ __LINE__ (i = 0) meta
+ cassert __FILE__ __LINE__ (i = 0) span
"Nested loops are not supported yet";
log#ldebug
(lazy
("eval_loop_symbolic: about to match the fixed-point context \
with the context at a continue:\n\
- src ctx (fixed-point ctx)"
- ^ eval_ctx_to_string ~meta:(Some meta) fp_ctx
+ ^ eval_ctx_to_string ~span:(Some span) fp_ctx
^ "\n\n-tgt ctx (ctx at continue):\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
- match_ctx_with_target config meta loop_id false fp_bl_corresp
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
+ match_ctx_with_target config span loop_id false fp_bl_corresp
fp_input_svalues fixed_ids fp_ctx ctx
| Unit | LoopReturn _ | EndEnterLoop _ | EndContinue _ ->
(* For why we can't get [Unit], see the comments inside {!eval_loop_concrete}.
For [EndEnterLoop] and [EndContinue]: we don't support nested loops for now.
*)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
(* Apply and compose *)
@@ -219,9 +219,9 @@ let eval_loop_symbolic (config : config) (meta : meta)
log#ldebug
(lazy
("eval_loop_symbolic: result:" ^ "\n- src context:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx
^ "\n- fixed point:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) fp_ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) fp_ctx
^ "\n- fixed_sids: "
^ SymbolicValueId.Set.show fixed_ids.sids
^ "\n- fresh_sids: "
@@ -247,7 +247,7 @@ let eval_loop_symbolic (config : config) (meta : meta)
match av.value with
| ABorrow _ -> true
| ALoan _ -> false
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let borrows, loans = List.partition is_borrow abs.avalues in
@@ -256,10 +256,10 @@ let eval_loop_symbolic (config : config) (meta : meta)
(fun (av : typed_avalue) ->
match av.value with
| ABorrow (AMutBorrow (bid, child_av)) ->
- sanity_check __FILE__ __LINE__ (is_aignored child_av.value) meta;
+ sanity_check __FILE__ __LINE__ (is_aignored child_av.value) span;
Some (bid, child_av.ty)
| ABorrow (ASharedBorrow _) -> None
- | _ -> craise __FILE__ __LINE__ meta "Unreachable")
+ | _ -> craise __FILE__ __LINE__ span "Unreachable")
borrows
in
let borrows = ref (BorrowId.Map.of_list borrows) in
@@ -269,10 +269,10 @@ let eval_loop_symbolic (config : config) (meta : meta)
(fun (av : typed_avalue) ->
match av.value with
| ALoan (AMutLoan (bid, child_av)) ->
- sanity_check __FILE__ __LINE__ (is_aignored child_av.value) meta;
+ sanity_check __FILE__ __LINE__ (is_aignored child_av.value) span;
Some bid
| ALoan (ASharedLoan _) -> None
- | _ -> craise __FILE__ __LINE__ meta "Unreachable")
+ | _ -> craise __FILE__ __LINE__ span "Unreachable")
loans
in
@@ -288,7 +288,7 @@ let eval_loop_symbolic (config : config) (meta : meta)
ty)
loan_ids
in
- sanity_check __FILE__ __LINE__ (BorrowId.Map.is_empty !borrows) meta;
+ sanity_check __FILE__ __LINE__ (BorrowId.Map.is_empty !borrows) span;
given_back_tys
in
@@ -301,25 +301,25 @@ let eval_loop_symbolic (config : config) (meta : meta)
| None -> None
| Some el -> (
match el with
- | [] -> internal_error __FILE__ __LINE__ meta
+ | [] -> internal_error __FILE__ __LINE__ span
| e :: el ->
let fun_end_expr = cf_fun_end (Some e) in
let loop_expr = cf_loop_body (Some el) in
S.synthesize_loop loop_id input_svalues fresh_sids rg_to_given_back
- fun_end_expr loop_expr meta)
+ fun_end_expr loop_expr span)
in
(res_fun_end :: resl_loop_body, cc)
-let eval_loop (config : config) (meta : meta) (eval_loop_body : stl_cm_fun) :
+let eval_loop (config : config) (span : span) (eval_loop_body : stl_cm_fun) :
stl_cm_fun =
fun ctx ->
match config.mode with
- | ConcreteMode -> (eval_loop_concrete meta eval_loop_body) ctx
+ | ConcreteMode -> (eval_loop_concrete span eval_loop_body) ctx
| SymbolicMode ->
(* Simplify the context by ending the unnecessary borrows/loans and getting
rid of the useless symbolic values (which are in anonymous variables) *)
let ctx, cc =
- cleanup_fresh_values_and_abs config meta empty_ids_set ctx
+ cleanup_fresh_values_and_abs config span empty_ids_set ctx
in
(* We want to make sure the loop will *not* manipulate shared avalues
@@ -340,5 +340,5 @@ let eval_loop (config : config) (meta : meta) (eval_loop_body : stl_cm_fun) :
introduce *fixed* abstractions, and again later to introduce
*non-fixed* abstractions.
*)
- let ctx, cc = comp cc (prepare_ashared_loans meta None ctx) in
- comp cc (eval_loop_symbolic config meta eval_loop_body ctx)
+ let ctx, cc = comp cc (prepare_ashared_loans span None ctx) in
+ comp cc (eval_loop_symbolic config span eval_loop_body ctx)
diff --git a/compiler/InterpreterLoops.mli b/compiler/InterpreterLoops.mli
index 630e1e12..567250af 100644
--- a/compiler/InterpreterLoops.mli
+++ b/compiler/InterpreterLoops.mli
@@ -65,4 +65,4 @@ open Meta
The `stl_cm_fun` required as input must be the function to evaluate the
loop body (i.e., `eval_statement` applied to the loop body).
*)
-val eval_loop : config -> meta -> stl_cm_fun -> stl_cm_fun
+val eval_loop : config -> span -> stl_cm_fun -> stl_cm_fun
diff --git a/compiler/InterpreterLoopsCore.ml b/compiler/InterpreterLoopsCore.ml
index a5b3a021..991f259f 100644
--- a/compiler/InterpreterLoopsCore.ml
+++ b/compiler/InterpreterLoopsCore.ml
@@ -53,7 +53,7 @@ type abs_borrows_loans_maps = {
regions.
*)
module type PrimMatcher = sig
- val meta : Meta.meta
+ val span : Meta.span
val match_etys : eval_ctx -> eval_ctx -> ety -> ety -> ety
val match_rtys : eval_ctx -> eval_ctx -> rty -> rty -> rty
@@ -65,7 +65,7 @@ module type PrimMatcher = sig
val match_distinct_adts :
eval_ctx -> eval_ctx -> ety -> adt_value -> adt_value -> typed_value
- (** The meta-value is the result of a match.
+ (** The span-value is the result of a match.
We take an additional function as input, which acts as a matcher over
typed values, to be able to lookup the shared values and match them.
@@ -256,7 +256,7 @@ module type PrimMatcher = sig
end
module type Matcher = sig
- val meta : Meta.meta
+ val span : Meta.span
(** Match two values.
@@ -279,7 +279,7 @@ end
Very annoying: functors only take modules as inputs...
*)
module type MatchCheckEquivState = sig
- val meta : Meta.meta
+ val span : Meta.span
(** [true] if we check equivalence between contexts, [false] if we match
a source context with a target context. *)
@@ -351,7 +351,7 @@ module type MatchJoinState = sig
(** The abstractions introduced when performing the matches *)
val nabs : abs list ref
- val meta : Meta.meta
+ val span : Meta.span
end
(** Split an environment between the fixed abstractions, values, etc. and
@@ -359,7 +359,7 @@ end
Returns: (fixed, new abs, new dummies)
*)
-let ctx_split_fixed_new (meta : Meta.meta) (fixed_ids : ids_sets)
+let ctx_split_fixed_new (span : Meta.span) (fixed_ids : ids_sets)
(ctx : eval_ctx) : env * abs list * typed_value list =
let is_fresh_did (id : DummyVarId.id) : bool =
not (DummyVarId.Set.mem id fixed_ids.dids)
@@ -383,7 +383,7 @@ let ctx_split_fixed_new (meta : Meta.meta) (fixed_ids : ids_sets)
(fun ee ->
match ee with
| EAbs abs -> abs
- | _ -> craise __FILE__ __LINE__ meta "Unreachable")
+ | _ -> craise __FILE__ __LINE__ span "Unreachable")
new_absl
in
let new_dummyl =
@@ -391,7 +391,7 @@ let ctx_split_fixed_new (meta : Meta.meta) (fixed_ids : ids_sets)
(fun ee ->
match ee with
| EBinding (BDummy _, v) -> v
- | _ -> craise __FILE__ __LINE__ meta "Unreachable")
+ | _ -> craise __FILE__ __LINE__ span "Unreachable")
new_dummyl
in
(filt_env, new_absl, new_dummyl)
diff --git a/compiler/InterpreterLoopsFixedPoint.ml b/compiler/InterpreterLoopsFixedPoint.ml
index 329abcf3..6c87f1c8 100644
--- a/compiler/InterpreterLoopsFixedPoint.ml
+++ b/compiler/InterpreterLoopsFixedPoint.ml
@@ -23,7 +23,7 @@ exception FoundAbsId of AbstractionId.id
- end the borrows which appear in fresh anonymous values and don't contain loans
- end the fresh region abstractions which can be ended (no loans)
*)
-let rec end_useless_fresh_borrows_and_abs (config : config) (meta : Meta.meta)
+let rec end_useless_fresh_borrows_and_abs (config : config) (span : Meta.span)
(fixed_ids : ids_sets) : cm_fun =
fun ctx ->
let rec explore_env (env : env) : unit =
@@ -56,7 +56,7 @@ let rec end_useless_fresh_borrows_and_abs (config : config) (meta : Meta.meta)
| EAbs abs :: env when not (AbstractionId.Set.mem abs.abs_id fixed_ids.aids)
-> (
(* Check if it is possible to end the abstraction: if yes, raise an exception *)
- let opt_loan = get_first_non_ignored_aloan_in_abstraction meta abs in
+ let opt_loan = get_first_non_ignored_aloan_in_abstraction span abs in
match opt_loan with
| None ->
(* No remaining loans: we can end the abstraction *)
@@ -66,7 +66,7 @@ let rec end_useless_fresh_borrows_and_abs (config : config) (meta : Meta.meta)
explore_env env)
| _ :: env -> explore_env env
in
- let rec_call = end_useless_fresh_borrows_and_abs config meta fixed_ids in
+ let rec_call = end_useless_fresh_borrows_and_abs config span fixed_ids in
try
(* Explore the environment *)
explore_env ctx.env;
@@ -74,10 +74,10 @@ let rec end_useless_fresh_borrows_and_abs (config : config) (meta : Meta.meta)
(ctx, fun e -> e)
with
| FoundAbsId abs_id ->
- let ctx, cc = end_abstraction config meta abs_id ctx in
+ let ctx, cc = end_abstraction config span abs_id ctx in
comp cc (rec_call ctx)
| FoundBorrowId bid ->
- let ctx, cc = end_borrow config meta bid ctx in
+ let ctx, cc = end_borrow config span bid ctx in
comp cc (rec_call ctx)
(* Explore the fresh anonymous values and replace all the values which are not
@@ -119,10 +119,10 @@ let cleanup_fresh_values (fixed_ids : ids_sets) (ctx : eval_ctx) : eval_ctx =
- also end the borrows which appear in fresh anonymous values and don't contain loans
- end the fresh region abstractions which can be ended (no loans)
*)
-let cleanup_fresh_values_and_abs (config : config) (meta : Meta.meta)
+let cleanup_fresh_values_and_abs (config : config) (span : Meta.span)
(fixed_ids : ids_sets) : cm_fun =
fun ctx ->
- let ctx, cc = end_useless_fresh_borrows_and_abs config meta fixed_ids ctx in
+ let ctx, cc = end_useless_fresh_borrows_and_abs config span fixed_ids ctx in
let ctx = cleanup_fresh_values fixed_ids ctx in
(ctx, cc)
@@ -133,7 +133,7 @@ let cleanup_fresh_values_and_abs (config : config) (meta : Meta.meta)
called typically after we merge abstractions together (see {!collapse_ctx}
for instance).
*)
-let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
+let reorder_loans_borrows_in_fresh_abs (span : Meta.span)
(old_abs_ids : AbstractionId.Set.t) (ctx : eval_ctx) : eval_ctx =
let reorder_in_fresh_abs (abs : abs) : abs =
(* Split between the loans and borrows *)
@@ -141,7 +141,7 @@ let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
match av.value with
| ABorrow _ -> true
| ALoan _ -> false
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
let aborrows, aloans = List.partition is_borrow abs.avalues in
@@ -154,13 +154,13 @@ let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
let get_borrow_id (av : typed_avalue) : BorrowId.id =
match av.value with
| ABorrow (AMutBorrow (bid, _) | ASharedBorrow bid) -> bid
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
let get_loan_id (av : typed_avalue) : BorrowId.id =
match av.value with
| ALoan (AMutLoan (lid, _)) -> lid
| ALoan (ASharedLoan (lids, _, _)) -> BorrowId.Set.min_elt lids
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
(* We use ordered maps to reorder the borrows and loans *)
let reorder (get_bid : typed_avalue -> BorrowId.id)
@@ -184,7 +184,7 @@ let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
{ ctx with env }
-let prepare_ashared_loans (meta : Meta.meta) (loop_id : LoopId.id option) :
+let prepare_ashared_loans (span : Meta.span) (loop_id : LoopId.id option) :
cm_fun =
fun ctx0 ->
let ctx = ctx0 in
@@ -213,7 +213,7 @@ let prepare_ashared_loans (meta : Meta.meta) (loop_id : LoopId.id option) :
(* Remove the shared loans *)
let v = value_remove_shared_loans v in
(* Substitute the symbolic values and the region *)
- Substitute.typed_value_subst_ids meta
+ Substitute.typed_value_subst_ids span
(fun r -> if RegionId.Set.mem r rids then nrid else r)
(fun x -> x)
(fun x -> x)
@@ -265,32 +265,32 @@ let prepare_ashared_loans (meta : Meta.meta) (loop_id : LoopId.id option) :
borrow_substs := (lid, nlid) :: !borrow_substs;
(* Rem.: the below sanity checks are not really necessary *)
- sanity_check __FILE__ __LINE__ (AbstractionId.Set.is_empty abs.parents) meta;
- sanity_check __FILE__ __LINE__ (abs.original_parents = []) meta;
+ sanity_check __FILE__ __LINE__ (AbstractionId.Set.is_empty abs.parents) span;
+ sanity_check __FILE__ __LINE__ (abs.original_parents = []) span;
sanity_check __FILE__ __LINE__
(RegionId.Set.is_empty abs.ancestors_regions)
- meta;
+ span;
(* Introduce the new abstraction for the shared values *)
- cassert __FILE__ __LINE__ (ty_no_regions sv.ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions sv.ty) span
"Nested borrows are not supported yet";
let rty = sv.ty in
(* Create the shared loan child *)
let child_rty = rty in
- let child_av = mk_aignored meta child_rty in
+ let child_av = mk_aignored span child_rty in
(* Create the shared loan *)
let loan_rty = TRef (RFVar nrid, rty, RShared) in
let loan_value =
ALoan (ASharedLoan (BorrowId.Set.singleton nlid, nsv, child_av))
in
- let loan_value = mk_typed_avalue meta loan_rty loan_value in
+ let loan_value = mk_typed_avalue span loan_rty loan_value in
(* Create the shared borrow *)
let borrow_rty = loan_rty in
let borrow_value = ABorrow (ASharedBorrow lid) in
- let borrow_value = mk_typed_avalue meta borrow_rty borrow_value in
+ let borrow_value = mk_typed_avalue span borrow_rty borrow_value in
(* Create the abstraction *)
let avalues = [ borrow_value; loan_value ] in
@@ -324,7 +324,7 @@ let prepare_ashared_loans (meta : Meta.meta) (loop_id : LoopId.id option) :
let collect_shared_values_in_abs (abs : abs) : unit =
let collect_shared_value lids (sv : typed_value) =
(* Sanity check: we don't support nested borrows for now *)
- sanity_check __FILE__ __LINE__ (not (value_has_borrows ctx sv.value)) meta;
+ sanity_check __FILE__ __LINE__ (not (value_has_borrows ctx sv.value)) span;
(* Filter the loan ids whose corresponding borrows appear in abstractions
(see the documentation of the function) *)
@@ -360,7 +360,7 @@ let prepare_ashared_loans (meta : Meta.meta) (loop_id : LoopId.id option) :
method! visit_symbolic_value env sv =
cassert __FILE__ __LINE__
(not (symbolic_value_has_borrows ctx sv))
- meta
+ span
"There should be no symbolic values with borrows inside the \
abstraction";
super#visit_symbolic_value env sv
@@ -441,11 +441,11 @@ let prepare_ashared_loans (meta : Meta.meta) (loop_id : LoopId.id option) :
in
(ctx, cf)
-let prepare_ashared_loans_no_synth (meta : Meta.meta) (loop_id : LoopId.id)
+let prepare_ashared_loans_no_synth (span : Meta.span) (loop_id : LoopId.id)
(ctx : eval_ctx) : eval_ctx =
- fst (prepare_ashared_loans meta (Some loop_id) ctx)
+ fst (prepare_ashared_loans span (Some loop_id) ctx)
-let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
+let compute_loop_entry_fixed_point (config : config) (span : Meta.span)
(loop_id : LoopId.id) (eval_loop_body : stl_cm_fun) (ctx0 : eval_ctx) :
eval_ctx * ids_sets * abs RegionGroupId.Map.t =
(* Introduce "reborrows" for the shared values in the abstractions, so that
@@ -455,16 +455,16 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
For more details, see the comments for {!prepare_ashared_loans}
*)
- let ctx = prepare_ashared_loans_no_synth meta loop_id ctx0 in
+ let ctx = prepare_ashared_loans_no_synth span loop_id ctx0 in
(* Debug *)
log#ldebug
(lazy
("compute_loop_entry_fixed_point: after prepare_ashared_loans:"
^ "\n\n- ctx0:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx0
^ "\n\n- ctx1:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx
^ "\n\n"));
(* The fixed ids. They are the ids of the original ctx, after we ended
@@ -496,10 +496,10 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
(* End those borrows and abstractions *)
let end_borrows_abs blids aids ctx =
let ctx =
- InterpreterBorrows.end_borrows_no_synth config meta blids ctx
+ InterpreterBorrows.end_borrows_no_synth config span blids ctx
in
let ctx =
- InterpreterBorrows.end_abstractions_no_synth config meta aids ctx
+ InterpreterBorrows.end_abstractions_no_synth config span aids ctx
in
ctx
in
@@ -530,7 +530,7 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
(* Join the context with the context at the loop entry *)
let (_, _), ctx2 =
- loop_join_origin_with_continue_ctxs config meta loop_id fixed_ids ctx1
+ loop_join_origin_with_continue_ctxs config span loop_id fixed_ids ctx1
ctxs
in
ctx2
@@ -560,15 +560,15 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
log#ldebug (lazy "compute_fixed_point: equiv_ctx:");
let fixed_ids = compute_fixed_ids [ ctx1; ctx2 ] in
let check_equivalent = true in
- let lookup_shared_value _ = craise __FILE__ __LINE__ meta "Unreachable" in
+ let lookup_shared_value _ = craise __FILE__ __LINE__ span "Unreachable" in
Option.is_some
- (match_ctxs meta check_equivalent fixed_ids lookup_shared_value
+ (match_ctxs span check_equivalent fixed_ids lookup_shared_value
lookup_shared_value ctx1 ctx2)
in
let max_num_iter = Config.loop_fixed_point_max_num_iters in
let rec compute_fixed_point (ctx : eval_ctx) (i0 : int) (i : int) : eval_ctx =
if i = 0 then
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Could not compute a loop fixed point in " ^ string_of_int i0
^ " iterations")
else
@@ -582,15 +582,15 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
| Return | Panic | Break _ -> None
| Unit ->
(* See the comment in {!eval_loop} *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Continue i ->
(* For now we don't support continues to outer loops *)
- cassert __FILE__ __LINE__ (i = 0) meta
+ cassert __FILE__ __LINE__ (i = 0) span
"Continues to outer loops not supported yet";
Some ctx
| LoopReturn _ | EndEnterLoop _ | EndContinue _ ->
(* We don't support nested loops for now *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Nested loops are not supported for now"
in
let continue_ctxs = List.filter_map keep_continue_ctx ctx_resl in
@@ -602,9 +602,9 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
log#ldebug
(lazy
("compute_fixed_point:" ^ "\n\n- ctx0:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx
^ "\n\n- ctx1:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx1
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx1
^ "\n\n"));
(* Check if we reached a fixed point: if not, iterate *)
@@ -617,7 +617,7 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
(lazy
("compute_fixed_point: fixed point computed before matching with input \
region groups:" ^ "\n\n- fp:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) fp
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) fp
^ "\n\n"));
(* Make sure we have exactly one loop abstraction per function region (merge
@@ -639,10 +639,10 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
method! visit_abs _ abs =
match abs.kind with
| Loop (loop_id', _, kind) ->
- sanity_check __FILE__ __LINE__ (loop_id' = loop_id) meta;
- sanity_check __FILE__ __LINE__ (kind = LoopSynthInput) meta;
+ sanity_check __FILE__ __LINE__ (loop_id' = loop_id) span;
+ sanity_check __FILE__ __LINE__ (kind = LoopSynthInput) span;
(* The abstractions introduced so far should be endable *)
- sanity_check __FILE__ __LINE__ (abs.can_end = true) meta;
+ sanity_check __FILE__ __LINE__ (abs.can_end = true) span;
add_aid abs.abs_id;
abs
| _ -> abs
@@ -672,12 +672,12 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
| Continue _ | Panic -> ()
| Break _ ->
(* We enforce that we can't get there: see {!PrePasses.remove_loop_breaks} *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Unit | LoopReturn _ | EndEnterLoop _ | EndContinue _ ->
(* For why we can't get [Unit], see the comments inside {!eval_loop_concrete}.
For [EndEnterLoop] and [EndContinue]: we don't support nested loops for now.
*)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Return ->
log#ldebug (lazy "compute_loop_entry_fixed_point: cf_loop: Return");
(* Should we consume the return value and pop the frame?
@@ -692,14 +692,14 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
order (and we check that it is indeed the case) *)
let abs_id = AbstractionId.of_int (RegionGroupId.to_int rg_id) in
(* By default, the [SynthInput] abs can't end *)
- let ctx = ctx_set_abs_can_end meta ctx abs_id true in
+ let ctx = ctx_set_abs_can_end span ctx abs_id true in
sanity_check __FILE__ __LINE__
(let abs = ctx_lookup_abs ctx abs_id in
abs.kind = SynthInput rg_id)
- meta;
+ span;
(* End this abstraction *)
let ctx =
- InterpreterBorrows.end_abstraction_no_synth config meta abs_id
+ InterpreterBorrows.end_abstraction_no_synth config span abs_id
ctx
in
(* Explore the context, and check which abstractions are not there anymore *)
@@ -718,7 +718,7 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
(fun _ ids ->
cassert __FILE__ __LINE__
(AbstractionId.Set.disjoint !aids_union ids)
- meta
+ span
"The sets of abstractions we need to end per region group are not \
pairwise disjoint";
aids_union := AbstractionId.Set.union ids !aids_union)
@@ -729,7 +729,7 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
se, but if it doesn't happen it is bizarre and worth investigating... *)
sanity_check __FILE__ __LINE__
(AbstractionId.Set.equal !aids_union !fp_aids)
- meta;
+ span;
(* Merge the abstractions which need to be merged, and compute the map from
region id to abstraction id *)
@@ -768,7 +768,7 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
in
let abs = ctx_lookup_abs !fp !id0 in
let abs = { abs with kind = abs_kind } in
- let fp', _ = ctx_subst_abs meta !fp !id0 abs in
+ let fp', _ = ctx_subst_abs span !fp !id0 abs in
fp := fp';
(* Merge all the abstractions into this one *)
List.iter
@@ -781,14 +781,14 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
^ AbstractionId.to_string !id0));
(* Note that we merge *into* [id0] *)
let fp', id0' =
- merge_into_abstraction meta loop_id abs_kind false !fp id
+ merge_into_abstraction span loop_id abs_kind false !fp id
!id0
in
fp := fp';
id0 := id0';
()
with ValueMatchFailure _ ->
- craise __FILE__ __LINE__ meta "Unexpected")
+ craise __FILE__ __LINE__ span "Unexpected")
ids;
(* Register the mapping *)
let abs = ctx_lookup_abs !fp !id0 in
@@ -799,7 +799,7 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
(* Reorder the loans and borrows in the fresh abstractions in the fixed-point *)
let fp =
- reorder_loans_borrows_in_fresh_abs meta (Option.get !fixed_ids).aids !fp
+ reorder_loans_borrows_in_fresh_abs span (Option.get !fixed_ids).aids !fp
in
(* Update the abstraction's [can_end] field and their kinds.
@@ -821,8 +821,8 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
method! visit_abs _ abs =
match abs.kind with
| Loop (loop_id', _, kind) ->
- sanity_check __FILE__ __LINE__ (loop_id' = loop_id) meta;
- sanity_check __FILE__ __LINE__ (kind = LoopSynthInput) meta;
+ sanity_check __FILE__ __LINE__ (loop_id' = loop_id) span;
+ sanity_check __FILE__ __LINE__ (kind = LoopSynthInput) span;
let kind : abs_kind =
if remove_rg_id then Loop (loop_id, None, LoopSynthInput)
else abs.kind
@@ -844,7 +844,7 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
(lazy
("compute_fixed_point: fixed point after matching with the function \
region groups:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) fp_test));
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) fp_test));
compute_fixed_point fp_test 1 1
in
@@ -856,30 +856,30 @@ let compute_loop_entry_fixed_point (config : config) (meta : Meta.meta)
(* Return *)
(fp, fixed_ids, rg_to_abs)
-let compute_fixed_point_id_correspondance (meta : Meta.meta)
+let compute_fixed_point_id_correspondance (span : Meta.span)
(fixed_ids : ids_sets) (src_ctx : eval_ctx) (tgt_ctx : eval_ctx) :
borrow_loan_corresp =
log#ldebug
(lazy
("compute_fixed_point_id_correspondance:\n\n- fixed_ids:\n"
^ show_ids_sets fixed_ids ^ "\n\n- src_ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) src_ctx
+ ^ eval_ctx_to_string ~span:(Some span) src_ctx
^ "\n\n- tgt_ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) tgt_ctx
+ ^ eval_ctx_to_string ~span:(Some span) tgt_ctx
^ "\n\n"));
- let filt_src_env, _, _ = ctx_split_fixed_new meta fixed_ids src_ctx in
+ let filt_src_env, _, _ = ctx_split_fixed_new span fixed_ids src_ctx in
let filt_src_ctx = { src_ctx with env = filt_src_env } in
- let filt_tgt_env, new_absl, _ = ctx_split_fixed_new meta fixed_ids tgt_ctx in
+ let filt_tgt_env, new_absl, _ = ctx_split_fixed_new span fixed_ids tgt_ctx in
let filt_tgt_ctx = { tgt_ctx with env = filt_tgt_env } in
log#ldebug
(lazy
("compute_fixed_point_id_correspondance:\n\n- fixed_ids:\n"
^ show_ids_sets fixed_ids ^ "\n\n- filt_src_ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) filt_src_ctx
+ ^ eval_ctx_to_string ~span:(Some span) filt_src_ctx
^ "\n\n- filt_tgt_ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) filt_tgt_ctx
+ ^ eval_ctx_to_string ~span:(Some span) filt_tgt_ctx
^ "\n\n"));
(* Match the source context and the filtered target context *)
@@ -888,15 +888,15 @@ let compute_fixed_point_id_correspondance (meta : Meta.meta)
let fixed_ids = ids_sets_empty_borrows_loans fixed_ids in
let open InterpreterBorrowsCore in
let lookup_shared_loan lid ctx : typed_value =
- match snd (lookup_loan meta ek_all lid ctx) with
+ match snd (lookup_loan span ek_all lid ctx) with
| Concrete (VSharedLoan (_, v)) -> v
| Abstract (ASharedLoan (_, v, _)) -> v
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let lookup_in_tgt id = lookup_shared_loan id tgt_ctx in
let lookup_in_src id = lookup_shared_loan id src_ctx in
Option.get
- (match_ctxs meta check_equiv fixed_ids lookup_in_tgt lookup_in_src
+ (match_ctxs span check_equiv fixed_ids lookup_in_tgt lookup_in_src
filt_tgt_ctx filt_src_ctx)
in
@@ -953,7 +953,7 @@ let compute_fixed_point_id_correspondance (meta : Meta.meta)
(* Check that the loan and borrows are related *)
sanity_check __FILE__ __LINE__
(BorrowId.Set.equal ids.borrow_ids loan_ids)
- meta)
+ span)
new_absl;
(* For every target abstraction (going back to the [list_nth_mut] example,
@@ -996,7 +996,7 @@ let compute_fixed_point_id_correspondance (meta : Meta.meta)
loan_to_borrow_id_map = tgt_loan_to_borrow;
}
-let compute_fp_ctx_symbolic_values (meta : Meta.meta) (ctx : eval_ctx)
+let compute_fp_ctx_symbolic_values (span : Meta.span) (ctx : eval_ctx)
(fp_ctx : eval_ctx) : SymbolicValueId.Set.t * symbolic_value list =
let old_ids, _ = compute_ctx_ids ctx in
let fp_ids, fp_ids_maps = compute_ctx_ids fp_ctx in
@@ -1077,10 +1077,10 @@ let compute_fp_ctx_symbolic_values (meta : Meta.meta) (ctx : eval_ctx)
method! visit_VSharedBorrow env bid =
let open InterpreterBorrowsCore in
let v =
- match snd (lookup_loan meta ek_all bid fp_ctx) with
+ match snd (lookup_loan span ek_all bid fp_ctx) with
| Concrete (VSharedLoan (_, v)) -> v
| Abstract (ASharedLoan (_, v, _)) -> v
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
self#visit_typed_value env v
@@ -1101,9 +1101,9 @@ let compute_fp_ctx_symbolic_values (meta : Meta.meta) (ctx : eval_ctx)
log#ldebug
(lazy
("compute_fp_ctx_symbolic_values:" ^ "\n- src context:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx
^ "\n- fixed point:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) fp_ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) fp_ctx
^ "\n- fresh_sids: "
^ SymbolicValueId.Set.show fresh_sids
^ "\n- input_svalues: "
diff --git a/compiler/InterpreterLoopsFixedPoint.mli b/compiler/InterpreterLoopsFixedPoint.mli
index d367c94c..59d42812 100644
--- a/compiler/InterpreterLoopsFixedPoint.mli
+++ b/compiler/InterpreterLoopsFixedPoint.mli
@@ -13,7 +13,7 @@ open InterpreterLoopsCore
- config
- fixed ids (the fixeds ids are the ids we consider as non-fresh)
*)
-val cleanup_fresh_values_and_abs : config -> Meta.meta -> ids_sets -> Cps.cm_fun
+val cleanup_fresh_values_and_abs : config -> Meta.span -> ids_sets -> Cps.cm_fun
(** Prepare the shared loans in the abstractions by moving them to fresh
abstractions.
@@ -60,7 +60,7 @@ val cleanup_fresh_values_and_abs : config -> Meta.meta -> ids_sets -> Cps.cm_fun
we only introduce a fresh abstraction for [l1].
*)
-val prepare_ashared_loans : Meta.meta -> loop_id option -> Cps.cm_fun
+val prepare_ashared_loans : Meta.span -> loop_id option -> Cps.cm_fun
(** Compute a fixed-point for the context at the entry of the loop.
We also return:
@@ -78,7 +78,7 @@ val prepare_ashared_loans : Meta.meta -> loop_id option -> Cps.cm_fun
*)
val compute_loop_entry_fixed_point :
config ->
- Meta.meta ->
+ Meta.span ->
loop_id ->
(* This function is the function to evaluate the loop body (eval_statement applied
to the proper arguments) *)
@@ -163,7 +163,7 @@ val compute_loop_entry_fixed_point :
through the loan [l1] is actually the value which has to be given back to [l0].
*)
val compute_fixed_point_id_correspondance :
- Meta.meta -> ids_sets -> eval_ctx -> eval_ctx -> borrow_loan_corresp
+ Meta.span -> ids_sets -> eval_ctx -> eval_ctx -> borrow_loan_corresp
(** Compute the set of "quantified" symbolic value ids in a fixed-point context.
@@ -172,7 +172,7 @@ val compute_fixed_point_id_correspondance :
- the list of input symbolic values
*)
val compute_fp_ctx_symbolic_values :
- Meta.meta ->
+ Meta.span ->
eval_ctx ->
eval_ctx ->
symbolic_value_id_set * symbolic_value list
diff --git a/compiler/InterpreterLoopsJoinCtxs.ml b/compiler/InterpreterLoopsJoinCtxs.ml
index de00cb93..c67869ac 100644
--- a/compiler/InterpreterLoopsJoinCtxs.ml
+++ b/compiler/InterpreterLoopsJoinCtxs.ml
@@ -19,7 +19,7 @@ let log = Logging.loops_join_ctxs_log
called typically after we merge abstractions together (see {!collapse_ctx}
for instance).
*)
-let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
+let reorder_loans_borrows_in_fresh_abs (span : Meta.span)
(old_abs_ids : AbstractionId.Set.t) (ctx : eval_ctx) : eval_ctx =
let reorder_in_fresh_abs (abs : abs) : abs =
(* Split between the loans and borrows *)
@@ -27,7 +27,7 @@ let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
match av.value with
| ABorrow _ -> true
| ALoan _ -> false
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
let aborrows, aloans = List.partition is_borrow abs.avalues in
@@ -40,13 +40,13 @@ let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
let get_borrow_id (av : typed_avalue) : BorrowId.id =
match av.value with
| ABorrow (AMutBorrow (bid, _) | ASharedBorrow bid) -> bid
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
let get_loan_id (av : typed_avalue) : BorrowId.id =
match av.value with
| ALoan (AMutLoan (lid, _)) -> lid
| ALoan (ASharedLoan (lids, _, _)) -> BorrowId.Set.min_elt lids
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
(* We use ordered maps to reorder the borrows and loans *)
let reorder (get_bid : typed_avalue -> BorrowId.id)
@@ -129,7 +129,7 @@ let reorder_loans_borrows_in_fresh_abs (meta : Meta.meta)
This can happen when merging environments (note that such environments are not well-formed -
they become well formed again after collapsing).
*)
-let collapse_ctx (meta : Meta.meta) (loop_id : LoopId.id)
+let collapse_ctx (span : Meta.span) (loop_id : LoopId.id)
(merge_funs : merge_duplicates_funcs option) (old_ids : ids_sets)
(ctx0 : eval_ctx) : eval_ctx =
(* Debug *)
@@ -137,7 +137,7 @@ let collapse_ctx (meta : Meta.meta) (loop_id : LoopId.id)
(lazy
("collapse_ctx:\n\n- fixed_ids:\n" ^ show_ids_sets old_ids
^ "\n\n- ctx0:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string ~span:(Some span) ctx0
^ "\n\n"));
let abs_kind : abs_kind = Loop (loop_id, None, LoopSynthInput) in
@@ -162,7 +162,7 @@ let collapse_ctx (meta : Meta.meta) (loop_id : LoopId.id)
| EBinding (BDummy id, v) ->
if is_fresh_did id then
let absl =
- convert_value_to_abstractions meta abs_kind can_end
+ convert_value_to_abstractions span abs_kind can_end
destructure_shared_values ctx0 v
in
List.map (fun abs -> EAbs abs) absl
@@ -174,20 +174,20 @@ let collapse_ctx (meta : Meta.meta) (loop_id : LoopId.id)
(lazy
("collapse_ctx: after converting values to abstractions:\n"
^ show_ids_sets old_ids ^ "\n\n- ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n\n"));
log#ldebug
(lazy
("collapse_ctx: after decomposing the shared values in the abstractions:\n"
^ show_ids_sets old_ids ^ "\n\n- ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n\n"));
(* Explore all the *new* abstractions, and compute various maps *)
let explore (abs : abs) = is_fresh_abs_id abs.abs_id in
let ids_maps =
- compute_abs_borrows_loans_maps meta (merge_funs = None) explore env
+ compute_abs_borrows_loans_maps span (merge_funs = None) explore env
in
let {
abs_ids;
@@ -257,12 +257,12 @@ let collapse_ctx (meta : Meta.meta) (loop_id : LoopId.id)
^ " into "
^ AbstractionId.to_string abs_id0
^ ":\n\n"
- ^ eval_ctx_to_string ~meta:(Some meta) !ctx));
+ ^ eval_ctx_to_string ~span:(Some span) !ctx));
(* Update the environment - pay attention to the order: we
we merge [abs_id1] *into* [abs_id0] *)
let nctx, abs_id =
- merge_into_abstraction meta abs_kind can_end merge_funs
+ merge_into_abstraction span abs_kind can_end merge_funs
!ctx abs_id1 abs_id0
in
ctx := nctx;
@@ -278,27 +278,27 @@ let collapse_ctx (meta : Meta.meta) (loop_id : LoopId.id)
(lazy
("collapse_ctx:\n\n- fixed_ids:\n" ^ show_ids_sets old_ids
^ "\n\n- after collapse:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) !ctx
+ ^ eval_ctx_to_string ~span:(Some span) !ctx
^ "\n\n"));
(* Reorder the loans and borrows in the fresh abstractions *)
- let ctx = reorder_loans_borrows_in_fresh_abs meta old_ids.aids !ctx in
+ let ctx = reorder_loans_borrows_in_fresh_abs span old_ids.aids !ctx in
log#ldebug
(lazy
("collapse_ctx:\n\n- fixed_ids:\n" ^ show_ids_sets old_ids
^ "\n\n- after collapse and reorder borrows/loans:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx
+ ^ eval_ctx_to_string ~span:(Some span) ctx
^ "\n\n"));
(* Return the new context *)
ctx
-let mk_collapse_ctx_merge_duplicate_funs (meta : Meta.meta)
+let mk_collapse_ctx_merge_duplicate_funs (span : Meta.span)
(loop_id : LoopId.id) (ctx : eval_ctx) : merge_duplicates_funcs =
(* Rem.: the merge functions raise exceptions (that we catch). *)
let module S : MatchJoinState = struct
- let meta = meta
+ let span = span
let loop_id = loop_id
let nabs = ref []
end in
@@ -316,8 +316,8 @@ let mk_collapse_ctx_merge_duplicate_funs (meta : Meta.meta)
*)
let merge_amut_borrows id ty0 child0 _ty1 child1 =
(* Sanity checks *)
- sanity_check __FILE__ __LINE__ (is_aignored child0.value) meta;
- sanity_check __FILE__ __LINE__ (is_aignored child1.value) meta;
+ sanity_check __FILE__ __LINE__ (is_aignored child0.value) span;
+ sanity_check __FILE__ __LINE__ (is_aignored child1.value) span;
(* We need to pick a type for the avalue. The types on the left and on the
right may use different regions: it doesn't really matter (here, we pick
@@ -337,10 +337,10 @@ let mk_collapse_ctx_merge_duplicate_funs (meta : Meta.meta)
let _, ty1, _ = ty_as_ref ty1 in
sanity_check __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos ty0))
- meta;
+ span;
sanity_check __FILE__ __LINE__
(not (ty_has_borrows ctx.type_ctx.type_infos ty1))
- meta
+ span
in
(* Same remarks as for [merge_amut_borrows] *)
@@ -351,8 +351,8 @@ let mk_collapse_ctx_merge_duplicate_funs (meta : Meta.meta)
let merge_amut_loans id ty0 child0 _ty1 child1 =
(* Sanity checks *)
- sanity_check __FILE__ __LINE__ (is_aignored child0.value) meta;
- sanity_check __FILE__ __LINE__ (is_aignored child1.value) meta;
+ sanity_check __FILE__ __LINE__ (is_aignored child0.value) span;
+ sanity_check __FILE__ __LINE__ (is_aignored child1.value) span;
(* Same remarks as for [merge_amut_borrows] *)
let ty = ty0 in
let child = child0 in
@@ -362,8 +362,8 @@ let mk_collapse_ctx_merge_duplicate_funs (meta : Meta.meta)
let merge_ashared_loans ids ty0 (sv0 : typed_value) child0 _ty1
(sv1 : typed_value) child1 =
(* Sanity checks *)
- sanity_check __FILE__ __LINE__ (is_aignored child0.value) meta;
- sanity_check __FILE__ __LINE__ (is_aignored child1.value) meta;
+ sanity_check __FILE__ __LINE__ (is_aignored child0.value) span;
+ sanity_check __FILE__ __LINE__ (is_aignored child1.value) span;
(* Same remarks as for [merge_amut_borrows].
This time we need to also merge the shared values. We rely on the
@@ -371,10 +371,10 @@ let mk_collapse_ctx_merge_duplicate_funs (meta : Meta.meta)
*)
sanity_check __FILE__ __LINE__
(not (value_has_loans_or_borrows ctx sv0.value))
- meta;
+ span;
sanity_check __FILE__ __LINE__
(not (value_has_loans_or_borrows ctx sv1.value))
- meta;
+ span;
let ty = ty0 in
let child = child0 in
let sv = M.match_typed_values ctx ctx sv0 sv1 in
@@ -388,12 +388,12 @@ let mk_collapse_ctx_merge_duplicate_funs (meta : Meta.meta)
merge_ashared_loans;
}
-let merge_into_abstraction (meta : Meta.meta) (loop_id : LoopId.id)
+let merge_into_abstraction (span : Meta.span) (loop_id : LoopId.id)
(abs_kind : abs_kind) (can_end : bool) (ctx : eval_ctx)
(aid0 : AbstractionId.id) (aid1 : AbstractionId.id) :
eval_ctx * AbstractionId.id =
- let merge_funs = mk_collapse_ctx_merge_duplicate_funs meta loop_id ctx in
- merge_into_abstraction meta abs_kind can_end (Some merge_funs) ctx aid0 aid1
+ let merge_funs = mk_collapse_ctx_merge_duplicate_funs span loop_id ctx in
+ merge_into_abstraction span abs_kind can_end (Some merge_funs) ctx aid0 aid1
(** Collapse an environment, merging the duplicated borrows/loans.
@@ -402,22 +402,22 @@ let merge_into_abstraction (meta : Meta.meta) (loop_id : LoopId.id)
We do this because when we join environments, we may introduce duplicated
loans and borrows. See the explanations for {!join_ctxs}.
*)
-let collapse_ctx_with_merge (meta : Meta.meta) (loop_id : LoopId.id)
+let collapse_ctx_with_merge (span : Meta.span) (loop_id : LoopId.id)
(old_ids : ids_sets) (ctx : eval_ctx) : eval_ctx =
- let merge_funs = mk_collapse_ctx_merge_duplicate_funs meta loop_id ctx in
- try collapse_ctx meta loop_id (Some merge_funs) old_ids ctx
- with ValueMatchFailure _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ let merge_funs = mk_collapse_ctx_merge_duplicate_funs span loop_id ctx in
+ try collapse_ctx span loop_id (Some merge_funs) old_ids ctx
+ with ValueMatchFailure _ -> craise __FILE__ __LINE__ span "Unexpected"
-let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
+let join_ctxs (span : Meta.span) (loop_id : LoopId.id) (fixed_ids : ids_sets)
(ctx0 : eval_ctx) (ctx1 : eval_ctx) : ctx_or_update =
(* Debug *)
log#ldebug
(lazy
("join_ctxs:\n\n- fixed_ids:\n" ^ show_ids_sets fixed_ids
^ "\n\n- ctx0:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx0
^ "\n\n- ctx1:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx1
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx1
^ "\n\n"));
let env0 = List.rev ctx0.env in
@@ -431,10 +431,10 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
(lazy
("join_suffixes:\n\n- fixed_ids:\n" ^ show_ids_sets fixed_ids
^ "\n\n- ctx0:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta)
+ ^ eval_ctx_to_string_no_filter ~span:(Some span)
{ ctx0 with env = List.rev env0 }
^ "\n\n- ctx1:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta)
+ ^ eval_ctx_to_string_no_filter ~span:(Some span)
{ ctx1 with env = List.rev env1 }
^ "\n\n"));
@@ -443,18 +443,18 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
match ee with
| EBinding (BVar _, _) ->
(* Variables are necessarily in the prefix *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| EBinding (BDummy did, _) ->
sanity_check __FILE__ __LINE__
(not (DummyVarId.Set.mem did fixed_ids.dids))
- meta
+ span
| EAbs abs ->
sanity_check __FILE__ __LINE__
(not (AbstractionId.Set.mem abs.abs_id fixed_ids.aids))
- meta
+ span
| EFrame ->
(* This should have been eliminated *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
List.iter check_valid env0;
List.iter check_valid env1;
@@ -465,7 +465,7 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
in
let module S : MatchJoinState = struct
- let meta = meta
+ let span = span
let loop_id = loop_id
let nabs = nabs
end in
@@ -481,9 +481,9 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
(lazy
("join_prefixes: BDummys:\n\n- fixed_ids:\n" ^ "\n"
^ show_ids_sets fixed_ids ^ "\n\n- value0:\n"
- ^ env_elem_to_string meta ctx0 var0
+ ^ env_elem_to_string span ctx0 var0
^ "\n\n- value1:\n"
- ^ env_elem_to_string meta ctx1 var1
+ ^ env_elem_to_string span ctx1 var1
^ "\n\n"));
(* Two cases: the dummy value is an old value, in which case the bindings
@@ -491,7 +491,7 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
are not in the prefix anymore *)
if DummyVarId.Set.mem b0 fixed_ids.dids then (
(* Still in the prefix: match the values *)
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
let b = b0 in
let v = M.match_typed_values ctx0 ctx1 v0 v1 in
let var = EBinding (BDummy b, v) in
@@ -506,14 +506,14 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
(lazy
("join_prefixes: BVars:\n\n- fixed_ids:\n" ^ "\n"
^ show_ids_sets fixed_ids ^ "\n\n- value0:\n"
- ^ env_elem_to_string meta ctx0 var0
+ ^ env_elem_to_string span ctx0 var0
^ "\n\n- value1:\n"
- ^ env_elem_to_string meta ctx1 var1
+ ^ env_elem_to_string span ctx1 var1
^ "\n\n"));
(* Variable bindings *must* be in the prefix and consequently their
ids must be the same *)
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
(* Match the values *)
let b = b0 in
let v = M.match_typed_values ctx0 ctx1 v0 v1 in
@@ -526,15 +526,15 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
(lazy
("join_prefixes: Abs:\n\n- fixed_ids:\n" ^ "\n"
^ show_ids_sets fixed_ids ^ "\n\n- abs0:\n"
- ^ abs_to_string meta ctx0 abs0
+ ^ abs_to_string span ctx0 abs0
^ "\n\n- abs1:\n"
- ^ abs_to_string meta ctx1 abs1
+ ^ abs_to_string span ctx1 abs1
^ "\n\n"));
(* Same as for the dummy values: there are two cases *)
if AbstractionId.Set.mem abs0.abs_id fixed_ids.aids then (
(* Still in the prefix: the abstractions must be the same *)
- sanity_check __FILE__ __LINE__ (abs0 = abs1) meta;
+ sanity_check __FILE__ __LINE__ (abs0 = abs1) span;
(* Continue *)
abs :: join_prefixes env0' env1')
else (* Not in the prefix anymore *)
@@ -549,7 +549,7 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
let env0, env1 =
match (env0, env1) with
| EFrame :: env0, EFrame :: env1 -> (env0, env1)
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
log#ldebug
@@ -611,7 +611,7 @@ let join_ctxs (meta : Meta.meta) (loop_id : LoopId.id) (fixed_ids : ids_sets)
with ValueMatchFailure e -> Error e
(** Destructure all the new abstractions *)
-let destructure_new_abs (meta : Meta.meta) (loop_id : LoopId.id)
+let destructure_new_abs (span : Meta.span) (loop_id : LoopId.id)
(old_abs_ids : AbstractionId.Set.t) (ctx : eval_ctx) : eval_ctx =
let abs_kind : abs_kind = Loop (loop_id, None, LoopSynthInput) in
let can_end = true in
@@ -624,7 +624,7 @@ let destructure_new_abs (meta : Meta.meta) (loop_id : LoopId.id)
(fun abs ->
if is_fresh_abs_id abs.abs_id then
let abs =
- destructure_abs meta abs_kind can_end destructure_shared_values ctx
+ destructure_abs span abs_kind can_end destructure_shared_values ctx
abs
in
abs
@@ -664,7 +664,7 @@ let refresh_abs (old_abs : AbstractionId.Set.t) (ctx : eval_ctx) : eval_ctx =
in
{ ctx with env }
-let loop_join_origin_with_continue_ctxs (config : config) (meta : Meta.meta)
+let loop_join_origin_with_continue_ctxs (config : config) (span : Meta.span)
(loop_id : LoopId.id) (fixed_ids : ids_sets) (old_ctx : eval_ctx)
(ctxl : eval_ctx list) : (eval_ctx * eval_ctx list) * eval_ctx =
(* # Join with the new contexts, one by one
@@ -677,7 +677,7 @@ let loop_join_origin_with_continue_ctxs (config : config) (meta : Meta.meta)
*)
let joined_ctx = ref old_ctx in
let rec join_one_aux (ctx : eval_ctx) : eval_ctx =
- match join_ctxs meta loop_id fixed_ids !joined_ctx ctx with
+ match join_ctxs span loop_id fixed_ids !joined_ctx ctx with
| Ok nctx ->
joined_ctx := nctx;
ctx
@@ -685,11 +685,11 @@ let loop_join_origin_with_continue_ctxs (config : config) (meta : Meta.meta)
let ctx =
match err with
| LoanInRight bid ->
- InterpreterBorrows.end_borrow_no_synth config meta bid ctx
+ InterpreterBorrows.end_borrow_no_synth config span bid ctx
| LoansInRight bids ->
- InterpreterBorrows.end_borrows_no_synth config meta bids ctx
+ InterpreterBorrows.end_borrows_no_synth config span bids ctx
| AbsInRight _ | AbsInLeft _ | LoanInLeft _ | LoansInLeft _ ->
- craise __FILE__ __LINE__ meta "Unexpected"
+ craise __FILE__ __LINE__ span "Unexpected"
in
join_one_aux ctx
in
@@ -697,21 +697,21 @@ let loop_join_origin_with_continue_ctxs (config : config) (meta : Meta.meta)
log#ldebug
(lazy
("loop_join_origin_with_continue_ctxs:join_one: initial ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Destructure the abstractions introduced in the new context *)
- let ctx = destructure_new_abs meta loop_id fixed_ids.aids ctx in
+ let ctx = destructure_new_abs span loop_id fixed_ids.aids ctx in
log#ldebug
(lazy
("loop_join_origin_with_continue_ctxs:join_one: after destructure:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Collapse the context we want to add to the join *)
- let ctx = collapse_ctx meta loop_id None fixed_ids ctx in
+ let ctx = collapse_ctx span loop_id None fixed_ids ctx in
log#ldebug
(lazy
("loop_join_origin_with_continue_ctxs:join_one: after collapse:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Refresh the fresh abstractions *)
let ctx = refresh_abs fixed_ids.aids ctx in
@@ -721,19 +721,19 @@ let loop_join_origin_with_continue_ctxs (config : config) (meta : Meta.meta)
log#ldebug
(lazy
("loop_join_origin_with_continue_ctxs:join_one: after join:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx1));
+ ^ eval_ctx_to_string ~span:(Some span) ctx1));
(* Collapse again - the join might have introduce abstractions we want
to merge with the others (note that those abstractions may actually
lead to borrows/loans duplications) *)
- joined_ctx := collapse_ctx_with_merge meta loop_id fixed_ids !joined_ctx;
+ joined_ctx := collapse_ctx_with_merge span loop_id fixed_ids !joined_ctx;
log#ldebug
(lazy
("loop_join_origin_with_continue_ctxs:join_one: after join-collapse:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) !joined_ctx));
+ ^ eval_ctx_to_string ~span:(Some span) !joined_ctx));
(* Sanity check *)
- if !Config.sanity_checks then Invariants.check_invariants meta !joined_ctx;
+ if !Config.sanity_checks then Invariants.check_invariants span !joined_ctx;
(* Return *)
ctx1
in
diff --git a/compiler/InterpreterLoopsJoinCtxs.mli b/compiler/InterpreterLoopsJoinCtxs.mli
index 0e84657c..f4b5194a 100644
--- a/compiler/InterpreterLoopsJoinCtxs.mli
+++ b/compiler/InterpreterLoopsJoinCtxs.mli
@@ -16,7 +16,7 @@ open InterpreterLoopsCore
- [aid1]
*)
val merge_into_abstraction :
- Meta.meta ->
+ Meta.span ->
loop_id ->
abs_kind ->
bool ->
@@ -86,7 +86,7 @@ val merge_into_abstraction :
- [ctx1]
*)
val join_ctxs :
- Meta.meta -> loop_id -> ids_sets -> eval_ctx -> eval_ctx -> ctx_or_update
+ Meta.span -> loop_id -> ids_sets -> eval_ctx -> eval_ctx -> ctx_or_update
(** Join the context at the entry of the loop with the contexts upon reentry
(upon reaching the [Continue] statement - the goal is to compute a fixed
@@ -106,7 +106,7 @@ val join_ctxs :
*)
val loop_join_origin_with_continue_ctxs :
config ->
- Meta.meta ->
+ Meta.span ->
loop_id ->
ids_sets ->
eval_ctx ->
diff --git a/compiler/InterpreterLoopsMatchCtxs.ml b/compiler/InterpreterLoopsMatchCtxs.ml
index b95148bd..e25adb2c 100644
--- a/compiler/InterpreterLoopsMatchCtxs.ml
+++ b/compiler/InterpreterLoopsMatchCtxs.ml
@@ -20,7 +20,7 @@ module S = SynthesizeSymbolic
(** The local logger *)
let log = Logging.loops_match_ctxs_log
-let compute_abs_borrows_loans_maps (meta : Meta.meta) (no_duplicates : bool)
+let compute_abs_borrows_loans_maps (span : Meta.span) (no_duplicates : bool)
(explore : abs -> bool) (env : env) : abs_borrows_loans_maps =
let abs_ids = ref [] in
let abs_to_borrows = ref AbstractionId.Map.empty in
@@ -45,7 +45,7 @@ let compute_abs_borrows_loans_maps (meta : Meta.meta) (no_duplicates : bool)
| Some set ->
sanity_check __FILE__ __LINE__
((not check_not_already_registered) || not (Id1.Set.mem id1 set))
- meta);
+ span);
(* Update the mapping *)
map :=
Id0.Map.update id0
@@ -54,11 +54,11 @@ let compute_abs_borrows_loans_maps (meta : Meta.meta) (no_duplicates : bool)
| None -> Some (Id1.Set.singleton id1)
| Some ids ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (not check_singleton_sets) meta;
+ sanity_check __FILE__ __LINE__ (not check_singleton_sets) span;
sanity_check __FILE__ __LINE__
((not check_not_already_registered)
|| not (Id1.Set.mem id1 ids))
- meta;
+ span;
(* Update *)
Some (Id1.Set.add id1 ids))
!map
@@ -92,12 +92,12 @@ let compute_abs_borrows_loans_maps (meta : Meta.meta) (no_duplicates : bool)
(* Process those normally *)
super#visit_aloan_content abs_id lc
| AIgnoredMutLoan (_, child)
- | AEndedIgnoredMutLoan { child; given_back = _; given_back_meta = _ }
+ | AEndedIgnoredMutLoan { child; given_back = _; given_back_span = _ }
| AIgnoredSharedLoan child ->
(* Ignore the id of the loan, if there is *)
self#visit_typed_avalue abs_id child
| AEndedMutLoan _ | AEndedSharedLoan _ ->
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
(** Make sure we don't register the ignored ids *)
method! visit_aborrow_content abs_id bc =
@@ -106,12 +106,12 @@ let compute_abs_borrows_loans_maps (meta : Meta.meta) (no_duplicates : bool)
(* Process those normally *)
super#visit_aborrow_content abs_id bc
| AIgnoredMutBorrow (_, child)
- | AEndedIgnoredMutBorrow { child; given_back = _; given_back_meta = _ }
+ | AEndedIgnoredMutBorrow { child; given_back = _; given_back_span = _ }
->
(* Ignore the id of the borrow, if there is *)
self#visit_typed_avalue abs_id child
| AEndedMutBorrow _ | AEndedSharedBorrow ->
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
method! visit_borrow_id abs_id bid = register_borrow_id abs_id bid
method! visit_loan_id abs_id lid = register_loan_id abs_id lid
@@ -147,18 +147,18 @@ let compute_abs_borrows_loans_maps (meta : Meta.meta) (no_duplicates : bool)
TODO: probably don't need to take [match_regions] as input anymore.
*)
-let rec match_types (meta : Meta.meta) (match_distinct_types : ty -> ty -> ty)
+let rec match_types (span : Meta.span) (match_distinct_types : ty -> ty -> ty)
(match_regions : region -> region -> region) (ty0 : ty) (ty1 : ty) : ty =
- let match_rec = match_types meta match_distinct_types match_regions in
+ let match_rec = match_types span match_distinct_types match_regions in
match (ty0, ty1) with
| TAdt (id0, generics0), TAdt (id1, generics1) ->
- sanity_check __FILE__ __LINE__ (id0 = id1) meta;
+ sanity_check __FILE__ __LINE__ (id0 = id1) span;
sanity_check __FILE__ __LINE__
(generics0.const_generics = generics1.const_generics)
- meta;
+ span;
sanity_check __FILE__ __LINE__
(generics0.trait_refs = generics1.trait_refs)
- meta;
+ span;
let id = id0 in
let const_generics = generics1.const_generics in
let trait_refs = generics1.trait_refs in
@@ -175,23 +175,23 @@ let rec match_types (meta : Meta.meta) (match_distinct_types : ty -> ty -> ty)
let generics = { regions; types; const_generics; trait_refs } in
TAdt (id, generics)
| TVar vid0, TVar vid1 ->
- sanity_check __FILE__ __LINE__ (vid0 = vid1) meta;
+ sanity_check __FILE__ __LINE__ (vid0 = vid1) span;
let vid = vid0 in
TVar vid
| TLiteral lty0, TLiteral lty1 ->
- sanity_check __FILE__ __LINE__ (lty0 = lty1) meta;
+ sanity_check __FILE__ __LINE__ (lty0 = lty1) span;
ty0
| TNever, TNever -> ty0
| TRef (r0, ty0, k0), TRef (r1, ty1, k1) ->
let r = match_regions r0 r1 in
let ty = match_rec ty0 ty1 in
- sanity_check __FILE__ __LINE__ (k0 = k1) meta;
+ sanity_check __FILE__ __LINE__ (k0 = k1) span;
let k = k0 in
TRef (r, ty, k)
| _ -> match_distinct_types ty0 ty1
module MakeMatcher (M : PrimMatcher) : Matcher = struct
- let meta = M.meta
+ let span = M.span
let rec match_typed_values (ctx0 : eval_ctx) (ctx1 : eval_ctx)
(v0 : typed_value) (v1 : typed_value) : typed_value =
@@ -221,10 +221,10 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
(* For now, we don't merge ADTs which contain borrows *)
sanity_check __FILE__ __LINE__
(not (value_has_borrows v0.value))
- M.meta;
+ M.span;
sanity_check __FILE__ __LINE__
(not (value_has_borrows v1.value))
- M.meta;
+ M.span;
(* Merge *)
M.match_distinct_adts ctx0 ctx1 ty av0 av1)
| VBottom, VBottom -> v0
@@ -243,7 +243,7 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
(not
(ValuesUtils.value_has_borrows ctx0.type_ctx.type_infos
bv.value))
- M.meta "The join of nested borrows is not supported yet";
+ M.span "The join of nested borrows is not supported yet";
let bid, bv =
M.match_mut_borrows ctx0 ctx1 ty bid0 bv0 bid1 bv1 bv
in
@@ -256,7 +256,7 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
trying to match a reserved borrow, which shouldn't happen because
reserved borrow should be eliminated very quickly - they are introduced
just before function calls which activate them *)
- craise __FILE__ __LINE__ M.meta "Unexpected"
+ craise __FILE__ __LINE__ M.span "Unexpected"
in
{ value = VBorrow bc; ty }
| VLoan lc0, VLoan lc1 ->
@@ -268,14 +268,14 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
let sv = match_rec sv0 sv1 in
cassert __FILE__ __LINE__
(not (value_has_borrows sv.value))
- M.meta "The join of nested borrows is not supported yet";
+ M.span "The join of nested borrows is not supported yet";
let ids, sv = M.match_shared_loans ctx0 ctx1 ty ids0 ids1 sv in
VSharedLoan (ids, sv)
| VMutLoan id0, VMutLoan id1 ->
let id = M.match_mut_loans ctx0 ctx1 ty id0 id1 in
VMutLoan id
| VSharedLoan _, VMutLoan _ | VMutLoan _, VSharedLoan _ ->
- craise __FILE__ __LINE__ M.meta "Unreachable"
+ craise __FILE__ __LINE__ M.span "Unreachable"
in
{ value = VLoan lc; ty = v1.ty }
| VSymbolic sv0, VSymbolic sv1 ->
@@ -283,12 +283,12 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
be eagerly expanded, and we don't support nested borrows *)
cassert __FILE__ __LINE__
(not (value_has_borrows v0.value))
- M.meta
+ M.span
"Nested borrows are not supported yet and all the symbolic values \
containing borrows are currently forced to be eagerly expanded";
cassert __FILE__ __LINE__
(not (value_has_borrows v1.value))
- M.meta
+ M.span
"Nested borrows are not supported yet and all the symbolic values \
containing borrows are currently forced to be eagerly expanded";
(* Match *)
@@ -310,19 +310,19 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
log#ldebug
(lazy
("Unexpected match case:\n- value0: "
- ^ typed_value_to_string ~meta:(Some M.meta) ctx0 v0
+ ^ typed_value_to_string ~span:(Some M.span) ctx0 v0
^ "\n- value1: "
- ^ typed_value_to_string ~meta:(Some M.meta) ctx1 v1));
- craise __FILE__ __LINE__ M.meta "Unexpected match case"
+ ^ typed_value_to_string ~span:(Some M.span) ctx1 v1));
+ craise __FILE__ __LINE__ M.span "Unexpected match case"
and match_typed_avalues (ctx0 : eval_ctx) (ctx1 : eval_ctx)
(v0 : typed_avalue) (v1 : typed_avalue) : typed_avalue =
log#ldebug
(lazy
("match_typed_avalues:\n- value0: "
- ^ typed_avalue_to_string ~meta:(Some M.meta) ctx0 v0
+ ^ typed_avalue_to_string ~span:(Some M.span) ctx0 v0
^ "\n- value1: "
- ^ typed_avalue_to_string ~meta:(Some M.meta) ctx1 v1));
+ ^ typed_avalue_to_string ~span:(Some M.span) ctx1 v1));
(* Using ValuesUtils.value_has_borrows on purpose here: we want
to make explicit the fact that, though we have to pick
@@ -348,8 +348,8 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
{ value; ty }
else (* Merge *)
M.match_distinct_aadts ctx0 ctx1 v0.ty av0 v1.ty av1 ty
- | ABottom, ABottom -> mk_abottom M.meta ty
- | AIgnored, AIgnored -> mk_aignored M.meta ty
+ | ABottom, ABottom -> mk_abottom M.span ty
+ | AIgnored, AIgnored -> mk_aignored M.span ty
| ABorrow bc0, ABorrow bc1 -> (
log#ldebug (lazy "match_typed_avalues: borrows");
match (bc0, bc1) with
@@ -367,7 +367,7 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
M.match_amut_borrows ctx0 ctx1 v0.ty bid0 av0 v1.ty bid1 av1 ty av
| AIgnoredMutBorrow _, AIgnoredMutBorrow _ ->
(* The abstractions are destructured: we shouldn't get there *)
- craise __FILE__ __LINE__ M.meta "Unexpected"
+ craise __FILE__ __LINE__ M.span "Unexpected"
| AProjSharedBorrow asb0, AProjSharedBorrow asb1 -> (
match (asb0, asb1) with
| [], [] ->
@@ -376,7 +376,7 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
v0
| _ ->
(* We should get there only if there are nested borrows *)
- craise __FILE__ __LINE__ M.meta "Unexpected")
+ craise __FILE__ __LINE__ M.span "Unexpected")
| _ ->
(* TODO: getting there is not necessarily inconsistent (it may
just be because the environments don't match) so we may want
@@ -387,7 +387,7 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
we are *currently* ending it, in which case we need
to completely end it before continuing.
*)
- craise __FILE__ __LINE__ M.meta "Unexpected")
+ craise __FILE__ __LINE__ M.span "Unexpected")
| ALoan lc0, ALoan lc1 -> (
log#ldebug (lazy "match_typed_avalues: loans");
(* TODO: maybe we should enforce that the ids are always exactly the same -
@@ -399,7 +399,7 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
let av = match_arec av0 av1 in
sanity_check __FILE__ __LINE__
(not (value_has_borrows sv.value))
- M.meta;
+ M.span;
M.match_ashared_loans ctx0 ctx1 v0.ty ids0 sv0 av0 v1.ty ids1 sv1
av1 ty sv av
| AMutLoan (id0, av0), AMutLoan (id1, av1) ->
@@ -414,35 +414,35 @@ module MakeMatcher (M : PrimMatcher) : Matcher = struct
| AIgnoredSharedLoan _, AIgnoredSharedLoan _ ->
(* Those should have been filtered when destructuring the abstractions -
they are necessary only when there are nested borrows *)
- craise __FILE__ __LINE__ M.meta "Unreachable"
- | _ -> craise __FILE__ __LINE__ M.meta "Unreachable")
+ craise __FILE__ __LINE__ M.span "Unreachable"
+ | _ -> craise __FILE__ __LINE__ M.span "Unreachable")
| ASymbolic _, ASymbolic _ ->
(* For now, we force all the symbolic values containing borrows to
be eagerly expanded, and we don't support nested borrows *)
- craise __FILE__ __LINE__ M.meta "Unreachable"
+ craise __FILE__ __LINE__ M.span "Unreachable"
| _ -> M.match_avalues ctx0 ctx1 v0 v1
end
module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
(** Small utility *)
- let meta = S.meta
+ let span = S.span
let push_abs (abs : abs) : unit = S.nabs := abs :: !S.nabs
let push_absl (absl : abs list) : unit = List.iter push_abs absl
let match_etys _ _ ty0 ty1 =
- sanity_check __FILE__ __LINE__ (ty0 = ty1) meta;
+ sanity_check __FILE__ __LINE__ (ty0 = ty1) span;
ty0
let match_rtys _ _ ty0 ty1 =
(* The types must be equal - in effect, this forbids to match symbolic
values containing borrows *)
- sanity_check __FILE__ __LINE__ (ty0 = ty1) meta;
+ sanity_check __FILE__ __LINE__ (ty0 = ty1) span;
ty0
let match_distinct_literals (_ : eval_ctx) (_ : eval_ctx) (ty : ety)
(_ : literal) (_ : literal) : typed_value =
- mk_fresh_symbolic_typed_value_from_no_regions_ty meta ty
+ mk_fresh_symbolic_typed_value_from_no_regions_ty span ty
let match_distinct_adts (ctx0 : eval_ctx) (ctx1 : eval_ctx) (ty : ety)
(adt0 : adt_value) (adt1 : adt_value) : typed_value =
@@ -451,7 +451,7 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
updates
*)
let check_no_borrows ctx (v : typed_value) =
- sanity_check __FILE__ __LINE__ (not (value_has_borrows ctx v.value)) meta
+ sanity_check __FILE__ __LINE__ (not (value_has_borrows ctx v.value)) span
in
List.iter (check_no_borrows ctx0) adt0.field_values;
List.iter (check_no_borrows ctx1) adt1.field_values;
@@ -474,18 +474,18 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
if
bottom_in_adt_value ctx0.ended_regions adt0
|| bottom_in_adt_value ctx1.ended_regions adt1
- then mk_bottom meta ty
+ then mk_bottom span ty
else
(* No borrows, no loans, no bottoms: we can introduce a symbolic value *)
- mk_fresh_symbolic_typed_value_from_no_regions_ty meta ty
+ mk_fresh_symbolic_typed_value_from_no_regions_ty span ty
let match_shared_borrows (ctx0 : eval_ctx) (ctx1 : eval_ctx) match_rec
(ty : ety) (bid0 : borrow_id) (bid1 : borrow_id) : borrow_id =
(* Lookup the shared values and match them - we do this mostly
to make sure we end loans which might appear on one side
and not on the other. *)
- let sv0 = lookup_shared_value meta ctx0 bid0 in
- let sv1 = lookup_shared_value meta ctx1 bid1 in
+ let sv0 = lookup_shared_value span ctx0 bid0 in
+ let sv1 = lookup_shared_value span ctx1 bid1 in
let sv = match_rec sv0 sv1 in
if bid0 = bid1 then bid0
else
@@ -510,7 +510,7 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
let borrows = [ mk_aborrow bid0; mk_aborrow bid1 ] in
let loan =
- ASharedLoan (BorrowId.Set.singleton bid2, sv, mk_aignored meta bv_ty)
+ ASharedLoan (BorrowId.Set.singleton bid2, sv, mk_aignored span bv_ty)
in
(* Note that an aloan has a borrow type *)
let loan : typed_avalue = { value = ALoan loan; ty = borrow_ty } in
@@ -588,10 +588,10 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
*)
cassert __FILE__ __LINE__
(not (ValuesUtils.value_has_borrows ctx0.type_ctx.type_infos bv.value))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
if bv0 = bv1 then (
- sanity_check __FILE__ __LINE__ (bv0 = bv) meta;
+ sanity_check __FILE__ __LINE__ (bv0 = bv) span;
(bid0, bv))
else
let rid = fresh_region_id () in
@@ -599,19 +599,19 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
let kind = RMut in
let bv_ty = bv.ty in
- sanity_check __FILE__ __LINE__ (ty_no_regions bv_ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_no_regions bv_ty) span;
let borrow_ty = mk_ref_ty (RFVar rid) bv_ty kind in
let borrow_av =
let ty = borrow_ty in
- let value = ABorrow (AMutBorrow (bid0, mk_aignored meta bv_ty)) in
- mk_typed_avalue meta ty value
+ let value = ABorrow (AMutBorrow (bid0, mk_aignored span bv_ty)) in
+ mk_typed_avalue span ty value
in
let loan_av =
let ty = borrow_ty in
- let value = ALoan (AMutLoan (nbid, mk_aignored meta bv_ty)) in
- mk_typed_avalue meta ty value
+ let value = ALoan (AMutLoan (nbid, mk_aignored span bv_ty)) in
+ mk_typed_avalue span ty value
in
let avalues = [ borrow_av; loan_av ] in
@@ -645,21 +645,21 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
(* Generate a fresh symbolic value for the borrowed value *)
let _, bv_ty, kind = ty_as_ref ty in
- let sv = mk_fresh_symbolic_typed_value_from_no_regions_ty meta bv_ty in
+ let sv = mk_fresh_symbolic_typed_value_from_no_regions_ty span bv_ty in
let borrow_ty = mk_ref_ty (RFVar rid) bv_ty kind in
(* Generate the avalues for the abstraction *)
let mk_aborrow (bid : borrow_id) (bv : typed_value) : typed_avalue =
let bv_ty = bv.ty in
- cassert __FILE__ __LINE__ (ty_no_regions bv_ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions bv_ty) span
"Nested borrows are not supported yet";
- let value = ABorrow (AMutBorrow (bid, mk_aignored meta bv_ty)) in
+ let value = ABorrow (AMutBorrow (bid, mk_aignored span bv_ty)) in
{ value; ty = borrow_ty }
in
let borrows = [ mk_aborrow bid0 bv0; mk_aborrow bid1 bv1 ] in
- let loan = AMutLoan (bid2, mk_aignored meta bv_ty) in
+ let loan = AMutLoan (bid2, mk_aignored span bv_ty) in
(* Note that an aloan has a borrow type *)
let loan : typed_avalue = { value = ALoan loan; ty = borrow_ty } in
@@ -700,7 +700,7 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
raise (ValueMatchFailure (LoansInRight extra_ids_right));
(* This should always be true if we get here *)
- sanity_check __FILE__ __LINE__ (ids0 = ids1) meta;
+ sanity_check __FILE__ __LINE__ (ids0 = ids1) span;
let ids = ids0 in
(* Return *)
@@ -720,7 +720,7 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
let id1 = sv1.sv_id in
if id0 = id1 then (
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (sv0 = sv1) meta;
+ sanity_check __FILE__ __LINE__ (sv0 = sv1) span;
(* Return *)
sv0)
else (
@@ -728,7 +728,7 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
borrows *)
sanity_check __FILE__ __LINE__
(not (ty_has_borrows ctx0.type_ctx.type_infos sv0.sv_ty))
- meta;
+ span;
(* TODO: the symbolic values may contain bottoms: we're being conservatice,
and fail (for now) if part of a symbolic value contains a bottom.
A more general approach would be to introduce a symbolic value
@@ -736,8 +736,8 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
sanity_check __FILE__ __LINE__
((not (symbolic_value_has_ended_regions ctx0.ended_regions sv0))
&& not (symbolic_value_has_ended_regions ctx1.ended_regions sv1))
- meta;
- mk_fresh_symbolic_value meta sv0.sv_ty)
+ span;
+ mk_fresh_symbolic_value span sv0.sv_ty)
let match_symbolic_with_other (ctx0 : eval_ctx) (ctx1 : eval_ctx)
(left : bool) (sv : symbolic_value) (v : typed_value) : typed_value =
@@ -749,14 +749,14 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
let type_infos = ctx0.type_ctx.type_infos in
cassert __FILE__ __LINE__
(not (ty_has_borrows type_infos sv.sv_ty))
- meta
+ span
"Check that:\n\
\ - there are no borrows in the symbolic value\n\
\ - there are no borrows in the \"regular\" value\n\
\ If there are loans in the regular value, raise an exception.";
cassert __FILE__ __LINE__
(not (ValuesUtils.value_has_borrows type_infos v.value))
- meta
+ span
"Check that:\n\
\ - there are no borrows in the symbolic value\n\
\ - there are no borrows in the \"regular\" value\n\
@@ -778,8 +778,8 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
if
symbolic_value_has_ended_regions ctx0.ended_regions sv
|| bottom_in_value ctx1.ended_regions v
- then mk_bottom meta sv.sv_ty
- else mk_fresh_symbolic_typed_value meta sv.sv_ty
+ then mk_bottom span sv.sv_ty
+ else mk_fresh_symbolic_typed_value span sv.sv_ty
let match_bottom_with_other (ctx0 : eval_ctx) (ctx1 : eval_ctx) (left : bool)
(v : typed_value) : typed_value =
@@ -794,7 +794,7 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
with
| Some (BorrowContent _) ->
(* Can't get there: we only ask for outer *loans* *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Some (LoanContent lc) -> (
match lc with
| VSharedLoan (ids, _) ->
@@ -812,37 +812,37 @@ module MakeJoinMatcher (S : MatchJoinState) : PrimMatcher = struct
let destructure_shared_values = true in
let ctx = if value_is_left then ctx0 else ctx1 in
let absl =
- convert_value_to_abstractions meta abs_kind can_end
+ convert_value_to_abstractions span abs_kind can_end
destructure_shared_values ctx v
in
push_absl absl;
(* Return [Bottom] *)
- mk_bottom meta v.ty
+ mk_bottom span v.ty
(* As explained in comments: we don't use the join matcher to join avalues,
only concrete values *)
let match_distinct_aadts _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_ashared_borrows _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_amut_borrows _ _ _ _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_ashared_loans _ _ _ _ _ _ _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_amut_loans _ _ _ _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
- let match_avalues _ _ _ _ = craise __FILE__ __LINE__ meta "Unreachable"
+ let match_avalues _ _ _ _ = craise __FILE__ __LINE__ span "Unreachable"
end
(* Very annoying: functors only take modules as inputs... *)
module type MatchMoveState = sig
- val meta : Meta.meta
+ val span : Meta.span
(** The current loop *)
val loop_id : LoopId.id
@@ -868,19 +868,19 @@ end
indeed matches the resulting target environment: it will be re-checked later.
*)
module MakeMoveMatcher (S : MatchMoveState) : PrimMatcher = struct
- let meta = S.meta
+ let span = S.span
(** Small utility *)
let push_moved_value (v : typed_value) : unit = S.nvalues := v :: !S.nvalues
let match_etys _ _ ty0 ty1 =
- sanity_check __FILE__ __LINE__ (ty0 = ty1) meta;
+ sanity_check __FILE__ __LINE__ (ty0 = ty1) span;
ty0
let match_rtys _ _ ty0 ty1 =
(* The types must be equal - in effect, this forbids to match symbolic
values containing borrows *)
- sanity_check __FILE__ __LINE__ (ty0 = ty1) meta;
+ sanity_check __FILE__ __LINE__ (ty0 = ty1) span;
ty0
let match_distinct_literals (_ : eval_ctx) (_ : eval_ctx) (ty : ety)
@@ -925,7 +925,7 @@ module MakeMoveMatcher (S : MatchMoveState) : PrimMatcher = struct
if
symbolic_value_has_ended_regions ctx0.ended_regions sv
|| bottom_in_value ctx1.ended_regions v
- then mk_bottom meta sv.sv_ty
+ then mk_bottom span sv.sv_ty
else if left then v
else mk_typed_value_from_symbolic_value sv
@@ -941,47 +941,47 @@ module MakeMoveMatcher (S : MatchMoveState) : PrimMatcher = struct
with
| Some (BorrowContent _) ->
(* Can't get there: we only ask for outer *loans* *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Some (LoanContent _) ->
(* We should have ended all the outer loans *)
- craise __FILE__ __LINE__ meta "Unexpected outer loan"
+ craise __FILE__ __LINE__ span "Unexpected outer loan"
| None ->
(* Move the value - note that we shouldn't get there if we
were not allowed to move the value in the first place. *)
push_moved_value v;
(* Return [Bottom] *)
- mk_bottom meta v.ty)
+ mk_bottom span v.ty)
else
(* If we get there it means the source environment (e.g., the
fixed-point) has a non-bottom value, while the target environment
(e.g., the environment we have when we reach the continue)
has bottom: we shouldn't get there. *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
(* As explained in comments: we don't use the join matcher to join avalues,
only concrete values *)
let match_distinct_aadts _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_ashared_borrows _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_amut_borrows _ _ _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_ashared_loans _ _ _ _ _ _ _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
let match_amut_loans _ _ _ _ _ _ _ _ _ _ =
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
- let match_avalues _ _ _ _ = craise __FILE__ __LINE__ meta "Unreachable"
+ let match_avalues _ _ _ _ = craise __FILE__ __LINE__ span "Unreachable"
end
module MakeCheckEquivMatcher (S : MatchCheckEquivState) : CheckEquivMatcher =
struct
- let meta = S.meta
+ let span = S.span
module MkGetSetM (Id : Identifiers.Id) = struct
module Inj = Id.InjSubst
@@ -1081,11 +1081,11 @@ struct
RFVar rid
| _ -> raise (Distinct "match_rtys")
in
- match_types meta match_distinct_types match_regions ty0 ty1
+ match_types span match_distinct_types match_regions ty0 ty1
let match_distinct_literals (_ : eval_ctx) (_ : eval_ctx) (ty : ety)
(_ : literal) (_ : literal) : typed_value =
- mk_fresh_symbolic_typed_value_from_no_regions_ty meta ty
+ mk_fresh_symbolic_typed_value_from_no_regions_ty span ty
let match_distinct_adts (_ : eval_ctx) (_ : eval_ctx) (_ty : ety)
(_adt0 : adt_value) (_adt1 : adt_value) : typed_value =
@@ -1112,9 +1112,9 @@ struct
(lazy
("MakeCheckEquivMatcher: match_shared_borrows: looked up values:"
^ "sv0: "
- ^ typed_value_to_string ~meta:(Some meta) ctx0 v0
+ ^ typed_value_to_string ~span:(Some span) ctx0 v0
^ ", sv1: "
- ^ typed_value_to_string ~meta:(Some meta) ctx1 v1));
+ ^ typed_value_to_string ~span:(Some span) ctx1 v1));
let _ = match_typed_values v0 v1 in
()
@@ -1163,7 +1163,7 @@ struct
(* Check: fixed values are fixed *)
sanity_check __FILE__ __LINE__
(id0 = id1 || not (SymbolicValueId.InjSubst.mem id0 !S.sid_map))
- meta;
+ span;
(* Update the symbolic value mapping *)
let sv1 = mk_typed_value_from_symbolic_value sv1 in
@@ -1180,12 +1180,12 @@ struct
(sv : symbolic_value) (v : typed_value) : typed_value =
if S.check_equiv then raise (Distinct "match_symbolic_with_other")
else (
- sanity_check __FILE__ __LINE__ left meta;
+ sanity_check __FILE__ __LINE__ left span;
let id = sv.sv_id in
(* Check: fixed values are fixed *)
sanity_check __FILE__ __LINE__
(not (SymbolicValueId.InjSubst.mem id !S.sid_map))
- meta;
+ span;
(* Update the binding for the target symbolic value *)
S.sid_to_value_map :=
SymbolicValueId.Map.add_strict id v !S.sid_to_value_map;
@@ -1202,7 +1202,7 @@ struct
let value_is_left = not left in
let ctx = if value_is_left then ctx0 else ctx1 in
if left && not (value_has_loans_or_borrows ctx v.value) then
- mk_bottom meta v.ty
+ mk_bottom span v.ty
else
raise
(Distinct
@@ -1238,7 +1238,7 @@ struct
("MakeCheckEquivMatcher:match_amut_loans:" ^ "\n- id0: "
^ BorrowId.to_string id0 ^ "\n- id1: " ^ BorrowId.to_string id1
^ "\n- ty: " ^ ty_to_string ctx0 ty ^ "\n- av: "
- ^ typed_avalue_to_string ~meta:(Some meta) ctx1 av));
+ ^ typed_avalue_to_string ~span:(Some span) ctx1 av));
let id = match_loan_id id0 id1 in
let value = ALoan (AMutLoan (id, av)) in
@@ -1248,13 +1248,13 @@ struct
log#ldebug
(lazy
("avalues don't match:\n- v0: "
- ^ typed_avalue_to_string ~meta:(Some meta) ctx0 v0
+ ^ typed_avalue_to_string ~span:(Some span) ctx0 v0
^ "\n- v1: "
- ^ typed_avalue_to_string ~meta:(Some meta) ctx1 v1));
+ ^ typed_avalue_to_string ~span:(Some span) ctx1 v1));
raise (Distinct "match_avalues")
end
-let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
+let match_ctxs (span : Meta.span) (check_equiv : bool) (fixed_ids : ids_sets)
(lookup_shared_value_in_ctx0 : BorrowId.id -> typed_value)
(lookup_shared_value_in_ctx1 : BorrowId.id -> typed_value) (ctx0 : eval_ctx)
(ctx1 : eval_ctx) : ids_maps option =
@@ -1262,9 +1262,9 @@ let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
(lazy
("match_ctxs:\n\n- fixed_ids:\n" ^ show_ids_sets fixed_ids
^ "\n\n- ctx0:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx0
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx0
^ "\n\n- ctx1:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) ctx1
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) ctx1
^ "\n\n"));
(* Initialize the maps and instantiate the matcher *)
@@ -1306,7 +1306,7 @@ let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
in
let module S : MatchCheckEquivState = struct
- let meta = meta
+ let span = span
let check_equiv = check_equiv
let rid_map = rid_map
let blid_map = blid_map
@@ -1394,10 +1394,10 @@ let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
^ "\n- aid_map: "
^ AbstractionId.InjSubst.show_t !aid_map
^ "\n\n- ctx0:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta)
+ ^ eval_ctx_to_string_no_filter ~span:(Some span)
{ ctx0 with env = List.rev env0 }
^ "\n\n- ctx1:\n"
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta)
+ ^ eval_ctx_to_string_no_filter ~span:(Some span)
{ ctx1 with env = List.rev env1 }
^ "\n\n"));
@@ -1407,19 +1407,19 @@ let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
be the same and their values equal (and the borrows/loans/symbolic *)
if DummyVarId.Set.mem b0 fixed_ids.dids then (
(* Fixed values: the values must be equal *)
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
- sanity_check __FILE__ __LINE__ (v0 = v1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
+ sanity_check __FILE__ __LINE__ (v0 = v1) span;
(* The ids present in the left value must be fixed *)
let ids, _ = compute_typed_value_ids v0 in
sanity_check __FILE__ __LINE__
((not S.check_equiv) || ids_are_fixed ids)
- meta);
+ span);
(* We still match the values - allows to compute mappings (which
are the identity actually) *)
let _ = M.match_typed_values ctx0 ctx1 v0 v1 in
match_envs env0' env1'
| EBinding (BVar b0, v0) :: env0', EBinding (BVar b1, v1) :: env1' ->
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
(* Match the values *)
let _ = M.match_typed_values ctx0 ctx1 v0 v1 in
(* Continue *)
@@ -1430,12 +1430,12 @@ let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
if AbstractionId.Set.mem abs0.abs_id fixed_ids.aids then (
log#ldebug (lazy "match_ctxs: match_envs: matching abs: fixed abs");
(* Still in the prefix: the abstractions must be the same *)
- sanity_check __FILE__ __LINE__ (abs0 = abs1) meta;
+ sanity_check __FILE__ __LINE__ (abs0 = abs1) span;
(* Their ids must be fixed *)
let ids, _ = compute_abs_ids abs0 in
sanity_check __FILE__ __LINE__
((not S.check_equiv) || ids_are_fixed ids)
- meta;
+ span;
(* Continue *)
match_envs env0' env1')
else (
@@ -1463,7 +1463,7 @@ let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
let env0, env1 =
match (env0, env1) with
| EFrame :: env0, EFrame :: env1 -> (env0, env1)
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
match_envs env0 env1;
@@ -1490,15 +1490,15 @@ let match_ctxs (meta : Meta.meta) (check_equiv : bool) (fixed_ids : ids_sets)
^ "\n"));
None
-let ctxs_are_equivalent (meta : Meta.meta) (fixed_ids : ids_sets)
+let ctxs_are_equivalent (span : Meta.span) (fixed_ids : ids_sets)
(ctx0 : eval_ctx) (ctx1 : eval_ctx) : bool =
let check_equivalent = true in
- let lookup_shared_value _ = craise __FILE__ __LINE__ meta "Unreachable" in
+ let lookup_shared_value _ = craise __FILE__ __LINE__ span "Unreachable" in
Option.is_some
- (match_ctxs meta check_equivalent fixed_ids lookup_shared_value
+ (match_ctxs span check_equivalent fixed_ids lookup_shared_value
lookup_shared_value ctx0 ctx1)
-let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
+let prepare_match_ctx_with_target (config : config) (span : Meta.span)
(loop_id : LoopId.id) (fixed_ids : ids_sets) (src_ctx : eval_ctx) : cm_fun =
fun tgt_ctx ->
(* Debug *)
@@ -1506,25 +1506,25 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
(lazy
("prepare_match_ctx_with_target:\n" ^ "\n- fixed_ids: "
^ show_ids_sets fixed_ids ^ "\n" ^ "\n- src_ctx: "
- ^ eval_ctx_to_string ~meta:(Some meta) src_ctx
+ ^ eval_ctx_to_string ~span:(Some span) src_ctx
^ "\n- tgt_ctx: "
- ^ eval_ctx_to_string ~meta:(Some meta) tgt_ctx));
+ ^ eval_ctx_to_string ~span:(Some span) tgt_ctx));
(* End the loans which lead to mismatches when joining *)
let rec reorganize_join_tgt : cm_fun =
fun tgt_ctx ->
(* Collect fixed values in the source and target contexts: end the loans in the
source context which don't appear in the target context *)
- let filt_src_env, _, _ = ctx_split_fixed_new meta fixed_ids src_ctx in
- let filt_tgt_env, _, _ = ctx_split_fixed_new meta fixed_ids tgt_ctx in
+ let filt_src_env, _, _ = ctx_split_fixed_new span fixed_ids src_ctx in
+ let filt_tgt_env, _, _ = ctx_split_fixed_new span fixed_ids tgt_ctx in
log#ldebug
(lazy
("prepare_match_ctx_with_target: reorganize_join_tgt:\n"
^ "\n- fixed_ids: " ^ show_ids_sets fixed_ids ^ "\n"
^ "\n- filt_src_ctx: "
- ^ env_to_string meta src_ctx filt_src_env
+ ^ env_to_string span src_ctx filt_src_env
^ "\n- filt_tgt_ctx: "
- ^ env_to_string meta tgt_ctx filt_tgt_env));
+ ^ env_to_string span tgt_ctx filt_tgt_env));
(* Remove the abstractions *)
let filter (ee : env_elem) : bool =
@@ -1537,7 +1537,7 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
let nabs = ref [] in
let module S : MatchJoinState = struct
- let meta = meta
+ let span = span
let loop_id = loop_id
let nabs = nabs
end in
@@ -1549,14 +1549,14 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
(fun (var0, var1) ->
match (var0, var1) with
| EBinding (BDummy b0, v0), EBinding (BDummy b1, v1) ->
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
let _ = M.match_typed_values src_ctx tgt_ctx v0 v1 in
()
| EBinding (BVar b0, v0), EBinding (BVar b1, v1) ->
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
let _ = M.match_typed_values src_ctx tgt_ctx v0 v1 in
()
- | _ -> craise __FILE__ __LINE__ meta "Unexpected")
+ | _ -> craise __FILE__ __LINE__ span "Unexpected")
(List.combine filt_src_env filt_tgt_env)
in
(* No exception was thrown: continue *)
@@ -1565,9 +1565,9 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
("prepare_match_ctx_with_target: reorganize_join_tgt: done with \
borrows/loans:\n" ^ "\n- fixed_ids: " ^ show_ids_sets fixed_ids
^ "\n" ^ "\n- filt_src_ctx: "
- ^ env_to_string meta src_ctx filt_src_env
+ ^ env_to_string span src_ctx filt_src_env
^ "\n- filt_tgt_ctx: "
- ^ env_to_string meta tgt_ctx filt_tgt_env));
+ ^ env_to_string span tgt_ctx filt_tgt_env));
(* We are done with the borrows/loans: now make sure we move all
the values which are bottom in the src environment (i.e., the
@@ -1576,7 +1576,7 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
environment *)
let nvalues = ref [] in
let module S : MatchMoveState = struct
- let meta = meta
+ let span = span
let loop_id = loop_id
let nvalues = nvalues
end in
@@ -1587,14 +1587,14 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
(fun (var0, var1) ->
match (var0, var1) with
| EBinding (BDummy b0, v0), EBinding ((BDummy b1 as var1), v1) ->
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
let v = M.match_typed_values src_ctx tgt_ctx v0 v1 in
(var1, v)
| EBinding (BVar b0, v0), EBinding ((BVar b1 as var1), v1) ->
- sanity_check __FILE__ __LINE__ (b0 = b1) meta;
+ sanity_check __FILE__ __LINE__ (b0 = b1) span;
let v = M.match_typed_values src_ctx tgt_ctx v0 v1 in
(var1, v)
- | _ -> craise __FILE__ __LINE__ meta "Unexpected")
+ | _ -> craise __FILE__ __LINE__ span "Unexpected")
(List.combine filt_src_env filt_tgt_env)
in
let var_to_new_val = BinderMap.of_list var_to_new_val in
@@ -1623,9 +1623,9 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
("prepare_match_ctx_with_target: reorganize_join_tgt: done with \
borrows/loans and moves:\n" ^ "\n- fixed_ids: "
^ show_ids_sets fixed_ids ^ "\n" ^ "\n- src_ctx: "
- ^ eval_ctx_to_string ~meta:(Some meta) src_ctx
+ ^ eval_ctx_to_string ~span:(Some span) src_ctx
^ "\n- tgt_ctx: "
- ^ eval_ctx_to_string ~meta:(Some meta) tgt_ctx));
+ ^ eval_ctx_to_string ~span:(Some span) tgt_ctx));
(tgt_ctx, fun e -> e)
with ValueMatchFailure e ->
@@ -1633,18 +1633,18 @@ let prepare_match_ctx_with_target (config : config) (meta : Meta.meta)
let ctx, cc =
match e with
| LoanInRight bid ->
- InterpreterBorrows.end_borrow config meta bid tgt_ctx
+ InterpreterBorrows.end_borrow config span bid tgt_ctx
| LoansInRight bids ->
- InterpreterBorrows.end_borrows config meta bids tgt_ctx
+ InterpreterBorrows.end_borrows config span bids tgt_ctx
| AbsInRight _ | AbsInLeft _ | LoanInLeft _ | LoansInLeft _ ->
- craise __FILE__ __LINE__ meta "Unexpected"
+ craise __FILE__ __LINE__ span "Unexpected"
in
comp cc (reorganize_join_tgt ctx)
in
(* Apply the reorganization *)
reorganize_join_tgt tgt_ctx
-let match_ctx_with_target (config : config) (meta : Meta.meta)
+let match_ctx_with_target (config : config) (span : Meta.span)
(loop_id : LoopId.id) (is_loop_entry : bool)
(fp_bl_maps : borrow_loan_corresp)
(fp_input_svalues : SymbolicValueId.id list) (fixed_ids : ids_sets)
@@ -1663,7 +1663,7 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
were introduced during the loop iterations)
*)
let tgt_ctx, cc =
- prepare_match_ctx_with_target config meta loop_id fixed_ids src_ctx tgt_ctx
+ prepare_match_ctx_with_target config span loop_id fixed_ids src_ctx tgt_ctx
in
(* Introduce the "identity" abstractions for the loop re-entry.
@@ -1691,11 +1691,11 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
^ eval_ctx_to_string src_ctx ^ "\n- tgt_ctx: " ^ eval_ctx_to_string tgt_ctx
));
- let filt_tgt_env, _, _ = ctx_split_fixed_new meta fixed_ids tgt_ctx in
+ let filt_tgt_env, _, _ = ctx_split_fixed_new span fixed_ids tgt_ctx in
let filt_src_env, new_absl, new_dummyl =
- ctx_split_fixed_new meta fixed_ids src_ctx
+ ctx_split_fixed_new span fixed_ids src_ctx
in
- sanity_check __FILE__ __LINE__ (new_dummyl = []) meta;
+ sanity_check __FILE__ __LINE__ (new_dummyl = []) span;
let filt_tgt_ctx = { tgt_ctx with env = filt_tgt_env } in
let filt_src_ctx = { src_ctx with env = filt_src_env } in
@@ -1704,16 +1704,16 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
let fixed_ids = ids_sets_empty_borrows_loans fixed_ids in
let open InterpreterBorrowsCore in
let lookup_shared_loan lid ctx : typed_value =
- match snd (lookup_loan meta ek_all lid ctx) with
+ match snd (lookup_loan span ek_all lid ctx) with
| Concrete (VSharedLoan (_, v)) -> v
| Abstract (ASharedLoan (_, v, _)) -> v
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let lookup_in_src id = lookup_shared_loan id src_ctx in
let lookup_in_tgt id = lookup_shared_loan id tgt_ctx in
(* Match *)
Option.get
- (match_ctxs meta check_equiv fixed_ids lookup_in_src lookup_in_tgt
+ (match_ctxs span check_equiv fixed_ids lookup_in_src lookup_in_tgt
filt_src_ctx filt_tgt_ctx)
in
let tgt_to_src_borrow_map =
@@ -1727,15 +1727,15 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
log#ldebug
(lazy
("match_ctx_with_target: cf_introduce_loop_fp_abs:" ^ "\n\n- src_ctx: "
- ^ eval_ctx_to_string ~meta:(Some meta) src_ctx
+ ^ eval_ctx_to_string ~span:(Some span) src_ctx
^ "\n\n- tgt_ctx: "
- ^ eval_ctx_to_string ~meta:(Some meta) tgt_ctx
+ ^ eval_ctx_to_string ~span:(Some span) tgt_ctx
^ "\n\n- filt_tgt_ctx: "
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) filt_tgt_ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) filt_tgt_ctx
^ "\n\n- filt_src_ctx: "
- ^ eval_ctx_to_string_no_filter ~meta:(Some meta) filt_src_ctx
+ ^ eval_ctx_to_string_no_filter ~span:(Some span) filt_src_ctx
^ "\n\n- new_absl:\n"
- ^ eval_ctx_to_string ~meta:(Some meta)
+ ^ eval_ctx_to_string ~span:(Some span)
{ src_ctx with env = List.map (fun abs -> EAbs abs) new_absl }
^ "\n\n- fixed_ids:\n" ^ show_ids_sets fixed_ids ^ "\n\n- fp_bl_maps:\n"
^ show_borrow_loan_corresp fp_bl_maps
@@ -1834,7 +1834,7 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
values containing borrows to not be eagerly expanded.
*)
sanity_check __FILE__ __LINE__ Config.greedy_expand_symbolics_with_borrows
- meta;
+ span;
(* Update the borrows and loans in the abstractions of the target context.
@@ -1905,7 +1905,7 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
and because of this, it should actually be mapped to itself *)
sanity_check __FILE__ __LINE__
(BorrowId.InjSubst.find id src_to_tgt_maps.borrow_id_map = id)
- meta;
+ span;
id
| Some id -> id
@@ -1917,8 +1917,8 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
method! visit_abs env abs =
match abs.kind with
| Loop (loop_id', rg_id, kind) ->
- sanity_check __FILE__ __LINE__ (loop_id' = loop_id) meta;
- sanity_check __FILE__ __LINE__ (kind = LoopSynthInput) meta;
+ sanity_check __FILE__ __LINE__ (loop_id' = loop_id) span;
+ sanity_check __FILE__ __LINE__ (kind = LoopSynthInput) span;
let can_end = false in
let kind : abs_kind = Loop (loop_id, rg_id, LoopCall) in
let abs = { abs with kind; can_end } in
@@ -1936,18 +1936,18 @@ let match_ctx_with_target (config : config) (meta : Meta.meta)
log#ldebug
(lazy
("match_ctx_with_target: cf_introduce_loop_fp_abs: done:\n- result ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) tgt_ctx));
+ ^ eval_ctx_to_string ~span:(Some span) tgt_ctx));
(* Sanity check *)
if !Config.sanity_checks then
- Invariants.check_borrowed_values_invariant meta tgt_ctx;
+ Invariants.check_borrowed_values_invariant span tgt_ctx;
(* End all the borrows which appear in the *new* abstractions *)
let new_borrows =
BorrowId.Set.of_list
(List.map snd (BorrowId.Map.bindings !src_fresh_borrows_map))
in
let tgt_ctx, cc =
- comp cc (InterpreterBorrows.end_borrows config meta new_borrows tgt_ctx)
+ comp cc (InterpreterBorrows.end_borrows config span new_borrows tgt_ctx)
in
(* Compute the loop input values *)
diff --git a/compiler/InterpreterLoopsMatchCtxs.mli b/compiler/InterpreterLoopsMatchCtxs.mli
index a8002ad4..ab585220 100644
--- a/compiler/InterpreterLoopsMatchCtxs.mli
+++ b/compiler/InterpreterLoopsMatchCtxs.mli
@@ -19,7 +19,7 @@ open InterpreterLoopsCore
- [env]
*)
val compute_abs_borrows_loans_maps :
- Meta.meta -> bool -> (abs -> bool) -> env -> abs_borrows_loans_maps
+ Meta.span -> bool -> (abs -> bool) -> env -> abs_borrows_loans_maps
(** Generic functor to implement matching functions between values, environments,
etc.
@@ -91,7 +91,7 @@ module MakeCheckEquivMatcher : functor (_ : MatchCheckEquivState) ->
We return an optional ids map: [Some] if the match succeeded, [None] otherwise.
*)
val match_ctxs :
- Meta.meta ->
+ Meta.span ->
bool ->
ids_sets ->
(loan_id -> typed_value) ->
@@ -136,7 +136,7 @@ val match_ctxs :
- [ctx0]
- [ctx1]
*)
-val ctxs_are_equivalent : Meta.meta -> ids_sets -> eval_ctx -> eval_ctx -> bool
+val ctxs_are_equivalent : Meta.span -> ids_sets -> eval_ctx -> eval_ctx -> bool
(** Reorganize a target context so that we can match it with a source context
(remember that the source context is generally the fixed point context,
@@ -151,7 +151,7 @@ val ctxs_are_equivalent : Meta.meta -> ids_sets -> eval_ctx -> eval_ctx -> bool
*)
val prepare_match_ctx_with_target :
- config -> Meta.meta -> LoopId.id -> ids_sets -> eval_ctx -> cm_fun
+ config -> Meta.span -> LoopId.id -> ids_sets -> eval_ctx -> cm_fun
(** Match a context with a target context.
@@ -301,7 +301,7 @@ val prepare_match_ctx_with_target :
*)
val match_ctx_with_target :
config ->
- Meta.meta ->
+ Meta.span ->
loop_id ->
bool ->
borrow_loan_corresp ->
diff --git a/compiler/InterpreterPaths.ml b/compiler/InterpreterPaths.ml
index a76ebfeb..faba1088 100644
--- a/compiler/InterpreterPaths.ml
+++ b/compiler/InterpreterPaths.ml
@@ -69,7 +69,7 @@ type projection_access = {
TODO: use exceptions?
*)
-let rec access_projection (meta : Meta.meta) (access : projection_access)
+let rec access_projection (span : Meta.span) (access : projection_access)
(ctx : eval_ctx)
(* Function to (eventually) update the value we find *)
(update : typed_value -> typed_value) (p : projection) (v : typed_value) :
@@ -87,7 +87,7 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
(lazy
("Not the same type:\n- nv.ty: " ^ show_ety nv.ty ^ "\n- v.ty: "
^ show_ety v.ty));
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Assertion failed: new value doesn't have the same type as its \
destination");
Ok (ctx, { read = v; updated = nv })
@@ -100,14 +100,14 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
(* Check consistency *)
(match (proj_kind, type_id) with
| ProjAdt (def_id, opt_variant_id), TAdtId def_id' ->
- sanity_check __FILE__ __LINE__ (def_id = def_id') meta;
+ sanity_check __FILE__ __LINE__ (def_id = def_id') span;
sanity_check __FILE__ __LINE__
(opt_variant_id = adt.variant_id)
- meta
- | _ -> craise __FILE__ __LINE__ meta "Unreachable");
+ span
+ | _ -> craise __FILE__ __LINE__ span "Unreachable");
(* Actually project *)
let fv = FieldId.nth adt.field_values field_id in
- match access_projection meta access ctx update p' fv with
+ match access_projection span access ctx update p' fv with
| Error err -> Error err
| Ok (ctx, res) ->
(* Update the field value *)
@@ -121,10 +121,10 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
| Field (ProjTuple arity, field_id), VAdt adt, TAdt (TTuple, _) -> (
sanity_check __FILE__ __LINE__
(arity = List.length adt.field_values)
- meta;
+ span;
let fv = FieldId.nth adt.field_values field_id in
(* Project *)
- match access_projection meta access ctx update p' fv with
+ match access_projection span access ctx update p' fv with
| Error err -> Error err
| Ok (ctx, res) ->
(* Update the field value *)
@@ -151,7 +151,7 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
* it shouldn't happen due to user code, and we leverage it
* when implementing box dereferencement for the concrete
* interpreter *)
- match access_projection meta access ctx update p' bv with
+ match access_projection span access ctx update p' bv with
| Error err -> Error err
| Ok (ctx, res) ->
let nv =
@@ -168,18 +168,18 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
| VSharedBorrow bid ->
(* Lookup the loan content, and explore from there *)
if access.lookup_shared_borrows then
- match lookup_loan meta ek bid ctx with
+ match lookup_loan span ek bid ctx with
| _, Concrete (VMutLoan _) ->
- craise __FILE__ __LINE__ meta "Expected a shared loan"
+ craise __FILE__ __LINE__ span "Expected a shared loan"
| _, Concrete (VSharedLoan (bids, sv)) -> (
(* Explore the shared value *)
- match access_projection meta access ctx update p' sv with
+ match access_projection span access ctx update p' sv with
| Error err -> Error err
| Ok (ctx, res) ->
(* Update the shared loan with the new value returned
by {!access_projection} *)
let ctx =
- update_loan meta ek bid
+ update_loan span ek bid
(VSharedLoan (bids, res.updated))
ctx
in
@@ -189,29 +189,29 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
Abstract
( AMutLoan (_, _)
| AEndedMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan (_, _)
| AIgnoredMutLoan (_, _)
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ }
+ { given_back = _; child = _; given_back_span = _ }
| AIgnoredSharedLoan _ ) ) ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Expected a shared (abstraction) loan"
| _, Abstract (ASharedLoan (bids, sv, _av)) -> (
(* Explore the shared value *)
- match access_projection meta access ctx update p' sv with
+ match access_projection span access ctx update p' sv with
| Error err -> Error err
| Ok (ctx, res) ->
(* Relookup the child avalue *)
let av =
- match lookup_loan meta ek bid ctx with
+ match lookup_loan span ek bid ctx with
| _, Abstract (ASharedLoan (_, _, av)) -> av
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
(* Update the shared loan with the new value returned
by {!access_projection} *)
let ctx =
- update_aloan meta ek bid
+ update_aloan span ek bid
(ASharedLoan (bids, res.updated, av))
ctx
in
@@ -221,7 +221,7 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
| VReservedMutBorrow bid -> Error (FailReservedMutBorrow bid)
| VMutBorrow (bid, bv) ->
if access.enter_mut_borrows then
- match access_projection meta access ctx update p' bv with
+ match access_projection span access ctx update p' bv with
| Error err -> Error err
| Ok (ctx, res) ->
let nv =
@@ -238,7 +238,7 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
we mustn't ignore the current projection element *)
if access.enter_shared_loans then
match
- access_projection meta access ctx update (pe :: p') sv
+ access_projection span access ctx update (pe :: p') sv
with
| Error err -> Error err
| Ok (ctx, res) ->
@@ -252,7 +252,7 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
let pe = "- pe: " ^ show_projection_elem pe in
let v = "- v:\n" ^ show_value v in
let ty = "- ty:\n" ^ show_ety ty in
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Inconsistent projection:\n" ^ pe ^ "\n" ^ v ^ "\n" ^ ty))
(** Generic function to access (read/write) the value at a given place.
@@ -261,18 +261,18 @@ let rec access_projection (meta : Meta.meta) (access : projection_access)
environment, if we managed to access the place, or the precise reason
why we failed.
*)
-let access_place (meta : Meta.meta) (access : projection_access)
+let access_place (span : Meta.span) (access : projection_access)
(* Function to (eventually) update the value we find *)
(update : typed_value -> typed_value) (p : place) (ctx : eval_ctx) :
(eval_ctx * typed_value) path_access_result =
(* Lookup the variable's value *)
- let value = ctx_lookup_var_value meta ctx p.var_id in
+ let value = ctx_lookup_var_value span ctx p.var_id in
(* Apply the projection *)
- match access_projection meta access ctx update p.projection value with
+ match access_projection span access ctx update p.projection value with
| Error err -> Error err
| Ok (ctx, res) ->
(* Update the value *)
- let ctx = ctx_update_var_value meta ctx p.var_id res.updated in
+ let ctx = ctx_update_var_value span ctx p.var_id res.updated in
(* Return *)
Ok (ctx, res.read)
@@ -308,12 +308,12 @@ let access_kind_to_projection_access (access : access_kind) : projection_access
Note that we only access the value at the place, and do not check that
the value is "well-formed" (for instance that it doesn't contain bottoms).
*)
-let try_read_place (meta : Meta.meta) (access : access_kind) (p : place)
+let try_read_place (span : Meta.span) (access : access_kind) (p : place)
(ctx : eval_ctx) : typed_value path_access_result =
let access = access_kind_to_projection_access access in
(* The update function is the identity *)
let update v = v in
- match access_place meta access update p ctx with
+ match access_place span access update p ctx with
| Error err -> Error err
| Ok (ctx1, read_value) ->
(* Note that we ignore the new environment: it should be the same as the
@@ -325,41 +325,41 @@ let try_read_place (meta : Meta.meta) (access : access_kind) (p : place)
"Unexpected environment update:\nNew environment:\n"
^ show_env ctx1.env ^ "\n\nOld environment:\n" ^ show_env ctx.env
in
- craise __FILE__ __LINE__ meta msg);
+ craise __FILE__ __LINE__ span msg);
Ok read_value
-let read_place (meta : Meta.meta) (access : access_kind) (p : place)
+let read_place (span : Meta.span) (access : access_kind) (p : place)
(ctx : eval_ctx) : typed_value =
- match try_read_place meta access p ctx with
+ match try_read_place span access p ctx with
| Error e ->
- craise __FILE__ __LINE__ meta ("Unreachable: " ^ show_path_fail_kind e)
+ craise __FILE__ __LINE__ span ("Unreachable: " ^ show_path_fail_kind e)
| Ok v -> v
(** Attempt to update the value at a given place *)
-let try_write_place (meta : Meta.meta) (access : access_kind) (p : place)
+let try_write_place (span : Meta.span) (access : access_kind) (p : place)
(nv : typed_value) (ctx : eval_ctx) : eval_ctx path_access_result =
let access = access_kind_to_projection_access access in
(* The update function substitutes the value with the new value *)
let update _ = nv in
- match access_place meta access update p ctx with
+ match access_place span access update p ctx with
| Error err -> Error err
| Ok (ctx, _) ->
(* We ignore the read value *)
Ok ctx
-let write_place (meta : Meta.meta) (access : access_kind) (p : place)
+let write_place (span : Meta.span) (access : access_kind) (p : place)
(nv : typed_value) (ctx : eval_ctx) : eval_ctx =
- match try_write_place meta access p nv ctx with
+ match try_write_place span access p nv ctx with
| Error e ->
- craise __FILE__ __LINE__ meta ("Unreachable: " ^ show_path_fail_kind e)
+ craise __FILE__ __LINE__ span ("Unreachable: " ^ show_path_fail_kind e)
| Ok ctx -> ctx
-let compute_expanded_bottom_adt_value (meta : Meta.meta) (ctx : eval_ctx)
+let compute_expanded_bottom_adt_value (span : Meta.span) (ctx : eval_ctx)
(def_id : TypeDeclId.id) (opt_variant_id : VariantId.id option)
(generics : generic_args) : typed_value =
sanity_check __FILE__ __LINE__
(TypesUtils.generic_args_only_erased_regions generics)
- meta;
+ span;
(* Lookup the definition and check if it is an enumeration - it
should be an enumeration if and only if the projection element
is a field projection with *some* variant id. Retrieve the list
@@ -367,22 +367,22 @@ let compute_expanded_bottom_adt_value (meta : Meta.meta) (ctx : eval_ctx)
let def = ctx_lookup_type_decl ctx def_id in
sanity_check __FILE__ __LINE__
(List.length generics.regions = List.length def.generics.regions)
- meta;
+ span;
(* Compute the field types *)
let field_types =
- AssociatedTypes.type_decl_get_inst_norm_field_etypes meta ctx def
+ AssociatedTypes.type_decl_get_inst_norm_field_etypes span ctx def
opt_variant_id generics
in
(* Initialize the expanded value *)
- let fields = List.map (mk_bottom meta) field_types in
+ let fields = List.map (mk_bottom span) field_types in
let av = VAdt { variant_id = opt_variant_id; field_values = fields } in
let ty = TAdt (TAdtId def_id, generics) in
{ value = av; ty }
-let compute_expanded_bottom_tuple_value (meta : Meta.meta)
+let compute_expanded_bottom_tuple_value (span : Meta.span)
(field_types : ety list) : typed_value =
(* Generate the field values *)
- let fields = List.map (mk_bottom meta) field_types in
+ let fields = List.map (mk_bottom span) field_types in
let v = VAdt { variant_id = None; field_values = fields } in
let generics = TypesUtils.mk_generic_args [] field_types [] [] in
let ty = TAdt (TTuple, generics) in
@@ -409,7 +409,7 @@ let compute_expanded_bottom_tuple_value (meta : Meta.meta)
about which variant we should project to, which is why we *can* set the
variant index when writing one of its fields).
*)
-let expand_bottom_value_from_projection (meta : Meta.meta)
+let expand_bottom_value_from_projection (span : Meta.span)
(access : access_kind) (p : place) (remaining_pes : int)
(pe : projection_elem) (ty : ety) (ctx : eval_ctx) : eval_ctx =
(* Debugging *)
@@ -438,39 +438,39 @@ let expand_bottom_value_from_projection (meta : Meta.meta)
(* "Regular" ADTs *)
| ( Field (ProjAdt (def_id, opt_variant_id), _),
TAdt (TAdtId def_id', generics) ) ->
- sanity_check __FILE__ __LINE__ (def_id = def_id') meta;
- compute_expanded_bottom_adt_value meta ctx def_id opt_variant_id
+ sanity_check __FILE__ __LINE__ (def_id = def_id') span;
+ compute_expanded_bottom_adt_value span ctx def_id opt_variant_id
generics
(* Tuples *)
| ( Field (ProjTuple arity, _),
TAdt
(TTuple, { regions = []; types; const_generics = []; trait_refs = [] })
) ->
- sanity_check __FILE__ __LINE__ (arity = List.length types) meta;
+ sanity_check __FILE__ __LINE__ (arity = List.length types) span;
(* Generate the field values *)
- compute_expanded_bottom_tuple_value meta types
+ compute_expanded_bottom_tuple_value span types
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Unreachable: " ^ show_projection_elem pe ^ ", " ^ show_ety ty)
in
(* Update the context by inserting the expanded value at the proper place *)
- match try_write_place meta access p' nv ctx with
+ match try_write_place span access p' nv ctx with
| Ok ctx -> ctx
- | Error _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | Error _ -> craise __FILE__ __LINE__ span "Unreachable"
-let rec update_ctx_along_read_place (config : config) (meta : Meta.meta)
+let rec update_ctx_along_read_place (config : config) (span : Meta.span)
(access : access_kind) (p : place) : cm_fun =
fun ctx ->
(* Attempt to read the place: if it fails, update the environment and retry *)
- match try_read_place meta access p ctx with
+ match try_read_place span access p ctx with
| Ok _ -> (ctx, fun e -> e)
| Error err ->
let ctx, cc =
match err with
- | FailSharedLoan bids -> end_borrows config meta bids ctx
- | FailMutLoan bid -> end_borrow config meta bid ctx
+ | FailSharedLoan bids -> end_borrows config span bids ctx
+ | FailMutLoan bid -> end_borrow config span bid ctx
| FailReservedMutBorrow bid ->
- promote_reserved_mut_borrow config meta bid ctx
+ promote_reserved_mut_borrow config span bid ctx
| FailSymbolic (i, sp) ->
(* Expand the symbolic value *)
let proj, _ =
@@ -478,54 +478,54 @@ let rec update_ctx_along_read_place (config : config) (meta : Meta.meta)
(List.length p.projection - i)
in
let prefix = { p with projection = proj } in
- expand_symbolic_value_no_branching config meta sp
- (Some (Synth.mk_mplace meta prefix ctx))
+ expand_symbolic_value_no_branching config span sp
+ (Some (Synth.mk_mplace span prefix ctx))
ctx
| FailBottom (_, _, _) ->
(* We can't expand {!Bottom} values while reading them *)
- craise __FILE__ __LINE__ meta "Found bottom while reading a place"
+ craise __FILE__ __LINE__ span "Found bottom while reading a place"
| FailBorrow _ ->
- craise __FILE__ __LINE__ meta "Could not read a borrow"
+ craise __FILE__ __LINE__ span "Could not read a borrow"
in
- comp cc (update_ctx_along_read_place config meta access p ctx)
+ comp cc (update_ctx_along_read_place config span access p ctx)
-let rec update_ctx_along_write_place (config : config) (meta : Meta.meta)
+let rec update_ctx_along_write_place (config : config) (span : Meta.span)
(access : access_kind) (p : place) : cm_fun =
fun ctx ->
(* Attempt to *read* (yes, *read*: we check the access to the place, and
write to it later) the place: if it fails, update the environment and retry *)
- match try_read_place meta access p ctx with
+ match try_read_place span access p ctx with
| Ok _ -> (ctx, fun e -> e)
| Error err ->
(* Update the context *)
let ctx, cc =
match err with
- | FailSharedLoan bids -> end_borrows config meta bids ctx
- | FailMutLoan bid -> end_borrow config meta bid ctx
+ | FailSharedLoan bids -> end_borrows config span bids ctx
+ | FailMutLoan bid -> end_borrow config span bid ctx
| FailReservedMutBorrow bid ->
- promote_reserved_mut_borrow config meta bid ctx
+ promote_reserved_mut_borrow config span bid ctx
| FailSymbolic (_pe, sp) ->
(* Expand the symbolic value *)
- expand_symbolic_value_no_branching config meta sp
- (Some (Synth.mk_mplace meta p ctx))
+ expand_symbolic_value_no_branching config span sp
+ (Some (Synth.mk_mplace span p ctx))
ctx
| FailBottom (remaining_pes, pe, ty) ->
(* Expand the {!Bottom} value *)
let ctx =
- expand_bottom_value_from_projection meta access p remaining_pes pe
+ expand_bottom_value_from_projection span access p remaining_pes pe
ty ctx
in
(ctx, fun e -> e)
| FailBorrow _ ->
- craise __FILE__ __LINE__ meta "Could not write to a borrow"
+ craise __FILE__ __LINE__ span "Could not write to a borrow"
in
(* Retry *)
- comp cc (update_ctx_along_write_place config meta access p ctx)
+ comp cc (update_ctx_along_write_place config span access p ctx)
(** Small utility used to break control-flow *)
exception UpdateCtx of (eval_ctx * (eval_result -> eval_result))
-let rec end_loans_at_place (config : config) (meta : Meta.meta)
+let rec end_loans_at_place (config : config) (span : Meta.span)
(access : access_kind) (p : place) : cm_fun =
fun ctx ->
(* Iterator to explore a value and update the context whenever we find
@@ -543,7 +543,7 @@ let rec end_loans_at_place (config : config) (meta : Meta.meta)
(* Nothing special to do *) super#visit_borrow_content env bc
| VReservedMutBorrow bid ->
(* We need to activate reserved borrows *)
- let res = promote_reserved_mut_borrow config meta bid ctx in
+ let res = promote_reserved_mut_borrow config span bid ctx in
raise (UpdateCtx res)
method! visit_loan_content env lc =
@@ -554,17 +554,17 @@ let rec end_loans_at_place (config : config) (meta : Meta.meta)
match access with
| Read -> super#visit_VSharedLoan env bids v
| Write | Move ->
- let res = end_borrows config meta bids ctx in
+ let res = end_borrows config span bids ctx in
raise (UpdateCtx res))
| VMutLoan bid ->
(* We always need to end mutable borrows *)
- let res = end_borrow config meta bid ctx in
+ let res = end_borrow config span bid ctx in
raise (UpdateCtx res)
end
in
(* First, retrieve the value *)
- let v = read_place meta access p ctx in
+ let v = read_place span access p ctx in
(* Inspect the value and update the context while doing so.
If the context gets updated: perform a recursive call (many things
may have been updated in the context: we need to re-read the value
@@ -578,16 +578,16 @@ let rec end_loans_at_place (config : config) (meta : Meta.meta)
with UpdateCtx (ctx, cc) ->
(* We need to update the context: compose the caugth continuation with
* a recursive call to reinspect the value *)
- comp cc (end_loans_at_place config meta access p ctx)
+ comp cc (end_loans_at_place config span access p ctx)
-let drop_outer_loans_at_lplace (config : config) (meta : Meta.meta) (p : place)
+let drop_outer_loans_at_lplace (config : config) (span : Meta.span) (p : place)
: cm_fun =
fun ctx ->
(* Move the current value in the place outside of this place and into
* a temporary dummy variable *)
let access = Write in
- let v = read_place meta access p ctx in
- let ctx = write_place meta access p (mk_bottom meta v.ty) ctx in
+ let v = read_place span access p ctx in
+ let ctx = write_place span access p (mk_bottom span v.ty) ctx in
let dummy_id = fresh_dummy_var_id () in
let ctx = ctx_push_dummy_var ctx dummy_id v in
(* Auxiliary function: while there are loans to end in the
@@ -595,7 +595,7 @@ let drop_outer_loans_at_lplace (config : config) (meta : Meta.meta) (p : place)
let rec drop : cm_fun =
fun ctx ->
(* Read the value *)
- let v = ctx_lookup_dummy_var meta ctx dummy_id in
+ let v = ctx_lookup_dummy_var span ctx dummy_id in
(* Check if there are loans (and only loans) to end *)
let with_borrows = false in
match get_first_outer_loan_or_borrow_in_value with_borrows v with
@@ -607,11 +607,11 @@ let drop_outer_loans_at_lplace (config : config) (meta : Meta.meta) (p : place)
let ctx, cc =
match c with
| LoanContent (VSharedLoan (bids, _)) ->
- end_borrows config meta bids ctx
- | LoanContent (VMutLoan bid) -> end_borrow config meta bid ctx
+ end_borrows config span bids ctx
+ | LoanContent (VMutLoan bid) -> end_borrow config span bid ctx
| BorrowContent _ ->
(* Can't get there: we are only looking up the loans *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
in
(* Retry *)
comp cc (drop ctx)
@@ -620,29 +620,29 @@ let drop_outer_loans_at_lplace (config : config) (meta : Meta.meta) (p : place)
let ctx, cc = drop ctx in
(* Pop the temporary value and reinsert it *)
(* Pop *)
- let ctx, v = ctx_remove_dummy_var meta ctx dummy_id in
+ let ctx, v = ctx_remove_dummy_var span ctx dummy_id in
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (not (outer_loans_in_value v)) meta;
+ sanity_check __FILE__ __LINE__ (not (outer_loans_in_value v)) span;
(* Reinsert *)
- let ctx = write_place meta access p v ctx in
+ let ctx = write_place span access p v ctx in
(* Return *)
(ctx, cc)
-let prepare_lplace (config : config) (meta : Meta.meta) (p : place)
+let prepare_lplace (config : config) (span : Meta.span) (p : place)
(ctx : eval_ctx) : typed_value * eval_ctx * (eval_result -> eval_result) =
log#ldebug
(lazy
("prepare_lplace:" ^ "\n- p: " ^ place_to_string ctx p
^ "\n- Initial context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Access the place *)
let access = Write in
- let ctx, cc = update_ctx_along_write_place config meta access p ctx in
+ let ctx, cc = update_ctx_along_write_place config span access p ctx in
(* End the loans at the place we are about to overwrite *)
- let ctx, cc = comp cc (drop_outer_loans_at_lplace config meta p ctx) in
+ let ctx, cc = comp cc (drop_outer_loans_at_lplace config span p ctx) in
(* Read the value and check it *)
- let v = read_place meta access p ctx in
+ let v = read_place span access p ctx in
(* Sanity checks *)
- sanity_check __FILE__ __LINE__ (not (outer_loans_in_value v)) meta;
+ sanity_check __FILE__ __LINE__ (not (outer_loans_in_value v)) span;
(* Return *)
(v, ctx, cc)
diff --git a/compiler/InterpreterPaths.mli b/compiler/InterpreterPaths.mli
index c266e7ae..86f0dcc0 100644
--- a/compiler/InterpreterPaths.mli
+++ b/compiler/InterpreterPaths.mli
@@ -14,14 +14,14 @@ type access_kind = Read | Write | Move
until it manages to fully access the provided place.
*)
val update_ctx_along_read_place :
- config -> Meta.meta -> access_kind -> place -> cm_fun
+ config -> Meta.span -> access_kind -> place -> cm_fun
(** Update the environment to be able to write to a place.
See {!update_ctx_along_read_place}.
*)
val update_ctx_along_write_place :
- config -> Meta.meta -> access_kind -> place -> cm_fun
+ config -> Meta.span -> access_kind -> place -> cm_fun
(** Read the value at a given place.
@@ -31,7 +31,7 @@ val update_ctx_along_write_place :
Note that we only access the value at the place, and do not check that
the value is "well-formed" (for instance that it doesn't contain bottoms).
*)
-val read_place : Meta.meta -> access_kind -> place -> eval_ctx -> typed_value
+val read_place : Meta.span -> access_kind -> place -> eval_ctx -> typed_value
(** Update the value at a given place.
@@ -43,21 +43,21 @@ val read_place : Meta.meta -> access_kind -> place -> eval_ctx -> typed_value
overwrite it.
*)
val write_place :
- Meta.meta -> access_kind -> place -> typed_value -> eval_ctx -> eval_ctx
+ Meta.span -> access_kind -> place -> typed_value -> eval_ctx -> eval_ctx
(** Compute an expanded tuple ⊥ value.
[compute_expanded_bottom_tuple_value [ty0, ..., tyn]] returns
[(⊥:ty0, ..., ⊥:tyn)]
*)
-val compute_expanded_bottom_tuple_value : Meta.meta -> ety list -> typed_value
+val compute_expanded_bottom_tuple_value : Meta.span -> ety list -> typed_value
(** Compute an expanded ADT ⊥ value.
The types in the generics should use erased regions.
*)
val compute_expanded_bottom_adt_value :
- Meta.meta ->
+ Meta.span ->
eval_ctx ->
TypeDeclId.id ->
VariantId.id option ->
@@ -77,7 +77,7 @@ val compute_expanded_bottom_adt_value :
that the place is *inside* a borrow, if we end the borrow, we won't be able
to reinsert the value back).
*)
-val drop_outer_loans_at_lplace : config -> Meta.meta -> place -> cm_fun
+val drop_outer_loans_at_lplace : config -> Meta.span -> place -> cm_fun
(** End the loans at a given place: read the value, if it contains a loan,
end this loan, repeat.
@@ -88,7 +88,7 @@ val drop_outer_loans_at_lplace : config -> Meta.meta -> place -> cm_fun
when moving values, we can't move a value which contains loans and thus need
to end them, etc.
*)
-val end_loans_at_place : config -> Meta.meta -> access_kind -> place -> cm_fun
+val end_loans_at_place : config -> Meta.span -> access_kind -> place -> cm_fun
(** Small utility.
@@ -101,7 +101,7 @@ val end_loans_at_place : config -> Meta.meta -> access_kind -> place -> cm_fun
*)
val prepare_lplace :
config ->
- Meta.meta ->
+ Meta.span ->
place ->
eval_ctx ->
typed_value * eval_ctx * (eval_result -> eval_result)
diff --git a/compiler/InterpreterProjectors.ml b/compiler/InterpreterProjectors.ml
index 3993d845..a887c44c 100644
--- a/compiler/InterpreterProjectors.ml
+++ b/compiler/InterpreterProjectors.ml
@@ -12,13 +12,13 @@ open Errors
let log = Logging.projectors_log
(** [ty] shouldn't contain erased regions *)
-let rec apply_proj_borrows_on_shared_borrow (meta : Meta.meta) (ctx : eval_ctx)
+let rec apply_proj_borrows_on_shared_borrow (span : Meta.span) (ctx : eval_ctx)
(fresh_reborrow : BorrowId.id -> BorrowId.id) (regions : RegionId.Set.t)
(v : typed_value) (ty : rty) : abstract_shared_borrows =
(* Sanity check - TODO: move those elsewhere (here we perform the check at every
* recursive call which is a bit overkill...) *)
let ety = Subst.erase_regions ty in
- sanity_check __FILE__ __LINE__ (ty_is_rty ty && ety = v.ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty && ety = v.ty) span;
(* Project - if there are no regions from the abstraction in the type, return [_] *)
if not (ty_has_regions_in_set regions ty) then []
else
@@ -27,7 +27,7 @@ let rec apply_proj_borrows_on_shared_borrow (meta : Meta.meta) (ctx : eval_ctx)
| VAdt adt, TAdt (id, generics) ->
(* Retrieve the types of the fields *)
let field_types =
- Assoc.ctx_adt_value_get_inst_norm_field_rtypes meta ctx adt id
+ Assoc.ctx_adt_value_get_inst_norm_field_rtypes span ctx adt id
generics
in
@@ -36,12 +36,12 @@ let rec apply_proj_borrows_on_shared_borrow (meta : Meta.meta) (ctx : eval_ctx)
let proj_fields =
List.map
(fun (fv, fty) ->
- apply_proj_borrows_on_shared_borrow meta ctx fresh_reborrow
+ apply_proj_borrows_on_shared_borrow span ctx fresh_reborrow
regions fv fty)
fields_types
in
List.concat proj_fields
- | VBottom, _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | VBottom, _ -> craise __FILE__ __LINE__ span "Unreachable"
| VBorrow bc, TRef (r, ref_ty, kind) ->
(* Retrieve the bid of the borrow and the asb of the projected borrowed value *)
let bid, asb =
@@ -50,27 +50,27 @@ let rec apply_proj_borrows_on_shared_borrow (meta : Meta.meta) (ctx : eval_ctx)
| VMutBorrow (bid, bv), RMut ->
(* Apply the projection on the borrowed value *)
let asb =
- apply_proj_borrows_on_shared_borrow meta ctx fresh_reborrow
+ apply_proj_borrows_on_shared_borrow span ctx fresh_reborrow
regions bv ref_ty
in
(bid, asb)
| VSharedBorrow bid, RShared ->
(* Lookup the shared value *)
let ek = ek_all in
- let sv = lookup_loan meta ek bid ctx in
+ let sv = lookup_loan span ek bid ctx in
let asb =
match sv with
| _, Concrete (VSharedLoan (_, sv))
| _, Abstract (ASharedLoan (_, sv, _)) ->
- apply_proj_borrows_on_shared_borrow meta ctx fresh_reborrow
+ apply_proj_borrows_on_shared_borrow span ctx fresh_reborrow
regions sv ref_ty
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
(bid, asb)
| VReservedMutBorrow _, _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Can't apply a proj_borrow over a reserved mutable borrow"
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let asb =
(* Check if the region is in the set of projected regions (note that
@@ -81,24 +81,24 @@ let rec apply_proj_borrows_on_shared_borrow (meta : Meta.meta) (ctx : eval_ctx)
else asb
in
asb
- | VLoan _, _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | VLoan _, _ -> craise __FILE__ __LINE__ span "Unreachable"
| VSymbolic s, _ ->
(* Check that the projection doesn't contain ended regions *)
sanity_check __FILE__ __LINE__
(not
- (projections_intersect meta s.sv_ty ctx.ended_regions ty regions))
- meta;
+ (projections_intersect span s.sv_ty ctx.ended_regions ty regions))
+ span;
[ AsbProjReborrows (s, ty) ]
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
-let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
+let rec apply_proj_borrows (span : Meta.span) (check_symbolic_no_ended : bool)
(ctx : eval_ctx) (fresh_reborrow : BorrowId.id -> BorrowId.id)
(regions : RegionId.Set.t) (ancestors_regions : RegionId.Set.t)
(v : typed_value) (ty : rty) : typed_avalue =
(* Sanity check - TODO: move this elsewhere (here we perform the check at every
* recursive call which is a bit overkill...) *)
let ety = Substitute.erase_regions ty in
- sanity_check __FILE__ __LINE__ (ty_is_rty ty && ety = v.ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty && ety = v.ty) span;
(* Project - if there are no regions from the abstraction in the type, return [_] *)
if not (ty_has_regions_in_set regions ty) then { value = AIgnored; ty }
else
@@ -108,7 +108,7 @@ let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
| VAdt adt, TAdt (id, generics) ->
(* Retrieve the types of the fields *)
let field_types =
- Assoc.ctx_adt_value_get_inst_norm_field_rtypes meta ctx adt id
+ Assoc.ctx_adt_value_get_inst_norm_field_rtypes span ctx adt id
generics
in
(* Project over the field values *)
@@ -116,12 +116,12 @@ let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
let proj_fields =
List.map
(fun (fv, fty) ->
- apply_proj_borrows meta check_symbolic_no_ended ctx
+ apply_proj_borrows span check_symbolic_no_ended ctx
fresh_reborrow regions ancestors_regions fv fty)
fields_types
in
AAdt { variant_id = adt.variant_id; field_values = proj_fields }
- | VBottom, _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | VBottom, _ -> craise __FILE__ __LINE__ span "Unreachable"
| VBorrow bc, TRef (r, ref_ty, kind) ->
if
(* Check if the region is in the set of projected regions (note that
@@ -134,7 +134,7 @@ let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
| VMutBorrow (bid, bv), RMut ->
(* Apply the projection on the borrowed value *)
let bv =
- apply_proj_borrows meta check_symbolic_no_ended ctx
+ apply_proj_borrows span check_symbolic_no_ended ctx
fresh_reborrow regions ancestors_regions bv ref_ty
in
AMutBorrow (bid, bv)
@@ -152,9 +152,9 @@ let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
*)
ASharedBorrow bid
| VReservedMutBorrow _, _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Can't apply a proj_borrow over a reserved mutable borrow"
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
ABorrow bc
else
@@ -166,7 +166,7 @@ let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
| VMutBorrow (bid, bv), RMut ->
(* Apply the projection on the borrowed value *)
let bv =
- apply_proj_borrows meta check_symbolic_no_ended ctx
+ apply_proj_borrows span check_symbolic_no_ended ctx
fresh_reborrow regions ancestors_regions bv ref_ty
in
(* If the borrow id is in the ancestor's regions, we still need
@@ -179,23 +179,23 @@ let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
| VSharedBorrow bid, RShared ->
(* Lookup the shared value *)
let ek = ek_all in
- let sv = lookup_loan meta ek bid ctx in
+ let sv = lookup_loan span ek bid ctx in
let asb =
match sv with
| _, Concrete (VSharedLoan (_, sv))
| _, Abstract (ASharedLoan (_, sv, _)) ->
- apply_proj_borrows_on_shared_borrow meta ctx
+ apply_proj_borrows_on_shared_borrow span ctx
fresh_reborrow regions sv ref_ty
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
in
AProjSharedBorrow asb
| VReservedMutBorrow _, _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Can't apply a proj_borrow over a reserved mutable borrow"
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
ABorrow bc
- | VLoan _, _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | VLoan _, _ -> craise __FILE__ __LINE__ span "Unreachable"
| VSymbolic s, _ ->
(* Check that the projection doesn't contain already ended regions,
* if necessary *)
@@ -213,20 +213,20 @@ let rec apply_proj_borrows (meta : Meta.meta) (check_symbolic_no_ended : bool)
^ RegionId.Set.to_string None rset2
^ "\n"));
sanity_check __FILE__ __LINE__
- (not (projections_intersect meta ty1 rset1 ty2 rset2))
- meta);
+ (not (projections_intersect span ty1 rset1 ty2 rset2))
+ span);
ASymbolic (AProjBorrows (s, ty))
| _ ->
log#ltrace
(lazy
("apply_proj_borrows: unexpected inputs:\n- input value: "
- ^ typed_value_to_string ~meta:(Some meta) ctx v
+ ^ typed_value_to_string ~span:(Some span) ctx v
^ "\n- proj rty: " ^ ty_to_string ctx ty));
- internal_error __FILE__ __LINE__ meta
+ internal_error __FILE__ __LINE__ span
in
{ value; ty }
-let symbolic_expansion_non_borrow_to_value (meta : Meta.meta)
+let symbolic_expansion_non_borrow_to_value (span : Meta.span)
(sv : symbolic_value) (see : symbolic_expansion) : typed_value =
let ty = Subst.erase_regions sv.sv_ty in
let value =
@@ -238,11 +238,11 @@ let symbolic_expansion_non_borrow_to_value (meta : Meta.meta)
in
VAdt { variant_id; field_values }
| SeMutRef (_, _) | SeSharedRef (_, _) ->
- craise __FILE__ __LINE__ meta "Unexpected symbolic reference expansion"
+ craise __FILE__ __LINE__ span "Unexpected symbolic reference expansion"
in
{ value; ty }
-let symbolic_expansion_non_shared_borrow_to_value (meta : Meta.meta)
+let symbolic_expansion_non_shared_borrow_to_value (span : Meta.span)
(sv : symbolic_value) (see : symbolic_expansion) : typed_value =
match see with
| SeMutRef (bid, bv) ->
@@ -251,22 +251,22 @@ let symbolic_expansion_non_shared_borrow_to_value (meta : Meta.meta)
let value = VBorrow (VMutBorrow (bid, bv)) in
{ value; ty }
| SeSharedRef (_, _) ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Unexpected symbolic shared reference expansion"
- | _ -> symbolic_expansion_non_borrow_to_value meta sv see
+ | _ -> symbolic_expansion_non_borrow_to_value span sv see
(** Apply (and reduce) a projector over loans to a value.
TODO: detailed comments. See [apply_proj_borrows]
*)
-let apply_proj_loans_on_symbolic_expansion (meta : Meta.meta)
+let apply_proj_loans_on_symbolic_expansion (span : Meta.span)
(regions : RegionId.Set.t) (ancestors_regions : RegionId.Set.t)
(see : symbolic_expansion) (original_sv_ty : rty) : typed_avalue =
(* Sanity check: if we have a proj_loans over a symbolic value, it should
* contain regions which we will project *)
sanity_check __FILE__ __LINE__
(ty_has_regions_in_set regions original_sv_ty)
- meta;
+ span;
(* Match *)
let (value, ty) : avalue * ty =
match (see, original_sv_ty) with
@@ -281,7 +281,7 @@ let apply_proj_loans_on_symbolic_expansion (meta : Meta.meta)
(AAdt { variant_id; field_values }, original_sv_ty)
| SeMutRef (bid, spc), TRef (r, ref_ty, RMut) ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (spc.sv_ty = ref_ty) meta;
+ sanity_check __FILE__ __LINE__ (spc.sv_ty = ref_ty) span;
(* Apply the projector to the borrowed value *)
let child_av = mk_aproj_loans_value_from_symbolic_value regions spc in
(* Check if the region is in the set of projected regions (note that
@@ -299,7 +299,7 @@ let apply_proj_loans_on_symbolic_expansion (meta : Meta.meta)
(ALoan (AIgnoredMutLoan (opt_bid, child_av)), ref_ty)
| SeSharedRef (bids, spc), TRef (r, ref_ty, RShared) ->
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (spc.sv_ty = ref_ty) meta;
+ sanity_check __FILE__ __LINE__ (spc.sv_ty = ref_ty) span;
(* Apply the projector to the borrowed value *)
let child_av = mk_aproj_loans_value_from_symbolic_value regions spc in
(* Check if the region is in the set of projected regions (note that
@@ -311,7 +311,7 @@ let apply_proj_loans_on_symbolic_expansion (meta : Meta.meta)
else
(* Not in the set: ignore *)
(ALoan (AIgnoredSharedLoan child_av), ref_ty)
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
{ value; ty }
@@ -337,7 +337,7 @@ let apply_proj_loans_on_symbolic_expansion (meta : Meta.meta)
borrows - easy - and mutable borrows - in this case, we reborrow the whole
borrow: [mut_borrow ... ~~> shared_loan {...} (mut_borrow ...)]).
*)
-let apply_reborrows (meta : Meta.meta)
+let apply_reborrows (span : Meta.span)
(reborrows : (BorrowId.id * BorrowId.id) list) (ctx : eval_ctx) : eval_ctx =
(* This is a bit brutal, but whenever we insert a reborrow, we remove
* it from the list. This allows us to check that all the reborrows were
@@ -456,11 +456,11 @@ let apply_reborrows (meta : Meta.meta)
super#visit_ASharedLoan env bids sv av
| AIgnoredSharedLoan _
| AMutLoan (_, _)
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan (_, _)
| AIgnoredMutLoan (_, _)
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ } ->
+ { given_back = _; child = _; given_back_span = _ } ->
(* Nothing particular to do *)
super#visit_aloan_content env lc
end
@@ -469,11 +469,11 @@ let apply_reborrows (meta : Meta.meta)
(* Visit *)
let ctx = obj#visit_eval_ctx () ctx in
(* Check that there are no reborrows remaining *)
- sanity_check __FILE__ __LINE__ (!reborrows = []) meta;
+ sanity_check __FILE__ __LINE__ (!reborrows = []) span;
(* Return *)
ctx
-let prepare_reborrows (config : config) (meta : Meta.meta)
+let prepare_reborrows (config : config) (span : Meta.span)
(allow_reborrows : bool) :
(BorrowId.id -> BorrowId.id) * (eval_ctx -> eval_ctx) =
let reborrows : (BorrowId.id * BorrowId.id) list ref = ref [] in
@@ -483,35 +483,35 @@ let prepare_reborrows (config : config) (meta : Meta.meta)
let bid' = fresh_borrow_id () in
reborrows := (bid, bid') :: !reborrows;
bid')
- else craise __FILE__ __LINE__ meta "Unexpected reborrow"
+ else craise __FILE__ __LINE__ span "Unexpected reborrow"
in
(* The function to apply the reborrows in a context *)
let apply_registered_reborrows (ctx : eval_ctx) : eval_ctx =
match config.mode with
| ConcreteMode ->
- sanity_check __FILE__ __LINE__ (!reborrows = []) meta;
+ sanity_check __FILE__ __LINE__ (!reborrows = []) span;
ctx
| SymbolicMode ->
(* Apply the reborrows *)
- apply_reborrows meta !reborrows ctx
+ apply_reborrows span !reborrows ctx
in
(fresh_reborrow, apply_registered_reborrows)
(** [ty] shouldn't have erased regions *)
-let apply_proj_borrows_on_input_value (config : config) (meta : Meta.meta)
+let apply_proj_borrows_on_input_value (config : config) (span : Meta.span)
(ctx : eval_ctx) (regions : RegionId.Set.t)
(ancestors_regions : RegionId.Set.t) (v : typed_value) (ty : rty) :
eval_ctx * typed_avalue =
- sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty) span;
let check_symbolic_no_ended = true in
let allow_reborrows = true in
(* Prepare the reborrows *)
let fresh_reborrow, apply_registered_reborrows =
- prepare_reborrows config meta allow_reborrows
+ prepare_reborrows config span allow_reborrows
in
(* Apply the projector *)
let av =
- apply_proj_borrows meta check_symbolic_no_ended ctx fresh_reborrow regions
+ apply_proj_borrows span check_symbolic_no_ended ctx fresh_reborrow regions
ancestors_regions v ty
in
(* Apply the reborrows *)
diff --git a/compiler/InterpreterProjectors.mli b/compiler/InterpreterProjectors.mli
index 17569ac8..43cdc09d 100644
--- a/compiler/InterpreterProjectors.mli
+++ b/compiler/InterpreterProjectors.mli
@@ -15,7 +15,7 @@ open Contexts
[original_sv_ty]: shouldn't have erased regions
*)
val apply_proj_loans_on_symbolic_expansion :
- Meta.meta ->
+ Meta.span ->
RegionId.Set.t ->
RegionId.Set.t ->
symbolic_expansion ->
@@ -24,7 +24,7 @@ val apply_proj_loans_on_symbolic_expansion :
(** Convert a symbolic expansion *which is not a borrow* to a value *)
val symbolic_expansion_non_borrow_to_value :
- Meta.meta -> symbolic_value -> symbolic_expansion -> typed_value
+ Meta.span -> symbolic_value -> symbolic_expansion -> typed_value
(** Convert a symbolic expansion *which is not a shared borrow* to a value.
@@ -33,7 +33,7 @@ val symbolic_expansion_non_borrow_to_value :
during a symbolic expansion.
*)
val symbolic_expansion_non_shared_borrow_to_value :
- Meta.meta -> symbolic_value -> symbolic_expansion -> typed_value
+ Meta.span -> symbolic_value -> symbolic_expansion -> typed_value
(** Auxiliary function to prepare reborrowing operations (used when
applying projectors).
@@ -49,7 +49,7 @@ val symbolic_expansion_non_shared_borrow_to_value :
*)
val prepare_reborrows :
config ->
- Meta.meta ->
+ Meta.span ->
bool ->
(BorrowId.id -> BorrowId.id) * (eval_ctx -> eval_ctx)
@@ -104,7 +104,7 @@ val prepare_reborrows :
then we interpret the borrow [l] as belonging to region [r]
*)
val apply_proj_borrows :
- Meta.meta ->
+ Meta.span ->
bool ->
eval_ctx ->
(BorrowId.id -> BorrowId.id) ->
@@ -125,7 +125,7 @@ val apply_proj_borrows :
*)
val apply_proj_borrows_on_input_value :
config ->
- Meta.meta ->
+ Meta.span ->
eval_ctx ->
RegionId.Set.t ->
RegionId.Set.t ->
diff --git a/compiler/InterpreterStatements.ml b/compiler/InterpreterStatements.ml
index 66677eff..c6a65757 100644
--- a/compiler/InterpreterStatements.ml
+++ b/compiler/InterpreterStatements.ml
@@ -19,33 +19,33 @@ module S = SynthesizeSymbolic
let log = L.statements_log
(** Drop a value at a given place - TODO: factorize this with [assign_to_place] *)
-let drop_value (config : config) (meta : Meta.meta) (p : place) : cm_fun =
+let drop_value (config : config) (span : Meta.span) (p : place) : cm_fun =
fun ctx ->
log#ldebug
(lazy
("drop_value: place: " ^ place_to_string ctx p ^ "\n- Initial context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Note that we use [Write], not [Move]: we allow to drop values *below* borrows *)
let access = Write in
(* First make sure we can access the place, by ending loans or expanding
* symbolic values along the path, for instance *)
- let ctx, cc = update_ctx_along_read_place config meta access p ctx in
+ let ctx, cc = update_ctx_along_read_place config span access p ctx in
(* Prepare the place (by ending the outer loans *at* the place). *)
- let v, ctx, cc = comp2 cc (prepare_lplace config meta p ctx) in
+ let v, ctx, cc = comp2 cc (prepare_lplace config span p ctx) in
(* Replace the value with {!Bottom} *)
let ctx =
(* Move the value at destination (that we will overwrite) to a dummy variable
* to preserve the borrows it may contain *)
- let mv = InterpreterPaths.read_place meta access p ctx in
+ let mv = InterpreterPaths.read_place span access p ctx in
let dummy_id = fresh_dummy_var_id () in
let ctx = ctx_push_dummy_var ctx dummy_id mv in
(* Update the destination to ⊥ *)
let nv = { v with value = VBottom } in
- let ctx = write_place meta access p nv ctx in
+ let ctx = write_place span access p nv ctx in
log#ldebug
(lazy
("drop_value: place: " ^ place_to_string ctx p ^ "\n- Final context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
ctx
in
(* Compose and apply *)
@@ -57,30 +57,30 @@ let push_dummy_var (vid : DummyVarId.id) (v : typed_value) (ctx : eval_ctx) :
ctx_push_dummy_var ctx vid v
(** Remove a dummy variable from the environment *)
-let remove_dummy_var (meta : Meta.meta) (vid : DummyVarId.id) (ctx : eval_ctx) :
+let remove_dummy_var (span : Meta.span) (vid : DummyVarId.id) (ctx : eval_ctx) :
typed_value * eval_ctx =
- let ctx, v = ctx_remove_dummy_var meta ctx vid in
+ let ctx, v = ctx_remove_dummy_var span ctx vid in
(v, ctx)
(** Push an uninitialized variable to the environment *)
-let push_uninitialized_var (meta : Meta.meta) (var : var) (ctx : eval_ctx) :
+let push_uninitialized_var (span : Meta.span) (var : var) (ctx : eval_ctx) :
eval_ctx =
- ctx_push_uninitialized_var meta ctx var
+ ctx_push_uninitialized_var span ctx var
(** Push a list of uninitialized variables to the environment *)
-let push_uninitialized_vars (meta : Meta.meta) (vars : var list)
+let push_uninitialized_vars (span : Meta.span) (vars : var list)
(ctx : eval_ctx) : eval_ctx =
- ctx_push_uninitialized_vars meta ctx vars
+ ctx_push_uninitialized_vars span ctx vars
(** Push a variable to the environment *)
-let push_var (meta : Meta.meta) (var : var) (v : typed_value) (ctx : eval_ctx) :
+let push_var (span : Meta.span) (var : var) (v : typed_value) (ctx : eval_ctx) :
eval_ctx =
- ctx_push_var meta ctx var v
+ ctx_push_var span ctx var v
(** Push a list of variables to the environment *)
-let push_vars (meta : Meta.meta) (vars : (var * typed_value) list)
+let push_vars (span : Meta.span) (vars : (var * typed_value) list)
(ctx : eval_ctx) : eval_ctx =
- ctx_push_vars meta ctx vars
+ ctx_push_vars span ctx vars
(** Assign a value to a given place.
@@ -89,59 +89,59 @@ let push_vars (meta : Meta.meta) (vars : (var * typed_value) list)
dummy variable and putting in its destination (after having checked that
preparing the destination didn't introduce ⊥).
*)
-let assign_to_place (config : config) (meta : Meta.meta) (rv : typed_value)
+let assign_to_place (config : config) (span : Meta.span) (rv : typed_value)
(p : place) : cm_fun =
fun ctx ->
log#ldebug
(lazy
("assign_to_place:" ^ "\n- rv: "
- ^ typed_value_to_string ~meta:(Some meta) ctx rv
+ ^ typed_value_to_string ~span:(Some span) ctx rv
^ "\n- p: " ^ place_to_string ctx p ^ "\n- Initial context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Push the rvalue to a dummy variable, for bookkeeping *)
let rvalue_vid = fresh_dummy_var_id () in
let ctx = push_dummy_var rvalue_vid rv ctx in
(* Prepare the destination *)
- let _, ctx, cc = prepare_lplace config meta p ctx in
+ let _, ctx, cc = prepare_lplace config span p ctx in
(* Retrieve the rvalue from the dummy variable *)
- let rv, ctx = remove_dummy_var meta rvalue_vid ctx in
+ let rv, ctx = remove_dummy_var span rvalue_vid ctx in
(* Move the value at destination (that we will overwrite) to a dummy variable
to preserve the borrows *)
- let mv = InterpreterPaths.read_place meta Write p ctx in
+ let mv = InterpreterPaths.read_place span Write p ctx in
let dest_vid = fresh_dummy_var_id () in
let ctx = ctx_push_dummy_var ctx dest_vid mv in
(* Write to the destination *)
(* Checks - maybe the bookkeeping updated the rvalue and introduced bottoms *)
exec_assert __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions rv))
- meta "The value to move contains bottom";
+ span "The value to move contains bottom";
(* Update the destination *)
- let ctx = write_place meta Write p rv ctx in
+ let ctx = write_place span Write p rv ctx in
(* Debug *)
log#ldebug
(lazy
("assign_to_place:" ^ "\n- rv: "
- ^ typed_value_to_string ~meta:(Some meta) ctx rv
+ ^ typed_value_to_string ~span:(Some span) ctx rv
^ "\n- p: " ^ place_to_string ctx p ^ "\n- Final context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Return *)
(ctx, cc)
(** Evaluate an assertion, when the scrutinee is not symbolic *)
-let eval_assertion_concrete (config : config) (meta : Meta.meta)
+let eval_assertion_concrete (config : config) (span : Meta.span)
(assertion : assertion) : st_cm_fun =
fun ctx ->
(* There won't be any symbolic expansions: fully evaluate the operand *)
- let v, ctx, eval_op = eval_operand config meta assertion.cond ctx in
+ let v, ctx, eval_op = eval_operand config span assertion.cond ctx in
let st =
match v.value with
| VLiteral (VBool b) ->
(* Branch *)
if b = assertion.expected then Unit else Panic
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Expected a boolean, got: "
- ^ typed_value_to_string ~meta:(Some meta) ctx v)
+ ^ typed_value_to_string ~span:(Some span) ctx v)
in
(* Compose and apply *)
((ctx, st), eval_op)
@@ -152,13 +152,13 @@ let eval_assertion_concrete (config : config) (meta : Meta.meta)
a call to [assert ...] then continue in the success branch (and thus
expand the boolean to [true]).
*)
-let eval_assertion (config : config) (meta : Meta.meta) (assertion : assertion)
+let eval_assertion (config : config) (span : Meta.span) (assertion : assertion)
: st_cm_fun =
fun ctx ->
(* Evaluate the operand *)
- let v, ctx, cf_eval_op = eval_operand config meta assertion.cond ctx in
+ let v, ctx, cf_eval_op = eval_operand config span assertion.cond ctx in
(* Evaluate the assertion *)
- sanity_check __FILE__ __LINE__ (v.ty = TLiteral TBool) meta;
+ sanity_check __FILE__ __LINE__ (v.ty = TLiteral TBool) span;
let st, cf_eval_assert =
(* We make a choice here: we could completely decouple the concrete and
* symbolic executions here but choose not to. In the case where we
@@ -168,24 +168,24 @@ let eval_assertion (config : config) (meta : Meta.meta) (assertion : assertion)
match v.value with
| VLiteral (VBool _) ->
(* Delegate to the concrete evaluation function *)
- eval_assertion_concrete config meta assertion ctx
+ eval_assertion_concrete config span assertion ctx
| VSymbolic sv ->
- sanity_check __FILE__ __LINE__ (config.mode = SymbolicMode) meta;
- sanity_check __FILE__ __LINE__ (sv.sv_ty = TLiteral TBool) meta;
+ sanity_check __FILE__ __LINE__ (config.mode = SymbolicMode) span;
+ sanity_check __FILE__ __LINE__ (sv.sv_ty = TLiteral TBool) span;
(* We continue the execution as if the test had succeeded, and thus
* perform the symbolic expansion: sv ~~> true.
* We will of course synthesize an assertion in the generated code
* (see below). *)
let ctx =
- apply_symbolic_expansion_non_borrow config meta sv ctx
+ apply_symbolic_expansion_non_borrow config span sv ctx
(SeLiteral (VBool true))
in
(* Add the synthesized assertion *)
((ctx, Unit), S.synthesize_assertion ctx v)
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Expected a boolean, got: "
- ^ typed_value_to_string ~meta:(Some meta) ctx v)
+ ^ typed_value_to_string ~span:(Some span) ctx v)
in
(* Compose and apply *)
(st, cc_comp cf_eval_op cf_eval_assert)
@@ -201,7 +201,7 @@ let eval_assertion (config : config) (meta : Meta.meta) (assertion : assertion)
a variant with all its fields set to {!Bottom}.
For instance, something like: [Cons Bottom Bottom].
*)
-let set_discriminant (config : config) (meta : Meta.meta) (p : place)
+let set_discriminant (config : config) (span : Meta.span) (p : place)
(variant_id : VariantId.id) : st_cm_fun =
fun ctx ->
log#ldebug
@@ -210,11 +210,11 @@ let set_discriminant (config : config) (meta : Meta.meta) (p : place)
^ "\n- variant id: "
^ VariantId.to_string variant_id
^ "\n- initial context:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Access the value *)
let access = Write in
- let ctx, cc = update_ctx_along_read_place config meta access p ctx in
- let v, ctx, cc = comp2 cc (prepare_lplace config meta p ctx) in
+ let ctx, cc = update_ctx_along_read_place config span access p ctx in
+ let v, ctx, cc = comp2 cc (prepare_lplace config span p ctx) in
(* Update the value *)
match (v.ty, v.value) with
| TAdt ((TAdtId _ as type_id), generics), VAdt av -> (
@@ -226,7 +226,7 @@ let set_discriminant (config : config) (meta : Meta.meta) (p : place)
*)
match av.variant_id with
| None ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Found a struct value while expecting an enum"
| Some variant_id' ->
if variant_id' = variant_id then (* Nothing to do *)
@@ -236,26 +236,26 @@ let set_discriminant (config : config) (meta : Meta.meta) (p : place)
let bottom_v =
match type_id with
| TAdtId def_id ->
- compute_expanded_bottom_adt_value meta ctx def_id
+ compute_expanded_bottom_adt_value span ctx def_id
(Some variant_id) generics
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let ctx, cc =
- comp cc (assign_to_place config meta bottom_v p ctx)
+ comp cc (assign_to_place config span bottom_v p ctx)
in
((ctx, Unit), cc))
| TAdt ((TAdtId _ as type_id), generics), VBottom ->
let bottom_v =
match type_id with
| TAdtId def_id ->
- compute_expanded_bottom_adt_value meta ctx def_id (Some variant_id)
+ compute_expanded_bottom_adt_value span ctx def_id (Some variant_id)
generics
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
- let ctx, cc = comp cc (assign_to_place config meta bottom_v p ctx) in
+ let ctx, cc = comp cc (assign_to_place config span bottom_v p ctx) in
((ctx, Unit), cc)
| _, VSymbolic _ ->
- sanity_check __FILE__ __LINE__ (config.mode = SymbolicMode) meta;
+ sanity_check __FILE__ __LINE__ (config.mode = SymbolicMode) span;
(* This is a bit annoying: in theory we should expand the symbolic value
* then set the discriminant, because in the case the discriminant is
* exactly the one we set, the fields are left untouched, and in the
@@ -263,10 +263,10 @@ let set_discriminant (config : config) (meta : Meta.meta) (p : place)
* For now, we forbid setting the discriminant of a symbolic value:
* setting a discriminant should only be used to initialize a value,
* or reset an already initialized value, really. *)
- craise __FILE__ __LINE__ meta "Unexpected value"
- | _, (VAdt _ | VBottom) -> craise __FILE__ __LINE__ meta "Inconsistent state"
+ craise __FILE__ __LINE__ span "Unexpected value"
+ | _, (VAdt _ | VBottom) -> craise __FILE__ __LINE__ span "Inconsistent state"
| _, (VLiteral _ | VBorrow _ | VLoan _) ->
- craise __FILE__ __LINE__ meta "Unexpected value"
+ craise __FILE__ __LINE__ span "Unexpected value"
(** Push a frame delimiter in the context's environment *)
let ctx_push_frame (ctx : eval_ctx) : eval_ctx =
@@ -278,15 +278,15 @@ let push_frame (ctx : eval_ctx) : eval_ctx = ctx_push_frame ctx
(** Small helper: compute the type of the return value for a specific
instantiation of an assumed function.
*)
-let get_assumed_function_return_type (meta : Meta.meta) (ctx : eval_ctx)
+let get_assumed_function_return_type (span : Meta.span) (ctx : eval_ctx)
(fid : assumed_fun_id) (generics : generic_args) : ety =
- sanity_check __FILE__ __LINE__ (generics.trait_refs = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.trait_refs = []) span;
(* [Box::free] has a special treatment *)
match fid with
| BoxFree ->
- sanity_check __FILE__ __LINE__ (generics.regions = []) meta;
- sanity_check __FILE__ __LINE__ (List.length generics.types = 1) meta;
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.regions = []) span;
+ sanity_check __FILE__ __LINE__ (List.length generics.types = 1) span;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
mk_unit_ty
| _ ->
(* Retrieve the function's signature *)
@@ -302,30 +302,30 @@ let get_assumed_function_return_type (meta : Meta.meta) (ctx : eval_ctx)
Subst.erase_regions_substitute_types ty_subst cg_subst tr_subst tr_self
sg.output
in
- AssociatedTypes.ctx_normalize_erase_ty meta ctx ty
+ AssociatedTypes.ctx_normalize_erase_ty span ctx ty
-let move_return_value (config : config) (meta : Meta.meta)
+let move_return_value (config : config) (span : Meta.span)
(pop_return_value : bool) (ctx : eval_ctx) :
typed_value option * eval_ctx * (eval_result -> eval_result) =
if pop_return_value then
let ret_vid = VarId.zero in
let v, ctx, cc =
- eval_operand config meta (Move (mk_place_from_var_id ret_vid)) ctx
+ eval_operand config span (Move (mk_place_from_var_id ret_vid)) ctx
in
(Some v, ctx, cc)
else (None, ctx, fun e -> e)
-let pop_frame (config : config) (meta : Meta.meta) (pop_return_value : bool)
+let pop_frame (config : config) (span : Meta.span) (pop_return_value : bool)
(ctx : eval_ctx) :
typed_value option * eval_ctx * (eval_result -> eval_result) =
(* Debug *)
- log#ldebug (lazy ("pop_frame:\n" ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ log#ldebug (lazy ("pop_frame:\n" ^ eval_ctx_to_string ~span:(Some span) ctx));
(* List the local variables, but the return variable *)
let ret_vid = VarId.zero in
let rec list_locals env =
match env with
- | [] -> craise __FILE__ __LINE__ meta "Inconsistent environment"
+ | [] -> craise __FILE__ __LINE__ span "Inconsistent environment"
| EAbs _ :: env -> list_locals env
| EBinding (BDummy _, _) :: env -> list_locals env
| EBinding (BVar var, _) :: env ->
@@ -342,14 +342,14 @@ let pop_frame (config : config) (meta : Meta.meta) (pop_return_value : bool)
^ "]"));
(* Move the return value out of the return variable *)
- let v, ctx, cc = move_return_value config meta pop_return_value ctx in
+ let v, ctx, cc = move_return_value config span pop_return_value ctx in
let _ =
match v with
| None -> ()
| Some ret_value ->
sanity_check __FILE__ __LINE__
(not (bottom_in_value ctx.ended_regions ret_value))
- meta
+ span
in
(* Drop the outer *loans* we find in the local variables *)
@@ -359,21 +359,21 @@ let pop_frame (config : config) (meta : Meta.meta) (pop_return_value : bool)
let locals = List.rev locals in
fold_left_apply_continuation
(fun lid ctx ->
- drop_outer_loans_at_lplace config meta (mk_place_from_var_id lid) ctx)
+ drop_outer_loans_at_lplace config span (mk_place_from_var_id lid) ctx)
locals ctx)
in
(* Debug *)
log#ldebug
(lazy
("pop_frame: after dropping outer loans in local variables:\n"
- ^ eval_ctx_to_string ~meta:(Some meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some span) ctx));
(* Pop the frame - we remove the [Frame] delimiter, and reintroduce all
* the local variables (which may still contain borrow permissions - but
* no outer loans) as dummy variables in the caller frame *)
let rec pop env =
match env with
- | [] -> craise __FILE__ __LINE__ meta "Inconsistent environment"
+ | [] -> craise __FILE__ __LINE__ span "Inconsistent environment"
| EAbs abs :: env -> EAbs abs :: pop env
| EBinding (_, v) :: env ->
let vid = fresh_dummy_var_id () in
@@ -386,14 +386,14 @@ let pop_frame (config : config) (meta : Meta.meta) (pop_return_value : bool)
(v, ctx, cc)
(** Pop the current frame and assign the returned value to its destination. *)
-let pop_frame_assign (config : config) (meta : Meta.meta) (dest : place) :
+let pop_frame_assign (config : config) (span : Meta.span) (dest : place) :
cm_fun =
fun ctx ->
- let v, ctx, cc = pop_frame config meta true ctx in
- comp cc (assign_to_place config meta (Option.get v) dest ctx)
+ let v, ctx, cc = pop_frame config span true ctx in
+ comp cc (assign_to_place config span (Option.get v) dest ctx)
(** Auxiliary function - see {!eval_assumed_function_call} *)
-let eval_box_new_concrete (config : config) (meta : Meta.meta)
+let eval_box_new_concrete (config : config) (span : Meta.span)
(generics : generic_args) : cm_fun =
fun ctx ->
(* Check and retrieve the arguments *)
@@ -409,11 +409,11 @@ let eval_box_new_concrete (config : config) (meta : Meta.meta)
(* Required type checking *)
cassert __FILE__ __LINE__
(input_value.ty = boxed_ty)
- meta "The input given to Box::new doesn't have the proper type";
+ span "The input given to Box::new doesn't have the proper type";
(* Move the input value *)
let v, ctx, cc =
- eval_operand config meta
+ eval_operand config span
(Move (mk_place_from_var_id input_var.index))
ctx
in
@@ -423,12 +423,12 @@ let eval_box_new_concrete (config : config) (meta : Meta.meta)
let generics = TypesUtils.mk_generic_args_from_types [ boxed_ty ] in
let box_ty = TAdt (TAssumed TBox, generics) in
let box_v = VAdt { variant_id = None; field_values = [ v ] } in
- let box_v = mk_typed_value meta box_ty box_v in
+ let box_v = mk_typed_value span box_ty box_v in
(* Move this value to the return variable *)
let dest = mk_place_from_var_id VarId.zero in
- comp cc (assign_to_place config meta box_v dest ctx)
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent state"
+ comp cc (assign_to_place config span box_v dest ctx)
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent state"
(** Auxiliary function - see {!eval_assumed_function_call}.
@@ -449,28 +449,28 @@ let eval_box_new_concrete (config : config) (meta : Meta.meta)
It thus updates the box value (by calling {!drop_value}) and updates
the destination (by setting it to [()]).
*)
-let eval_box_free (config : config) (meta : Meta.meta) (generics : generic_args)
+let eval_box_free (config : config) (span : Meta.span) (generics : generic_args)
(args : operand list) (dest : place) : cm_fun =
fun ctx ->
match (generics.regions, generics.types, generics.const_generics, args) with
| [], [ boxed_ty ], [], [ Move input_box_place ] ->
(* Required type checking *)
let input_box =
- InterpreterPaths.read_place meta Write input_box_place ctx
+ InterpreterPaths.read_place span Write input_box_place ctx
in
(let input_ty = ty_get_box input_box.ty in
sanity_check __FILE__ __LINE__ (input_ty = boxed_ty))
- meta;
+ span;
(* Drop the value *)
- let ctx, cc = drop_value config meta input_box_place ctx in
+ let ctx, cc = drop_value config span input_box_place ctx in
(* Update the destination by setting it to [()] *)
- comp cc (assign_to_place config meta mk_unit_value dest ctx)
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent state"
+ comp cc (assign_to_place config span mk_unit_value dest ctx)
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent state"
(** Evaluate a non-local function call in concrete mode *)
-let eval_assumed_function_call_concrete (config : config) (meta : Meta.meta)
+let eval_assumed_function_call_concrete (config : config) (span : Meta.span)
(fid : assumed_fun_id) (call : call) : cm_fun =
fun ctx ->
let args = call.args in
@@ -478,12 +478,12 @@ let eval_assumed_function_call_concrete (config : config) (meta : Meta.meta)
match call.func with
| FnOpMove _ ->
(* Closure case: TODO *)
- craise __FILE__ __LINE__ meta "Closures are not supported yet"
+ craise __FILE__ __LINE__ span "Closures are not supported yet"
| FnOpRegular func -> (
let generics = func.generics in
(* Sanity check: we don't fully handle the const generic vars environment
in concrete mode yet *)
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
(* There are two cases (and this is extremely annoying):
- the function is not box_free
- the function is box_free
@@ -492,12 +492,12 @@ let eval_assumed_function_call_concrete (config : config) (meta : Meta.meta)
match fid with
| BoxFree ->
(* Degenerate case: box_free *)
- eval_box_free config meta generics args dest ctx
+ eval_box_free config span generics args dest ctx
| _ ->
(* "Normal" case: not box_free *)
(* Evaluate the operands *)
(* let ctx, args_vl = eval_operands config ctx args in *)
- let args_vl, ctx, cc = eval_operands config meta args ctx in
+ let args_vl, ctx, cc = eval_operands config span args ctx in
(* Evaluate the call
*
@@ -512,9 +512,9 @@ let eval_assumed_function_call_concrete (config : config) (meta : Meta.meta)
(* Create and push the return variable *)
let ret_vid = VarId.zero in
- let ret_ty = get_assumed_function_return_type meta ctx fid generics in
+ let ret_ty = get_assumed_function_return_type span ctx fid generics in
let ret_var = mk_var ret_vid (Some "@return") ret_ty in
- let ctx = push_uninitialized_var meta ret_var ctx in
+ let ctx = push_uninitialized_var span ret_var ctx in
(* Create and push the input variables *)
let input_vars =
@@ -522,26 +522,26 @@ let eval_assumed_function_call_concrete (config : config) (meta : Meta.meta)
(fun id (v : typed_value) -> (mk_var id None v.ty, v))
args_vl
in
- let ctx = push_vars meta input_vars ctx in
+ let ctx = push_vars span input_vars ctx in
(* "Execute" the function body. As the functions are assumed, here we call
* custom functions to perform the proper manipulations: we don't have
* access to a body. *)
let ctx, cf_eval_body =
match fid with
- | BoxNew -> eval_box_new_concrete config meta generics ctx
+ | BoxNew -> eval_box_new_concrete config span generics ctx
| BoxFree ->
(* Should have been treated above *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| ArrayIndexShared | ArrayIndexMut | ArrayToSliceShared
| ArrayToSliceMut | ArrayRepeat | SliceIndexShared | SliceIndexMut
->
- craise __FILE__ __LINE__ meta "Unimplemented"
+ craise __FILE__ __LINE__ span "Unimplemented"
in
let cc = cc_comp cc cf_eval_body in
(* Pop the frame *)
- comp cc (pop_frame_assign config meta dest ctx))
+ comp cc (pop_frame_assign config span dest ctx))
(** Helper
@@ -698,7 +698,7 @@ let create_push_abstractions_from_abs_region_groups
which means that whenever we call a provided trait method, we do not refer
to a trait clause but directly to the method provided in the trait declaration.
*)
-let eval_transparent_function_call_symbolic_inst (meta : Meta.meta)
+let eval_transparent_function_call_symbolic_inst (span : Meta.span)
(call : call) (ctx : eval_ctx) :
fun_id_or_trait_method_ref
* generic_args
@@ -709,7 +709,7 @@ let eval_transparent_function_call_symbolic_inst (meta : Meta.meta)
match call.func with
| FnOpMove _ ->
(* Closure case: TODO *)
- craise __FILE__ __LINE__ meta "Closures are not supported yet"
+ craise __FILE__ __LINE__ span "Closures are not supported yet"
| FnOpRegular func -> (
match func.func with
| FunId (FRegular fid) ->
@@ -727,13 +727,13 @@ let eval_transparent_function_call_symbolic_inst (meta : Meta.meta)
ctx.fun_ctx.regions_hierarchies
in
let inst_sg =
- instantiate_fun_sig meta ctx func.generics tr_self def.signature
+ instantiate_fun_sig span ctx func.generics tr_self def.signature
regions_hierarchy
in
(func.func, func.generics, None, def, regions_hierarchy, inst_sg)
| FunId (FAssumed _) ->
(* Unreachable: must be a transparent function *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| TraitMethod (trait_ref, method_name, _) -> (
log#ldebug
(lazy
@@ -774,7 +774,7 @@ let eval_transparent_function_call_symbolic_inst (meta : Meta.meta)
ctx.fun_ctx.regions_hierarchies
in
let inst_sg =
- instantiate_fun_sig meta ctx generics tr_self
+ instantiate_fun_sig span ctx generics tr_self
method_def.signature regions_hierarchy
in
(* Also update the function identifier: we want to forget
@@ -795,7 +795,7 @@ let eval_transparent_function_call_symbolic_inst (meta : Meta.meta)
(remember: for now, we forbid overriding provided methods) *)
cassert __FILE__ __LINE__
(trait_impl.provided_methods = [])
- meta "Overriding provided methods is currently forbidden";
+ span "Overriding provided methods is currently forbidden";
let trait_decl =
ctx_lookup_trait_decl ctx
trait_ref.trait_decl_ref.trait_decl_id
@@ -842,7 +842,7 @@ let eval_transparent_function_call_symbolic_inst (meta : Meta.meta)
in
let tr_self = TraitRef trait_ref in
let inst_sg =
- instantiate_fun_sig meta ctx all_generics tr_self
+ instantiate_fun_sig span ctx all_generics tr_self
method_def.signature regions_hierarchy
in
( func.func,
@@ -884,7 +884,7 @@ let eval_transparent_function_call_symbolic_inst (meta : Meta.meta)
in
let tr_self = TraitRef trait_ref in
let inst_sg =
- instantiate_fun_sig meta ctx generics tr_self
+ instantiate_fun_sig span ctx generics tr_self
method_def.signature regions_hierarchy
in
( func.func,
@@ -903,16 +903,16 @@ let rec eval_statement (config : config) (st : statement) : stl_cm_fun =
("\n**About to evaluate statement**: [\n"
^ statement_to_string_with_tab ctx st
^ "\n]\n\n**Context**:\n"
- ^ eval_ctx_to_string ~meta:(Some st.meta) ctx
+ ^ eval_ctx_to_string ~span:(Some st.span) ctx
^ "\n\n"));
(* Take a snapshot of the current context for the purpose of generating pretty names *)
let cc = S.save_snapshot ctx in
(* Expand the symbolic values if necessary - we need to do that before
checking the invariants *)
- let ctx, cc = comp cc (greedy_expand_symbolic_values config st.meta ctx) in
+ let ctx, cc = comp cc (greedy_expand_symbolic_values config st.span ctx) in
(* Sanity check *)
- Invariants.check_invariants st.meta ctx;
+ Invariants.check_invariants st.span ctx;
(* Evaluate *)
let stl, cf_eval_st =
@@ -927,69 +927,69 @@ let rec eval_statement (config : config) (st : statement) : stl_cm_fun =
match rvalue with
| Global (gid, generics) ->
(* Evaluate the global *)
- eval_global config st.meta p gid generics ctx
+ eval_global config st.span p gid generics ctx
| _ ->
(* Evaluate the rvalue *)
let res, ctx, cc =
- eval_rvalue_not_global config st.meta rvalue ctx
+ eval_rvalue_not_global config st.span rvalue ctx
in
(* Assign *)
log#ldebug
(lazy
("about to assign to place: " ^ place_to_string ctx p
^ "\n- Context:\n"
- ^ eval_ctx_to_string ~meta:(Some st.meta) ctx));
+ ^ eval_ctx_to_string ~span:(Some st.span) ctx));
let (ctx, res), cf_assign =
match res with
| Error EPanic -> ((ctx, Panic), fun e -> e)
| Ok rv ->
- (* Update the synthesized AST - here we store additional meta-information.
+ (* Update the synthesized AST - here we store additional span-information.
* We do it only in specific cases (it is not always useful, and
* also it can lead to issues - for instance, if we borrow a
* reserved borrow, we later can't translate it to pure values...) *)
let cc =
match rvalue with
- | Global _ -> craise __FILE__ __LINE__ st.meta "Unreachable"
+ | Global _ -> craise __FILE__ __LINE__ st.span "Unreachable"
| Use _
| RvRef (_, (BShared | BMut | BTwoPhaseMut | BShallow))
| UnaryOp _ | BinaryOp _ | Discriminant _ | Aggregate _ ->
let rp = rvalue_get_place rvalue in
let rp =
match rp with
- | Some rp -> Some (S.mk_mplace st.meta rp ctx)
+ | Some rp -> Some (S.mk_mplace st.span rp ctx)
| None -> None
in
S.synthesize_assignment ctx
- (S.mk_mplace st.meta p ctx)
+ (S.mk_mplace st.span p ctx)
rv rp
in
let ctx, cc =
- comp cc (assign_to_place config st.meta rv p ctx)
+ comp cc (assign_to_place config st.span rv p ctx)
in
((ctx, Unit), cc)
in
let cc = cc_comp cc cf_assign in
(* Compose and apply *)
- ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.meta cc))
+ ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.span cc))
| FakeRead p ->
- let ctx, cc = eval_fake_read config st.meta p ctx in
- ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ st.meta cc)
+ let ctx, cc = eval_fake_read config st.span p ctx in
+ ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ st.span cc)
| SetDiscriminant (p, variant_id) ->
- let (ctx, res), cc = set_discriminant config st.meta p variant_id ctx in
- ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.meta cc)
+ let (ctx, res), cc = set_discriminant config st.span p variant_id ctx in
+ ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.span cc)
| Drop p ->
- let ctx, cc = drop_value config st.meta p ctx in
- ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ st.meta cc)
+ let ctx, cc = drop_value config st.span p ctx in
+ ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ st.span cc)
| Assert assertion ->
- let (ctx, res), cc = eval_assertion config st.meta assertion ctx in
- ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.meta cc)
- | Call call -> eval_function_call config st.meta call ctx
- | Panic -> ([ (ctx, Panic) ], cc_singleton __FILE__ __LINE__ st.meta cc)
- | Return -> ([ (ctx, Return) ], cc_singleton __FILE__ __LINE__ st.meta cc)
- | Break i -> ([ (ctx, Break i) ], cc_singleton __FILE__ __LINE__ st.meta cc)
+ let (ctx, res), cc = eval_assertion config st.span assertion ctx in
+ ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.span cc)
+ | Call call -> eval_function_call config st.span call ctx
+ | Panic -> ([ (ctx, Panic) ], cc_singleton __FILE__ __LINE__ st.span cc)
+ | Return -> ([ (ctx, Return) ], cc_singleton __FILE__ __LINE__ st.span cc)
+ | Break i -> ([ (ctx, Break i) ], cc_singleton __FILE__ __LINE__ st.span cc)
| Continue i ->
- ([ (ctx, Continue i) ], cc_singleton __FILE__ __LINE__ st.meta cc)
- | Nop -> ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ st.meta cc)
+ ([ (ctx, Continue i) ], cc_singleton __FILE__ __LINE__ st.span cc)
+ | Nop -> ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ st.span cc)
| Sequence (st1, st2) ->
(* Evaluate the first statement *)
let ctx_resl, cf_st1 = eval_statement config st1 ctx in
@@ -1005,7 +1005,7 @@ let rec eval_statement (config : config) (st : statement) : stl_cm_fun =
(* Control-flow break: transmit. We enumerate the cases on purpose *)
| Panic | Break _ | Continue _ | Return | LoopReturn _
| EndEnterLoop _ | EndContinue _ ->
- ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.meta cc))
+ ([ (ctx, res) ], cc_singleton __FILE__ __LINE__ st.span cc))
ctx_resl
in
(* Put everything together:
@@ -1014,18 +1014,18 @@ let rec eval_statement (config : config) (st : statement) : stl_cm_fun =
expression from the continuations for the individual branches
*)
let ctx_resl, cf_st2 =
- comp_seqs __FILE__ __LINE__ st.meta ctx_res_cfl
+ comp_seqs __FILE__ __LINE__ st.span ctx_res_cfl
in
(ctx_resl, cc_comp cf_st1 cf_st2)
| Loop loop_body ->
let eval_loop_body = eval_statement config loop_body in
- InterpreterLoops.eval_loop config st.meta eval_loop_body ctx
- | Switch switch -> eval_switch config st.meta switch ctx
+ InterpreterLoops.eval_loop config st.span eval_loop_body ctx
+ | Switch switch -> eval_switch config st.span switch ctx
in
(* Compose and apply *)
(stl, cc_comp cc cf_eval_st)
-and eval_global (config : config) (meta : Meta.meta) (dest : place)
+and eval_global (config : config) (span : Meta.span) (dest : place)
(gid : GlobalDeclId.id) (generics : generic_args) : stl_cm_fun =
fun ctx ->
let global = ctx_lookup_global_decl ctx gid in
@@ -1034,11 +1034,11 @@ and eval_global (config : config) (meta : Meta.meta) (dest : place)
(* Treat the evaluation of the global as a call to the global body *)
let func = { func = FunId (FRegular global.body); generics } in
let call = { func = FnOpRegular func; args = []; dest } in
- eval_transparent_function_call_concrete config meta global.body call ctx
+ eval_transparent_function_call_concrete config span global.body call ctx
| SymbolicMode -> (
(* Generate a fresh symbolic value. In the translation, this fresh symbolic value will be
* defined as equal to the value of the global (see {!S.synthesize_global_eval}). *)
- cassert __FILE__ __LINE__ (ty_no_regions global.ty) meta
+ cassert __FILE__ __LINE__ (ty_no_regions global.ty) span
"Const globals should not contain regions";
(* Instantiate the type *)
(* There shouldn't be any reference to Self *)
@@ -1051,9 +1051,9 @@ and eval_global (config : config) (meta : Meta.meta) (dest : place)
Subst.erase_regions_substitute_types ty_subst cg_subst tr_subst tr_self
global.ty
in
- let sval = mk_fresh_symbolic_value meta ty in
+ let sval = mk_fresh_symbolic_value span ty in
let ctx, cc =
- assign_to_place config meta
+ assign_to_place config span
(mk_typed_value_from_symbolic_value sval)
dest ctx
in
@@ -1062,11 +1062,11 @@ and eval_global (config : config) (meta : Meta.meta) (dest : place)
match el with
| Some [ e ] ->
(cc_comp (S.synthesize_global_eval gid generics sval) cc) (Some e)
- | Some _ -> internal_error __FILE__ __LINE__ meta
+ | Some _ -> internal_error __FILE__ __LINE__ span
| _ -> None ))
(** Evaluate a switch *)
-and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
+and eval_switch (config : config) (span : Meta.span) (switch : switch) :
stl_cm_fun =
fun ctx ->
(* We evaluate the operand in two steps:
@@ -1081,7 +1081,7 @@ and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
match switch with
| If (op, st1, st2) ->
(* Evaluate the operand *)
- let op_v, ctx, cf_eval_op = eval_operand config meta op ctx in
+ let op_v, ctx, cf_eval_op = eval_operand config span op ctx in
(* Switch on the value *)
let ctx_resl, cf_if =
match op_v.value with
@@ -1093,35 +1093,35 @@ and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
(* Expand the symbolic boolean, and continue by evaluating
the branches *)
let (ctx_true, ctx_false), cf_bool =
- expand_symbolic_bool config meta sv
- (S.mk_opt_place_from_op meta op ctx)
+ expand_symbolic_bool config span sv
+ (S.mk_opt_place_from_op span op ctx)
ctx
in
let resl_true = eval_statement config st1 ctx_true in
let resl_false = eval_statement config st2 ctx_false in
let ctx_resl, cf_branches =
- comp_seqs __FILE__ __LINE__ meta [ resl_true; resl_false ]
+ comp_seqs __FILE__ __LINE__ span [ resl_true; resl_false ]
in
let cc el =
match cf_branches el with
| None -> None
| Some [ e_true; e_false ] -> cf_bool (Some (e_true, e_false))
- | _ -> internal_error __FILE__ __LINE__ meta
+ | _ -> internal_error __FILE__ __LINE__ span
in
(ctx_resl, cc)
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent state"
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent state"
in
(* Compose *)
(ctx_resl, cc_comp cf_eval_op cf_if)
| SwitchInt (op, int_ty, stgts, otherwise) ->
(* Evaluate the operand *)
- let op_v, ctx, cf_eval_op = eval_operand config meta op ctx in
+ let op_v, ctx, cf_eval_op = eval_operand config span op ctx in
(* Switch on the value *)
let ctx_resl, cf_switch =
match op_v.value with
| VLiteral (VScalar sv) -> (
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (sv.int_ty = int_ty) meta;
+ sanity_check __FILE__ __LINE__ (sv.int_ty = int_ty) span;
(* Find the branch *)
match List.find_opt (fun (svl, _) -> List.mem sv svl) stgts with
| None -> eval_statement config otherwise ctx
@@ -1140,8 +1140,8 @@ and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
in
(* Expand the symbolic value *)
let (ctx_branches, ctx_otherwise), cf_int =
- expand_symbolic_int config meta sv
- (S.mk_opt_place_from_op meta op ctx)
+ expand_symbolic_int config span sv
+ (S.mk_opt_place_from_op span op ctx)
int_ty values ctx
in
(* Evaluate the branches: first the "regular" branches *)
@@ -1156,7 +1156,7 @@ and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
in
(* Compose the continuations *)
let resl, cf =
- comp_seqs __FILE__ __LINE__ meta
+ comp_seqs __FILE__ __LINE__ span
(resl_branches @ [ resl_otherwise ])
in
let cc el =
@@ -1167,7 +1167,7 @@ and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
cf_int (Some (el, e_otherwise))
in
(resl, cc_comp cc cf)
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent state"
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent state"
in
(* Compose *)
(ctx_resl, cc_comp cf_eval_op cf_switch)
@@ -1176,7 +1176,7 @@ and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
let access = Read in
let expand_prim_copy = false in
let p_v, ctx, cf_read_p =
- access_rplace_reorganize_and_read config meta expand_prim_copy access p
+ access_rplace_reorganize_and_read config span expand_prim_copy access p
ctx
in
(* Match on the value *)
@@ -1193,31 +1193,31 @@ and eval_switch (config : config) (meta : Meta.meta) (switch : switch) :
match List.find_opt (fun (svl, _) -> List.mem dv svl) stgts with
| None -> (
match otherwise with
- | None -> craise __FILE__ __LINE__ meta "No otherwise branch"
+ | None -> craise __FILE__ __LINE__ span "No otherwise branch"
| Some otherwise -> eval_statement config otherwise ctx)
| Some (_, tgt) -> eval_statement config tgt ctx)
| VSymbolic sv ->
(* Expand the symbolic value - may lead to branching *)
let ctxl, cf_expand =
- expand_symbolic_adt config meta sv
- (Some (S.mk_mplace meta p ctx))
+ expand_symbolic_adt config span sv
+ (Some (S.mk_mplace span p ctx))
ctx
in
(* Re-evaluate the switch - the value is not symbolic anymore,
which means we will go to the other branch *)
let resl =
- List.map (fun ctx -> (eval_switch config meta switch) ctx) ctxl
+ List.map (fun ctx -> (eval_switch config span switch) ctx) ctxl
in
(* Compose the continuations *)
- let ctx_resl, cf = comp_seqs __FILE__ __LINE__ meta resl in
+ let ctx_resl, cf = comp_seqs __FILE__ __LINE__ span resl in
(ctx_resl, cc_comp cf_expand cf)
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent state"
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent state"
in
(* Compose *)
(ctx_resl, cc_comp cf_read_p cf_match)
(** Evaluate a function call (auxiliary helper for [eval_statement]) *)
-and eval_function_call (config : config) (meta : Meta.meta) (call : call) :
+and eval_function_call (config : config) (span : Meta.span) (call : call) :
stl_cm_fun =
(* There are several cases:
- this is a local function, in which case we execute its body
@@ -1225,71 +1225,71 @@ and eval_function_call (config : config) (meta : Meta.meta) (call : call) :
- this is a trait method
*)
match config.mode with
- | ConcreteMode -> eval_function_call_concrete config meta call
- | SymbolicMode -> eval_function_call_symbolic config meta call
+ | ConcreteMode -> eval_function_call_concrete config span call
+ | SymbolicMode -> eval_function_call_symbolic config span call
-and eval_function_call_concrete (config : config) (meta : Meta.meta)
+and eval_function_call_concrete (config : config) (span : Meta.span)
(call : call) : stl_cm_fun =
fun ctx ->
match call.func with
- | FnOpMove _ -> craise __FILE__ __LINE__ meta "Closures are not supported yet"
+ | FnOpMove _ -> craise __FILE__ __LINE__ span "Closures are not supported yet"
| FnOpRegular func -> (
match func.func with
| FunId (FRegular fid) ->
- eval_transparent_function_call_concrete config meta fid call ctx
+ eval_transparent_function_call_concrete config span fid call ctx
| FunId (FAssumed fid) -> (
(* Continue - note that we do as if the function call has been successful,
* by giving {!Unit} to the continuation, because we place us in the case
* where we haven't panicked. Of course, the translation needs to take the
* panic case into account... *)
let ctx, cc =
- eval_assumed_function_call_concrete config meta fid call ctx
+ eval_assumed_function_call_concrete config span fid call ctx
in
( [ (ctx, Unit) ],
fun el ->
match el with
| Some [ e ] -> cc (Some e)
- | Some _ -> internal_error __FILE__ __LINE__ meta
+ | Some _ -> internal_error __FILE__ __LINE__ span
| _ -> None ))
- | TraitMethod _ -> craise __FILE__ __LINE__ meta "Unimplemented")
+ | TraitMethod _ -> craise __FILE__ __LINE__ span "Unimplemented")
-and eval_function_call_symbolic (config : config) (meta : Meta.meta)
+and eval_function_call_symbolic (config : config) (span : Meta.span)
(call : call) : stl_cm_fun =
match call.func with
- | FnOpMove _ -> craise __FILE__ __LINE__ meta "Closures are not supported yet"
+ | FnOpMove _ -> craise __FILE__ __LINE__ span "Closures are not supported yet"
| FnOpRegular func -> (
match func.func with
| FunId (FRegular _) | TraitMethod _ ->
- eval_transparent_function_call_symbolic config meta call
+ eval_transparent_function_call_symbolic config span call
| FunId (FAssumed fid) ->
- eval_assumed_function_call_symbolic config meta fid call func)
+ eval_assumed_function_call_symbolic config span fid call func)
(** Evaluate a local (i.e., non-assumed) function call in concrete mode *)
-and eval_transparent_function_call_concrete (config : config) (meta : Meta.meta)
+and eval_transparent_function_call_concrete (config : config) (span : Meta.span)
(fid : FunDeclId.id) (call : call) : stl_cm_fun =
fun ctx ->
let args = call.args in
let dest = call.dest in
match call.func with
- | FnOpMove _ -> craise __FILE__ __LINE__ meta "Closures are not supported yet"
+ | FnOpMove _ -> craise __FILE__ __LINE__ span "Closures are not supported yet"
| FnOpRegular func ->
let generics = func.generics in
(* Sanity check: we don't fully handle the const generic vars environment
in concrete mode yet *)
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
(* Retrieve the (correctly instantiated) body *)
let def = ctx_lookup_fun_decl ctx fid in
(* We can evaluate the function call only if it is not opaque *)
let body =
match def.body with
| None ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Can't evaluate a call to an opaque function: "
^ name_to_string ctx def.name)
| Some body -> body
in
(* TODO: we need to normalize the types if we want to correctly support traits *)
- cassert __FILE__ __LINE__ (generics.trait_refs = []) body.meta
+ cassert __FILE__ __LINE__ (generics.trait_refs = []) body.span
"Traits are not supported yet in concrete mode";
(* There shouldn't be any reference to Self *)
let tr_self = UnknownTrait __FUNCTION__ in
@@ -1301,8 +1301,8 @@ and eval_transparent_function_call_concrete (config : config) (meta : Meta.meta)
(* Evaluate the input operands *)
sanity_check __FILE__ __LINE__
(List.length args = body.arg_count)
- body.meta;
- let vl, ctx, cc = eval_operands config body.meta args ctx in
+ body.span;
+ let vl, ctx, cc = eval_operands config body.span args ctx in
(* Push a frame delimiter - we use {!comp_transmit} to transmit the result
* of the operands evaluation from above to the functions afterwards, while
@@ -1314,24 +1314,24 @@ and eval_transparent_function_call_concrete (config : config) (meta : Meta.meta)
let ret_var, locals =
match locals with
| ret_ty :: locals -> (ret_ty, locals)
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let input_locals, locals =
Collections.List.split_at locals body.arg_count
in
- let ctx = push_var meta ret_var (mk_bottom meta ret_var.var_ty) ctx in
+ let ctx = push_var span ret_var (mk_bottom span ret_var.var_ty) ctx in
(* 2. Push the input values *)
let ctx =
let inputs = List.combine input_locals vl in
(* Note that this function checks that the variables and their values
* have the same type (this is important) *)
- push_vars meta inputs ctx
+ push_vars span inputs ctx
in
(* 3. Push the remaining local variables (initialized as {!Bottom}) *)
- let ctx = push_uninitialized_vars meta locals ctx in
+ let ctx = push_uninitialized_vars span locals ctx in
(* Execute the function body *)
let ctx_resl, cc = comp cc (eval_function_body config body_st ctx) in
@@ -1345,11 +1345,11 @@ and eval_transparent_function_call_concrete (config : config) (meta : Meta.meta)
| Return ->
(* Pop the stack frame, retrieve the return value, move it to
its destination and continue *)
- let ctx, cf = pop_frame_assign config meta dest ctx in
+ let ctx, cf = pop_frame_assign config span dest ctx in
((ctx, Unit), cf)
| Break _ | Continue _ | Unit | LoopReturn _ | EndEnterLoop _
| EndContinue _ ->
- craise __FILE__ __LINE__ meta "Unreachable")
+ craise __FILE__ __LINE__ span "Unreachable")
ctx_resl
in
let ctx_resl, cfl = List.split ctx_resl_cfl in
@@ -1364,29 +1364,29 @@ and eval_transparent_function_call_concrete (config : config) (meta : Meta.meta)
(ctx_resl, cc_comp cc cf_pop)
(** Evaluate a local (i.e., non-assumed) function call in symbolic mode *)
-and eval_transparent_function_call_symbolic (config : config) (meta : Meta.meta)
+and eval_transparent_function_call_symbolic (config : config) (span : Meta.span)
(call : call) : stl_cm_fun =
fun ctx ->
let func, generics, trait_method_generics, def, regions_hierarchy, inst_sg =
- eval_transparent_function_call_symbolic_inst meta call ctx
+ eval_transparent_function_call_symbolic_inst span call ctx
in
(* Sanity check: same number of inputs *)
sanity_check __FILE__ __LINE__
(List.length call.args = List.length def.signature.inputs)
- def.item_meta.meta;
+ def.item_meta.span;
(* Sanity check: no nested borrows, borrows in ADTs, etc. *)
cassert __FILE__ __LINE__
(List.for_all
(fun ty -> not (ty_has_nested_borrows ctx.type_ctx.type_infos ty))
(inst_sg.output :: inst_sg.inputs))
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
cassert __FILE__ __LINE__
(List.for_all
(fun ty -> not (ty_has_adt_with_borrows ctx.type_ctx.type_infos ty))
(inst_sg.output :: inst_sg.inputs))
- meta "ADTs containing borrows are not supported yet";
+ span "ADTs containing borrows are not supported yet";
(* Evaluate the function call *)
- eval_function_call_symbolic_from_inst_sig config def.item_meta.meta func
+ eval_function_call_symbolic_from_inst_sig config def.item_meta.span func
def.signature regions_hierarchy inst_sg generics trait_method_generics
call.args call.dest ctx
@@ -1402,7 +1402,7 @@ and eval_transparent_function_call_symbolic (config : config) (meta : Meta.meta)
trait ref as input.
*)
and eval_function_call_symbolic_from_inst_sig (config : config)
- (meta : Meta.meta) (fid : fun_id_or_trait_method_ref) (sg : fun_sig)
+ (span : Meta.span) (fid : fun_id_or_trait_method_ref) (sg : fun_sig)
(regions_hierarchy : region_var_groups) (inst_sg : inst_fun_sig)
(generics : generic_args)
(trait_method_generics : (generic_args * trait_instance_id) option)
@@ -1422,18 +1422,18 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
(* Generate a fresh symbolic value for the return value *)
let ret_sv_ty = inst_sg.output in
- let ret_spc = mk_fresh_symbolic_value meta ret_sv_ty in
+ let ret_spc = mk_fresh_symbolic_value span ret_sv_ty in
let ret_value = mk_typed_value_from_symbolic_value ret_spc in
let ret_av regions =
mk_aproj_loans_value_from_symbolic_value regions ret_spc
in
let args_places =
- List.map (fun p -> S.mk_opt_place_from_op meta p ctx) args
+ List.map (fun p -> S.mk_opt_place_from_op span p ctx) args
in
- let dest_place = Some (S.mk_mplace meta dest ctx) in
+ let dest_place = Some (S.mk_mplace span dest ctx) in
(* Evaluate the input operands *)
- let args, ctx, cc = eval_operands config meta args ctx in
+ let args, ctx, cc = eval_operands config span args ctx in
(* Generate the abstractions and insert them in the context *)
let abs_ids = List.map (fun rg -> rg.id) inst_sg.regions_hierarchy in
@@ -1445,7 +1445,7 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
(fun ((arg, rty) : typed_value * rty) ->
arg.ty = Subst.erase_regions rty)
args_with_rtypes)
- meta "The input arguments don't have the proper type";
+ span "The input arguments don't have the proper type";
(* Check that the input arguments don't contain symbolic values that can't
* be fed to functions (i.e., symbolic values output from function return
* values and which contain borrows of borrows can't be used as function
@@ -1455,7 +1455,7 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
(fun arg ->
not (value_has_ret_symbolic_value_with_borrow_under_mut ctx arg))
args)
- meta;
+ span;
(* Initialize the abstractions and push them in the context.
* First, we define the function which, given an initialized, empty
@@ -1467,7 +1467,7 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
let ctx, args_projs =
List.fold_left_map
(fun ctx (arg, arg_rty) ->
- apply_proj_borrows_on_input_value config meta ctx abs.regions
+ apply_proj_borrows_on_input_value config span ctx abs.regions
abs.ancestors_regions arg arg_rty)
ctx args_with_rtypes
in
@@ -1491,7 +1491,7 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
in
(* Move the return value to its destination *)
- let ctx, cc = comp cc (assign_to_place config meta ret_value dest ctx) in
+ let ctx, cc = comp cc (assign_to_place config span ret_value dest ctx) in
(* End the abstractions which don't contain loans and don't have parent
* abstractions.
@@ -1511,7 +1511,7 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
(* Check if it contains non-ignored loans *)
&& Option.is_none
(InterpreterBorrowsCore
- .get_first_non_ignored_aloan_in_abstraction meta abs))
+ .get_first_non_ignored_aloan_in_abstraction span abs))
!abs_ids
in
(* Check if there are abstractions to end *)
@@ -1521,7 +1521,7 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
(* End the abstractions which can be ended *)
let no_loans_abs = AbstractionId.Set.of_list no_loans_abs in
let ctx, cc =
- InterpreterBorrows.end_abstractions config meta no_loans_abs ctx
+ InterpreterBorrows.end_abstractions config span no_loans_abs ctx
in
(* Recursive call *)
comp cc (end_abs_with_no_loans ctx))
@@ -1544,10 +1544,10 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
* by giving {!Unit} to the continuation, because we place us in the case
* where we haven't panicked. Of course, the translation needs to take the
* panic case into account... *)
- ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ meta cc)
+ ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ span cc)
(** Evaluate a non-local function call in symbolic mode *)
-and eval_assumed_function_call_symbolic (config : config) (meta : Meta.meta)
+and eval_assumed_function_call_symbolic (config : config) (span : Meta.span)
(fid : assumed_fun_id) (call : call) (func : fn_ptr) : stl_cm_fun =
fun ctx ->
let generics = func.generics in
@@ -1559,7 +1559,7 @@ and eval_assumed_function_call_symbolic (config : config) (meta : Meta.meta)
(List.for_all
(fun ty -> not (ty_has_borrows ctx.type_ctx.type_infos ty))
generics.types)
- meta;
+ span;
(* There are two cases (and this is extremely annoying):
- the function is not box_free
@@ -1570,8 +1570,8 @@ and eval_assumed_function_call_symbolic (config : config) (meta : Meta.meta)
| BoxFree ->
(* Degenerate case: box_free - note that this is not really a function
* call: no need to call a "synthesize_..." function *)
- let ctx, cc = eval_box_free config meta generics args dest ctx in
- ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ meta cc)
+ let ctx, cc = eval_box_free config span generics args dest ctx in
+ ([ (ctx, Unit) ], cc_singleton __FILE__ __LINE__ span cc)
| _ ->
(* "Normal" case: not box_free *)
(* In symbolic mode, the behaviour of a function call is completely defined
@@ -1581,7 +1581,7 @@ and eval_assumed_function_call_symbolic (config : config) (meta : Meta.meta)
match fid with
| BoxFree ->
(* Should have been treated above *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| _ ->
let regions_hierarchy =
LlbcAstUtils.FunIdMap.find (FAssumed fid)
@@ -1591,13 +1591,13 @@ and eval_assumed_function_call_symbolic (config : config) (meta : Meta.meta)
let tr_self = UnknownTrait __FUNCTION__ in
let sg = Assumed.get_assumed_fun_sig fid in
let inst_sg =
- instantiate_fun_sig meta ctx generics tr_self sg regions_hierarchy
+ instantiate_fun_sig span ctx generics tr_self sg regions_hierarchy
in
(sg, regions_hierarchy, inst_sg)
in
(* Evaluate the function call *)
- eval_function_call_symbolic_from_inst_sig config meta
+ eval_function_call_symbolic_from_inst_sig config span
(FunId (FAssumed fid)) sg regions_hierarchy inst_sig generics None args
dest ctx
@@ -1614,9 +1614,9 @@ and eval_function_body (config : config) (body : statement) : stl_cm_fun =
* delegate the check to the caller. *)
(* Expand the symbolic values if necessary - we need to do that before
* checking the invariants *)
- let ctx, cf = greedy_expand_symbolic_values config body.meta ctx in
+ let ctx, cf = greedy_expand_symbolic_values config body.span ctx in
(* Sanity check *)
- Invariants.check_invariants body.meta ctx;
+ Invariants.check_invariants body.span ctx;
(* Continue *)
((ctx, res), cf))
ctx_resl
diff --git a/compiler/InterpreterStatements.mli b/compiler/InterpreterStatements.mli
index 79ce1f73..c70396d6 100644
--- a/compiler/InterpreterStatements.mli
+++ b/compiler/InterpreterStatements.mli
@@ -18,7 +18,7 @@ open Cps
*)
val pop_frame :
config ->
- Meta.meta ->
+ Meta.span ->
bool ->
eval_ctx ->
typed_value option * eval_ctx * (eval_result -> eval_result)
diff --git a/compiler/InterpreterUtils.ml b/compiler/InterpreterUtils.ml
index a10ba89e..653a0e24 100644
--- a/compiler/InterpreterUtils.ml
+++ b/compiler/InterpreterUtils.ml
@@ -49,14 +49,14 @@ let statement_to_string ctx = Print.EvalCtx.statement_to_string ctx "" " "
let statement_to_string_with_tab ctx =
Print.EvalCtx.statement_to_string ctx " " " "
-let env_elem_to_string meta ctx =
- Print.EvalCtx.env_elem_to_string ~meta:(Some meta) ctx "" " "
+let env_elem_to_string span ctx =
+ Print.EvalCtx.env_elem_to_string ~span:(Some span) ctx "" " "
-let env_to_string meta ctx env =
- eval_ctx_to_string ~meta:(Some meta) { ctx with env }
+let env_to_string span ctx env =
+ eval_ctx_to_string ~span:(Some span) { ctx with env }
-let abs_to_string meta ctx =
- Print.EvalCtx.abs_to_string ~meta:(Some meta) ctx "" " "
+let abs_to_string span ctx =
+ Print.EvalCtx.abs_to_string ~span:(Some span) ctx "" " "
let same_symbolic_id (sv0 : symbolic_value) (sv1 : symbolic_value) : bool =
sv0.sv_id = sv1.sv_id
@@ -69,31 +69,31 @@ let mk_place_from_var_id (var_id : VarId.id) : place =
{ var_id; projection = [] }
(** Create a fresh symbolic value *)
-let mk_fresh_symbolic_value (meta : Meta.meta) (ty : ty) : symbolic_value =
+let mk_fresh_symbolic_value (span : Meta.span) (ty : ty) : symbolic_value =
(* Sanity check *)
- sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty) span;
let sv_id = fresh_symbolic_value_id () in
let svalue = { sv_id; sv_ty = ty } in
svalue
-let mk_fresh_symbolic_value_from_no_regions_ty (meta : Meta.meta) (ty : ty) :
+let mk_fresh_symbolic_value_from_no_regions_ty (span : Meta.span) (ty : ty) :
symbolic_value =
- sanity_check __FILE__ __LINE__ (ty_no_regions ty) meta;
- mk_fresh_symbolic_value meta ty
+ sanity_check __FILE__ __LINE__ (ty_no_regions ty) span;
+ mk_fresh_symbolic_value span ty
(** Create a fresh symbolic value *)
-let mk_fresh_symbolic_typed_value (meta : Meta.meta) (rty : ty) : typed_value =
- sanity_check __FILE__ __LINE__ (ty_is_rty rty) meta;
+let mk_fresh_symbolic_typed_value (span : Meta.span) (rty : ty) : typed_value =
+ sanity_check __FILE__ __LINE__ (ty_is_rty rty) span;
let ty = Substitute.erase_regions rty in
(* Generate the fresh a symbolic value *)
- let value = mk_fresh_symbolic_value meta rty in
+ let value = mk_fresh_symbolic_value span rty in
let value = VSymbolic value in
{ value; ty }
-let mk_fresh_symbolic_typed_value_from_no_regions_ty (meta : Meta.meta)
+let mk_fresh_symbolic_typed_value_from_no_regions_ty (span : Meta.span)
(ty : ty) : typed_value =
- sanity_check __FILE__ __LINE__ (ty_no_regions ty) meta;
- mk_fresh_symbolic_typed_value meta ty
+ sanity_check __FILE__ __LINE__ (ty_no_regions ty) span;
+ mk_fresh_symbolic_typed_value span ty
(** Create a typed value from a symbolic value. *)
let mk_typed_value_from_symbolic_value (svalue : symbolic_value) : typed_value =
@@ -119,10 +119,10 @@ let mk_aproj_loans_value_from_symbolic_value (regions : RegionId.Set.t)
else { value = AIgnored; ty = svalue.sv_ty }
(** Create a borrows projector from a symbolic value *)
-let mk_aproj_borrows_from_symbolic_value (meta : Meta.meta)
+let mk_aproj_borrows_from_symbolic_value (span : Meta.span)
(proj_regions : RegionId.Set.t) (svalue : symbolic_value) (proj_ty : ty) :
aproj =
- sanity_check __FILE__ __LINE__ (ty_is_rty proj_ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty proj_ty) span;
if ty_has_regions_in_set proj_regions proj_ty then
AProjBorrows (svalue, proj_ty)
else AIgnoredProjBorrows
@@ -136,7 +136,7 @@ let borrow_in_asb (bid : BorrowId.id) (asb : abstract_shared_borrows) : bool =
List.exists (borrow_is_asb bid) asb
(** TODO: move *)
-let remove_borrow_from_asb (meta : Meta.meta) (bid : BorrowId.id)
+let remove_borrow_from_asb (span : Meta.span) (bid : BorrowId.id)
(asb : abstract_shared_borrows) : abstract_shared_borrows =
let removed = ref 0 in
let asb =
@@ -148,7 +148,7 @@ let remove_borrow_from_asb (meta : Meta.meta) (bid : BorrowId.id)
false))
asb
in
- sanity_check __FILE__ __LINE__ (!removed = 1) meta;
+ sanity_check __FILE__ __LINE__ (!removed = 1) span;
asb
(** We sometimes need to return a value whose type may vary depending on
@@ -285,7 +285,7 @@ let value_has_ret_symbolic_value_with_borrow_under_mut (ctx : eval_ctx)
with Found -> true
(** Return the place used in an rvalue, if that makes sense.
- This is used to compute meta-data, to find pretty names.
+ This is used to compute span-data, to find pretty names.
*)
let rvalue_get_place (rv : rvalue) : place option =
match rv with
@@ -423,7 +423,7 @@ let empty_ids_set = fst (compute_ctxs_ids [])
(** **WARNING**: this function doesn't compute the normalized types
(for the trait type aliases). This should be computed afterwards.
*)
-let initialize_eval_ctx (meta : Meta.meta) (ctx : decls_ctx)
+let initialize_eval_ctx (span : Meta.span) (ctx : decls_ctx)
(region_groups : RegionGroupId.id list) (type_vars : type_var list)
(const_generic_vars : const_generic_var list) : eval_ctx =
reset_global_counters ();
@@ -432,7 +432,7 @@ let initialize_eval_ctx (meta : Meta.meta) (ctx : decls_ctx)
(List.map
(fun (cg : const_generic_var) ->
let ty = TLiteral cg.ty in
- let cv = mk_fresh_symbolic_typed_value meta ty in
+ let cv = mk_fresh_symbolic_typed_value span ty in
(cg.index, cv))
const_generic_vars)
in
@@ -455,7 +455,7 @@ let initialize_eval_ctx (meta : Meta.meta) (ctx : decls_ctx)
region ids. This is mostly used in preparation of function calls (when
evaluating in symbolic mode).
*)
-let instantiate_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
+let instantiate_fun_sig (span : Meta.span) (ctx : eval_ctx)
(generics : generic_args) (tr_self : trait_instance_id) (sg : fun_sig)
(regions_hierarchy : region_var_groups) : inst_fun_sig =
log#ldebug
@@ -496,10 +496,10 @@ let instantiate_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
types containing regions. *)
sanity_check __FILE__ __LINE__
(List.for_all TypesUtils.ty_no_regions generics.types)
- meta;
+ span;
sanity_check __FILE__ __LINE__
(TypesUtils.trait_instance_id_no_regions tr_self)
- meta;
+ span;
let tsubst =
Substitute.make_type_subst_from_vars sg.generics.types generics.types
in
@@ -513,7 +513,7 @@ let instantiate_fun_sig (meta : Meta.meta) (ctx : eval_ctx)
in
(* Substitute the signature *)
let inst_sig =
- AssociatedTypes.ctx_subst_norm_signature meta ctx asubst rsubst tsubst
+ AssociatedTypes.ctx_subst_norm_signature span ctx asubst rsubst tsubst
cgsubst tr_subst tr_self sg regions_hierarchy
in
(* Return *)
diff --git a/compiler/Invariants.ml b/compiler/Invariants.ml
index bae48f24..51be02c8 100644
--- a/compiler/Invariants.ml
+++ b/compiler/Invariants.ml
@@ -47,7 +47,7 @@ type borrow_kind = BMut | BShared | BReserved
- loans and borrows are correctly related
- a two-phase borrow can't point to a value inside an abstraction
*)
-let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
+let check_loans_borrows_relation_invariant (span : Meta.span) (ctx : eval_ctx) :
unit =
(* Link all the borrow ids to a representant - necessary because of shared
* borrows/loans *)
@@ -55,7 +55,7 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
(* Link all the id representants to a borrow information *)
let borrows_infos : borrow_info BorrowId.Map.t ref = ref BorrowId.Map.empty in
let context_to_string () : string =
- eval_ctx_to_string ~meta:(Some meta) ctx
+ eval_ctx_to_string ~span:(Some span) ctx
^ "- representants:\n"
^ ids_reprs_to_string " " !ids_reprs
^ "\n- info:\n"
@@ -78,12 +78,12 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
let infos = !borrows_infos in
(* Use the first borrow id as representant *)
let repr_bid = BorrowId.Set.min_elt bids in
- sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem repr_bid infos)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem repr_bid infos)) span;
(* Insert the mappings to the representant *)
let reprs =
BorrowId.Set.fold
(fun bid reprs ->
- sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem bid reprs)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem bid reprs)) span;
BorrowId.Map.add bid repr_bid reprs)
bids reprs
in
@@ -106,8 +106,8 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
let reprs = !ids_reprs in
let infos = !borrows_infos in
(* Sanity checks *)
- sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem bid reprs)) meta;
- sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem bid infos)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem bid reprs)) span;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Map.mem bid infos)) span;
(* Add the mapping for the representant *)
let reprs = BorrowId.Map.add bid bid reprs in
(* Add the mapping for the loan info *)
@@ -155,10 +155,10 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
| AIgnoredMutLoan (Some bid, _) -> register_ignored_loan RMut bid
| AIgnoredMutLoan (None, _)
| AIgnoredSharedLoan _
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ }
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ }
| AEndedSharedLoan (_, _)
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ } ->
+ { given_back = _; child = _; given_back_span = _ } ->
(* Do nothing *)
()
in
@@ -184,7 +184,7 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
"find_info: could not find the representant of borrow "
^ BorrowId.to_string bid ^ ":\nContext:\n" ^ context_to_string ()
in
- craise __FILE__ __LINE__ meta err
+ craise __FILE__ __LINE__ span err
in
let update_info (bid : BorrowId.id) (info : borrow_info) : unit =
@@ -196,7 +196,7 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
(fun x ->
match x with
| Some _ -> Some info
- | None -> craise __FILE__ __LINE__ meta "Unreachable")
+ | None -> craise __FILE__ __LINE__ span "Unreachable")
!borrows_infos
in
borrows_infos := infos
@@ -210,14 +210,14 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
(* Check that the borrow kind is consistent *)
(match (info.loan_kind, kind) with
| RShared, (BShared | BReserved) | RMut, BMut -> ()
- | _ -> craise __FILE__ __LINE__ meta "Invariant not satisfied");
+ | _ -> craise __FILE__ __LINE__ span "Invariant not satisfied");
(* A reserved borrow can't point to a value inside an abstraction *)
sanity_check __FILE__ __LINE__
(kind <> BReserved || not info.loan_in_abs)
- meta;
+ span;
(* Insert the borrow id *)
let borrow_ids = info.borrow_ids in
- sanity_check __FILE__ __LINE__ (not (BorrowId.Set.mem bid borrow_ids)) meta;
+ sanity_check __FILE__ __LINE__ (not (BorrowId.Set.mem bid borrow_ids)) span;
let info = { info with borrow_ids = BorrowId.Set.add bid borrow_ids } in
(* Update the info in the map *)
update_info bid info
@@ -272,7 +272,7 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
List.iter
(fun (rkind, bid) ->
let info = find_info bid in
- sanity_check __FILE__ __LINE__ (info.loan_kind = rkind) meta)
+ sanity_check __FILE__ __LINE__ (info.loan_kind = rkind) span)
!ignored_loans;
(* Then, check the borrow infos *)
@@ -283,12 +283,12 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
sanity_check __FILE__ __LINE__
(BorrowId.Set.elements info.loan_ids
= BorrowId.Set.elements info.borrow_ids)
- meta;
+ span;
match info.loan_kind with
| RMut ->
sanity_check __FILE__ __LINE__
(BorrowId.Set.cardinal info.loan_ids = 1)
- meta
+ span
| RShared -> ())
!borrows_infos
@@ -296,7 +296,7 @@ let check_loans_borrows_relation_invariant (meta : Meta.meta) (ctx : eval_ctx) :
- borrows/loans can't contain ⊥ or reserved mut borrows
- shared loans can't contain mutable loans
*)
-let check_borrowed_values_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
+let check_borrowed_values_invariant (span : Meta.span) (ctx : eval_ctx) : unit =
let visitor =
object
inherit [_] iter_eval_ctx as super
@@ -305,7 +305,7 @@ let check_borrowed_values_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
(* No ⊥ inside borrowed values *)
sanity_check __FILE__ __LINE__
(Config.allow_bottom_below_borrow || not info.outer_borrow)
- meta
+ span
method! visit_ABottom _info =
(* ⊥ inside an abstraction is not the same as in a regular value *)
@@ -318,7 +318,7 @@ let check_borrowed_values_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
| VSharedLoan (_, _) -> set_outer_shared info
| VMutLoan _ ->
(* No mutable loan inside a shared loan *)
- sanity_check __FILE__ __LINE__ (not info.outer_shared) meta;
+ sanity_check __FILE__ __LINE__ (not info.outer_shared) span;
set_outer_mut info
in
(* Continue exploring *)
@@ -330,7 +330,7 @@ let check_borrowed_values_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
match bc with
| VSharedBorrow _ -> set_outer_shared info
| VReservedMutBorrow _ ->
- sanity_check __FILE__ __LINE__ (not info.outer_borrow) meta;
+ sanity_check __FILE__ __LINE__ (not info.outer_borrow) span;
set_outer_shared info
| VMutBorrow (_, _) -> set_outer_mut info
in
@@ -343,12 +343,12 @@ let check_borrowed_values_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
match lc with
| AMutLoan (_, _) -> set_outer_mut info
| ASharedLoan (_, _, _) -> set_outer_shared info
- | AEndedMutLoan { given_back = _; child = _; given_back_meta = _ } ->
+ | AEndedMutLoan { given_back = _; child = _; given_back_span = _ } ->
set_outer_mut info
| AEndedSharedLoan (_, _) -> set_outer_shared info
| AIgnoredMutLoan (_, _) -> set_outer_mut info
| AEndedIgnoredMutLoan
- { given_back = _; child = _; given_back_meta = _ } ->
+ { given_back = _; child = _; given_back_span = _ } ->
set_outer_mut info
| AIgnoredSharedLoan _ -> set_outer_shared info
in
@@ -375,15 +375,15 @@ let check_borrowed_values_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
let info = { outer_borrow = false; outer_shared = false } in
visitor#visit_eval_ctx info ctx
-let check_literal_type (meta : Meta.meta) (cv : literal) (ty : literal_type) :
+let check_literal_type (span : Meta.span) (cv : literal) (ty : literal_type) :
unit =
match (cv, ty) with
| VScalar sv, TInteger int_ty ->
- sanity_check __FILE__ __LINE__ (sv.int_ty = int_ty) meta
+ sanity_check __FILE__ __LINE__ (sv.int_ty = int_ty) span
| VBool _, TBool | VChar _, TChar -> ()
- | _ -> craise __FILE__ __LINE__ meta "Erroneous typing"
+ | _ -> craise __FILE__ __LINE__ span "Erroneous typing"
-let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
+let check_typing_invariant (span : Meta.span) (ctx : eval_ctx) : unit =
(* TODO: the type of aloans doens't make sense: they have a type
* of the shape [& (mut) T] where they should have type [T]...
* This messes a bit the type invariant checks when checking the
@@ -403,20 +403,20 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
method! visit_EBinding info binder v =
(* We also check that the regions are erased *)
- sanity_check __FILE__ __LINE__ (ty_is_ety v.ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_ety v.ty) span;
super#visit_EBinding info binder v
method! visit_symbolic_value inside_abs v =
(* Check that the types have regions *)
- sanity_check __FILE__ __LINE__ (ty_is_rty v.sv_ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty v.sv_ty) span;
super#visit_symbolic_value inside_abs v
method! visit_typed_value info tv =
(* Check that the types have erased regions *)
- sanity_check __FILE__ __LINE__ (ty_is_ety tv.ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_ety tv.ty) span;
(* Check the current pair (value, type) *)
(match (tv.value, tv.ty) with
- | VLiteral cv, TLiteral ty -> check_literal_type meta cv ty
+ | VLiteral cv, TLiteral ty -> check_literal_type span cv ty
(* ADT case *)
| VAdt av, TAdt (TAdtId def_id, generics) ->
(* Retrieve the definition to check the variant id, the number of
@@ -425,33 +425,33 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
(* Check the number of parameters *)
sanity_check __FILE__ __LINE__
(List.length generics.regions = List.length def.generics.regions)
- meta;
+ span;
sanity_check __FILE__ __LINE__
(List.length generics.types = List.length def.generics.types)
- meta;
+ span;
(* Check that the variant id is consistent *)
(match (av.variant_id, def.kind) with
| Some variant_id, Enum variants ->
sanity_check __FILE__ __LINE__
(VariantId.to_int variant_id < List.length variants)
- meta
+ span
| None, Struct _ -> ()
- | _ -> craise __FILE__ __LINE__ meta "Erroneous typing");
+ | _ -> craise __FILE__ __LINE__ span "Erroneous typing");
(* Check that the field types are correct *)
let field_types =
- AssociatedTypes.type_decl_get_inst_norm_field_etypes meta ctx def
+ AssociatedTypes.type_decl_get_inst_norm_field_etypes span ctx def
av.variant_id generics
in
let fields_with_types = List.combine av.field_values field_types in
List.iter
(fun ((v, ty) : typed_value * ty) ->
- sanity_check __FILE__ __LINE__ (v.ty = ty) meta)
+ sanity_check __FILE__ __LINE__ (v.ty = ty) span)
fields_with_types
(* Tuple case *)
| VAdt av, TAdt (TTuple, generics) ->
- sanity_check __FILE__ __LINE__ (generics.regions = []) meta;
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
- sanity_check __FILE__ __LINE__ (av.variant_id = None) meta;
+ sanity_check __FILE__ __LINE__ (generics.regions = []) span;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
+ sanity_check __FILE__ __LINE__ (av.variant_id = None) span;
(* Check that the fields have the proper values - and check that there
* are as many fields as field types at the same time *)
let fields_with_types =
@@ -459,11 +459,11 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
in
List.iter
(fun ((v, ty) : typed_value * ty) ->
- sanity_check __FILE__ __LINE__ (v.ty = ty) meta)
+ sanity_check __FILE__ __LINE__ (v.ty = ty) span)
fields_with_types
(* Assumed type case *)
| VAdt av, TAdt (TAssumed aty_id, generics) -> (
- sanity_check __FILE__ __LINE__ (av.variant_id = None) meta;
+ sanity_check __FILE__ __LINE__ (av.variant_id = None) span;
match
( aty_id,
av.field_values,
@@ -473,14 +473,14 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
with
(* Box *)
| TBox, [ inner_value ], [], [ inner_ty ], [] ->
- sanity_check __FILE__ __LINE__ (inner_value.ty = inner_ty) meta
+ sanity_check __FILE__ __LINE__ (inner_value.ty = inner_ty) span
| TArray, inner_values, _, [ inner_ty ], [ cg ] ->
(* *)
sanity_check __FILE__ __LINE__
(List.for_all
(fun (v : typed_value) -> v.ty = inner_ty)
inner_values)
- meta;
+ span;
(* The length is necessarily concrete *)
let len =
(ValuesUtils.literal_as_scalar
@@ -489,46 +489,46 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
in
sanity_check __FILE__ __LINE__
(Z.of_int (List.length inner_values) = len)
- meta
+ span
| (TSlice | TStr), _, _, _, _ ->
- craise __FILE__ __LINE__ meta "Unexpected"
- | _ -> craise __FILE__ __LINE__ meta "Erroneous type")
+ craise __FILE__ __LINE__ span "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Erroneous type")
| VBottom, _ -> (* Nothing to check *) ()
| VBorrow bc, TRef (_, ref_ty, rkind) -> (
match (bc, rkind) with
| VSharedBorrow bid, RShared | VReservedMutBorrow bid, RMut -> (
(* Lookup the borrowed value to check it has the proper type *)
- let _, glc = lookup_loan meta ek_all bid ctx in
+ let _, glc = lookup_loan span ek_all bid ctx in
match glc with
| Concrete (VSharedLoan (_, sv))
| Abstract (ASharedLoan (_, sv, _)) ->
- sanity_check __FILE__ __LINE__ (sv.ty = ref_ty) meta
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent context")
+ sanity_check __FILE__ __LINE__ (sv.ty = ref_ty) span
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent context")
| VMutBorrow (_, bv), RMut ->
sanity_check __FILE__ __LINE__
((* Check that the borrowed value has the proper type *)
bv.ty = ref_ty)
- meta
- | _ -> craise __FILE__ __LINE__ meta "Erroneous typing")
+ span
+ | _ -> craise __FILE__ __LINE__ span "Erroneous typing")
| VLoan lc, ty -> (
match lc with
| VSharedLoan (_, sv) ->
- sanity_check __FILE__ __LINE__ (sv.ty = ty) meta
+ sanity_check __FILE__ __LINE__ (sv.ty = ty) span
| VMutLoan bid -> (
(* Lookup the borrowed value to check it has the proper type *)
- let glc = lookup_borrow meta ek_all bid ctx in
+ let glc = lookup_borrow span ek_all bid ctx in
match glc with
| Concrete (VMutBorrow (_, bv)) ->
- sanity_check __FILE__ __LINE__ (bv.ty = ty) meta
+ sanity_check __FILE__ __LINE__ (bv.ty = ty) span
| Abstract (AMutBorrow (_, sv)) ->
sanity_check __FILE__ __LINE__
(Substitute.erase_regions sv.ty = ty)
- meta
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent context"))
+ span
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent context"))
| VSymbolic sv, ty ->
let ty' = Substitute.erase_regions sv.sv_ty in
- sanity_check __FILE__ __LINE__ (ty' = ty) meta
- | _ -> craise __FILE__ __LINE__ meta "Erroneous typing");
+ sanity_check __FILE__ __LINE__ (ty' = ty) span
+ | _ -> craise __FILE__ __LINE__ span "Erroneous typing");
(* Continue exploring to inspect the subterms *)
super#visit_typed_value info tv
@@ -542,7 +542,7 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
* *)
method! visit_typed_avalue info atv =
(* Check that the types have regions *)
- sanity_check __FILE__ __LINE__ (ty_is_rty atv.ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty atv.ty) span;
(* Check the current pair (value, type) *)
(match (atv.value, atv.ty) with
(* ADT case *)
@@ -553,37 +553,37 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
(* Check the number of parameters *)
sanity_check __FILE__ __LINE__
(List.length generics.regions = List.length def.generics.regions)
- meta;
+ span;
sanity_check __FILE__ __LINE__
(List.length generics.types = List.length def.generics.types)
- meta;
+ span;
sanity_check __FILE__ __LINE__
(List.length generics.const_generics
= List.length def.generics.const_generics)
- meta;
+ span;
(* Check that the variant id is consistent *)
(match (av.variant_id, def.kind) with
| Some variant_id, Enum variants ->
sanity_check __FILE__ __LINE__
(VariantId.to_int variant_id < List.length variants)
- meta
+ span
| None, Struct _ -> ()
- | _ -> craise __FILE__ __LINE__ meta "Erroneous typing");
+ | _ -> craise __FILE__ __LINE__ span "Erroneous typing");
(* Check that the field types are correct *)
let field_types =
- AssociatedTypes.type_decl_get_inst_norm_field_rtypes meta ctx def
+ AssociatedTypes.type_decl_get_inst_norm_field_rtypes span ctx def
av.variant_id generics
in
let fields_with_types = List.combine av.field_values field_types in
List.iter
(fun ((v, ty) : typed_avalue * ty) ->
- sanity_check __FILE__ __LINE__ (v.ty = ty) meta)
+ sanity_check __FILE__ __LINE__ (v.ty = ty) span)
fields_with_types
(* Tuple case *)
| AAdt av, TAdt (TTuple, generics) ->
- sanity_check __FILE__ __LINE__ (generics.regions = []) meta;
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
- sanity_check __FILE__ __LINE__ (av.variant_id = None) meta;
+ sanity_check __FILE__ __LINE__ (generics.regions = []) span;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
+ sanity_check __FILE__ __LINE__ (av.variant_id = None) span;
(* Check that the fields have the proper values - and check that there
* are as many fields as field types at the same time *)
let fields_with_types =
@@ -591,11 +591,11 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
in
List.iter
(fun ((v, ty) : typed_avalue * ty) ->
- sanity_check __FILE__ __LINE__ (v.ty = ty) meta)
+ sanity_check __FILE__ __LINE__ (v.ty = ty) span)
fields_with_types
(* Assumed type case *)
| AAdt av, TAdt (TAssumed aty_id, generics) -> (
- sanity_check __FILE__ __LINE__ (av.variant_id = None) meta;
+ sanity_check __FILE__ __LINE__ (av.variant_id = None) span;
match
( aty_id,
av.field_values,
@@ -605,101 +605,101 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
with
(* Box *)
| TBox, [ boxed_value ], [], [ boxed_ty ], [] ->
- sanity_check __FILE__ __LINE__ (boxed_value.ty = boxed_ty) meta
- | _ -> craise __FILE__ __LINE__ meta "Erroneous type")
+ sanity_check __FILE__ __LINE__ (boxed_value.ty = boxed_ty) span
+ | _ -> craise __FILE__ __LINE__ span "Erroneous type")
| ABottom, _ -> (* Nothing to check *) ()
| ABorrow bc, TRef (_, ref_ty, rkind) -> (
match (bc, rkind) with
| AMutBorrow (_, av), RMut ->
(* Check that the child value has the proper type *)
- sanity_check __FILE__ __LINE__ (av.ty = ref_ty) meta
+ sanity_check __FILE__ __LINE__ (av.ty = ref_ty) span
| ASharedBorrow bid, RShared -> (
(* Lookup the borrowed value to check it has the proper type *)
- let _, glc = lookup_loan meta ek_all bid ctx in
+ let _, glc = lookup_loan span ek_all bid ctx in
match glc with
| Concrete (VSharedLoan (_, sv))
| Abstract (ASharedLoan (_, sv, _)) ->
sanity_check __FILE__ __LINE__
(sv.ty = Substitute.erase_regions ref_ty)
- meta
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent context")
+ span
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent context")
| AIgnoredMutBorrow (_opt_bid, av), RMut ->
- sanity_check __FILE__ __LINE__ (av.ty = ref_ty) meta
- | ( AEndedIgnoredMutBorrow { given_back; child; given_back_meta = _ },
+ sanity_check __FILE__ __LINE__ (av.ty = ref_ty) span
+ | ( AEndedIgnoredMutBorrow { given_back; child; given_back_span = _ },
RMut ) ->
- sanity_check __FILE__ __LINE__ (given_back.ty = ref_ty) meta;
- sanity_check __FILE__ __LINE__ (child.ty = ref_ty) meta
+ sanity_check __FILE__ __LINE__ (given_back.ty = ref_ty) span;
+ sanity_check __FILE__ __LINE__ (child.ty = ref_ty) span
| AProjSharedBorrow _, RShared -> ()
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent context")
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent context")
| ALoan lc, aty -> (
match lc with
| AMutLoan (bid, child_av) | AIgnoredMutLoan (Some bid, child_av)
-> (
let borrowed_aty = aloan_get_expected_child_type aty in
- sanity_check __FILE__ __LINE__ (child_av.ty = borrowed_aty) meta;
+ sanity_check __FILE__ __LINE__ (child_av.ty = borrowed_aty) span;
(* Lookup the borrowed value to check it has the proper type *)
- let glc = lookup_borrow meta ek_all bid ctx in
+ let glc = lookup_borrow span ek_all bid ctx in
match glc with
| Concrete (VMutBorrow (_, bv)) ->
sanity_check __FILE__ __LINE__
(bv.ty = Substitute.erase_regions borrowed_aty)
- meta
+ span
| Abstract (AMutBorrow (_, sv)) ->
sanity_check __FILE__ __LINE__
(Substitute.erase_regions sv.ty
= Substitute.erase_regions borrowed_aty)
- meta
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent context")
+ span
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent context")
| AIgnoredMutLoan (None, child_av) ->
let borrowed_aty = aloan_get_expected_child_type aty in
- sanity_check __FILE__ __LINE__ (child_av.ty = borrowed_aty) meta
+ sanity_check __FILE__ __LINE__ (child_av.ty = borrowed_aty) span
| ASharedLoan (_, sv, child_av) | AEndedSharedLoan (sv, child_av) ->
let borrowed_aty = aloan_get_expected_child_type aty in
sanity_check __FILE__ __LINE__
(sv.ty = Substitute.erase_regions borrowed_aty)
- meta;
+ span;
(* TODO: the type of aloans doesn't make sense, see above *)
- sanity_check __FILE__ __LINE__ (child_av.ty = borrowed_aty) meta
- | AEndedMutLoan { given_back; child; given_back_meta = _ }
- | AEndedIgnoredMutLoan { given_back; child; given_back_meta = _ } ->
+ sanity_check __FILE__ __LINE__ (child_av.ty = borrowed_aty) span
+ | AEndedMutLoan { given_back; child; given_back_span = _ }
+ | AEndedIgnoredMutLoan { given_back; child; given_back_span = _ } ->
let borrowed_aty = aloan_get_expected_child_type aty in
sanity_check __FILE__ __LINE__
(given_back.ty = borrowed_aty)
- meta;
- sanity_check __FILE__ __LINE__ (child.ty = borrowed_aty) meta
+ span;
+ sanity_check __FILE__ __LINE__ (child.ty = borrowed_aty) span
| AIgnoredSharedLoan child_av ->
sanity_check __FILE__ __LINE__
(child_av.ty = aloan_get_expected_child_type aty)
- meta)
+ span)
| ASymbolic aproj, ty -> (
let ty1 = Substitute.erase_regions ty in
match aproj with
| AProjLoans (sv, _) ->
let ty2 = Substitute.erase_regions sv.sv_ty in
- sanity_check __FILE__ __LINE__ (ty1 = ty2) meta;
+ sanity_check __FILE__ __LINE__ (ty1 = ty2) span;
(* Also check that the symbolic values contain regions of interest -
* otherwise they should have been reduced to [_] *)
let abs = Option.get info in
sanity_check __FILE__ __LINE__
(ty_has_regions_in_set abs.regions sv.sv_ty)
- meta
+ span
| AProjBorrows (sv, proj_ty) ->
let ty2 = Substitute.erase_regions sv.sv_ty in
- sanity_check __FILE__ __LINE__ (ty1 = ty2) meta;
+ sanity_check __FILE__ __LINE__ (ty1 = ty2) span;
(* Also check that the symbolic values contain regions of interest -
* otherwise they should have been reduced to [_] *)
let abs = Option.get info in
sanity_check __FILE__ __LINE__
(ty_has_regions_in_set abs.regions proj_ty)
- meta
+ span
| AEndedProjLoans (_msv, given_back_ls) ->
List.iter
(fun (_, proj) ->
match proj with
| AProjBorrows (_sv, ty') ->
- sanity_check __FILE__ __LINE__ (ty' = ty) meta
+ sanity_check __FILE__ __LINE__ (ty' = ty) span
| AEndedProjBorrows _ | AIgnoredProjBorrows -> ()
- | _ -> craise __FILE__ __LINE__ meta "Unexpected")
+ | _ -> craise __FILE__ __LINE__ span "Unexpected")
given_back_ls
| AEndedProjBorrows _ | AIgnoredProjBorrows -> ())
| AIgnored, _ -> ()
@@ -708,9 +708,9 @@ let check_typing_invariant (meta : Meta.meta) (ctx : eval_ctx) : unit =
(lazy
("Erroneous typing:" ^ "\n- raw value: " ^ show_typed_avalue atv
^ "\n- value: "
- ^ typed_avalue_to_string ~meta:(Some meta) ctx atv
+ ^ typed_avalue_to_string ~span:(Some span) ctx atv
^ "\n- type: " ^ ty_to_string ctx atv.ty));
- internal_error __FILE__ __LINE__ meta);
+ internal_error __FILE__ __LINE__ span);
(* Continue exploring to inspect the subterms *)
super#visit_typed_avalue info atv
end
@@ -749,7 +749,7 @@ type sv_info = {
- the union of the aproj_loans contains the aproj_borrows applied on the
same symbolic values
*)
-let check_symbolic_values (meta : Meta.meta) (ctx : eval_ctx) : unit =
+let check_symbolic_values (span : Meta.span) (ctx : eval_ctx) : unit =
(* Small utility *)
let module M = SymbolicValueId.Map in
let infos : sv_info M.t ref = ref M.empty in
@@ -819,19 +819,19 @@ let check_symbolic_values (meta : Meta.meta) (ctx : eval_ctx) : unit =
* projectors of borrows in abstractions *)
sanity_check __FILE__ __LINE__
(info.env_count = 0 || info.aproj_borrows = [])
- meta;
+ span;
(* A symbolic value containing borrows can't be duplicated (i.e., copied):
* it must be expanded first *)
if ty_has_borrows ctx.type_ctx.type_infos info.ty then
- sanity_check __FILE__ __LINE__ (info.env_count <= 1) meta;
+ sanity_check __FILE__ __LINE__ (info.env_count <= 1) span;
(* A duplicated symbolic value is necessarily copyable *)
sanity_check __FILE__ __LINE__
(info.env_count <= 1 || ty_is_copyable info.ty)
- meta;
+ span;
sanity_check __FILE__ __LINE__
(info.aproj_borrows = [] || info.aproj_loans <> [])
- meta;
+ span;
(* At the same time:
* - check that the loans don't intersect
* - compute the set of regions for which we project loans
@@ -845,7 +845,7 @@ let check_symbolic_values (meta : Meta.meta) (ctx : eval_ctx) : unit =
(fun rid regions ->
sanity_check __FILE__ __LINE__
(not (RegionId.Set.mem rid regions))
- meta;
+ span;
RegionId.Set.add rid regions)
regions linfo.regions
in
@@ -856,22 +856,22 @@ let check_symbolic_values (meta : Meta.meta) (ctx : eval_ctx) : unit =
List.iter
(fun binfo ->
sanity_check __FILE__ __LINE__
- (projection_contains meta info.ty loan_regions binfo.proj_ty
+ (projection_contains span info.ty loan_regions binfo.proj_ty
binfo.regions)
- meta)
+ span)
info.aproj_borrows;
()
in
M.iter check_info !infos
-let check_invariants (meta : Meta.meta) (ctx : eval_ctx) : unit =
+let check_invariants (span : Meta.span) (ctx : eval_ctx) : unit =
if !Config.sanity_checks then (
log#ldebug
(lazy
- ("Checking invariants:\n" ^ eval_ctx_to_string ~meta:(Some meta) ctx));
- check_loans_borrows_relation_invariant meta ctx;
- check_borrowed_values_invariant meta ctx;
- check_typing_invariant meta ctx;
- check_symbolic_values meta ctx)
+ ("Checking invariants:\n" ^ eval_ctx_to_string ~span:(Some span) ctx));
+ check_loans_borrows_relation_invariant span ctx;
+ check_borrowed_values_invariant span ctx;
+ check_typing_invariant span ctx;
+ check_symbolic_values span ctx)
else log#ldebug (lazy "Not checking invariants (check is not activated)")
diff --git a/compiler/Main.ml b/compiler/Main.ml
index 6161f2f2..29322049 100644
--- a/compiler/Main.ml
+++ b/compiler/Main.ml
@@ -282,7 +282,7 @@ let () =
if !Errors.error_list <> [] then (
List.iter
- (fun (meta, msg) -> log#serror (Errors.format_error_message meta msg))
+ (fun (span, msg) -> log#serror (Errors.format_error_message span msg))
(* Reverse the list of error messages so that we print them from the
earliest to the latest. *)
(List.rev !Errors.error_list);
diff --git a/compiler/PrePasses.ml b/compiler/PrePasses.ml
index c84cd39c..26141c72 100644
--- a/compiler/PrePasses.ml
+++ b/compiler/PrePasses.ml
@@ -36,7 +36,7 @@ let filter_drop_assigns (f : fun_decl) : fun_decl =
| Drop p1, Assign (p2, _) ->
if p1 = p2 then (self#visit_statement env st2).content
else super#visit_Sequence env st1 st2
- | Drop p1, Sequence ({ content = Assign (p2, _); meta = _ }, _) ->
+ | Drop p1, Sequence ({ content = Assign (p2, _); span = _ }, _) ->
if p1 = p2 then (self#visit_statement env st2).content
else super#visit_Sequence env st1 st2
| _ -> super#visit_Sequence env st1 st2
@@ -217,11 +217,11 @@ let remove_loop_breaks (crate : crate) (f : fun_decl) : fun_decl =
method! visit_statement entered_loop st =
match st.content with
| Loop loop ->
- cassert __FILE__ __LINE__ (not entered_loop) st.meta
+ cassert __FILE__ __LINE__ (not entered_loop) st.span
"Nested loops are not supported yet";
{ st with content = super#visit_Loop true loop }
| Break i ->
- cassert __FILE__ __LINE__ (i = 0) st.meta
+ cassert __FILE__ __LINE__ (i = 0) st.span
"Breaks to outer loops are not supported yet";
{ st with content = nst.content }
| _ -> super#visit_statement entered_loop st
@@ -240,7 +240,7 @@ let remove_loop_breaks (crate : crate) (f : fun_decl) : fun_decl =
| Loop _ ->
cassert __FILE__ __LINE__
(statement_has_no_loop_break_continue st2)
- st2.meta "Sequences of loops are not supported yet";
+ st2.span "Sequences of loops are not supported yet";
(replace_breaks_with st1 st2).content
| _ -> super#visit_Sequence env st1 st2
end
@@ -404,17 +404,17 @@ let remove_shallow_borrows (crate : crate) (f : fun_decl) : fun_decl =
inherit [_] iter_statement as super
(* Remember the span of the statement we enter *)
- method! visit_statement _ st = super#visit_statement st.meta st
+ method! visit_statement _ st = super#visit_statement st.span st
- method! visit_var_id meta id =
+ method! visit_var_id span id =
cassert __FILE__ __LINE__
(not (VarId.Set.mem id !filtered))
- meta
+ span
"Filtered variables should have completely disappeared from the \
body"
end
in
- check_visitor#visit_statement body.meta body;
+ check_visitor#visit_statement body.span body;
(* Return the updated body *)
body
@@ -446,7 +446,7 @@ let apply_passes (crate : crate) : crate =
report to the user the fact that we will ignore the function body *)
let fmt = Print.Crate.crate_to_fmt_env crate in
let name = Print.name_to_string fmt f.name in
- save_error __FILE__ __LINE__ (Some f.item_meta.meta)
+ save_error __FILE__ __LINE__ (Some f.item_meta.span)
("Ignoring the body of '" ^ name ^ "' because of previous error");
{ f with body = None }
in
diff --git a/compiler/Print.ml b/compiler/Print.ml
index 51286553..f7f1f54b 100644
--- a/compiler/Print.ml
+++ b/compiler/Print.ml
@@ -44,13 +44,13 @@ module Values = struct
* typed_avalue_to_string. At some point we had done it, because [typed_value]
* and [typed_avalue] were instances of the same general type [g_typed_value],
* but then we removed this general type because it proved to be a bad idea. *)
- let rec typed_value_to_string ?(meta : Meta.meta option = None)
+ let rec typed_value_to_string ?(span : Meta.span option = None)
(env : fmt_env) (v : typed_value) : string =
match v.value with
| VLiteral cv -> literal_to_string cv
| VAdt av -> (
let field_values =
- List.map (typed_value_to_string ~meta env) av.field_values
+ List.map (typed_value_to_string ~span env) av.field_values
in
match v.ty with
| TAdt (TTuple, _) ->
@@ -86,31 +86,31 @@ module Values = struct
(* Happens when we aggregate values *)
"@Array[" ^ String.concat ", " field_values ^ "]"
| _ ->
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
("Inconsistent value: " ^ show_typed_value v))
- | _ -> craise_opt_meta __FILE__ __LINE__ meta "Inconsistent typed value"
+ | _ -> craise_opt_span __FILE__ __LINE__ span "Inconsistent typed value"
)
| VBottom -> "⊥ : " ^ ty_to_string env v.ty
- | VBorrow bc -> borrow_content_to_string ~meta env bc
- | VLoan lc -> loan_content_to_string ~meta env lc
+ | VBorrow bc -> borrow_content_to_string ~span env bc
+ | VLoan lc -> loan_content_to_string ~span env lc
| VSymbolic s -> symbolic_value_to_string env s
- and borrow_content_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+ and borrow_content_to_string ?(span : Meta.span option = None) (env : fmt_env)
(bc : borrow_content) : string =
match bc with
| VSharedBorrow bid -> "shared_borrow@" ^ BorrowId.to_string bid
| VMutBorrow (bid, tv) ->
"mut_borrow@" ^ BorrowId.to_string bid ^ " ("
- ^ typed_value_to_string ~meta env tv
+ ^ typed_value_to_string ~span env tv
^ ")"
| VReservedMutBorrow bid -> "reserved_borrow@" ^ BorrowId.to_string bid
- and loan_content_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+ and loan_content_to_string ?(span : Meta.span option = None) (env : fmt_env)
(lc : loan_content) : string =
match lc with
| VSharedLoan (loans, v) ->
let loans = BorrowId.Set.to_string None loans in
- "@shared_loan(" ^ loans ^ ", " ^ typed_value_to_string ~meta env v ^ ")"
+ "@shared_loan(" ^ loans ^ ", " ^ typed_value_to_string ~span env v ^ ")"
| VMutLoan bid -> "ml@" ^ BorrowId.to_string bid
let abstract_shared_borrow_to_string (env : fmt_env)
@@ -148,12 +148,12 @@ module Values = struct
| AEndedProjBorrows _mv -> "_"
| AIgnoredProjBorrows -> "_"
- let rec typed_avalue_to_string ?(meta : Meta.meta option = None)
+ let rec typed_avalue_to_string ?(span : Meta.span option = None)
(env : fmt_env) (v : typed_avalue) : string =
match v.value with
| AAdt av -> (
let field_values =
- List.map (typed_avalue_to_string ~meta env) av.field_values
+ List.map (typed_avalue_to_string ~span env) av.field_values
in
match v.ty with
| TAdt (TTuple, _) ->
@@ -185,77 +185,77 @@ module Values = struct
(* Assumed type *)
match (aty, field_values) with
| TBox, [ bv ] -> "@Box(" ^ bv ^ ")"
- | _ -> craise_opt_meta __FILE__ __LINE__ meta "Inconsistent value")
- | _ -> craise_opt_meta __FILE__ __LINE__ meta "Inconsistent typed value"
+ | _ -> craise_opt_span __FILE__ __LINE__ span "Inconsistent value")
+ | _ -> craise_opt_span __FILE__ __LINE__ span "Inconsistent typed value"
)
| ABottom -> "⊥ : " ^ ty_to_string env v.ty
- | ABorrow bc -> aborrow_content_to_string ~meta env bc
- | ALoan lc -> aloan_content_to_string ~meta env lc
+ | ABorrow bc -> aborrow_content_to_string ~span env bc
+ | ALoan lc -> aloan_content_to_string ~span env lc
| ASymbolic s -> aproj_to_string env s
| AIgnored -> "_"
- and aloan_content_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+ and aloan_content_to_string ?(span : Meta.span option = None) (env : fmt_env)
(lc : aloan_content) : string =
match lc with
| AMutLoan (bid, av) ->
"@mut_loan(" ^ BorrowId.to_string bid ^ ", "
- ^ typed_avalue_to_string ~meta env av
+ ^ typed_avalue_to_string ~span env av
^ ")"
| ASharedLoan (loans, v, av) ->
let loans = BorrowId.Set.to_string None loans in
"@shared_loan(" ^ loans ^ ", "
- ^ typed_value_to_string ~meta env v
+ ^ typed_value_to_string ~span env v
^ ", "
- ^ typed_avalue_to_string ~meta env av
+ ^ typed_avalue_to_string ~span env av
^ ")"
| AEndedMutLoan ml ->
"@ended_mut_loan{"
- ^ typed_avalue_to_string ~meta env ml.child
+ ^ typed_avalue_to_string ~span env ml.child
^ "; "
- ^ typed_avalue_to_string ~meta env ml.given_back
+ ^ typed_avalue_to_string ~span env ml.given_back
^ " }"
| AEndedSharedLoan (v, av) ->
"@ended_shared_loan("
- ^ typed_value_to_string ~meta env v
+ ^ typed_value_to_string ~span env v
^ ", "
- ^ typed_avalue_to_string ~meta env av
+ ^ typed_avalue_to_string ~span env av
^ ")"
| AIgnoredMutLoan (opt_bid, av) ->
"@ignored_mut_loan("
^ option_to_string BorrowId.to_string opt_bid
^ ", "
- ^ typed_avalue_to_string ~meta env av
+ ^ typed_avalue_to_string ~span env av
^ ")"
| AEndedIgnoredMutLoan ml ->
"@ended_ignored_mut_loan{ "
- ^ typed_avalue_to_string ~meta env ml.child
+ ^ typed_avalue_to_string ~span env ml.child
^ "; "
- ^ typed_avalue_to_string ~meta env ml.given_back
+ ^ typed_avalue_to_string ~span env ml.given_back
^ "}"
| AIgnoredSharedLoan sl ->
- "@ignored_shared_loan(" ^ typed_avalue_to_string ~meta env sl ^ ")"
+ "@ignored_shared_loan(" ^ typed_avalue_to_string ~span env sl ^ ")"
- and aborrow_content_to_string ?(meta : Meta.meta option = None)
+ and aborrow_content_to_string ?(span : Meta.span option = None)
(env : fmt_env) (bc : aborrow_content) : string =
match bc with
| AMutBorrow (bid, av) ->
"mb@" ^ BorrowId.to_string bid ^ " ("
- ^ typed_avalue_to_string ~meta env av
+ ^ typed_avalue_to_string ~span env av
^ ")"
| ASharedBorrow bid -> "sb@" ^ BorrowId.to_string bid
| AIgnoredMutBorrow (opt_bid, av) ->
"@ignored_mut_borrow("
^ option_to_string BorrowId.to_string opt_bid
^ ", "
- ^ typed_avalue_to_string ~meta env av
+ ^ typed_avalue_to_string ~span env av
^ ")"
| AEndedMutBorrow (_mv, child) ->
- "@ended_mut_borrow(" ^ typed_avalue_to_string ~meta env child ^ ")"
- | AEndedIgnoredMutBorrow { child; given_back; given_back_meta = _ } ->
+ "@ended_mut_borrow(" ^ typed_avalue_to_string ~span env child ^ ")"
+ | AEndedIgnoredMutBorrow { child; given_back; given_back_span = _ } ->
"@ended_ignored_mut_borrow{ "
- ^ typed_avalue_to_string ~meta env child
+ ^ typed_avalue_to_string ~span env child
^ "; "
- ^ typed_avalue_to_string ~meta env given_back
+ ^ typed_avalue_to_string ~span env given_back
^ ")"
| AEndedSharedBorrow -> "@ended_shared_borrow"
| AProjSharedBorrow sb ->
@@ -285,13 +285,13 @@ module Values = struct
^ ")"
| Identity -> "Identity"
- let abs_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+ let abs_to_string ?(span : Meta.span option = None) (env : fmt_env)
(verbose : bool) (indent : string) (indent_incr : string) (abs : abs) :
string =
let indent2 = indent ^ indent_incr in
let avs =
List.map
- (fun av -> indent2 ^ typed_avalue_to_string ~meta env av)
+ (fun av -> indent2 ^ typed_avalue_to_string ~span env av)
abs.avalues
in
let avs = String.concat ",\n" avs in
@@ -335,7 +335,7 @@ module Contexts = struct
| BVar b -> var_binder_to_string env b
| BDummy bid -> dummy_var_id_to_string bid
- let env_elem_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+ let env_elem_to_string ?(span : Meta.span option = None) (env : fmt_env)
(verbose : bool) (with_var_types : bool) (indent : string)
(indent_incr : string) (ev : env_elem) : string =
match ev with
@@ -344,18 +344,18 @@ module Contexts = struct
let ty =
if with_var_types then " : " ^ ty_to_string env tv.ty else ""
in
- indent ^ bv ^ ty ^ " -> " ^ typed_value_to_string ~meta env tv ^ " ;"
- | EAbs abs -> abs_to_string ~meta env verbose indent indent_incr abs
+ indent ^ bv ^ ty ^ " -> " ^ typed_value_to_string ~span env tv ^ " ;"
+ | EAbs abs -> abs_to_string ~span env verbose indent indent_incr abs
| EFrame ->
- craise_opt_meta __FILE__ __LINE__ meta "Can't print a Frame element"
+ craise_opt_span __FILE__ __LINE__ span "Can't print a Frame element"
- let opt_env_elem_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+ let opt_env_elem_to_string ?(span : Meta.span option = None) (env : fmt_env)
(verbose : bool) (with_var_types : bool) (indent : string)
(indent_incr : string) (ev : env_elem option) : string =
match ev with
| None -> indent ^ "..."
| Some ev ->
- env_elem_to_string ~meta env verbose with_var_types indent indent_incr
+ env_elem_to_string ~span env verbose with_var_types indent indent_incr
ev
(** Filters "dummy" bindings from an environment, to gain space and clarity/
@@ -393,7 +393,7 @@ module Contexts = struct
"..." to gain space and clarity.
[with_var_types]: if true, print the type of the variables
*)
- let env_to_string ?(meta : Meta.meta option = None) (filter : bool)
+ let env_to_string ?(span : Meta.span option = None) (filter : bool)
(fmt_env : fmt_env) (verbose : bool) (with_var_types : bool) (env : env) :
string =
let env =
@@ -403,7 +403,7 @@ module Contexts = struct
^ String.concat "\n"
(List.map
(fun ev ->
- opt_env_elem_to_string ~meta fmt_env verbose with_var_types " "
+ opt_env_elem_to_string ~span fmt_env verbose with_var_types " "
" " ev)
env)
^ "\n}"
@@ -484,7 +484,7 @@ module Contexts = struct
let frames = split_aux [] [] env in
frames
- let eval_ctx_to_string_gen ?(meta : Meta.meta option = None) (verbose : bool)
+ let eval_ctx_to_string_gen ?(span : Meta.span option = None) (verbose : bool)
(filter : bool) (with_var_types : bool) (ctx : eval_ctx) : string =
let fmt_env = eval_ctx_to_fmt_env ctx in
let ended_regions = RegionId.Set.to_string None ctx.ended_regions in
@@ -502,26 +502,26 @@ module Contexts = struct
| EBinding (BDummy _, _) -> num_dummies := !num_abs + 1
| EBinding (BVar _, _) -> num_bindings := !num_bindings + 1
| EAbs _ -> num_abs := !num_abs + 1
- | _ -> craise_opt_meta __FILE__ __LINE__ meta "Unreachable")
+ | _ -> craise_opt_span __FILE__ __LINE__ span "Unreachable")
f;
"\n# Frame " ^ string_of_int i ^ ":" ^ "\n- locals: "
^ string_of_int !num_bindings
^ "\n- dummy bindings: " ^ string_of_int !num_dummies
^ "\n- abstractions: " ^ string_of_int !num_abs ^ "\n"
- ^ env_to_string ~meta filter fmt_env verbose with_var_types f
+ ^ env_to_string ~span filter fmt_env verbose with_var_types f
^ "\n")
frames
in
"# Ended regions: " ^ ended_regions ^ "\n" ^ "# " ^ string_of_int num_frames
^ " frame(s)\n" ^ String.concat "" frames
- let eval_ctx_to_string ?(meta : Meta.meta option = None) (ctx : eval_ctx) :
+ let eval_ctx_to_string ?(span : Meta.span option = None) (ctx : eval_ctx) :
string =
- eval_ctx_to_string_gen ~meta false true true ctx
+ eval_ctx_to_string_gen ~span false true true ctx
- let eval_ctx_to_string_no_filter ?(meta : Meta.meta option = None)
+ let eval_ctx_to_string_no_filter ?(span : Meta.span option = None)
(ctx : eval_ctx) : string =
- eval_ctx_to_string_gen ~meta false false true ctx
+ eval_ctx_to_string_gen ~span false false true ctx
end
(** Pretty-printing for LLBC ASTs (functions based on an evaluation context) *)
@@ -559,25 +559,25 @@ module EvalCtx = struct
let env = eval_ctx_to_fmt_env ctx in
trait_instance_id_to_string env x
- let borrow_content_to_string ?(meta : Meta.meta option = None)
+ let borrow_content_to_string ?(span : Meta.span option = None)
(ctx : eval_ctx) (bc : borrow_content) : string =
let env = eval_ctx_to_fmt_env ctx in
- borrow_content_to_string ~meta env bc
+ borrow_content_to_string ~span env bc
- let loan_content_to_string ?(meta : Meta.meta option = None) (ctx : eval_ctx)
+ let loan_content_to_string ?(span : Meta.span option = None) (ctx : eval_ctx)
(lc : loan_content) : string =
let env = eval_ctx_to_fmt_env ctx in
- loan_content_to_string ~meta env lc
+ loan_content_to_string ~span env lc
- let aborrow_content_to_string ?(meta : Meta.meta option = None)
+ let aborrow_content_to_string ?(span : Meta.span option = None)
(ctx : eval_ctx) (bc : aborrow_content) : string =
let env = eval_ctx_to_fmt_env ctx in
- aborrow_content_to_string ~meta env bc
+ aborrow_content_to_string ~span env bc
- let aloan_content_to_string ?(meta : Meta.meta option = None) (ctx : eval_ctx)
+ let aloan_content_to_string ?(span : Meta.span option = None) (ctx : eval_ctx)
(lc : aloan_content) : string =
let env = eval_ctx_to_fmt_env ctx in
- aloan_content_to_string ~meta env lc
+ aloan_content_to_string ~span env lc
let aproj_to_string (ctx : eval_ctx) (p : aproj) : string =
let env = eval_ctx_to_fmt_env ctx in
@@ -587,15 +587,15 @@ module EvalCtx = struct
let env = eval_ctx_to_fmt_env ctx in
symbolic_value_to_string env sv
- let typed_value_to_string ?(meta : Meta.meta option = None) (ctx : eval_ctx)
+ let typed_value_to_string ?(span : Meta.span option = None) (ctx : eval_ctx)
(v : typed_value) : string =
let env = eval_ctx_to_fmt_env ctx in
- typed_value_to_string ~meta env v
+ typed_value_to_string ~span env v
- let typed_avalue_to_string ?(meta : Meta.meta option = None) (ctx : eval_ctx)
+ let typed_avalue_to_string ?(span : Meta.span option = None) (ctx : eval_ctx)
(v : typed_avalue) : string =
let env = eval_ctx_to_fmt_env ctx in
- typed_avalue_to_string ~meta env v
+ typed_avalue_to_string ~span env v
let place_to_string (ctx : eval_ctx) (op : place) : string =
let env = eval_ctx_to_fmt_env ctx in
@@ -636,13 +636,13 @@ module EvalCtx = struct
let env = eval_ctx_to_fmt_env ctx in
trait_impl_to_string env " " " " timpl
- let env_elem_to_string ?(meta : Meta.meta option = None) (ctx : eval_ctx)
+ let env_elem_to_string ?(span : Meta.span option = None) (ctx : eval_ctx)
(indent : string) (indent_incr : string) (ev : env_elem) : string =
let env = eval_ctx_to_fmt_env ctx in
- env_elem_to_string ~meta env false true indent indent_incr ev
+ env_elem_to_string ~span env false true indent indent_incr ev
- let abs_to_string ?(meta : Meta.meta option = None) (ctx : eval_ctx)
+ let abs_to_string ?(span : Meta.span option = None) (ctx : eval_ctx)
(indent : string) (indent_incr : string) (abs : abs) : string =
let env = eval_ctx_to_fmt_env ctx in
- abs_to_string ~meta env false indent indent_incr abs
+ abs_to_string ~span env false indent indent_incr abs
end
diff --git a/compiler/PrintPure.ml b/compiler/PrintPure.ml
index db9c583d..b1b42207 100644
--- a/compiler/PrintPure.ml
+++ b/compiler/PrintPure.ml
@@ -288,14 +288,14 @@ let rec mprojection_to_string (env : fmt_env) (inside : string)
let mplace_to_string (env : fmt_env) (p : mplace) : string =
let name = match p.name with None -> "" | Some name -> name in
- (* We add the "llbc" suffix to the variable index, because meta-places
+ (* We add the "llbc" suffix to the variable index, because span-places
* use indices of the variables in the original LLBC program, while
* regular places use indices for the pure variables: we want to make
* this explicit, otherwise it is confusing. *)
let name = name ^ "^" ^ E.VarId.to_string p.var_id ^ "llbc" in
mprojection_to_string env name p.projection
-let adt_variant_to_string ?(meta = None) (env : fmt_env) (adt_id : type_id)
+let adt_variant_to_string ?(span = None) (env : fmt_env) (adt_id : type_id)
(variant_id : VariantId.id option) : string =
match adt_id with
| TTuple -> "Tuple"
@@ -309,34 +309,34 @@ let adt_variant_to_string ?(meta = None) (env : fmt_env) (adt_id : type_id)
match aty with
| TState | TArray | TSlice | TStr | TRawPtr _ ->
(* Those types are opaque: we can't get there *)
- craise_opt_meta __FILE__ __LINE__ meta "Unreachable"
+ craise_opt_span __FILE__ __LINE__ span "Unreachable"
| TResult ->
let variant_id = Option.get variant_id in
if variant_id = result_ok_id then "@Result::Return"
else if variant_id = result_fail_id then "@Result::Fail"
else
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Unreachable: improper variant id for result type"
| TError ->
let variant_id = Option.get variant_id in
if variant_id = error_failure_id then "@Error::Failure"
else if variant_id = error_out_of_fuel_id then "@Error::OutOfFuel"
else
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Unreachable: improper variant id for error type"
| TFuel ->
let variant_id = Option.get variant_id in
if variant_id = fuel_zero_id then "@Fuel::Zero"
else if variant_id = fuel_succ_id then "@Fuel::Succ"
else
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Unreachable: improper variant id for fuel type")
-let adt_field_to_string ?(meta = None) (env : fmt_env) (adt_id : type_id)
+let adt_field_to_string ?(span = None) (env : fmt_env) (adt_id : type_id)
(field_id : FieldId.id) : string =
match adt_id with
| TTuple ->
- craise_opt_meta __FILE__ __LINE__ meta "Unreachable"
+ craise_opt_span __FILE__ __LINE__ span "Unreachable"
(* Tuples don't use the opaque field id for the field indices, but [int] *)
| TAdtId def_id -> (
(* "Regular" ADT *)
@@ -349,15 +349,15 @@ let adt_field_to_string ?(meta = None) (env : fmt_env) (adt_id : type_id)
match aty with
| TState | TFuel | TArray | TSlice | TStr ->
(* Opaque types: we can't get there *)
- craise_opt_meta __FILE__ __LINE__ meta "Unreachable"
+ craise_opt_span __FILE__ __LINE__ span "Unreachable"
| TResult | TError | TRawPtr _ ->
(* Enumerations: we can't get there *)
- craise_opt_meta __FILE__ __LINE__ meta "Unreachable")
+ craise_opt_span __FILE__ __LINE__ span "Unreachable")
(** TODO: we don't need a general function anymore (it is now only used for
patterns)
*)
-let adt_g_value_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+let adt_g_value_to_string ?(span : Meta.span option = None) (env : fmt_env)
(value_to_string : 'v -> string) (variant_id : VariantId.id option)
(field_values : 'v list) (ty : ty) : string =
let field_values = List.map value_to_string field_values in
@@ -392,50 +392,50 @@ let adt_g_value_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
match aty with
| TState | TRawPtr _ ->
(* This type is opaque: we can't get there *)
- craise_opt_meta __FILE__ __LINE__ meta "Unreachable"
+ craise_opt_span __FILE__ __LINE__ span "Unreachable"
| TResult ->
let variant_id = Option.get variant_id in
if variant_id = result_ok_id then
match field_values with
| [ v ] -> "@Result::Return " ^ v
| _ ->
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Result::Return takes exactly one value"
else if variant_id = result_fail_id then
match field_values with
| [ v ] -> "@Result::Fail " ^ v
| _ ->
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Result::Fail takes exactly one value"
else
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Unreachable: improper variant id for result type"
| TError ->
- cassert_opt_meta __FILE__ __LINE__ (field_values = []) meta
+ cassert_opt_span __FILE__ __LINE__ (field_values = []) span
"Ill-formed error value";
let variant_id = Option.get variant_id in
if variant_id = error_failure_id then "@Error::Failure"
else if variant_id = error_out_of_fuel_id then "@Error::OutOfFuel"
else
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Unreachable: improper variant id for error type"
| TFuel ->
let variant_id = Option.get variant_id in
if variant_id = fuel_zero_id then (
- cassert_opt_meta __FILE__ __LINE__ (field_values = []) meta
+ cassert_opt_span __FILE__ __LINE__ (field_values = []) span
"Ill-formed full value";
"@Fuel::Zero")
else if variant_id = fuel_succ_id then
match field_values with
| [ v ] -> "@Fuel::Succ " ^ v
| _ ->
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"@Fuel::Succ takes exactly one value"
else
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
"Unreachable: improper variant id for fuel type"
| TArray | TSlice | TStr ->
- cassert_opt_meta __FILE__ __LINE__ (variant_id = None) meta
+ cassert_opt_span __FILE__ __LINE__ (variant_id = None) span
"Ill-formed value";
let field_values =
List.mapi (fun i v -> string_of_int i ^ " -> " ^ v) field_values
@@ -443,12 +443,12 @@ let adt_g_value_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
let id = assumed_ty_to_string aty in
id ^ " [" ^ String.concat "; " field_values ^ "]")
| _ ->
- craise_opt_meta __FILE__ __LINE__ meta
+ craise_opt_span __FILE__ __LINE__ span
("Inconsistently typed value: expected ADT type but found:" ^ "\n- ty: "
^ ty_to_string env false ty ^ "\n- variant_id: "
^ Print.option_to_string VariantId.to_string variant_id)
-let rec typed_pattern_to_string ?(meta : Meta.meta option = None)
+let rec typed_pattern_to_string ?(span : Meta.span option = None)
(env : fmt_env) (v : typed_pattern) : string =
match v.value with
| PatConstant cv -> literal_to_string cv
@@ -460,8 +460,8 @@ let rec typed_pattern_to_string ?(meta : Meta.meta option = None)
^ ")"
| PatDummy -> "_"
| PatAdt av ->
- adt_g_value_to_string ~meta env
- (typed_pattern_to_string ~meta env)
+ adt_g_value_to_string ~span env
+ (typed_pattern_to_string ~span env)
av.variant_id av.field_values v.ty
let fun_sig_to_string (env : fmt_env) (sg : fun_sig) : string =
@@ -542,7 +542,7 @@ let fun_or_op_id_to_string (env : fmt_env) (fun_id : fun_or_op_id) : string =
binop_to_string binop ^ "<" ^ integer_type_to_string int_ty ^ ">"
(** [inside]: controls the introduction of parentheses *)
-let rec texpression_to_string ?(metadata : Meta.meta option = None)
+let rec texpression_to_string ?(spandata : Meta.span option = None)
(env : fmt_env) (inside : bool) (indent : string) (indent_incr : string)
(e : texpression) : string =
match e.e with
@@ -553,26 +553,26 @@ let rec texpression_to_string ?(metadata : Meta.meta option = None)
(* Recursively destruct the app, to have a pair (app, arguments list) *)
let app, args = destruct_apps e in
(* Convert to string *)
- app_to_string ~meta:metadata env inside indent indent_incr app args
+ app_to_string ~span:spandata env inside indent indent_incr app args
| Lambda _ ->
let xl, e = destruct_lambdas e in
- let e = lambda_to_string ~meta:metadata env indent indent_incr xl e in
+ let e = lambda_to_string ~span:spandata env indent indent_incr xl e in
if inside then "(" ^ e ^ ")" else e
| Qualif _ ->
(* Qualifier without arguments *)
- app_to_string ~meta:metadata env inside indent indent_incr e []
+ app_to_string ~span:spandata env inside indent indent_incr e []
| Let (monadic, lv, re, e) ->
let e =
- let_to_string ~meta:metadata env indent indent_incr monadic lv re e
+ let_to_string ~span:spandata env indent indent_incr monadic lv re e
in
if inside then "(" ^ e ^ ")" else e
| Switch (scrutinee, body) ->
let e =
- switch_to_string ~meta:metadata env indent indent_incr scrutinee body
+ switch_to_string ~span:spandata env indent indent_incr scrutinee body
in
if inside then "(" ^ e ^ ")" else e
| Loop loop ->
- let e = loop_to_string ~meta:metadata env indent indent_incr loop in
+ let e = loop_to_string ~span:spandata env indent indent_incr loop in
if inside then "(" ^ e ^ ")" else e
| StructUpdate supd -> (
let s =
@@ -591,7 +591,7 @@ let rec texpression_to_string ?(metadata : Meta.meta option = None)
(fun (fid, fe) ->
let field = FieldId.nth field_names fid in
let fe =
- texpression_to_string ~metadata env false indent2 indent_incr
+ texpression_to_string ~spandata env false indent2 indent_incr
fe
in
"\n" ^ indent1 ^ field ^ " := " ^ fe ^ ";")
@@ -603,22 +603,22 @@ let rec texpression_to_string ?(metadata : Meta.meta option = None)
let fields =
List.map
(fun (_, fe) ->
- texpression_to_string ~metadata env false indent2 indent_incr fe)
+ texpression_to_string ~spandata env false indent2 indent_incr fe)
supd.updates
in
"[ " ^ String.concat ", " fields ^ " ]"
- | _ -> craise_opt_meta __FILE__ __LINE__ metadata "Unexpected")
- | Meta (meta, e) -> (
- let meta_s = emeta_to_string ~metadata env meta in
- let e = texpression_to_string ~metadata env inside indent indent_incr e in
- match meta with
+ | _ -> craise_opt_span __FILE__ __LINE__ spandata "Unexpected")
+ | Meta (span, e) -> (
+ let span_s = espan_to_string ~spandata env span in
+ let e = texpression_to_string ~spandata env inside indent indent_incr e in
+ match span with
| Assignment _ | SymbolicAssignments _ | SymbolicPlaces _ | Tag _ ->
- let e = meta_s ^ "\n" ^ indent ^ e in
+ let e = span_s ^ "\n" ^ indent ^ e in
if inside then "(" ^ e ^ ")" else e
- | MPlace _ -> "(" ^ meta_s ^ " " ^ e ^ ")")
+ | MPlace _ -> "(" ^ span_s ^ " " ^ e ^ ")")
| EError (_, _) -> "@Error"
-and app_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+and app_to_string ?(span : Meta.span option = None) (env : fmt_env)
(inside : bool) (indent : string) (indent_incr : string) (app : texpression)
(args : texpression list) : string =
(* There are two possibilities: either the [app] is an instantiated,
@@ -638,13 +638,13 @@ and app_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
(global_decl_id_to_string env global_id, generics)
| AdtCons adt_cons_id ->
let variant_s =
- adt_variant_to_string ~meta env adt_cons_id.adt_id
+ adt_variant_to_string ~span env adt_cons_id.adt_id
adt_cons_id.variant_id
in
(ConstStrings.constructor_prefix ^ variant_s, [])
| Proj { adt_id; field_id } ->
- let adt_s = adt_variant_to_string ~meta env adt_id None in
- let field_s = adt_field_to_string ~meta env adt_id field_id in
+ let adt_s = adt_variant_to_string ~span env adt_id None in
+ let field_s = adt_field_to_string ~span env adt_id field_id in
(* Adopting an F*-like syntax *)
(ConstStrings.constructor_prefix ^ adt_s ^ "?." ^ field_s, [])
| TraitConst (trait_ref, const_name) ->
@@ -654,7 +654,7 @@ and app_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
| _ ->
(* "Regular" expression case *)
let inside = args <> [] || (args = [] && inside) in
- ( texpression_to_string ~metadata:meta env inside indent indent_incr app,
+ ( texpression_to_string ~spandata:span env inside indent indent_incr app,
[] )
in
(* Convert the arguments.
@@ -663,7 +663,7 @@ and app_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
let arg_to_string =
let inside = true in
let indent1 = indent ^ indent_incr in
- texpression_to_string ~metadata:meta env inside indent1 indent_incr
+ texpression_to_string ~spandata:span env inside indent1 indent_incr
in
let args = List.map arg_to_string args in
let all_args = List.append generics args in
@@ -674,29 +674,29 @@ and app_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
(* Add parentheses *)
if all_args <> [] && inside then "(" ^ e ^ ")" else e
-and lambda_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+and lambda_to_string ?(span : Meta.span option = None) (env : fmt_env)
(indent : string) (indent_incr : string) (xl : typed_pattern list)
(e : texpression) : string =
- let xl = List.map (typed_pattern_to_string ~meta env) xl in
- let e = texpression_to_string ~metadata:meta env false indent indent_incr e in
+ let xl = List.map (typed_pattern_to_string ~span env) xl in
+ let e = texpression_to_string ~spandata:span env false indent indent_incr e in
"λ " ^ String.concat " " xl ^ ". " ^ e
-and let_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+and let_to_string ?(span : Meta.span option = None) (env : fmt_env)
(indent : string) (indent_incr : string) (monadic : bool)
(lv : typed_pattern) (re : texpression) (e : texpression) : string =
let indent1 = indent ^ indent_incr in
let inside = false in
let re =
- texpression_to_string ~metadata:meta env inside indent1 indent_incr re
+ texpression_to_string ~spandata:span env inside indent1 indent_incr re
in
let e =
- texpression_to_string ~metadata:meta env inside indent indent_incr e
+ texpression_to_string ~spandata:span env inside indent indent_incr e
in
- let lv = typed_pattern_to_string ~meta env lv in
+ let lv = typed_pattern_to_string ~span env lv in
if monadic then lv ^ " <-- " ^ re ^ ";\n" ^ indent ^ e
else "let " ^ lv ^ " = " ^ re ^ " in\n" ^ indent ^ e
-and switch_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+and switch_to_string ?(span : Meta.span option = None) (env : fmt_env)
(indent : string) (indent_incr : string) (scrutinee : texpression)
(body : switch_body) : string =
let indent1 = indent ^ indent_incr in
@@ -704,10 +704,10 @@ and switch_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
* in most situations it will be a value or a function call, so it should be
* ok*)
let scrut =
- texpression_to_string ~metadata:meta env true indent1 indent_incr scrutinee
+ texpression_to_string ~spandata:span env true indent1 indent_incr scrutinee
in
let e_to_string =
- texpression_to_string ~metadata:meta env false indent1 indent_incr
+ texpression_to_string ~spandata:span env false indent1 indent_incr
in
match body with
| If (e_true, e_false) ->
@@ -717,13 +717,13 @@ and switch_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
^ indent ^ "else\n" ^ indent1 ^ e_false
| Match branches ->
let branch_to_string (b : match_branch) : string =
- let pat = typed_pattern_to_string ~meta env b.pat in
+ let pat = typed_pattern_to_string ~span env b.pat in
indent ^ "| " ^ pat ^ " ->\n" ^ indent1 ^ e_to_string b.branch
in
let branches = List.map branch_to_string branches in
"match " ^ scrut ^ " with\n" ^ String.concat "\n" branches
-and loop_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
+and loop_to_string ?(span : Meta.span option = None) (env : fmt_env)
(indent : string) (indent_incr : string) (loop : loop) : string =
let indent1 = indent ^ indent_incr in
let indent2 = indent1 ^ indent_incr in
@@ -734,11 +734,11 @@ and loop_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
in
let output_ty = "output_ty: " ^ ty_to_string env false loop.output_ty in
let fun_end =
- texpression_to_string ~metadata:meta env false indent2 indent_incr
+ texpression_to_string ~spandata:span env false indent2 indent_incr
loop.fun_end
in
let loop_body =
- texpression_to_string ~metadata:meta env false indent2 indent_incr
+ texpression_to_string ~spandata:span env false indent2 indent_incr
loop.loop_body
in
"loop {\n" ^ indent1 ^ loop_inputs ^ "\n" ^ indent1 ^ output_ty ^ "\n"
@@ -746,10 +746,10 @@ and loop_to_string ?(meta : Meta.meta option = None) (env : fmt_env)
^ indent1 ^ "loop_body: {\n" ^ indent2 ^ loop_body ^ "\n" ^ indent1 ^ "}\n"
^ indent ^ "}"
-and emeta_to_string ?(metadata : Meta.meta option = None) (env : fmt_env)
- (meta : emeta) : string =
- let meta =
- match meta with
+and espan_to_string ?(spandata : Meta.span option = None) (env : fmt_env)
+ (span : espan) : string =
+ let span =
+ match span with
| Assignment (lp, rv, rp) ->
let rp =
match rp with
@@ -757,14 +757,14 @@ and emeta_to_string ?(metadata : Meta.meta option = None) (env : fmt_env)
| Some rp -> " [@src=" ^ mplace_to_string env rp ^ "]"
in
"@assign(" ^ mplace_to_string env lp ^ " := "
- ^ texpression_to_string ~metadata env false "" "" rv
+ ^ texpression_to_string ~spandata env false "" "" rv
^ rp ^ ")"
| SymbolicAssignments info ->
let infos =
List.map
(fun (var_id, rv) ->
VarId.to_string var_id ^ " == "
- ^ texpression_to_string ~metadata env false "" "" rv)
+ ^ texpression_to_string ~spandata env false "" "" rv)
info
in
let infos = String.concat ", " infos in
@@ -781,7 +781,7 @@ and emeta_to_string ?(metadata : Meta.meta option = None) (env : fmt_env)
| MPlace mp -> "@mplace=" ^ mplace_to_string env mp
| Tag msg -> "@tag \"" ^ msg ^ "\""
in
- "@meta[" ^ meta ^ "]"
+ "@span[" ^ span ^ "]"
let fun_decl_to_string (env : fmt_env) (def : fun_decl) : string =
let env = { env with generics = def.signature.generics } in
@@ -798,7 +798,7 @@ let fun_decl_to_string (env : fmt_env) (def : fun_decl) : string =
else " fun " ^ String.concat " " inputs ^ " ->\n" ^ indent
in
let body =
- texpression_to_string ~metadata:(Some def.meta) env inside indent indent
+ texpression_to_string ~spandata:(Some def.span) env inside indent indent
body.body
in
"let " ^ name ^ " :\n " ^ signature ^ " =\n" ^ inputs ^ body
diff --git a/compiler/Pure.ml b/compiler/Pure.ml
index 451767f8..d07b8cfa 100644
--- a/compiler/Pure.ml
+++ b/compiler/Pure.ml
@@ -50,8 +50,8 @@ type region_group_id = T.region_group_id [@@deriving show, ord]
type mutability = Mut | Const [@@deriving show, ord]
type loc = Meta.loc [@@deriving show, ord]
type file_name = Meta.file_name [@@deriving show, ord]
+type raw_span = Meta.raw_span [@@deriving show, ord]
type span = Meta.span [@@deriving show, ord]
-type meta = Meta.meta [@@deriving show, ord]
(** The assumed types for the pure AST.
@@ -393,7 +393,7 @@ type type_decl = {
the name used at extraction time will be derived from the
llbc_name.
*)
- meta : meta;
+ span : span;
generics : generic_params;
llbc_generics : Types.generic_params;
(** We use the LLBC generics to generate "pretty" names, for instance
@@ -426,7 +426,7 @@ type var = {
(* TODO: we might want to redefine field_proj_kind here, to prevent field accesses
* on enumerations.
* Also: tuples...
- * Rmk: projections are actually only used as meta-data.
+ * Rmk: projections are actually only used as span-data.
* *)
type mprojection_elem = { pkind : E.field_proj_kind; field_id : FieldId.id }
[@@deriving show]
@@ -622,7 +622,7 @@ class ['self] iter_expression_base =
method visit_qualif : 'env -> qualif -> unit = fun _ _ -> ()
method visit_loop_id : 'env -> loop_id -> unit = fun _ _ -> ()
method visit_field_id : 'env -> field_id -> unit = fun _ _ -> ()
- method visit_meta : 'env -> Meta.meta -> unit = fun _ _ -> ()
+ method visit_span : 'env -> Meta.span -> unit = fun _ _ -> ()
end
(** Ancestor for {!map_expression} visitor *)
@@ -634,7 +634,7 @@ class ['self] map_expression_base =
method visit_qualif : 'env -> qualif -> qualif = fun _ x -> x
method visit_loop_id : 'env -> loop_id -> loop_id = fun _ x -> x
method visit_field_id : 'env -> field_id -> field_id = fun _ x -> x
- method visit_meta : 'env -> Meta.meta -> Meta.meta = fun _ x -> x
+ method visit_span : 'env -> Meta.span -> Meta.span = fun _ x -> x
end
(** Ancestor for {!reduce_expression} visitor *)
@@ -646,7 +646,7 @@ class virtual ['self] reduce_expression_base =
method visit_qualif : 'env -> qualif -> 'a = fun _ _ -> self#zero
method visit_loop_id : 'env -> loop_id -> 'a = fun _ _ -> self#zero
method visit_field_id : 'env -> field_id -> 'a = fun _ _ -> self#zero
- method visit_meta : 'env -> Meta.meta -> 'a = fun _ _ -> self#zero
+ method visit_span : 'env -> Meta.span -> 'a = fun _ _ -> self#zero
end
(** Ancestor for {!mapreduce_expression} visitor *)
@@ -667,7 +667,7 @@ class virtual ['self] mapreduce_expression_base =
method visit_field_id : 'env -> field_id -> field_id * 'a =
fun _ x -> (x, self#zero)
- method visit_meta : 'env -> Meta.meta -> Meta.meta * 'a =
+ method visit_span : 'env -> Meta.span -> Meta.span * 'a =
fun _ x -> (x, self#zero)
end
@@ -732,8 +732,8 @@ type expression =
| Switch of texpression * switch_body
| Loop of loop (** See the comments for {!loop} *)
| StructUpdate of struct_update (** See the comments for {!struct_update} *)
- | Meta of (emeta[@opaque]) * texpression (** Meta-information *)
- | EError of Meta.meta option * string
+ | Meta of (espan[@opaque]) * texpression (** Meta-information *)
+ | EError of Meta.span option * string
and switch_body = If of texpression * texpression | Match of match_branch list
and match_branch = { pat : typed_pattern; branch : texpression }
@@ -752,7 +752,7 @@ and match_branch = { pat : typed_pattern; branch : texpression }
and loop = {
fun_end : texpression;
loop_id : loop_id;
- meta : meta; [@opaque]
+ span : span; [@opaque]
fuel0 : var_id;
fuel : var_id;
input_state : var_id option;
@@ -806,7 +806,7 @@ and texpression = { e : expression; ty : ty }
and mvalue = (texpression[@opaque])
(** Meta-information stored in the AST *)
-and emeta =
+and espan =
| Assignment of mplace * mvalue * mplace option
(** Information about an assignment which occured in LLBC.
We use this to guide the heuristics which derive pretty names.
@@ -1012,7 +1012,7 @@ type decomposed_fun_sig = {
]}
The function's type should be given by [mk_arrows sig.inputs sig.output].
- We provide additional meta-information with {!fun_sig.info}:
+ We provide additional span-information with {!fun_sig.info}:
- we divide between forward inputs and backward inputs (i.e., inputs specific
to the forward functions, and additional inputs necessary if the signature is
for a backward function)
@@ -1080,7 +1080,7 @@ type item_kind = A.item_kind [@@deriving show]
type fun_decl = {
def_id : FunDeclId.id;
is_local : bool;
- meta : meta;
+ span : span;
kind : item_kind;
num_loops : int;
(** The number of loops in the parent forward function (basically the number
@@ -1102,7 +1102,7 @@ type fun_decl = {
[@@deriving show]
type global_decl = {
- meta : meta;
+ span : span;
def_id : GlobalDeclId.id;
is_local : bool;
llbc_name : llbc_name; (** The original LLBC name. *)
@@ -1126,7 +1126,7 @@ type trait_decl = {
is_local : bool;
llbc_name : llbc_name;
name : string;
- meta : meta;
+ span : span;
generics : generic_params;
llbc_generics : Types.generic_params;
(** We use the LLBC generics to generate "pretty" names, for instance
@@ -1149,7 +1149,7 @@ type trait_impl = {
is_local : bool;
llbc_name : llbc_name;
name : string;
- meta : meta;
+ span : span;
impl_trait : trait_decl_ref;
llbc_impl_trait : Types.trait_decl_ref;
(** Same remark as for {!field:llbc_generics}. *)
diff --git a/compiler/PureMicroPasses.ml b/compiler/PureMicroPasses.ml
index 004ecfef..a4319b28 100644
--- a/compiler/PureMicroPasses.ml
+++ b/compiler/PureMicroPasses.ml
@@ -67,17 +67,17 @@ type pn_ctx = {
}
(** This function computes pretty names for the variables in the pure AST. It
- relies on the "meta"-place information in the AST to generate naming
+ relies on the "span"-place information in the AST to generate naming
constraints, and then uses those to compute the names.
The way it works is as follows:
- we only modify the names of the unnamed variables
- whenever we see an rvalue/pattern which is exactly an unnamed variable,
- and this value is linked to some meta-place information which contains
+ and this value is linked to some span-place information which contains
a name and an empty path, we consider we should use this name
- we try to propagate naming constraints on the pure variables use in the
synthesized programs, and also on the LLBC variables from the original
- program (information about the LLBC variables is stored in the meta-places)
+ program (information about the LLBC variables is stored in the span-places)
Something important is that, for every variable we find, the name of this
@@ -118,7 +118,7 @@ type pn_ctx = {
hd -> s2
]}
- When generating the symbolic AST, we save as meta-information that we
+ When generating the symbolic AST, we save as span-information that we
assign [s1] to the place [x] and [s2] to the place [hd]. This way,
we learn we can use the names [x] and [hd] for the variables which are
introduced by the match:
@@ -162,10 +162,10 @@ type pn_ctx = {
so we should use "x" as the basename (hence the resulting name "x1"). However,
this is non-trivial, because after desugaring the input argument given to [id]
is not [&mut x] but [move ^0] (i.e., it comes from a temporary, anonymous
- variable). For this reason, we use the meta-place [&mut x] as the meta-place
+ variable). For this reason, we use the span-place [&mut x] as the span-place
for the given back value (this is done during the synthesis), and propagate
naming information *also* on the LLBC variables (which are referenced by the
- meta-places).
+ span-places).
This way, because of [^0 = &mut x], we can propagate the name "x" to the place
[^0], then to the given back variable across the function call.
@@ -213,7 +213,7 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
* - we explore the expressions
* - we register the variables introduced by the let-bindings
* - we use the naming information we find (through the variables and the
- * meta-places) to update our context (i.e., maps from variable ids to
+ * span-places) to update our context (i.e., maps from variable ids to
* names)
* - we use this information to update the names of the variables used in the
* expressions
@@ -224,7 +224,7 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
let register_var (ctx : pn_ctx) (v : var) : pn_ctx =
sanity_check __FILE__ __LINE__
(not (VarId.Map.mem v.id ctx.pure_vars))
- def.meta;
+ def.span;
match v.basename with
| None -> ctx
| Some name ->
@@ -286,8 +286,8 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
in
{ ctx with llbc_vars }
in
- (* Add a constraint: given a variable id and an associated meta-place, try to
- * extract naming information from the meta-place and save it *)
+ (* Add a constraint: given a variable id and an associated span-place, try to
+ * extract naming information from the span-place and save it *)
let add_constraint (mp : mplace) (var_id : VarId.id) (ctx : pn_ctx) : pn_ctx =
(* Register the place *)
let ctx = register_mplace mp ctx in
@@ -306,12 +306,12 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
(* Register the place *)
let ctx = register_mplace mp ctx in
(* Add the constraint *)
- match (unmeta rv).e with Var vid -> add_constraint mp vid ctx | _ -> ctx
+ match (unspan rv).e with Var vid -> add_constraint mp vid ctx | _ -> ctx
in
let add_pure_var_value_constraint (var_id : VarId.id) (rv : texpression)
(ctx : pn_ctx) : pn_ctx =
(* Add the constraint *)
- match (unmeta rv).e with
+ match (unspan rv).e with
| Var vid -> (
(* Try to find a name for the vid *)
match VarId.Map.find_opt vid ctx.pure_vars with
@@ -361,8 +361,8 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
VarId.Map.mem lvar.id ctx.pure_vars
then ctx
else
- (* We ignore the left meta-place information: it should have been taken
- * care of by [add_left_constraint]. We try to use the right meta-place
+ (* We ignore the left span-place information: it should have been taken
+ * care of by [add_left_constraint]. We try to use the right span-place
* information *)
let add (name : string) (ctx : pn_ctx) : pn_ctx =
(* Add the constraint for the pure variable *)
@@ -373,7 +373,7 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
| Some lmp -> add_llbc_var_constraint lmp.var_id name ctx
in
(* We try to use the right-place information *)
- let rmp, re = opt_unmeta_mplace re in
+ let rmp, re = opt_unspan_mplace re in
let ctx =
match rmp with
| Some { var_id; name; projection = [] } -> (
@@ -386,7 +386,7 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
in
(* We try to use the rvalue information, if it is a variable *)
let ctx =
- match (unmeta re).e with
+ match (unspan re).e with
| Var rvar_id -> (
match VarId.Map.find_opt rvar_id ctx.pure_vars with
| None -> ctx
@@ -415,8 +415,8 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
| Loop loop -> update_loop loop ctx
| StructUpdate supd -> update_struct_update supd ctx
| Lambda (lb, e) -> update_lambda lb e ctx
- | Meta (meta, e) -> update_emeta meta e ctx
- | EError (meta, msg) -> (ctx, EError (meta, msg))
+ | Meta (span, e) -> update_espan span e ctx
+ | EError (span, msg) -> (ctx, EError (span, msg))
in
(ctx, { e; ty })
(* *)
@@ -475,7 +475,7 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
let {
fun_end;
loop_id;
- meta;
+ span;
fuel0;
fuel;
input_state;
@@ -494,7 +494,7 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
{
fun_end;
loop_id;
- meta;
+ span;
fuel0;
fuel;
input_state;
@@ -518,10 +518,10 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
let supd = { struct_id; init; updates } in
(ctx, StructUpdate supd)
(* *)
- and update_emeta (meta : emeta) (e : texpression) (ctx : pn_ctx) :
+ and update_espan (span : espan) (e : texpression) (ctx : pn_ctx) :
pn_ctx * expression =
let ctx =
- match meta with
+ match span with
| Assignment (mp, rvalue, rmp) ->
let ctx = add_right_constraint mp rvalue ctx in
let ctx =
@@ -551,7 +551,7 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
| Tag _ -> ctx
in
let ctx, e = update_texpression e ctx in
- let e = mk_emeta meta e in
+ let e = mk_espan span e in
(ctx, e.e)
in
@@ -578,12 +578,12 @@ let compute_pretty_names (def : fun_decl) : fun_decl =
in
{ def with body }
-(** Remove the meta-information *)
-let remove_meta (def : fun_decl) : fun_decl =
+(** Remove the span-information *)
+let remove_span (def : fun_decl) : fun_decl =
match def.body with
| None -> def
| Some body ->
- let body = { body with body = PureUtils.remove_meta body.body } in
+ let body = { body with body = PureUtils.remove_span body.body } in
{ def with body = Some body }
(** Introduce the special structure create/update expressions.
@@ -614,7 +614,7 @@ let intro_struct_updates (ctx : trans_ctx) (def : fun_decl) : fun_decl =
| App _ -> (
let app, args = destruct_apps e in
let ignore () =
- mk_apps def.meta
+ mk_apps def.span
(self#visit_texpression env app)
(List.map (self#visit_texpression env) args)
in
@@ -759,7 +759,7 @@ let simplify_let_bindings (_ctx : trans_ctx) (def : fun_decl) : fun_decl =
else if variant_id = result_fail_id then
(* Fail case *)
self#visit_expression env rv.e
- else craise __FILE__ __LINE__ def.meta "Unexpected"
+ else craise __FILE__ __LINE__ def.span "Unexpected"
| App _ ->
(* This might be the tuple case *)
if not monadic then
@@ -914,7 +914,7 @@ let inline_useless_var_reassignments (ctx : trans_ctx) ~(inline_named : bool)
} ) ->
(* Second case: we deconstruct a structure with one field that we will
extract as tuple. *)
- let adt_id, _ = PureUtils.ty_as_adt def.meta re.ty in
+ let adt_id, _ = PureUtils.ty_as_adt def.span re.ty in
(* Update the rhs (we may perform substitutions inside, and it is
* better to do them *before* we inline it *)
let re = self#visit_texpression env re in
@@ -1152,7 +1152,7 @@ let simplify_let_then_ok _ctx (def : fun_decl) =
| Some e ->
if match_pattern_and_expr lv e then
(* We need to wrap the right-value in a ret *)
- (mk_result_ok_texpression def.meta rv).e
+ (mk_result_ok_texpression def.span rv).e
else not_simpl_e
| None ->
if match_pattern_and_expr lv next_e then rv.e else not_simpl_e
@@ -1203,13 +1203,13 @@ let simplify_aggregates (ctx : trans_ctx) (def : fun_decl) : fun_decl =
let fields =
match adt_decl.kind with
| Enum _ | Opaque ->
- craise __FILE__ __LINE__ def.meta "Unreachable"
+ craise __FILE__ __LINE__ def.span "Unreachable"
| Struct fields -> fields
in
let num_fields = List.length fields in
(* In order to simplify, there must be as many arguments as
* there are fields *)
- sanity_check __FILE__ __LINE__ (num_fields > 0) def.meta;
+ sanity_check __FILE__ __LINE__ (num_fields > 0) def.span;
if num_fields = List.length args then
(* We now need to check that all the arguments are of the form:
* [x.field] for some variable [x], and where the projection
@@ -1249,7 +1249,7 @@ let simplify_aggregates (ctx : trans_ctx) (def : fun_decl) : fun_decl =
(List.for_all
(fun (generics1, _) -> generics1 = generics)
args)
- def.meta;
+ def.span;
{ e with e = Var x })
else super#visit_texpression env e
else super#visit_texpression env e
@@ -1406,7 +1406,7 @@ let decompose_loops (_ctx : trans_ctx) (def : fun_decl) :
in
sanity_check __FILE__ __LINE__
(fun_sig_info_is_wf loop_fwd_sig_info)
- def.meta;
+ def.span;
let inputs_tys =
let fuel = if !Config.use_fuel then [ mk_fuel_ty ] else [] in
@@ -1449,7 +1449,7 @@ let decompose_loops (_ctx : trans_ctx) (def : fun_decl) :
sanity_check __FILE__ __LINE__
(loop_fwd_effect_info.stateful
= Option.is_some loop.input_state)
- def.meta;
+ def.span;
match loop.input_state with
| None -> ([], [])
| Some input_state ->
@@ -1486,7 +1486,7 @@ let decompose_loops (_ctx : trans_ctx) (def : fun_decl) :
match fuel_vars with
| None -> loop.loop_body
| Some (fuel0, fuel) ->
- SymbolicToPure.wrap_in_match_fuel def.meta fuel0 fuel
+ SymbolicToPure.wrap_in_match_fuel def.span fuel0 fuel
loop.loop_body
in
@@ -1496,7 +1496,7 @@ let decompose_loops (_ctx : trans_ctx) (def : fun_decl) :
{
def_id = def.def_id;
is_local = def.is_local;
- meta = loop.meta;
+ span = loop.span;
kind = def.kind;
num_loops;
loop_id = Some loop.loop_id;
@@ -1580,9 +1580,9 @@ let eliminate_box_functions (_ctx : trans_ctx) (def : fun_decl) : fun_decl =
match aid with
| BoxNew ->
let arg, args = Collections.List.pop args in
- mk_apps def.meta arg args
+ mk_apps def.span arg args
| BoxFree ->
- sanity_check __FILE__ __LINE__ (args = []) def.meta;
+ sanity_check __FILE__ __LINE__ (args = []) def.span;
mk_unit_rvalue
| SliceIndexShared | SliceIndexMut | ArrayIndexShared
| ArrayIndexMut | ArrayToSliceShared | ArrayToSliceMut
@@ -1776,8 +1776,8 @@ let unfold_monadic_let_bindings (_ctx : trans_ctx) (def : fun_decl) : fun_decl =
*)
(* TODO: this information should be computed in SymbolicToPure and
* store in an enum ("monadic" should be an enum, not a bool). *)
- let re_ty = Option.get (opt_destruct_result def.meta re.ty) in
- sanity_check __FILE__ __LINE__ (lv.ty = re_ty) def.meta;
+ let re_ty = Option.get (opt_destruct_result def.span re.ty) in
+ sanity_check __FILE__ __LINE__ (lv.ty = re_ty) def.span;
let err_vid = fresh_id () in
let err_var : var =
{
@@ -1789,7 +1789,7 @@ let unfold_monadic_let_bindings (_ctx : trans_ctx) (def : fun_decl) : fun_decl =
let err_pat = mk_typed_pattern_from_var err_var None in
let fail_pat = mk_result_fail_pattern err_pat.value lv.ty in
let err_v = mk_texpression_from_var err_var in
- let fail_value = mk_result_fail_texpression def.meta err_v e.ty in
+ let fail_value = mk_result_fail_texpression def.span err_v e.ty in
let fail_branch = { pat = fail_pat; branch = fail_value } in
let success_pat = mk_result_ok_pattern lv in
let success_branch = { pat = success_pat; branch = e } in
@@ -2030,7 +2030,7 @@ let filter_loop_inputs (ctx : trans_ctx) (transl : pure_fun_translation list) :
^ String.concat ", " (List.map (var_to_string ctx) inputs_prefix)
^ "\n"));
let inputs_set = VarId.Set.of_list (List.map var_get_id inputs_prefix) in
- sanity_check __FILE__ __LINE__ (Option.is_some decl.loop_id) decl.meta;
+ sanity_check __FILE__ __LINE__ (Option.is_some decl.loop_id) decl.span;
let fun_id = (E.FRegular decl.def_id, decl.loop_id) in
@@ -2182,7 +2182,7 @@ let filter_loop_inputs (ctx : trans_ctx) (transl : pure_fun_translation list) :
in
let fwd_info = { fwd_info; effect_info; ignore_output } in
- sanity_check __FILE__ __LINE__ (fun_sig_info_is_wf fwd_info) decl.meta;
+ sanity_check __FILE__ __LINE__ (fun_sig_info_is_wf fwd_info) decl.span;
let signature =
{
generics;
@@ -2248,17 +2248,17 @@ let filter_loop_inputs (ctx : trans_ctx) (transl : pure_fun_translation list) :
in
(* Rebuild *)
- mk_apps decl.meta e_app args)
+ mk_apps decl.span e_app args)
| _ ->
let e_app = self#visit_texpression env e_app in
let args =
List.map (self#visit_texpression env) args
in
- mk_apps decl.meta e_app args)
+ mk_apps decl.span e_app args)
| _ ->
let e_app = self#visit_texpression env e_app in
let args = List.map (self#visit_texpression env) args in
- mk_apps decl.meta e_app args)
+ mk_apps decl.span e_app args)
| _ -> super#visit_texpression env e
end
in
@@ -2297,16 +2297,16 @@ let apply_passes_to_def (ctx : trans_ctx) (def : fun_decl) : fun_and_loops =
log#ldebug
(lazy ("compute_pretty_name:\n\n" ^ fun_decl_to_string ctx def ^ "\n"));
- (* TODO: we might want to leverage more the assignment meta-data, for
+ (* TODO: we might want to leverage more the assignment span-data, for
* aggregates for instance. *)
(* TODO: reorder the branches of the matches/switches *)
- (* The meta-information is now useless: remove it.
- * Rk.: some passes below use the fact that we removed the meta-data
- * (otherwise we would have to "unmeta" expressions before matching) *)
- let def = remove_meta def in
- log#ldebug (lazy ("remove_meta:\n\n" ^ fun_decl_to_string ctx def ^ "\n"));
+ (* The span-information is now useless: remove it.
+ * Rk.: some passes below use the fact that we removed the span-data
+ * (otherwise we would have to "unspan" expressions before matching) *)
+ let def = remove_span def in
+ log#ldebug (lazy ("remove_span:\n\n" ^ fun_decl_to_string ctx def ^ "\n"));
(* Extract the loop definitions by removing the {!Loop} node *)
let def, loops = decompose_loops ctx def in
diff --git a/compiler/PureTypeCheck.ml b/compiler/PureTypeCheck.ml
index c1da4019..8d2ccf41 100644
--- a/compiler/PureTypeCheck.ml
+++ b/compiler/PureTypeCheck.ml
@@ -9,15 +9,15 @@ open Errors
This function should only be used for "regular" ADTs, where the number
of fields is fixed: it shouldn't be used for arrays, slices, etc.
*)
-let get_adt_field_types (meta : Meta.meta)
+let get_adt_field_types (span : Meta.span)
(type_decls : type_decl TypeDeclId.Map.t) (type_id : type_id)
(variant_id : VariantId.id option) (generics : generic_args) : ty list =
match type_id with
| TTuple ->
(* Tuple *)
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
- sanity_check __FILE__ __LINE__ (generics.trait_refs = []) meta;
- sanity_check __FILE__ __LINE__ (variant_id = None) meta;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
+ sanity_check __FILE__ __LINE__ (generics.trait_refs = []) span;
+ sanity_check __FILE__ __LINE__ (variant_id = None) span;
generics.types
| TAdtId def_id ->
(* "Regular" ADT *)
@@ -28,33 +28,33 @@ let get_adt_field_types (meta : Meta.meta)
match aty with
| TState ->
(* This type is opaque *)
- craise __FILE__ __LINE__ meta "Unreachable: opaque type"
+ craise __FILE__ __LINE__ span "Unreachable: opaque type"
| TResult ->
let ty = Collections.List.to_cons_nil generics.types in
let variant_id = Option.get variant_id in
if variant_id = result_ok_id then [ ty ]
else if variant_id = result_fail_id then [ mk_error_ty ]
else
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Unreachable: improper variant id for result type"
| TError ->
- sanity_check __FILE__ __LINE__ (generics = empty_generic_args) meta;
+ sanity_check __FILE__ __LINE__ (generics = empty_generic_args) span;
let variant_id = Option.get variant_id in
sanity_check __FILE__ __LINE__
(variant_id = error_failure_id || variant_id = error_out_of_fuel_id)
- meta;
+ span;
[]
| TFuel ->
let variant_id = Option.get variant_id in
if variant_id = fuel_zero_id then []
else if variant_id = fuel_succ_id then [ mk_fuel_ty ]
else
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Unreachable: improper variant id for fuel type"
| TArray | TSlice | TStr | TRawPtr _ ->
(* Array: when not symbolic values (for instance, because of aggregates),
the array expressions are introduced as struct updates *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Attempting to access the fields of an opaque type")
type tc_ctx = {
@@ -67,38 +67,38 @@ type tc_ctx = {
(* TODO: add trait type constraints *)
}
-let check_literal (meta : Meta.meta) (v : literal) (ty : literal_type) : unit =
+let check_literal (span : Meta.span) (v : literal) (ty : literal_type) : unit =
match (ty, v) with
| TInteger int_ty, VScalar sv ->
- sanity_check __FILE__ __LINE__ (int_ty = sv.int_ty) meta
+ sanity_check __FILE__ __LINE__ (int_ty = sv.int_ty) span
| TBool, VBool _ | TChar, VChar _ -> ()
- | _ -> craise __FILE__ __LINE__ meta "Inconsistent type"
+ | _ -> craise __FILE__ __LINE__ span "Inconsistent type"
-let rec check_typed_pattern (meta : Meta.meta) (ctx : tc_ctx)
+let rec check_typed_pattern (span : Meta.span) (ctx : tc_ctx)
(v : typed_pattern) : tc_ctx =
log#ldebug (lazy ("check_typed_pattern: " ^ show_typed_pattern v));
match v.value with
| PatConstant cv ->
- check_literal meta cv (ty_as_literal meta v.ty);
+ check_literal span cv (ty_as_literal span v.ty);
ctx
| PatDummy -> ctx
| PatVar (var, _) ->
- sanity_check __FILE__ __LINE__ (var.ty = v.ty) meta;
+ sanity_check __FILE__ __LINE__ (var.ty = v.ty) span;
let env = VarId.Map.add var.id var.ty ctx.env in
{ ctx with env }
| PatAdt av ->
(* Compute the field types *)
- let type_id, generics = ty_as_adt meta v.ty in
+ let type_id, generics = ty_as_adt span v.ty in
let field_tys =
- get_adt_field_types meta ctx.type_decls type_id av.variant_id generics
+ get_adt_field_types span ctx.type_decls type_id av.variant_id generics
in
let check_value (ctx : tc_ctx) (ty : ty) (v : typed_pattern) : tc_ctx =
if ty <> v.ty then
(* TODO: we need to normalize the types *)
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
("Inconsistent types:" ^ "\n- ty: " ^ show_ty ty ^ "\n- v.ty: "
^ show_ty v.ty);
- check_typed_pattern meta ctx v
+ check_typed_pattern span ctx v
in
(* Check the field types: check that the field patterns have the expected
* types, and check that the field patterns themselves are well-typed *)
@@ -107,7 +107,7 @@ let rec check_typed_pattern (meta : Meta.meta) (ctx : tc_ctx)
ctx
(List.combine field_tys av.field_values)
-let rec check_texpression (meta : Meta.meta) (ctx : tc_ctx) (e : texpression) :
+let rec check_texpression (span : Meta.span) (ctx : tc_ctx) (e : texpression) :
unit =
match e.e with
| Var var_id -> (
@@ -117,24 +117,24 @@ let rec check_texpression (meta : Meta.meta) (ctx : tc_ctx) (e : texpression) :
* we use a locally nameless representation *)
match VarId.Map.find_opt var_id ctx.env with
| None -> ()
- | Some ty -> sanity_check __FILE__ __LINE__ (ty = e.ty) meta)
+ | Some ty -> sanity_check __FILE__ __LINE__ (ty = e.ty) span)
| CVar cg_id ->
let ty = T.ConstGenericVarId.Map.find cg_id ctx.const_generics in
- sanity_check __FILE__ __LINE__ (ty = e.ty) meta
- | Const cv -> check_literal meta cv (ty_as_literal meta e.ty)
+ sanity_check __FILE__ __LINE__ (ty = e.ty) span
+ | Const cv -> check_literal span cv (ty_as_literal span e.ty)
| App (app, arg) ->
- let input_ty, output_ty = destruct_arrow meta app.ty in
- sanity_check __FILE__ __LINE__ (input_ty = arg.ty) meta;
- sanity_check __FILE__ __LINE__ (output_ty = e.ty) meta;
- check_texpression meta ctx app;
- check_texpression meta ctx arg
+ let input_ty, output_ty = destruct_arrow span app.ty in
+ sanity_check __FILE__ __LINE__ (input_ty = arg.ty) span;
+ sanity_check __FILE__ __LINE__ (output_ty = e.ty) span;
+ check_texpression span ctx app;
+ check_texpression span ctx arg
| Lambda (pat, body) ->
- let pat_ty, body_ty = destruct_arrow meta e.ty in
- sanity_check __FILE__ __LINE__ (pat.ty = pat_ty) meta;
- sanity_check __FILE__ __LINE__ (body.ty = body_ty) meta;
+ let pat_ty, body_ty = destruct_arrow span e.ty in
+ sanity_check __FILE__ __LINE__ (pat.ty = pat_ty) span;
+ sanity_check __FILE__ __LINE__ (body.ty = body_ty) span;
(* Check the pattern and register the introduced variables at the same time *)
- let ctx = check_typed_pattern meta ctx pat in
- check_texpression meta ctx body
+ let ctx = check_typed_pattern span ctx pat in
+ check_texpression span ctx body
| Qualif qualif -> (
match qualif.id with
| FunOrOp _ -> () (* TODO *)
@@ -143,86 +143,86 @@ let rec check_texpression (meta : Meta.meta) (ctx : tc_ctx) (e : texpression) :
| Proj { adt_id = proj_adt_id; field_id } ->
(* Note we can only project fields of structures (not enumerations) *)
(* Deconstruct the projector type *)
- let adt_ty, field_ty = destruct_arrow meta e.ty in
- let adt_id, adt_generics = ty_as_adt meta adt_ty in
+ let adt_ty, field_ty = destruct_arrow span e.ty in
+ let adt_id, adt_generics = ty_as_adt span adt_ty in
(* Check the ADT type *)
- sanity_check __FILE__ __LINE__ (adt_id = proj_adt_id) meta;
- sanity_check __FILE__ __LINE__ (adt_generics = qualif.generics) meta;
+ sanity_check __FILE__ __LINE__ (adt_id = proj_adt_id) span;
+ sanity_check __FILE__ __LINE__ (adt_generics = qualif.generics) span;
(* Retrieve and check the expected field type *)
let variant_id = None in
let expected_field_tys =
- get_adt_field_types meta ctx.type_decls proj_adt_id variant_id
+ get_adt_field_types span ctx.type_decls proj_adt_id variant_id
qualif.generics
in
let expected_field_ty = FieldId.nth expected_field_tys field_id in
- sanity_check __FILE__ __LINE__ (expected_field_ty = field_ty) meta
+ sanity_check __FILE__ __LINE__ (expected_field_ty = field_ty) span
| AdtCons id -> (
let expected_field_tys =
- get_adt_field_types meta ctx.type_decls id.adt_id id.variant_id
+ get_adt_field_types span ctx.type_decls id.adt_id id.variant_id
qualif.generics
in
let field_tys, adt_ty = destruct_arrows e.ty in
- sanity_check __FILE__ __LINE__ (expected_field_tys = field_tys) meta;
+ sanity_check __FILE__ __LINE__ (expected_field_tys = field_tys) span;
match adt_ty with
| TAdt (type_id, generics) ->
- sanity_check __FILE__ __LINE__ (type_id = id.adt_id) meta;
- sanity_check __FILE__ __LINE__ (generics = qualif.generics) meta
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"))
+ sanity_check __FILE__ __LINE__ (type_id = id.adt_id) span;
+ sanity_check __FILE__ __LINE__ (generics = qualif.generics) span
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"))
| Let (monadic, pat, re, e_next) ->
let expected_pat_ty =
- if monadic then destruct_result meta re.ty else re.ty
+ if monadic then destruct_result span re.ty else re.ty
in
- sanity_check __FILE__ __LINE__ (pat.ty = expected_pat_ty) meta;
- sanity_check __FILE__ __LINE__ (e.ty = e_next.ty) meta;
+ sanity_check __FILE__ __LINE__ (pat.ty = expected_pat_ty) span;
+ sanity_check __FILE__ __LINE__ (e.ty = e_next.ty) span;
(* Check the right-expression *)
- check_texpression meta ctx re;
+ check_texpression span ctx re;
(* Check the pattern and register the introduced variables at the same time *)
- let ctx = check_typed_pattern meta ctx pat in
+ let ctx = check_typed_pattern span ctx pat in
(* Check the next expression *)
- check_texpression meta ctx e_next
+ check_texpression span ctx e_next
| Switch (scrut, switch_body) -> (
- check_texpression meta ctx scrut;
+ check_texpression span ctx scrut;
match switch_body with
| If (e_then, e_else) ->
- sanity_check __FILE__ __LINE__ (scrut.ty = TLiteral TBool) meta;
- sanity_check __FILE__ __LINE__ (e_then.ty = e.ty) meta;
- sanity_check __FILE__ __LINE__ (e_else.ty = e.ty) meta;
- check_texpression meta ctx e_then;
- check_texpression meta ctx e_else
+ sanity_check __FILE__ __LINE__ (scrut.ty = TLiteral TBool) span;
+ sanity_check __FILE__ __LINE__ (e_then.ty = e.ty) span;
+ sanity_check __FILE__ __LINE__ (e_else.ty = e.ty) span;
+ check_texpression span ctx e_then;
+ check_texpression span ctx e_else
| Match branches ->
let check_branch (br : match_branch) : unit =
- sanity_check __FILE__ __LINE__ (br.pat.ty = scrut.ty) meta;
- let ctx = check_typed_pattern meta ctx br.pat in
- check_texpression meta ctx br.branch
+ sanity_check __FILE__ __LINE__ (br.pat.ty = scrut.ty) span;
+ let ctx = check_typed_pattern span ctx br.pat in
+ check_texpression span ctx br.branch
in
List.iter check_branch branches)
| Loop loop ->
- sanity_check __FILE__ __LINE__ (loop.fun_end.ty = e.ty) meta;
- check_texpression meta ctx loop.fun_end;
- check_texpression meta ctx loop.loop_body
+ sanity_check __FILE__ __LINE__ (loop.fun_end.ty = e.ty) span;
+ check_texpression span ctx loop.fun_end;
+ check_texpression span ctx loop.loop_body
| StructUpdate supd -> (
(* Check the init value *)
(if Option.is_some supd.init then
match VarId.Map.find_opt (Option.get supd.init) ctx.env with
| None -> ()
- | Some ty -> sanity_check __FILE__ __LINE__ (ty = e.ty) meta);
+ | Some ty -> sanity_check __FILE__ __LINE__ (ty = e.ty) span);
(* Check the fields *)
(* Retrieve and check the expected field type *)
- let adt_id, adt_generics = ty_as_adt meta e.ty in
- sanity_check __FILE__ __LINE__ (adt_id = supd.struct_id) meta;
+ let adt_id, adt_generics = ty_as_adt span e.ty in
+ sanity_check __FILE__ __LINE__ (adt_id = supd.struct_id) span;
(* The id can only be: a custom type decl or an array *)
match adt_id with
| TAdtId _ ->
let variant_id = None in
let expected_field_tys =
- get_adt_field_types meta ctx.type_decls adt_id variant_id
+ get_adt_field_types span ctx.type_decls adt_id variant_id
adt_generics
in
List.iter
(fun ((fid, fe) : _ * texpression) ->
let expected_field_ty = FieldId.nth expected_field_tys fid in
- sanity_check __FILE__ __LINE__ (expected_field_ty = fe.ty) meta;
- check_texpression meta ctx fe)
+ sanity_check __FILE__ __LINE__ (expected_field_ty = fe.ty) span;
+ check_texpression span ctx fe)
supd.updates
| TAssumed TArray ->
let expected_field_ty =
@@ -230,11 +230,11 @@ let rec check_texpression (meta : Meta.meta) (ctx : tc_ctx) (e : texpression) :
in
List.iter
(fun ((_, fe) : _ * texpression) ->
- sanity_check __FILE__ __LINE__ (expected_field_ty = fe.ty) meta;
- check_texpression meta ctx fe)
+ sanity_check __FILE__ __LINE__ (expected_field_ty = fe.ty) span;
+ check_texpression span ctx fe)
supd.updates
- | _ -> craise __FILE__ __LINE__ meta "Unexpected")
+ | _ -> craise __FILE__ __LINE__ span "Unexpected")
| Meta (_, e_next) ->
- sanity_check __FILE__ __LINE__ (e_next.ty = e.ty) meta;
- check_texpression meta ctx e_next
- | EError (meta, msg) -> craise_opt_meta __FILE__ __LINE__ meta msg
+ sanity_check __FILE__ __LINE__ (e_next.ty = e.ty) span;
+ check_texpression span ctx e_next
+ | EError (span, msg) -> craise_opt_span __FILE__ __LINE__ span msg
diff --git a/compiler/PureUtils.ml b/compiler/PureUtils.ml
index 82a578d9..e7dcd933 100644
--- a/compiler/PureUtils.ml
+++ b/compiler/PureUtils.ml
@@ -80,10 +80,10 @@ let opt_dest_arrow_ty (ty : ty) : (ty * ty) option =
let is_arrow_ty (ty : ty) : bool = Option.is_some (opt_dest_arrow_ty ty)
-let dest_arrow_ty (meta : Meta.meta) (ty : ty) : ty * ty =
+let dest_arrow_ty (span : Meta.span) (ty : ty) : ty * ty =
match opt_dest_arrow_ty ty with
| Some (arg_ty, ret_ty) -> (arg_ty, ret_ty)
- | None -> craise __FILE__ __LINE__ meta "Not an arrow type"
+ | None -> craise __FILE__ __LINE__ span "Not an arrow type"
let compute_literal_type (cv : literal) : literal_type =
match cv with
@@ -91,7 +91,7 @@ let compute_literal_type (cv : literal) : literal_type =
| VBool _ -> TBool
| VChar _ -> TChar
| VStr _ | VByteStr _ ->
- craise_opt_meta __FILE__ __LINE__ None
+ craise_opt_span __FILE__ __LINE__ None
"String and byte string literals are unsupported"
let var_get_id (v : var) : VarId.id = v.id
@@ -222,34 +222,34 @@ let fun_sig_substitute (subst : subst) (sg : fun_sig) : inst_fun_sig =
Rem.: this function will *fail* if there are {!Pure.Loop}
nodes (you should call it on an expression where those nodes have been eliminated).
*)
-let rec let_group_requires_parentheses (meta : Meta.meta) (e : texpression) :
+let rec let_group_requires_parentheses (span : Meta.span) (e : texpression) :
bool =
match e.e with
| Var _ | CVar _ | Const _ | App _ | Qualif _ | StructUpdate _ -> false
| Let (monadic, _, _, next_e) ->
- if monadic then true else let_group_requires_parentheses meta next_e
+ if monadic then true else let_group_requires_parentheses span next_e
| Switch (_, _) -> false
- | Meta (_, next_e) -> let_group_requires_parentheses meta next_e
+ | Meta (_, next_e) -> let_group_requires_parentheses span next_e
| Lambda (_, _) ->
(* Being conservative here *)
true
| Loop _ ->
(* Should have been eliminated *)
- craise __FILE__ __LINE__ meta "Unreachable"
- | EError (meta, msg) ->
- craise_opt_meta __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span "Unreachable"
+ | EError (span, msg) ->
+ craise_opt_span __FILE__ __LINE__ span
msg (* TODO : check if true should'nt be returned instead ? *)
-let texpression_requires_parentheses meta e =
+let texpression_requires_parentheses span e =
match !Config.backend with
| FStar | Lean -> false
- | Coq | HOL4 -> let_group_requires_parentheses meta e
+ | Coq | HOL4 -> let_group_requires_parentheses span e
let is_var (e : texpression) : bool =
match e.e with Var _ -> true | _ -> false
-let as_var (meta : Meta.meta) (e : texpression) : VarId.id =
- match e.e with Var v -> v | _ -> craise __FILE__ __LINE__ meta "Not a var"
+let as_var (span : Meta.span) (e : texpression) : VarId.id =
+ match e.e with Var v -> v | _ -> craise __FILE__ __LINE__ span "Not a var"
let is_cvar (e : texpression) : bool =
match e.e with CVar _ -> true | _ -> false
@@ -260,17 +260,17 @@ let is_global (e : texpression) : bool =
let is_const (e : texpression) : bool =
match e.e with Const _ -> true | _ -> false
-let ty_as_adt (meta : Meta.meta) (ty : ty) : type_id * generic_args =
+let ty_as_adt (span : Meta.span) (ty : ty) : type_id * generic_args =
match ty with
| TAdt (id, generics) -> (id, generics)
- | _ -> craise __FILE__ __LINE__ meta "Not an ADT"
+ | _ -> craise __FILE__ __LINE__ span "Not an ADT"
(** Remove the external occurrences of {!Meta} *)
-let rec unmeta (e : texpression) : texpression =
- match e.e with Meta (_, e) -> unmeta e | _ -> e
+let rec unspan (e : texpression) : texpression =
+ match e.e with Meta (_, e) -> unspan e | _ -> e
-(** Remove *all* the meta information *)
-let remove_meta (e : texpression) : texpression =
+(** Remove *all* the span information *)
+let remove_span (e : texpression) : texpression =
let obj =
object
inherit [_] map_expression as super
@@ -300,13 +300,13 @@ let rec destruct_lets (e : texpression) :
(** Destruct an expression into a list of nested lets, where there
is no interleaving between monadic and non-monadic lets.
*)
-let destruct_lets_no_interleave (meta : Meta.meta) (e : texpression) :
+let destruct_lets_no_interleave (span : Meta.span) (e : texpression) :
(bool * typed_pattern * texpression) list * texpression =
(* Find the "kind" of the first let (monadic or non-monadic) *)
let m =
match e.e with
| Let (monadic, _, _, _) -> monadic
- | _ -> craise __FILE__ __LINE__ meta "Not a let-binding"
+ | _ -> craise __FILE__ __LINE__ span "Not a let-binding"
in
(* Destruct the rest *)
let rec destruct_lets (e : texpression) :
@@ -333,11 +333,11 @@ let destruct_apps (e : texpression) : texpression * texpression list =
aux [] e
(** Make an [App (app, arg)] expression *)
-let mk_app (meta : Meta.meta) (app : texpression) (arg : texpression) :
+let mk_app (span : Meta.span) (app : texpression) (arg : texpression) :
texpression =
let raise_or_return msg =
(* We shouldn't get there, so we save an error (and eventually raise an exception) *)
- save_error __FILE__ __LINE__ (Some meta) msg;
+ save_error __FILE__ __LINE__ (Some span) msg;
let e = App (app, arg) in
(* Dummy type - TODO: introduce an error type *)
let ty = app.ty in
@@ -357,9 +357,9 @@ let mk_app (meta : Meta.meta) (app : texpression) (arg : texpression) :
| _ -> raise_or_return "Expected an arrow type"
(** The reverse of {!destruct_apps} *)
-let mk_apps (meta : Meta.meta) (app : texpression) (args : texpression list) :
+let mk_apps (span : Meta.span) (app : texpression) (args : texpression list) :
texpression =
- List.fold_left (fun app arg -> mk_app meta app arg) app args
+ List.fold_left (fun app arg -> mk_app span app arg) app args
(** Destruct an expression into a qualif identifier and a list of arguments,
* if possible *)
@@ -382,29 +382,29 @@ let opt_destruct_function_call (e : texpression) :
| FunOrOp fun_id -> Some (fun_id, qualif.generics, args)
| _ -> None)
-let opt_destruct_result (meta : Meta.meta) (ty : ty) : ty option =
+let opt_destruct_result (span : Meta.span) (ty : ty) : ty option =
match ty with
| TAdt (TAssumed TResult, generics) ->
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
- sanity_check __FILE__ __LINE__ (generics.trait_refs = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
+ sanity_check __FILE__ __LINE__ (generics.trait_refs = []) span;
Some (Collections.List.to_cons_nil generics.types)
| _ -> None
-let destruct_result (meta : Meta.meta) (ty : ty) : ty =
- Option.get (opt_destruct_result meta ty)
+let destruct_result (span : Meta.span) (ty : ty) : ty =
+ Option.get (opt_destruct_result span ty)
-let opt_destruct_tuple (meta : Meta.meta) (ty : ty) : ty list option =
+let opt_destruct_tuple (span : Meta.span) (ty : ty) : ty list option =
match ty with
| TAdt (TTuple, generics) ->
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
- sanity_check __FILE__ __LINE__ (generics.trait_refs = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
+ sanity_check __FILE__ __LINE__ (generics.trait_refs = []) span;
Some generics.types
| _ -> None
-let destruct_arrow (meta : Meta.meta) (ty : ty) : ty * ty =
+let destruct_arrow (span : Meta.span) (ty : ty) : ty * ty =
match ty with
| TArrow (ty0, ty1) -> (ty0, ty1)
- | _ -> craise __FILE__ __LINE__ meta "Not an arrow type"
+ | _ -> craise __FILE__ __LINE__ span "Not an arrow type"
let rec destruct_arrows (ty : ty) : ty list * ty =
match ty with
@@ -438,20 +438,20 @@ let iter_switch_body_branches (f : texpression -> unit) (sb : switch_body) :
f e_else
| Match branches -> List.iter (fun (b : match_branch) -> f b.branch) branches
-let mk_switch (meta : Meta.meta) (scrut : texpression) (sb : switch_body) :
+let mk_switch (span : Meta.span) (scrut : texpression) (sb : switch_body) :
texpression =
(* Sanity check: the scrutinee has the proper type *)
(match sb with
- | If (_, _) -> sanity_check __FILE__ __LINE__ (scrut.ty = TLiteral TBool) meta
+ | If (_, _) -> sanity_check __FILE__ __LINE__ (scrut.ty = TLiteral TBool) span
| Match branches ->
List.iter
(fun (b : match_branch) ->
- sanity_check __FILE__ __LINE__ (b.pat.ty = scrut.ty) meta)
+ sanity_check __FILE__ __LINE__ (b.pat.ty = scrut.ty) span)
branches);
(* Sanity check: all the branches have the same type *)
let ty = get_switch_body_ty sb in
iter_switch_body_branches
- (fun e -> sanity_check __FILE__ __LINE__ (e.ty = ty) meta)
+ (fun e -> sanity_check __FILE__ __LINE__ (e.ty = ty) span)
sb;
(* Put together *)
let e = Switch (scrut, sb) in
@@ -491,13 +491,13 @@ let mk_dummy_pattern (ty : ty) : typed_pattern =
let value = PatDummy in
{ value; ty }
-let mk_emeta (m : emeta) (e : texpression) : texpression =
+let mk_espan (m : espan) (e : texpression) : texpression =
let ty = e.ty in
let e = Meta (m, e) in
{ e; ty }
let mk_mplace_texpression (mp : mplace) (e : texpression) : texpression =
- mk_emeta (MPlace mp) e
+ mk_espan (MPlace mp) e
let mk_opt_mplace_texpression (mp : mplace option) (e : texpression) :
texpression =
@@ -517,7 +517,7 @@ let mk_simpl_tuple_pattern (vl : typed_pattern list) : typed_pattern =
{ value; ty }
(** Similar to {!mk_simpl_tuple_pattern} *)
-let mk_simpl_tuple_texpression (meta : Meta.meta) (vl : texpression list) :
+let mk_simpl_tuple_texpression (span : Meta.span) (vl : texpression list) :
texpression =
match vl with
| [ v ] -> v
@@ -531,22 +531,22 @@ let mk_simpl_tuple_texpression (meta : Meta.meta) (vl : texpression list) :
let qualif = { id; generics = mk_generic_args_from_types tys } in
(* Put everything together *)
let cons = { e = Qualif qualif; ty } in
- mk_apps meta cons vl
+ mk_apps span cons vl
let mk_adt_pattern (adt_ty : ty) (variant_id : VariantId.id option)
(vl : typed_pattern list) : typed_pattern =
let value = PatAdt { variant_id; field_values = vl } in
{ value; ty = adt_ty }
-let ty_as_integer (meta : Meta.meta) (t : ty) : T.integer_type =
+let ty_as_integer (span : Meta.span) (t : ty) : T.integer_type =
match t with
| TLiteral (TInteger int_ty) -> int_ty
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
-let ty_as_literal (meta : Meta.meta) (t : ty) : T.literal_type =
+let ty_as_literal (span : Meta.span) (t : ty) : T.literal_type =
match t with
| TLiteral ty -> ty
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
let mk_state_ty : ty = TAdt (TAssumed TState, empty_generic_args)
@@ -563,15 +563,15 @@ let mk_error (error : VariantId.id) : texpression =
let e = Qualif qualif in
{ e; ty }
-let unwrap_result_ty (meta : Meta.meta) (ty : ty) : ty =
+let unwrap_result_ty (span : Meta.span) (ty : ty) : ty =
match ty with
| TAdt
( TAssumed TResult,
{ types = [ ty ]; const_generics = []; trait_refs = [] } ) ->
ty
- | _ -> craise __FILE__ __LINE__ meta "not a result type"
+ | _ -> craise __FILE__ __LINE__ span "not a result type"
-let mk_result_fail_texpression (meta : Meta.meta) (error : texpression)
+let mk_result_fail_texpression (span : Meta.span) (error : texpression)
(ty : ty) : texpression =
let type_args = [ ty ] in
let ty = TAdt (TAssumed TResult, mk_generic_args_from_types type_args) in
@@ -582,14 +582,14 @@ let mk_result_fail_texpression (meta : Meta.meta) (error : texpression)
let cons_e = Qualif qualif in
let cons_ty = mk_arrow error.ty ty in
let cons = { e = cons_e; ty = cons_ty } in
- mk_app meta cons error
+ mk_app span cons error
-let mk_result_fail_texpression_with_error_id (meta : Meta.meta)
+let mk_result_fail_texpression_with_error_id (span : Meta.span)
(error : VariantId.id) (ty : ty) : texpression =
let error = mk_error error in
- mk_result_fail_texpression meta error ty
+ mk_result_fail_texpression span error ty
-let mk_result_ok_texpression (meta : Meta.meta) (v : texpression) : texpression
+let mk_result_ok_texpression (span : Meta.span) (v : texpression) : texpression
=
let type_args = [ v.ty ] in
let ty = TAdt (TAssumed TResult, mk_generic_args_from_types type_args) in
@@ -600,7 +600,7 @@ let mk_result_ok_texpression (meta : Meta.meta) (v : texpression) : texpression
let cons_e = Qualif qualif in
let cons_ty = mk_arrow v.ty ty in
let cons = { e = cons_e; ty = cons_ty } in
- mk_app meta cons v
+ mk_app span cons v
(** Create a [Fail err] pattern which captures the error *)
let mk_result_fail_pattern (error_pat : pattern) (ty : ty) : typed_pattern =
@@ -621,7 +621,7 @@ let mk_result_ok_pattern (v : typed_pattern) : typed_pattern =
let value = PatAdt { variant_id = Some result_ok_id; field_values = [ v ] } in
{ value; ty }
-let opt_unmeta_mplace (e : texpression) : mplace option * texpression =
+let opt_unspan_mplace (e : texpression) : mplace option * texpression =
match e.e with Meta (MPlace mp, e) -> (Some mp, e) | _ -> (None, e)
let mk_state_var (id : VarId.id) : var =
@@ -636,7 +636,7 @@ let mk_fuel_var (id : VarId.id) : var =
let mk_fuel_texpression (id : VarId.id) : texpression =
{ e = Var id; ty = mk_fuel_ty }
-let rec typed_pattern_to_texpression (meta : Meta.meta) (pat : typed_pattern) :
+let rec typed_pattern_to_texpression (span : Meta.span) (pat : typed_pattern) :
texpression option =
let e_opt =
match pat.value with
@@ -645,14 +645,14 @@ let rec typed_pattern_to_texpression (meta : Meta.meta) (pat : typed_pattern) :
| PatDummy -> None
| PatAdt av ->
let fields =
- List.map (typed_pattern_to_texpression meta) av.field_values
+ List.map (typed_pattern_to_texpression span) av.field_values
in
if List.mem None fields then None
else
let fields_values = List.map (fun e -> Option.get e) fields in
(* Retrieve the type id and the type args from the pat type (simpler this way *)
- let adt_id, generics = ty_as_adt meta pat.ty in
+ let adt_id, generics = ty_as_adt span pat.ty in
(* Create the constructor *)
let qualif_id = AdtCons { adt_id; variant_id = av.variant_id } in
@@ -665,7 +665,7 @@ let rec typed_pattern_to_texpression (meta : Meta.meta) (pat : typed_pattern) :
let cons = { e = cons_e; ty = cons_ty } in
(* Apply the constructor *)
- Some (mk_apps meta cons fields_values).e
+ Some (mk_apps span cons fields_values).e
in
match e_opt with None -> None | Some e -> Some { e; ty = pat.ty }
@@ -692,7 +692,7 @@ let trait_decl_is_empty (trait_decl : trait_decl) : bool =
is_local = _;
name = _;
llbc_name = _;
- meta = _;
+ span = _;
generics = _;
llbc_generics = _;
preds = _;
@@ -714,7 +714,7 @@ let trait_impl_is_empty (trait_impl : trait_impl) : bool =
is_local = _;
name = _;
llbc_name = _;
- meta = _;
+ span = _;
impl_trait = _;
llbc_impl_trait = _;
generics = _;
diff --git a/compiler/RegionsHierarchy.ml b/compiler/RegionsHierarchy.ml
index 21be89ee..3ec42f5d 100644
--- a/compiler/RegionsHierarchy.ml
+++ b/compiler/RegionsHierarchy.ml
@@ -40,7 +40,7 @@ module Subst = Substitute
(** The local logger *)
let log = Logging.regions_hierarchy_log
-let compute_regions_hierarchy_for_sig (meta : Meta.meta option)
+let compute_regions_hierarchy_for_sig (span : Meta.span option)
(type_decls : type_decl TypeDeclId.Map.t)
(fun_decls : fun_decl FunDeclId.Map.t)
(global_decls : global_decl GlobalDeclId.Map.t)
@@ -52,11 +52,11 @@ let compute_regions_hierarchy_for_sig (meta : Meta.meta option)
associated types) *)
let norm_ctx : AssociatedTypes.norm_ctx =
let norm_trait_types =
- AssociatedTypes.compute_norm_trait_types_from_preds meta
+ AssociatedTypes.compute_norm_trait_types_from_preds span
sg.preds.trait_type_constraints
in
{
- meta;
+ span;
norm_trait_types;
type_decls;
fun_decls;
@@ -108,8 +108,8 @@ let compute_regions_hierarchy_for_sig (meta : Meta.meta option)
let add_edge ~(short : region) ~(long : region) =
(* Sanity checks *)
- sanity_check_opt_meta __FILE__ __LINE__ (short <> RErased) meta;
- sanity_check_opt_meta __FILE__ __LINE__ (long <> RErased) meta;
+ sanity_check_opt_span __FILE__ __LINE__ (short <> RErased) span;
+ sanity_check_opt_span __FILE__ __LINE__ (long <> RErased) span;
(* Ignore the locally bound regions (at the level of arrow types for instance *)
match (short, long) with
| RBVar _, _ | _, RBVar _ -> ()
@@ -175,14 +175,14 @@ let compute_regions_hierarchy_for_sig (meta : Meta.meta option)
| TTraitType (trait_ref, _) ->
(* The trait should reference a clause, and not an implementation
(otherwise it should have been normalized) *)
- sanity_check_opt_meta __FILE__ __LINE__
+ sanity_check_opt_span __FILE__ __LINE__
(AssociatedTypes.trait_instance_id_is_local_clause trait_ref.trait_id)
- meta;
+ span;
(* We have nothing to do *)
()
| TArrow (regions, inputs, output) ->
(* TODO: *)
- cassert_opt_meta __FILE__ __LINE__ (regions = []) meta
+ cassert_opt_span __FILE__ __LINE__ (regions = []) span
"We don't support arrow types with locally quantified regions";
(* We can ignore the outer regions *)
List.iter (explore_ty []) (output :: inputs)
@@ -226,7 +226,7 @@ let compute_regions_hierarchy_for_sig (meta : Meta.meta option)
(SccId.Map.bindings sccs.sccs)
in
(* The SCC should only contain the 'static *)
- sanity_check_opt_meta __FILE__ __LINE__ (static_scc = [ RStatic ]) meta;
+ sanity_check_opt_span __FILE__ __LINE__ (static_scc = [ RStatic ]) span;
(* Remove the group as well as references to this group from the
other SCCs *)
let { sccs; scc_deps } = sccs in
@@ -282,7 +282,7 @@ let compute_regions_hierarchy_for_sig (meta : Meta.meta option)
(fun r ->
match r with
| RFVar rid -> RegionId.Map.find rid region_id_to_var_map
- | _ -> craise __FILE__ __LINE__ (Option.get meta) "Unreachable")
+ | _ -> craise __FILE__ __LINE__ (Option.get span) "Unreachable")
scc
in
@@ -323,7 +323,7 @@ let compute_regions_hierarchies (type_decls : type_decl TypeDeclId.Map.t)
List.map
(fun ((fid, d) : FunDeclId.id * fun_decl) ->
( FRegular fid,
- (Types.name_to_string env d.name, d.signature, Some d.item_meta.meta)
+ (Types.name_to_string env d.name, d.signature, Some d.item_meta.span)
))
(FunDeclId.Map.bindings fun_decls)
in
@@ -335,8 +335,8 @@ let compute_regions_hierarchies (type_decls : type_decl TypeDeclId.Map.t)
in
FunIdMap.of_list
(List.map
- (fun (fid, (name, sg, meta)) ->
+ (fun (fid, (name, sg, span)) ->
( fid,
- compute_regions_hierarchy_for_sig meta type_decls fun_decls
+ compute_regions_hierarchy_for_sig span type_decls fun_decls
global_decls trait_decls trait_impls name sg ))
(regular @ assumed))
diff --git a/compiler/Substitute.ml b/compiler/Substitute.ml
index 177d8c24..37ef6987 100644
--- a/compiler/Substitute.ml
+++ b/compiler/Substitute.ml
@@ -68,7 +68,7 @@ let ctx_adt_get_instantiated_field_types (ctx : eval_ctx)
**IMPORTANT**: this function doesn't normalize the types, you may want to
use the [AssociatedTypes] equivalent instead.
*)
-let ctx_adt_value_get_instantiated_field_types (meta : Meta.meta)
+let ctx_adt_value_get_instantiated_field_types (span : Meta.span)
(ctx : eval_ctx) (adt : adt_value) (id : type_id) (generics : generic_args)
: ty list =
match id with
@@ -76,19 +76,19 @@ let ctx_adt_value_get_instantiated_field_types (meta : Meta.meta)
(* Retrieve the types of the fields *)
ctx_adt_get_instantiated_field_types ctx id adt.variant_id generics
| TTuple ->
- cassert __FILE__ __LINE__ (generics.regions = []) meta
+ cassert __FILE__ __LINE__ (generics.regions = []) span
"Tuples don't have region parameters";
generics.types
| TAssumed aty -> (
match aty with
| TBox ->
- sanity_check __FILE__ __LINE__ (generics.regions = []) meta;
- sanity_check __FILE__ __LINE__ (List.length generics.types = 1) meta;
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.regions = []) span;
+ sanity_check __FILE__ __LINE__ (List.length generics.types = 1) span;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
generics.types
| TArray | TSlice | TStr ->
(* Those types don't have fields *)
- craise __FILE__ __LINE__ meta "Unreachable")
+ craise __FILE__ __LINE__ span "Unreachable")
(** Substitute a function signature, together with the regions hierarchy
associated to that signature.
@@ -138,41 +138,41 @@ let subst_ids_visitor (r_subst : RegionId.id -> RegionId.id)
method! visit_loan_id _ bid = bsubst bid
method! visit_symbolic_value_id _ id = ssubst id
- (** We *do* visit meta-values *)
+ (** We *do* visit span-values *)
method! visit_msymbolic_value env sv = self#visit_symbolic_value env sv
- (** We *do* visit meta-values *)
+ (** We *do* visit span-values *)
method! visit_mvalue env v = self#visit_typed_value env v
method! visit_abstraction_id _ id = asubst id
end
-let typed_value_subst_ids (meta : Meta.meta)
+let typed_value_subst_ids (span : Meta.span)
(r_subst : RegionId.id -> RegionId.id)
(ty_subst : TypeVarId.id -> TypeVarId.id)
(cg_subst : ConstGenericVarId.id -> ConstGenericVarId.id)
(ssubst : SymbolicValueId.id -> SymbolicValueId.id)
(bsubst : BorrowId.id -> BorrowId.id) (v : typed_value) : typed_value =
- let asubst _ = craise __FILE__ __LINE__ meta "Unreachable" in
+ let asubst _ = craise __FILE__ __LINE__ span "Unreachable" in
let vis = subst_ids_visitor r_subst ty_subst cg_subst ssubst bsubst asubst in
vis#visit_typed_value () v
-let typed_value_subst_rids (meta : Meta.meta)
+let typed_value_subst_rids (span : Meta.span)
(r_subst : RegionId.id -> RegionId.id) (v : typed_value) : typed_value =
- typed_value_subst_ids meta r_subst
+ typed_value_subst_ids span r_subst
(fun x -> x)
(fun x -> x)
(fun x -> x)
(fun x -> x)
v
-let typed_avalue_subst_ids (meta : Meta.meta)
+let typed_avalue_subst_ids (span : Meta.span)
(r_subst : RegionId.id -> RegionId.id)
(ty_subst : TypeVarId.id -> TypeVarId.id)
(cg_subst : ConstGenericVarId.id -> ConstGenericVarId.id)
(ssubst : SymbolicValueId.id -> SymbolicValueId.id)
(bsubst : BorrowId.id -> BorrowId.id) (v : typed_avalue) : typed_avalue =
- let asubst _ = craise __FILE__ __LINE__ meta "Unreachable" in
+ let asubst _ = craise __FILE__ __LINE__ span "Unreachable" in
let vis = subst_ids_visitor r_subst ty_subst cg_subst ssubst bsubst asubst in
vis#visit_typed_avalue () v
@@ -194,9 +194,9 @@ let env_subst_ids (r_subst : RegionId.id -> RegionId.id)
let vis = subst_ids_visitor r_subst ty_subst cg_subst ssubst bsubst asubst in
vis#visit_env () x
-let typed_avalue_subst_rids (meta : Meta.meta)
+let typed_avalue_subst_rids (span : Meta.span)
(r_subst : RegionId.id -> RegionId.id) (x : typed_avalue) : typed_avalue =
- let asubst _ = craise __FILE__ __LINE__ meta "Unreachable" in
+ let asubst _ = craise __FILE__ __LINE__ span "Unreachable" in
let vis =
subst_ids_visitor r_subst
(fun x -> x)
diff --git a/compiler/SymbolicAst.ml b/compiler/SymbolicAst.ml
index f15a2c23..e9143ab5 100644
--- a/compiler/SymbolicAst.ml
+++ b/compiler/SymbolicAst.ml
@@ -8,7 +8,7 @@ open Expressions
open Values
open LlbcAst
-(** "Meta"-place: a place stored as meta-data.
+(** "Meta"-place: a place stored as span-data.
Whenever we need to introduce new symbolic variables, for instance because
of symbolic expansions, we try to store a "place", which gives information
@@ -62,7 +62,7 @@ type call = {
(** Meta information for expressions, not necessary for synthesis but useful to
guide it to generate a pretty output.
*)
-type emeta =
+type espan =
| Assignment of Contexts.eval_ctx * mplace * typed_value * mplace option
(** We generated an assignment (destination, assigned value, src) *)
| Snapshot of Contexts.eval_ctx
@@ -92,8 +92,8 @@ class ['self] iter_expression_base =
fun _ _ -> ()
method visit_mplace : 'env -> mplace -> unit = fun _ _ -> ()
- method visit_emeta : 'env -> emeta -> unit = fun _ _ -> ()
- method visit_meta : 'env -> Meta.meta -> unit = fun _ _ -> ()
+ method visit_espan : 'env -> espan -> unit = fun _ _ -> ()
+ method visit_span : 'env -> Meta.span -> unit = fun _ _ -> ()
method visit_region_group_id_map
: 'a. ('env -> 'a -> unit) -> 'env -> 'a region_group_id_map -> unit =
@@ -155,7 +155,7 @@ type expression =
| Expansion of mplace option * symbolic_value * expansion
(** Expansion of a symbolic value.
- The place is "meta": it gives the path to the symbolic value (if available)
+ The place is "span": it gives the path to the symbolic value (if available)
which got expanded (this path is available when the symbolic expansion
comes from a path evaluation, during an assignment for instance).
We use it to compute meaningful names for the variables we introduce,
@@ -211,8 +211,8 @@ type expression =
The boolean is [true].
TODO: merge this with Return.
*)
- | Meta of emeta * expression (** Meta information *)
- | Error of Meta.meta option * string
+ | Meta of espan * expression (** Meta information *)
+ | Error of Meta.span option * string
and loop = {
loop_id : loop_id;
@@ -226,7 +226,7 @@ and loop = {
end_expr : expression;
(** The end of the function (upon the moment it enters the loop) *)
loop_expr : expression; (** The symbolically executed loop body *)
- meta : Meta.meta; (** Information about where the origin of the loop body *)
+ span : Meta.span; (** Information about where the origin of the loop body *)
}
and expansion =
diff --git a/compiler/SymbolicToPure.ml b/compiler/SymbolicToPure.ml
index 3e22d36b..8dfe0abe 100644
--- a/compiler/SymbolicToPure.ml
+++ b/compiler/SymbolicToPure.ml
@@ -144,7 +144,7 @@ type loop_info = {
(** Body synthesis context *)
type bs_ctx = {
(* TODO: there are a lot of duplications with the various decls ctx *)
- meta : Meta.meta; (** The meta information about the current declaration *)
+ span : Meta.span; (** The span information about the current declaration *)
decls_ctx : C.decls_ctx;
type_ctx : type_ctx;
fun_ctx : fun_ctx;
@@ -342,7 +342,7 @@ let symbolic_value_to_string (ctx : bs_ctx) (sv : V.symbolic_value) : string =
let typed_value_to_string (ctx : bs_ctx) (v : V.typed_value) : string =
let env = bs_ctx_to_fmt_env ctx in
- Print.Values.typed_value_to_string ~meta:(Some ctx.meta) env v
+ Print.Values.typed_value_to_string ~span:(Some ctx.span) env v
let pure_ty_to_string (ctx : bs_ctx) (ty : ty) : string =
let env = bs_ctx_to_pure_fmt_env ctx in
@@ -366,7 +366,7 @@ let pure_type_decl_to_string (ctx : bs_ctx) (def : type_decl) : string =
let texpression_to_string (ctx : bs_ctx) (e : texpression) : string =
let env = bs_ctx_to_pure_fmt_env ctx in
- PrintPure.texpression_to_string ~metadata:(Some ctx.meta) env false "" " " e
+ PrintPure.texpression_to_string ~spandata:(Some ctx.span) env false "" " " e
let fun_id_to_string (ctx : bs_ctx) (id : A.fun_id) : string =
let env = bs_ctx_to_fmt_env ctx in
@@ -382,7 +382,7 @@ let fun_decl_to_string (ctx : bs_ctx) (def : Pure.fun_decl) : string =
let typed_pattern_to_string (ctx : bs_ctx) (p : Pure.typed_pattern) : string =
let env = bs_ctx_to_pure_fmt_env ctx in
- PrintPure.typed_pattern_to_string ~meta:(Some ctx.meta) env p
+ PrintPure.typed_pattern_to_string ~span:(Some ctx.span) env p
let ctx_get_effect_info_for_bid (ctx : bs_ctx) (bid : RegionGroupId.id option) :
fun_effect_info =
@@ -401,7 +401,7 @@ let abs_to_string (ctx : bs_ctx) (abs : V.abs) : string =
let verbose = false in
let indent = "" in
let indent_incr = " " in
- Print.Values.abs_to_string ~meta:(Some ctx.meta) env verbose indent
+ Print.Values.abs_to_string ~span:(Some ctx.span) env verbose indent
indent_incr abs
let bs_ctx_lookup_llbc_type_decl (id : TypeDeclId.id) (ctx : bs_ctx) :
@@ -414,44 +414,44 @@ let bs_ctx_lookup_llbc_fun_decl (id : A.FunDeclId.id) (ctx : bs_ctx) :
(* Some generic translation functions (we need to translate different "flavours"
of types: forward types, backward types, etc.) *)
-let rec translate_generic_args (meta : Meta.meta) (translate_ty : T.ty -> ty)
+let rec translate_generic_args (span : Meta.span) (translate_ty : T.ty -> ty)
(generics : T.generic_args) : generic_args =
(* We ignore the regions: if they didn't cause trouble for the symbolic execution,
then everything's fine *)
let types = List.map translate_ty generics.types in
let const_generics = generics.const_generics in
let trait_refs =
- List.map (translate_trait_ref meta translate_ty) generics.trait_refs
+ List.map (translate_trait_ref span translate_ty) generics.trait_refs
in
{ types; const_generics; trait_refs }
-and translate_trait_ref (meta : Meta.meta) (translate_ty : T.ty -> ty)
+and translate_trait_ref (span : Meta.span) (translate_ty : T.ty -> ty)
(tr : T.trait_ref) : trait_ref =
- let trait_id = translate_trait_instance_id meta translate_ty tr.trait_id in
- let generics = translate_generic_args meta translate_ty tr.generics in
+ let trait_id = translate_trait_instance_id span translate_ty tr.trait_id in
+ let generics = translate_generic_args span translate_ty tr.generics in
let trait_decl_ref =
- translate_trait_decl_ref meta translate_ty tr.trait_decl_ref
+ translate_trait_decl_ref span translate_ty tr.trait_decl_ref
in
{ trait_id; generics; trait_decl_ref }
-and translate_trait_decl_ref (meta : Meta.meta) (translate_ty : T.ty -> ty)
+and translate_trait_decl_ref (span : Meta.span) (translate_ty : T.ty -> ty)
(tr : T.trait_decl_ref) : trait_decl_ref =
let decl_generics =
- translate_generic_args meta translate_ty tr.decl_generics
+ translate_generic_args span translate_ty tr.decl_generics
in
{ trait_decl_id = tr.trait_decl_id; decl_generics }
-and translate_trait_instance_id (meta : Meta.meta) (translate_ty : T.ty -> ty)
+and translate_trait_instance_id (span : Meta.span) (translate_ty : T.ty -> ty)
(id : T.trait_instance_id) : trait_instance_id =
let translate_trait_instance_id =
- translate_trait_instance_id meta translate_ty
+ translate_trait_instance_id span translate_ty
in
match id with
| T.Self -> Self
| TraitImpl id -> TraitImpl id
| BuiltinOrAuto _ ->
(* We should have eliminated those in the prepasses *)
- craise __FILE__ __LINE__ meta "Unreachable"
+ craise __FILE__ __LINE__ span "Unreachable"
| Clause id -> Clause id
| ParentClause (inst_id, decl_id, clause_id) ->
let inst_id = translate_trait_instance_id inst_id in
@@ -459,22 +459,22 @@ and translate_trait_instance_id (meta : Meta.meta) (translate_ty : T.ty -> ty)
| ItemClause (inst_id, decl_id, item_name, clause_id) ->
let inst_id = translate_trait_instance_id inst_id in
ItemClause (inst_id, decl_id, item_name, clause_id)
- | TraitRef tr -> TraitRef (translate_trait_ref meta translate_ty tr)
+ | TraitRef tr -> TraitRef (translate_trait_ref span translate_ty tr)
| FnPointer _ | Closure _ ->
- craise __FILE__ __LINE__ meta "Closures are not supported yet"
- | Unsolved _ -> craise __FILE__ __LINE__ meta "Couldn't solve trait bound"
- | UnknownTrait s -> craise __FILE__ __LINE__ meta ("Unknown trait found: " ^ s)
+ craise __FILE__ __LINE__ span "Closures are not supported yet"
+ | Unsolved _ -> craise __FILE__ __LINE__ span "Couldn't solve trait bound"
+ | UnknownTrait s -> craise __FILE__ __LINE__ span ("Unknown trait found: " ^ s)
(** Translate a signature type - TODO: factor out the different translation functions *)
-let rec translate_sty (meta : Meta.meta) (ty : T.ty) : ty =
+let rec translate_sty (span : Meta.span) (ty : T.ty) : ty =
let translate = translate_sty in
match ty with
| T.TAdt (type_id, generics) -> (
- let generics = translate_sgeneric_args meta generics in
+ let generics = translate_sgeneric_args span generics in
match type_id with
| T.TAdtId adt_id -> TAdt (TAdtId adt_id, generics)
| T.TTuple ->
- sanity_check __FILE__ __LINE__ (generics.const_generics = []) meta;
+ sanity_check __FILE__ __LINE__ (generics.const_generics = []) span;
mk_simpl_tuple_ty generics.types
| T.TAssumed aty -> (
match aty with
@@ -483,87 +483,87 @@ let rec translate_sty (meta : Meta.meta) (ty : T.ty) : ty =
match generics.types with
| [ ty ] -> ty
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Box/vec/option type with incorrect number of arguments")
| T.TArray -> TAdt (TAssumed TArray, generics)
| T.TSlice -> TAdt (TAssumed TSlice, generics)
| T.TStr -> TAdt (TAssumed TStr, generics)))
| TVar vid -> TVar vid
| TLiteral ty -> TLiteral ty
- | TNever -> craise __FILE__ __LINE__ meta "Unreachable"
- | TRef (_, rty, _) -> translate meta rty
+ | TNever -> craise __FILE__ __LINE__ span "Unreachable"
+ | TRef (_, rty, _) -> translate span rty
| TRawPtr (ty, rkind) ->
let mut = match rkind with RMut -> Mut | RShared -> Const in
- let ty = translate meta ty in
+ let ty = translate span ty in
let generics = { types = [ ty ]; const_generics = []; trait_refs = [] } in
TAdt (TAssumed (TRawPtr mut), generics)
| TTraitType (trait_ref, type_name) ->
- let trait_ref = translate_strait_ref meta trait_ref in
+ let trait_ref = translate_strait_ref span trait_ref in
TTraitType (trait_ref, type_name)
| TArrow _ ->
- craise __FILE__ __LINE__ meta "Arrow types are not supported yet"
+ craise __FILE__ __LINE__ span "Arrow types are not supported yet"
-and translate_sgeneric_args (meta : Meta.meta) (generics : T.generic_args) :
+and translate_sgeneric_args (span : Meta.span) (generics : T.generic_args) :
generic_args =
- translate_generic_args meta (translate_sty meta) generics
+ translate_generic_args span (translate_sty span) generics
-and translate_strait_ref (meta : Meta.meta) (tr : T.trait_ref) : trait_ref =
- translate_trait_ref meta (translate_sty meta) tr
+and translate_strait_ref (span : Meta.span) (tr : T.trait_ref) : trait_ref =
+ translate_trait_ref span (translate_sty span) tr
-and translate_strait_instance_id (meta : Meta.meta) (id : T.trait_instance_id) :
+and translate_strait_instance_id (span : Meta.span) (id : T.trait_instance_id) :
trait_instance_id =
- translate_trait_instance_id meta (translate_sty meta) id
+ translate_trait_instance_id span (translate_sty span) id
-let translate_trait_clause (meta : Meta.meta) (clause : T.trait_clause) :
+let translate_trait_clause (span : Meta.span) (clause : T.trait_clause) :
trait_clause =
- let { T.clause_id; meta = _; trait_id; clause_generics } = clause in
- let generics = translate_sgeneric_args meta clause_generics in
+ let { T.clause_id; span = _; trait_id; clause_generics } = clause in
+ let generics = translate_sgeneric_args span clause_generics in
{ clause_id; trait_id; generics }
-let translate_strait_type_constraint (meta : Meta.meta)
+let translate_strait_type_constraint (span : Meta.span)
(ttc : T.trait_type_constraint) : trait_type_constraint =
let { T.trait_ref; type_name; ty } = ttc in
- let trait_ref = translate_strait_ref meta trait_ref in
- let ty = translate_sty meta ty in
+ let trait_ref = translate_strait_ref span trait_ref in
+ let ty = translate_sty span ty in
{ trait_ref; type_name; ty }
-let translate_predicates (meta : Meta.meta) (preds : T.predicates) : predicates
+let translate_predicates (span : Meta.span) (preds : T.predicates) : predicates
=
let trait_type_constraints =
List.map
- (translate_strait_type_constraint meta)
+ (translate_strait_type_constraint span)
preds.trait_type_constraints
in
{ trait_type_constraints }
-let translate_generic_params (meta : Meta.meta) (generics : T.generic_params) :
+let translate_generic_params (span : Meta.span) (generics : T.generic_params) :
generic_params =
let { T.regions = _; types; const_generics; trait_clauses } = generics in
- let trait_clauses = List.map (translate_trait_clause meta) trait_clauses in
+ let trait_clauses = List.map (translate_trait_clause span) trait_clauses in
{ types; const_generics; trait_clauses }
-let translate_field (meta : Meta.meta) (f : T.field) : field =
+let translate_field (span : Meta.span) (f : T.field) : field =
let field_name = f.field_name in
- let field_ty = translate_sty meta f.field_ty in
+ let field_ty = translate_sty span f.field_ty in
{ field_name; field_ty }
-let translate_fields (meta : Meta.meta) (fl : T.field list) : field list =
- List.map (translate_field meta) fl
+let translate_fields (span : Meta.span) (fl : T.field list) : field list =
+ List.map (translate_field span) fl
-let translate_variant (meta : Meta.meta) (v : T.variant) : variant =
+let translate_variant (span : Meta.span) (v : T.variant) : variant =
let variant_name = v.variant_name in
- let fields = translate_fields meta v.fields in
+ let fields = translate_fields span v.fields in
{ variant_name; fields }
-let translate_variants (meta : Meta.meta) (vl : T.variant list) : variant list =
- List.map (translate_variant meta) vl
+let translate_variants (span : Meta.span) (vl : T.variant list) : variant list =
+ List.map (translate_variant span) vl
(** Translate a type def kind from LLBC *)
-let translate_type_decl_kind (meta : Meta.meta) (kind : T.type_decl_kind) :
+let translate_type_decl_kind (span : Meta.span) (kind : T.type_decl_kind) :
type_decl_kind =
match kind with
- | T.Struct fields -> Struct (translate_fields meta fields)
- | T.Enum variants -> Enum (translate_variants meta variants)
+ | T.Struct fields -> Struct (translate_fields span fields)
+ | T.Enum variants -> Enum (translate_variants span variants)
| T.Opaque -> Opaque
(** Translate a type definition from LLBC
@@ -585,29 +585,29 @@ let translate_type_decl (ctx : Contexts.decls_ctx) (def : T.type_decl) :
let name = Print.Types.name_to_string env def.name in
let { T.regions; types; const_generics; trait_clauses } = def.generics in
(* Can't translate types with regions for now *)
- cassert __FILE__ __LINE__ (regions = []) def.item_meta.meta
+ cassert __FILE__ __LINE__ (regions = []) def.item_meta.span
"ADTs containing borrows are not supported yet";
let trait_clauses =
- List.map (translate_trait_clause def.item_meta.meta) trait_clauses
+ List.map (translate_trait_clause def.item_meta.span) trait_clauses
in
let generics = { types; const_generics; trait_clauses } in
- let kind = translate_type_decl_kind def.item_meta.meta def.T.kind in
- let preds = translate_predicates def.item_meta.meta def.preds in
+ let kind = translate_type_decl_kind def.item_meta.span def.T.kind in
+ let preds = translate_predicates def.item_meta.span def.preds in
let is_local = def.is_local in
- let meta = def.item_meta.meta in
+ let span = def.item_meta.span in
{
def_id;
is_local;
llbc_name;
name;
- meta;
+ span;
generics;
llbc_generics = def.generics;
kind;
preds;
}
-let translate_type_id (meta : Meta.meta) (id : T.type_id) : type_id =
+let translate_type_id (span : Meta.span) (id : T.type_id) : type_id =
match id with
| TAdtId adt_id -> TAdtId adt_id
| TAssumed aty ->
@@ -619,7 +619,7 @@ let translate_type_id (meta : Meta.meta) (id : T.type_id) : type_id =
| T.TBox ->
(* Boxes have to be eliminated: this type id shouldn't
be translated *)
- craise __FILE__ __LINE__ meta "Unexpected box type"
+ craise __FILE__ __LINE__ span "Unexpected box type"
in
TAssumed aty
| TTuple -> TTuple
@@ -632,16 +632,16 @@ let translate_type_id (meta : Meta.meta) (id : T.type_id) : type_id =
TODO: factor out the various translation functions.
*)
-let rec translate_fwd_ty (meta : Meta.meta) (type_infos : type_infos)
+let rec translate_fwd_ty (span : Meta.span) (type_infos : type_infos)
(ty : T.ty) : ty =
- let translate = translate_fwd_ty meta type_infos in
+ let translate = translate_fwd_ty span type_infos in
match ty with
| T.TAdt (type_id, generics) -> (
- let t_generics = translate_fwd_generic_args meta type_infos generics in
+ let t_generics = translate_fwd_generic_args span type_infos generics in
(* Eliminate boxes and simplify tuples *)
match type_id with
| TAdtId _ | TAssumed (TArray | TSlice | TStr) ->
- let type_id = translate_type_id meta type_id in
+ let type_id = translate_type_id span type_id in
TAdt (type_id, t_generics)
| TTuple ->
(* Note that if there is exactly one type, [mk_simpl_tuple_ty] is the
@@ -655,15 +655,15 @@ let rec translate_fwd_ty (meta : Meta.meta) (type_infos : type_infos)
(List.exists
(TypesUtils.ty_has_borrows type_infos)
generics.types))
- meta "ADTs containing borrows are not supported yet";
+ span "ADTs containing borrows are not supported yet";
match t_generics.types with
| [ bty ] -> bty
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Unreachable: box/vec/option receives exactly one type \
parameter"))
| TVar vid -> TVar vid
- | TNever -> craise __FILE__ __LINE__ meta "Unreachable"
+ | TNever -> craise __FILE__ __LINE__ span "Unreachable"
| TLiteral lty -> TLiteral lty
| TRef (_, rty, _) -> translate rty
| TRawPtr (ty, rkind) ->
@@ -672,33 +672,33 @@ let rec translate_fwd_ty (meta : Meta.meta) (type_infos : type_infos)
let generics = { types = [ ty ]; const_generics = []; trait_refs = [] } in
TAdt (TAssumed (TRawPtr mut), generics)
| TTraitType (trait_ref, type_name) ->
- let trait_ref = translate_fwd_trait_ref meta type_infos trait_ref in
+ let trait_ref = translate_fwd_trait_ref span type_infos trait_ref in
TTraitType (trait_ref, type_name)
| TArrow _ ->
- craise __FILE__ __LINE__ meta "Arrow types are not supported yet"
+ craise __FILE__ __LINE__ span "Arrow types are not supported yet"
-and translate_fwd_generic_args (meta : Meta.meta) (type_infos : type_infos)
+and translate_fwd_generic_args (span : Meta.span) (type_infos : type_infos)
(generics : T.generic_args) : generic_args =
- translate_generic_args meta (translate_fwd_ty meta type_infos) generics
+ translate_generic_args span (translate_fwd_ty span type_infos) generics
-and translate_fwd_trait_ref (meta : Meta.meta) (type_infos : type_infos)
+and translate_fwd_trait_ref (span : Meta.span) (type_infos : type_infos)
(tr : T.trait_ref) : trait_ref =
- translate_trait_ref meta (translate_fwd_ty meta type_infos) tr
+ translate_trait_ref span (translate_fwd_ty span type_infos) tr
-and translate_fwd_trait_instance_id (meta : Meta.meta) (type_infos : type_infos)
+and translate_fwd_trait_instance_id (span : Meta.span) (type_infos : type_infos)
(id : T.trait_instance_id) : trait_instance_id =
- translate_trait_instance_id meta (translate_fwd_ty meta type_infos) id
+ translate_trait_instance_id span (translate_fwd_ty span type_infos) id
(** Simply calls [translate_fwd_ty] *)
let ctx_translate_fwd_ty (ctx : bs_ctx) (ty : T.ty) : ty =
let type_infos = ctx.type_ctx.type_infos in
- translate_fwd_ty ctx.meta type_infos ty
+ translate_fwd_ty ctx.span type_infos ty
(** Simply calls [translate_fwd_generic_args] *)
let ctx_translate_fwd_generic_args (ctx : bs_ctx) (generics : T.generic_args) :
generic_args =
let type_infos = ctx.type_ctx.type_infos in
- translate_fwd_generic_args ctx.meta type_infos generics
+ translate_fwd_generic_args ctx.span type_infos generics
(** Translate a type, when some regions may have ended.
@@ -706,22 +706,22 @@ let ctx_translate_fwd_generic_args (ctx : bs_ctx) (generics : T.generic_args) :
[inside_mut]: are we inside a mutable borrow?
*)
-let rec translate_back_ty (meta : Meta.meta) (type_infos : type_infos)
+let rec translate_back_ty (span : Meta.span) (type_infos : type_infos)
(keep_region : T.region -> bool) (inside_mut : bool) (ty : T.ty) : ty option
=
- let translate = translate_back_ty meta type_infos keep_region inside_mut in
+ let translate = translate_back_ty span type_infos keep_region inside_mut in
(* A small helper for "leave" types *)
let wrap ty = if inside_mut then Some ty else None in
match ty with
| T.TAdt (type_id, generics) -> (
match type_id with
| TAdtId _ | TAssumed (TArray | TSlice | TStr) ->
- let type_id = translate_type_id meta type_id in
+ let type_id = translate_type_id span type_id in
if inside_mut then
(* We do not want to filter anything, so we translate the generics
as "forward" types *)
let generics =
- translate_fwd_generic_args meta type_infos generics
+ translate_fwd_generic_args span type_infos generics
in
Some (TAdt (type_id, generics))
else
@@ -734,7 +734,7 @@ let rec translate_back_ty (meta : Meta.meta) (type_infos : type_infos)
let types = List.filter_map translate generics.types in
if types <> [] then
let generics =
- translate_fwd_generic_args meta type_infos generics
+ translate_fwd_generic_args span type_infos generics
in
Some (TAdt (type_id, generics))
else None
@@ -742,12 +742,12 @@ let rec translate_back_ty (meta : Meta.meta) (type_infos : type_infos)
(* Don't accept ADTs (which are not tuples) with borrows for now *)
cassert __FILE__ __LINE__
(not (TypesUtils.ty_has_borrows type_infos ty))
- meta "ADTs containing borrows are not supported yet";
+ span "ADTs containing borrows are not supported yet";
(* Eliminate the box *)
match generics.types with
| [ bty ] -> translate bty
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Unreachable: boxes receive exactly one type parameter")
| TTuple -> (
(* Tuples can contain borrows (which we eliminate) *)
@@ -759,7 +759,7 @@ let rec translate_back_ty (meta : Meta.meta) (type_infos : type_infos)
* is the identity *)
Some (mk_simpl_tuple_ty tys_t)))
| TVar vid -> wrap (TVar vid)
- | TNever -> craise __FILE__ __LINE__ meta "Unreachable"
+ | TNever -> craise __FILE__ __LINE__ span "Unreachable"
| TLiteral lty -> wrap (TLiteral lty)
| TRef (r, rty, rkind) -> (
match rkind with
@@ -770,7 +770,7 @@ let rec translate_back_ty (meta : Meta.meta) (type_infos : type_infos)
(* Dive in, remembering the fact that we are inside a mutable borrow *)
let inside_mut = true in
if keep_region r then
- translate_back_ty meta type_infos keep_region inside_mut rty
+ translate_back_ty span type_infos keep_region inside_mut rty
else None)
| TRawPtr _ ->
(* TODO: not sure what to do here *)
@@ -781,17 +781,17 @@ let rec translate_back_ty (meta : Meta.meta) (type_infos : type_infos)
if inside_mut then
(* Translate the trait ref as a "forward" trait ref -
we do not want to filter any type *)
- let trait_ref = translate_fwd_trait_ref meta type_infos trait_ref in
+ let trait_ref = translate_fwd_trait_ref span type_infos trait_ref in
Some (TTraitType (trait_ref, type_name))
else None
| TArrow _ ->
- craise __FILE__ __LINE__ meta "Arrow types are not supported yet"
+ craise __FILE__ __LINE__ span "Arrow types are not supported yet"
(** Simply calls [translate_back_ty] *)
let ctx_translate_back_ty (ctx : bs_ctx) (keep_region : 'r -> bool)
(inside_mut : bool) (ty : T.ty) : ty option =
let type_infos = ctx.type_ctx.type_infos in
- translate_back_ty ctx.meta type_infos keep_region inside_mut ty
+ translate_back_ty ctx.span type_infos keep_region inside_mut ty
let mk_type_check_ctx (ctx : bs_ctx) : PureTypeCheck.tc_ctx =
let const_generics =
@@ -810,16 +810,16 @@ let mk_type_check_ctx (ctx : bs_ctx) : PureTypeCheck.tc_ctx =
}
let type_check_pattern (ctx : bs_ctx) (v : typed_pattern) : unit =
- let meta = ctx.meta in
+ let span = ctx.span in
let ctx = mk_type_check_ctx ctx in
- let _ = PureTypeCheck.check_typed_pattern meta ctx v in
+ let _ = PureTypeCheck.check_typed_pattern span ctx v in
()
let type_check_texpression (ctx : bs_ctx) (e : texpression) : unit =
if !Config.type_check_pure_code then
- let meta = ctx.meta in
+ let span = ctx.span in
let ctx = mk_type_check_ctx ctx in
- PureTypeCheck.check_texpression meta ctx e
+ PureTypeCheck.check_texpression span ctx e
let translate_fun_id_or_trait_method_ref (ctx : bs_ctx)
(id : A.fun_id_or_trait_method_ref) : fun_id_or_trait_method_ref =
@@ -827,7 +827,7 @@ let translate_fun_id_or_trait_method_ref (ctx : bs_ctx)
| FunId fun_id -> FunId fun_id
| TraitMethod (trait_ref, method_name, fun_decl_id) ->
let type_infos = ctx.type_ctx.type_infos in
- let trait_ref = translate_fwd_trait_ref ctx.meta type_infos trait_ref in
+ let trait_ref = translate_fwd_trait_ref ctx.span type_infos trait_ref in
TraitMethod (trait_ref, method_name, fun_decl_id)
let bs_ctx_register_forward_call (call_id : V.FunCallId.id) (forward : S.call)
@@ -837,7 +837,7 @@ let bs_ctx_register_forward_call (call_id : V.FunCallId.id) (forward : S.call)
let calls = ctx.calls in
sanity_check __FILE__ __LINE__
(not (V.FunCallId.Map.mem call_id calls))
- ctx.meta;
+ ctx.span;
let info = { forward; forward_inputs = args; back_funs } in
let calls = V.FunCallId.Map.add call_id info calls in
{ ctx with calls }
@@ -861,7 +861,7 @@ let bs_ctx_register_backward_call (abs : V.abs) (call_id : V.FunCallId.id)
let abstractions = ctx.abstractions in
sanity_check __FILE__ __LINE__
(not (V.AbstractionId.Map.mem abs.abs_id abstractions))
- ctx.meta;
+ ctx.span;
let abstractions =
V.AbstractionId.Map.add abs.abs_id (abs, back_args) abstractions
in
@@ -923,7 +923,7 @@ let mk_fuel_input_as_list (ctx : bs_ctx) (info : fun_effect_info) :
if function_uses_fuel info then [ mk_fuel_texpression ctx.fuel ] else []
(** Small utility. *)
-let compute_raw_fun_effect_info (meta : Meta.meta)
+let compute_raw_fun_effect_info (span : Meta.span)
(fun_infos : fun_info A.FunDeclId.Map.t)
(fun_id : A.fun_id_or_trait_method_ref) (lid : V.LoopId.id option)
(gid : T.RegionGroupId.id option) : fun_effect_info =
@@ -942,7 +942,7 @@ let compute_raw_fun_effect_info (meta : Meta.meta)
is_rec = info.is_rec || Option.is_some lid;
}
| FunId (FAssumed aid) ->
- sanity_check __FILE__ __LINE__ (lid = None) meta;
+ sanity_check __FILE__ __LINE__ (lid = None) span;
{
can_fail = Assumed.assumed_fun_can_fail aid;
stateful_group = false;
@@ -967,20 +967,20 @@ let get_fun_effect_info (ctx : bs_ctx) (fun_id : A.fun_id_or_trait_method_ref)
in
{ info with is_rec = info.is_rec || Option.is_some lid }
| FunId (FAssumed _) ->
- compute_raw_fun_effect_info ctx.meta ctx.fun_ctx.fun_infos fun_id lid
+ compute_raw_fun_effect_info ctx.span ctx.fun_ctx.fun_infos fun_id lid
gid)
| Some lid -> (
(* This is necessarily for the current function *)
match fun_id with
| FunId (FRegular fid) -> (
- sanity_check __FILE__ __LINE__ (fid = ctx.fun_decl.def_id) ctx.meta;
+ sanity_check __FILE__ __LINE__ (fid = ctx.fun_decl.def_id) ctx.span;
(* Lookup the loop *)
let lid = V.LoopId.Map.find lid ctx.loop_ids_map in
let loop_info = LoopId.Map.find lid ctx.loops in
match gid with
| None -> loop_info.fwd_effect_info
| Some gid -> RegionGroupId.Map.find gid loop_info.back_effect_infos)
- | _ -> craise __FILE__ __LINE__ ctx.meta "Unreachable")
+ | _ -> craise __FILE__ __LINE__ ctx.span "Unreachable")
(** Translate a function signature to a decomposed function signature.
@@ -993,7 +993,7 @@ let get_fun_effect_info (ctx : bs_ctx) (fun_id : A.fun_id_or_trait_method_ref)
We use [bid] ("backward function id") only if we split the forward
and the backward functions.
*)
-let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
+let translate_fun_sig_with_regions_hierarchy_to_decomposed (span : Meta.span)
(decls_ctx : C.decls_ctx) (fun_id : A.fun_id_or_trait_method_ref)
(regions_hierarchy : T.region_var_groups) (sg : A.fun_sig)
(input_names : string option list) : decomposed_fun_sig =
@@ -1009,18 +1009,18 @@ let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
List.map (fun (g : T.region_var_group) -> g.id) regions_hierarchy
in
let ctx =
- InterpreterUtils.initialize_eval_ctx meta decls_ctx region_groups
+ InterpreterUtils.initialize_eval_ctx span decls_ctx region_groups
sg.generics.types sg.generics.const_generics
in
(* Compute the normalization map for the *sty* types and add it to the context *)
- AssociatedTypes.ctx_add_norm_trait_types_from_preds meta ctx
+ AssociatedTypes.ctx_add_norm_trait_types_from_preds span ctx
sg.preds.trait_type_constraints
in
(* Normalize the signature *)
let sg =
let ({ A.inputs; output; _ } : A.fun_sig) = sg in
- let norm = AssociatedTypes.ctx_normalize_ty meta ctx in
+ let norm = AssociatedTypes.ctx_normalize_ty span ctx in
let inputs = List.map norm inputs in
let output = norm output in
{ sg with A.inputs; output }
@@ -1028,12 +1028,12 @@ let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
(* Is the forward function stateful, and can it fail? *)
let fwd_effect_info =
- compute_raw_fun_effect_info meta fun_infos fun_id None None
+ compute_raw_fun_effect_info span fun_infos fun_id None None
in
(* Compute the forward inputs *)
let fwd_fuel = mk_fuel_input_ty_as_list fwd_effect_info in
let fwd_inputs_no_fuel_no_state =
- List.map (translate_fwd_ty meta type_infos) sg.inputs
+ List.map (translate_fwd_ty span type_infos) sg.inputs
in
(* State input for the forward function *)
let fwd_state_ty =
@@ -1045,7 +1045,7 @@ let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
List.concat [ fwd_fuel; fwd_inputs_no_fuel_no_state; fwd_state_ty ]
in
(* Compute the backward output, without the effect information *)
- let fwd_output = translate_fwd_ty meta type_infos sg.output in
+ let fwd_output = translate_fwd_ty span type_infos sg.output in
(* Compute the type information for the backward function *)
(* Small helper to translate types for backward functions *)
@@ -1067,12 +1067,12 @@ let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
let keep_region r =
match r with
| T.RStatic -> raise Unimplemented
- | RErased -> craise __FILE__ __LINE__ meta "Unexpected erased region"
- | RBVar _ -> craise __FILE__ __LINE__ meta "Unexpected bound region"
+ | RErased -> craise __FILE__ __LINE__ span "Unexpected erased region"
+ | RBVar _ -> craise __FILE__ __LINE__ span "Unexpected bound region"
| RFVar rid -> T.RegionId.Set.mem rid gr_regions
in
let inside_mut = false in
- translate_back_ty meta type_infos keep_region inside_mut ty
+ translate_back_ty span type_infos keep_region inside_mut ty
in
let translate_back_inputs_for_gid (gid : T.RegionGroupId.id) : ty list =
(* For now we don't supported nested borrows, so we check that there
@@ -1080,7 +1080,7 @@ let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
let parents = list_ancestor_region_groups regions_hierarchy gid in
cassert __FILE__ __LINE__
(T.RegionGroupId.Set.is_empty parents)
- meta "Nested borrows are not supported yet";
+ span "Nested borrows are not supported yet";
(* For now, we don't allow nested borrows, so the additional inputs to the
backward function can only come from borrows that were returned like
in (for the backward function we introduce for 'a):
@@ -1148,7 +1148,7 @@ let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
RegionGroupId.id * back_sg_info =
let gid = rg.id in
let back_effect_info =
- compute_raw_fun_effect_info meta fun_infos fun_id None (Some gid)
+ compute_raw_fun_effect_info span fun_infos fun_id None (Some gid)
in
let inputs_no_state = translate_back_inputs_for_gid gid in
let inputs_no_state =
@@ -1237,15 +1237,15 @@ let translate_fun_sig_with_regions_hierarchy_to_decomposed (meta : Meta.meta)
else false
in
let info = { fwd_info; effect_info = fwd_effect_info; ignore_output } in
- sanity_check __FILE__ __LINE__ (fun_sig_info_is_wf info) meta;
+ sanity_check __FILE__ __LINE__ (fun_sig_info_is_wf info) span;
info
in
(* Generic parameters *)
- let generics = translate_generic_params meta sg.generics in
+ let generics = translate_generic_params span sg.generics in
(* Return *)
- let preds = translate_predicates meta sg.preds in
+ let preds = translate_predicates span sg.preds in
{
generics;
llbc_generics = sg.generics;
@@ -1263,10 +1263,10 @@ let translate_fun_sig_to_decomposed (decls_ctx : C.decls_ctx)
let regions_hierarchy =
FunIdMap.find (FRegular fun_id) decls_ctx.fun_ctx.regions_hierarchies
in
- let meta =
- (FunDeclId.Map.find fun_id decls_ctx.fun_ctx.fun_decls).item_meta.meta
+ let span =
+ (FunDeclId.Map.find fun_id decls_ctx.fun_ctx.fun_decls).item_meta.span
in
- translate_fun_sig_with_regions_hierarchy_to_decomposed meta decls_ctx
+ translate_fun_sig_with_regions_hierarchy_to_decomposed span decls_ctx
(FunId (FRegular fun_id)) regions_hierarchy sg input_names
let translate_fun_sig_from_decl_to_decomposed (decls_ctx : C.decls_ctx)
@@ -1546,18 +1546,18 @@ let lookup_var_for_symbolic_value (sv : V.symbolic_value) (ctx : bs_ctx) : var =
match V.SymbolicValueId.Map.find_opt sv.sv_id ctx.sv_to_var with
| Some v -> v
| None ->
- craise __FILE__ __LINE__ ctx.meta
+ craise __FILE__ __LINE__ ctx.span
("Could not find var for symbolic value: "
^ V.SymbolicValueId.to_string sv.sv_id)
(** Peel boxes as long as the value is of the form [Box<T>] *)
-let rec unbox_typed_value (meta : Meta.meta) (v : V.typed_value) : V.typed_value
+let rec unbox_typed_value (span : Meta.span) (v : V.typed_value) : V.typed_value
=
match (v.value, v.ty) with
| V.VAdt av, T.TAdt (T.TAssumed T.TBox, _) -> (
match av.field_values with
- | [ bv ] -> unbox_typed_value meta bv
- | _ -> craise __FILE__ __LINE__ meta "Unreachable")
+ | [ bv ] -> unbox_typed_value span bv
+ | _ -> craise __FILE__ __LINE__ span "Unreachable")
| _ -> v
(** Translate a symbolic value.
@@ -1596,7 +1596,7 @@ let symbolic_value_to_texpression (ctx : bs_ctx) (sv : V.symbolic_value) :
let rec typed_value_to_texpression (ctx : bs_ctx) (ectx : C.eval_ctx)
(v : V.typed_value) : texpression =
(* We need to ignore boxes *)
- let v = unbox_typed_value ctx.meta v in
+ let v = unbox_typed_value ctx.span v in
let translate = typed_value_to_texpression ctx ectx in
(* Translate the type *)
let ty = ctx_translate_fwd_ty ctx v.ty in
@@ -1610,12 +1610,12 @@ let rec typed_value_to_texpression (ctx : bs_ctx) (ectx : C.eval_ctx)
(* Eliminate the tuple wrapper if it is a tuple with exactly one field *)
match v.ty with
| TAdt (TTuple, _) ->
- sanity_check __FILE__ __LINE__ (variant_id = None) ctx.meta;
- mk_simpl_tuple_texpression ctx.meta field_values
+ sanity_check __FILE__ __LINE__ (variant_id = None) ctx.span;
+ mk_simpl_tuple_texpression ctx.span field_values
| _ ->
(* Retrieve the type and the translated generics from the translated
type (simpler this way) *)
- let adt_id, generics = ty_as_adt ctx.meta ty in
+ let adt_id, generics = ty_as_adt ctx.span ty in
(* Create the constructor *)
let qualif_id = AdtCons { adt_id; variant_id = av.variant_id } in
let qualif = { id = qualif_id; generics } in
@@ -1626,26 +1626,26 @@ let rec typed_value_to_texpression (ctx : bs_ctx) (ectx : C.eval_ctx)
let cons_ty = mk_arrows field_tys ty in
let cons = { e = cons_e; ty = cons_ty } in
(* Apply the constructor *)
- mk_apps ctx.meta cons field_values)
- | VBottom -> craise __FILE__ __LINE__ ctx.meta "Unexpected bottom value"
+ mk_apps ctx.span cons field_values)
+ | VBottom -> craise __FILE__ __LINE__ ctx.span "Unexpected bottom value"
| VLoan lc -> (
match lc with
| VSharedLoan (_, v) -> translate v
- | VMutLoan _ -> craise __FILE__ __LINE__ ctx.meta "Unreachable")
+ | VMutLoan _ -> craise __FILE__ __LINE__ ctx.span "Unreachable")
| VBorrow bc -> (
match bc with
| VSharedBorrow bid ->
(* Lookup the shared value in the context, and continue *)
let sv =
- InterpreterBorrowsCore.lookup_shared_value ctx.meta ectx bid
+ InterpreterBorrowsCore.lookup_shared_value ctx.span ectx bid
in
translate sv
| VReservedMutBorrow bid ->
(* Same as for shared borrows. However, note that we use reserved borrows
- * only in *meta-data*: a value *actually used* in the translation can't come
+ * only in *span-data*: a value *actually used* in the translation can't come
* from an unpromoted reserved borrow *)
let sv =
- InterpreterBorrowsCore.lookup_shared_value ctx.meta ectx bid
+ InterpreterBorrowsCore.lookup_shared_value ctx.span ectx bid
in
translate sv
| VMutBorrow (_, v) ->
@@ -1666,7 +1666,7 @@ let rec typed_value_to_texpression (ctx : bs_ctx) (ectx : C.eval_ctx)
value
(** Explore an abstraction value and convert it to a consumed value
- by collecting all the meta-values from the ended *loans*.
+ by collecting all the span-values from the ended *loans*.
Consumed values are rvalues because when an abstraction ends we
introduce a call to a backward function in the synthesized program,
@@ -1692,7 +1692,7 @@ let rec typed_avalue_to_consumed (ctx : bs_ctx) (ectx : C.eval_ctx)
let adt_id, _ = TypesUtils.ty_as_adt av.ty in
match adt_id with
| TAdtId _ | TAssumed (TBox | TArray | TSlice | TStr) ->
- cassert __FILE__ __LINE__ (field_values = []) ctx.meta
+ cassert __FILE__ __LINE__ (field_values = []) ctx.span
"ADTs containing borrows are not supported yet";
None
| TTuple ->
@@ -1701,9 +1701,9 @@ let rec typed_avalue_to_consumed (ctx : bs_ctx) (ectx : C.eval_ctx)
else
(* Note that if there is exactly one field value,
* [mk_simpl_tuple_rvalue] is the identity *)
- let rv = mk_simpl_tuple_texpression ctx.meta field_values in
+ let rv = mk_simpl_tuple_texpression ctx.span field_values in
Some rv)
- | ABottom -> craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ | ABottom -> craise __FILE__ __LINE__ ctx.span "Unreachable"
| ALoan lc -> aloan_content_to_consumed ctx ectx lc
| ABorrow bc -> aborrow_content_to_consumed ctx bc
| ASymbolic aproj -> aproj_to_consumed ctx aproj
@@ -1721,10 +1721,10 @@ and aloan_content_to_consumed (ctx : bs_ctx) (ectx : C.eval_ctx)
(lc : V.aloan_content) : texpression option =
match lc with
| AMutLoan (_, _) | ASharedLoan (_, _, _) ->
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
- | AEndedMutLoan { child = _; given_back = _; given_back_meta } ->
- (* Return the meta-value *)
- Some (typed_value_to_texpression ctx ectx given_back_meta)
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
+ | AEndedMutLoan { child = _; given_back = _; given_back_span } ->
+ (* Return the span-value *)
+ Some (typed_value_to_texpression ctx ectx given_back_span)
| AEndedSharedLoan (_, _) ->
(* We don't dive into shared loans: there is nothing to give back
* inside (note that there could be a mutable borrow in the shared
@@ -1733,7 +1733,7 @@ and aloan_content_to_consumed (ctx : bs_ctx) (ectx : C.eval_ctx)
None
| AIgnoredMutLoan (_, _) ->
(* There can be *inner* not ended mutable loans, but not outer ones *)
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
| AEndedIgnoredMutLoan _ ->
(* This happens with nested borrows: we need to dive in *)
raise Unimplemented
@@ -1745,7 +1745,7 @@ and aborrow_content_to_consumed (_ctx : bs_ctx) (bc : V.aborrow_content) :
texpression option =
match bc with
| V.AMutBorrow (_, _) | ASharedBorrow _ | AIgnoredMutBorrow (_, _) ->
- craise __FILE__ __LINE__ _ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ _ctx.span "Unreachable"
| AEndedMutBorrow (_, _) ->
(* We collect consumed values: ignore *)
None
@@ -1764,7 +1764,7 @@ and aproj_to_consumed (ctx : bs_ctx) (aproj : V.aproj) : texpression option =
| V.AEndedProjLoans (_, [ (mnv, child_aproj) ]) ->
sanity_check __FILE__ __LINE__
(child_aproj = AIgnoredProjBorrows)
- ctx.meta;
+ ctx.span;
(* The symbolic value was updated *)
Some (symbolic_value_to_texpression ctx mnv)
| V.AEndedProjLoans (_, _) ->
@@ -1773,7 +1773,7 @@ and aproj_to_consumed (ctx : bs_ctx) (aproj : V.aproj) : texpression option =
raise Unimplemented
| AEndedProjBorrows _ -> (* We consider consumed values *) None
| AIgnoredProjBorrows | AProjLoans (_, _) | AProjBorrows (_, _) ->
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
(** Convert the abstraction values in an abstraction to consumed values.
@@ -1793,7 +1793,7 @@ let translate_mprojection_elem (pe : E.projection_elem) :
let translate_mprojection (p : E.projection) : mprojection =
List.filter_map translate_mprojection_elem p
-(** Translate a "meta"-place *)
+(** Translate a "span"-place *)
let translate_mplace (p : S.mplace) : mplace =
let var_id = p.bv.index in
let name = p.bv.name in
@@ -1804,7 +1804,7 @@ let translate_opt_mplace (p : S.mplace option) : mplace option =
match p with None -> None | Some p -> Some (translate_mplace p)
(** Explore an abstraction value and convert it to a given back value
- by collecting all the meta-values from the ended *borrows*.
+ by collecting all the span-values from the ended *borrows*.
Given back values are patterns, because when an abstraction ends, we
introduce a call to a backward function in the synthesized program,
@@ -1814,7 +1814,7 @@ let translate_opt_mplace (p : S.mplace option) : mplace option =
^^^^^^^^
]}
- [mp]: it is possible to provide some meta-place information, to guide
+ [mp]: it is possible to provide some span-place information, to guide
the heuristics which later find pretty names for the variables.
*)
let rec typed_avalue_to_given_back (mp : mplace option) (av : V.typed_avalue)
@@ -1823,7 +1823,7 @@ let rec typed_avalue_to_given_back (mp : mplace option) (av : V.typed_avalue)
match av.value with
| AAdt adt_v -> (
(* Translate the field values *)
- (* For now we forget the meta-place information so that it doesn't get used
+ (* For now we forget the span-place information so that it doesn't get used
* by several fields (which would then all have the same name...), but we
* might want to do something smarter *)
let mp = None in
@@ -1839,20 +1839,20 @@ let rec typed_avalue_to_given_back (mp : mplace option) (av : V.typed_avalue)
let adt_id, _ = TypesUtils.ty_as_adt av.ty in
match adt_id with
| TAdtId _ | TAssumed (TBox | TArray | TSlice | TStr) ->
- cassert __FILE__ __LINE__ (field_values = []) ctx.meta
+ cassert __FILE__ __LINE__ (field_values = []) ctx.span
"ADTs with borrows are not supported yet";
(ctx, None)
| TTuple ->
(* Return *)
let variant_id = adt_v.variant_id in
- sanity_check __FILE__ __LINE__ (variant_id = None) ctx.meta;
+ sanity_check __FILE__ __LINE__ (variant_id = None) ctx.span;
if field_values = [] then (ctx, None)
else
(* Note that if there is exactly one field value, [mk_simpl_tuple_pattern]
* is the identity *)
let lv = mk_simpl_tuple_pattern field_values in
(ctx, Some lv))
- | ABottom -> craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ | ABottom -> craise __FILE__ __LINE__ ctx.span "Unreachable"
| ALoan lc -> aloan_content_to_given_back mp lc ctx
| ABorrow bc -> aborrow_content_to_given_back mp bc ctx
| ASymbolic aproj -> aproj_to_given_back mp aproj ctx
@@ -1868,14 +1868,14 @@ and aloan_content_to_given_back (_mp : mplace option) (lc : V.aloan_content)
(ctx : bs_ctx) : bs_ctx * typed_pattern option =
match lc with
| AMutLoan (_, _) | ASharedLoan (_, _, _) ->
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
- | AEndedMutLoan { child = _; given_back = _; given_back_meta = _ }
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
+ | AEndedMutLoan { child = _; given_back = _; given_back_span = _ }
| AEndedSharedLoan (_, _) ->
(* We consider given back values, and thus ignore those *)
(ctx, None)
| AIgnoredMutLoan (_, _) ->
(* There can be *inner* not ended mutable loans, but not outer ones *)
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
| AEndedIgnoredMutLoan _ ->
(* This happens with nested borrows: we need to dive in *)
raise Unimplemented
@@ -1887,9 +1887,9 @@ and aborrow_content_to_given_back (mp : mplace option) (bc : V.aborrow_content)
(ctx : bs_ctx) : bs_ctx * typed_pattern option =
match bc with
| V.AMutBorrow (_, _) | ASharedBorrow _ | AIgnoredMutBorrow (_, _) ->
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
| AEndedMutBorrow (msv, _) ->
- (* Return the meta-symbolic-value *)
+ (* Return the span-symbolic-value *)
let ctx, var = fresh_var_for_symbolic_value msv ctx in
(ctx, Some (mk_typed_pattern_from_var var mp))
| AEndedIgnoredMutBorrow _ ->
@@ -1909,14 +1909,14 @@ and aproj_to_given_back (mp : mplace option) (aproj : V.aproj) (ctx : bs_ctx) :
(List.for_all
(fun (_, aproj) -> aproj = V.AIgnoredProjBorrows)
child_projs)
- ctx.meta "Nested borrows are not supported yet";
+ ctx.span "Nested borrows are not supported yet";
(ctx, None)
| AEndedProjBorrows mv ->
- (* Return the meta-value *)
+ (* Return the span-value *)
let ctx, var = fresh_var_for_symbolic_value mv ctx in
(ctx, Some (mk_typed_pattern_from_var var mp))
| AIgnoredProjBorrows | AProjLoans (_, _) | AProjBorrows (_, _) ->
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
(** Convert the abstraction values in an abstraction to given back values.
@@ -1954,11 +1954,11 @@ let get_abs_ancestors (ctx : bs_ctx) (abs : V.abs) (call_id : V.FunCallId.id) :
let abs_ancestors = list_ancestor_abstractions ctx abs call_id in
(call_info.forward, abs_ancestors)
-(** Add meta-information to an expression *)
-let mk_emeta_symbolic_assignments (vars : var list) (values : texpression list)
+(** Add span-information to an expression *)
+let mk_espan_symbolic_assignments (vars : var list) (values : texpression list)
(e : texpression) : texpression =
let var_values = List.combine (List.map var_get_id vars) values in
- if var_values <> [] then mk_emeta (SymbolicAssignments var_values) e else e
+ if var_values <> [] then mk_espan (SymbolicAssignments var_values) e else e
(** Derive naming information from a context.
@@ -2000,8 +2000,8 @@ let eval_ctx_to_symbolic_assignments_info (ctx : bs_ctx)
(* Return the computed information *)
!info
-let translate_error (meta : Meta.meta option) (msg : string) : texpression =
- { e = EError (meta, msg); ty = Error }
+let translate_error (span : Meta.span option) (msg : string) : texpression =
+ { e = EError (span, msg); ty = Error }
let rec translate_expression (e : S.expression) (ctx : bs_ctx) : texpression =
match e with
@@ -2021,7 +2021,7 @@ let rec translate_expression (e : S.expression) (ctx : bs_ctx) : texpression =
| Expansion (p, sv, exp) -> translate_expansion p sv exp ctx
| IntroSymbolic (ectx, p, sv, v, e) ->
translate_intro_symbolic ectx p sv v e ctx
- | Meta (meta, e) -> translate_emeta meta e ctx
+ | Meta (span, e) -> translate_espan span e ctx
| ForwardEnd (ectx, loop_input_values, e, back_e) ->
(* Translate the end of a function, or the end of a loop.
@@ -2029,7 +2029,7 @@ let rec translate_expression (e : S.expression) (ctx : bs_ctx) : texpression =
*)
translate_forward_end ectx loop_input_values e back_e ctx
| Loop loop -> translate_loop loop ctx
- | Error (meta, msg) -> translate_error meta msg
+ | Error (span, msg) -> translate_error span msg
and translate_panic (ctx : bs_ctx) : texpression = Option.get ctx.mk_panic
@@ -2048,9 +2048,9 @@ and translate_return (ectx : C.eval_ctx) (opt_v : V.typed_value option)
and translate_return_with_loop (loop_id : V.LoopId.id) (is_continue : bool)
(ctx : bs_ctx) : texpression =
- sanity_check __FILE__ __LINE__ (is_continue = ctx.inside_loop) ctx.meta;
+ sanity_check __FILE__ __LINE__ (is_continue = ctx.inside_loop) ctx.span;
let loop_id = V.LoopId.Map.find loop_id ctx.loop_ids_map in
- sanity_check __FILE__ __LINE__ (loop_id = Option.get ctx.loop_id) ctx.meta;
+ sanity_check __FILE__ __LINE__ (loop_id = Option.get ctx.loop_id) ctx.span;
(* Lookup the loop information *)
let loop_id = Option.get ctx.loop_id in
@@ -2074,7 +2074,7 @@ and translate_return_with_loop (loop_id : V.LoopId.id) (is_continue : bool)
match ctx.backward_outputs with Some outputs -> outputs | None -> []
in
let field_values = List.map mk_texpression_from_var backward_outputs in
- mk_simpl_tuple_texpression ctx.meta field_values
+ mk_simpl_tuple_texpression ctx.span field_values
in
(* We may need to return a state
@@ -2088,11 +2088,11 @@ and translate_return_with_loop (loop_id : V.LoopId.id) (is_continue : bool)
let output =
if effect_info.stateful then
let state_rvalue = mk_state_texpression ctx.state_var in
- mk_simpl_tuple_texpression ctx.meta [ state_rvalue; output ]
+ mk_simpl_tuple_texpression ctx.span [ state_rvalue; output ]
else output
in
(* Wrap in a result - TODO: check effect_info.can_fail to not always wrap *)
- mk_emeta (Tag "return_with_loop") (mk_result_ok_texpression ctx.meta output)
+ mk_espan (Tag "return_with_loop") (mk_result_ok_texpression ctx.span output)
and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
texpression =
@@ -2143,7 +2143,7 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
let sg = Option.get call.sg in
let decls_ctx = ctx.decls_ctx in
let dsg =
- translate_fun_sig_with_regions_hierarchy_to_decomposed ctx.meta
+ translate_fun_sig_with_regions_hierarchy_to_decomposed ctx.span
decls_ctx fid call.regions_hierarchy sg
(List.map (fun _ -> None) sg.inputs)
in
@@ -2157,7 +2157,7 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
ctx_translate_fwd_generic_args ctx all_generics
in
let tr_self =
- translate_fwd_trait_instance_id ctx.meta
+ translate_fwd_trait_instance_id ctx.span
ctx.type_ctx.type_infos tr_self
in
(tr_self, all_generics)
@@ -2189,7 +2189,7 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
| PeIdent (s, _) -> s
| PeImpl _ ->
(* We shouldn't get there *)
- craise __FILE__ __LINE__ decl.item_meta.meta "Unexpected")
+ craise __FILE__ __LINE__ decl.item_meta.span "Unexpected")
in
name ^ "_back"
in
@@ -2277,7 +2277,7 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
| S.Unop E.Neg -> (
match args with
| [ arg ] ->
- let int_ty = ty_as_integer ctx.meta arg.ty in
+ let int_ty = ty_as_integer ctx.span arg.ty in
(* Note that negation can lead to an overflow and thus fail (it
* is thus monadic) *)
let effect_info =
@@ -2292,7 +2292,7 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
let ctx, dest = fresh_var_for_symbolic_value call.dest ctx in
let dest = mk_typed_pattern_from_var dest dest_mplace in
(ctx, Unop (Neg int_ty), effect_info, args, dest)
- | _ -> craise __FILE__ __LINE__ ctx.meta "Unreachable")
+ | _ -> craise __FILE__ __LINE__ ctx.span "Unreachable")
| S.Unop (E.Cast cast_kind) -> (
match cast_kind with
| CastScalar (src_ty, tgt_ty) ->
@@ -2310,16 +2310,16 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
let dest = mk_typed_pattern_from_var dest dest_mplace in
(ctx, Unop (Cast (src_ty, tgt_ty)), effect_info, args, dest)
| CastFnPtr _ ->
- craise __FILE__ __LINE__ ctx.meta "TODO: function casts")
+ craise __FILE__ __LINE__ ctx.span "TODO: function casts")
| S.Binop binop -> (
match args with
| [ arg0; arg1 ] ->
- let int_ty0 = ty_as_integer ctx.meta arg0.ty in
- let int_ty1 = ty_as_integer ctx.meta arg1.ty in
+ let int_ty0 = ty_as_integer ctx.span arg0.ty in
+ let int_ty1 = ty_as_integer ctx.span arg1.ty in
(match binop with
(* The Rust compiler accepts bitshifts for any integer type combination for ty0, ty1 *)
| E.Shl | E.Shr -> ()
- | _ -> sanity_check __FILE__ __LINE__ (int_ty0 = int_ty1) ctx.meta);
+ | _ -> sanity_check __FILE__ __LINE__ (int_ty0 = int_ty1) ctx.span);
let effect_info =
{
can_fail = ExpressionsUtils.binop_can_fail binop;
@@ -2332,7 +2332,7 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
let ctx, dest = fresh_var_for_symbolic_value call.dest ctx in
let dest = mk_typed_pattern_from_var dest dest_mplace in
(ctx, Binop (binop, int_ty0), effect_info, args, dest)
- | _ -> craise __FILE__ __LINE__ ctx.meta "Unreachable")
+ | _ -> craise __FILE__ __LINE__ ctx.span "Unreachable")
in
let func = { id = FunOrOp fun_id; generics } in
let input_tys = (List.map (fun (x : texpression) -> x.ty)) args in
@@ -2341,7 +2341,7 @@ and translate_function_call (call : S.call) (e : S.expression) (ctx : bs_ctx) :
in
let func_ty = mk_arrows input_tys ret_ty in
let func = { e = Qualif func; ty = func_ty } in
- let call = mk_apps ctx.meta func args in
+ let call = mk_apps ctx.span func args in
(* Translate the next expression *)
let next_e = translate_expression e ctx in
(* Put together *)
@@ -2375,7 +2375,7 @@ and translate_end_abstraction_synth_input (ectx : C.eval_ctx) (abs : V.abs)
^ "\n- loop_id: "
^ Print.option_to_string Pure.LoopId.to_string ctx.loop_id
^ "\n- eval_ctx:\n"
- ^ eval_ctx_to_string ~meta:(Some ctx.meta) ectx
+ ^ eval_ctx_to_string ~span:(Some ctx.span) ectx
^ "\n- abs:\n" ^ abs_to_string ctx abs ^ "\n"));
(* When we end an input abstraction, this input abstraction gets back
@@ -2389,7 +2389,7 @@ and translate_end_abstraction_synth_input (ectx : C.eval_ctx) (abs : V.abs)
for a parent backward function.
*)
let bid = Option.get ctx.bid in
- sanity_check __FILE__ __LINE__ (rg_id = bid) ctx.meta;
+ sanity_check __FILE__ __LINE__ (rg_id = bid) ctx.span;
(* First, introduce the given back variables.
@@ -2439,7 +2439,7 @@ and translate_end_abstraction_synth_input (ectx : C.eval_ctx) (abs : V.abs)
(fun (var, v) ->
sanity_check __FILE__ __LINE__
((var : var).ty = (v : texpression).ty)
- ctx.meta)
+ ctx.span)
variables_values;
(* Translate the next expression *)
let next_e = translate_expression e ctx in
@@ -2460,7 +2460,7 @@ and translate_end_abstraction_fun_call (ectx : C.eval_ctx) (abs : V.abs)
| S.Fun (fun_id, _) -> fun_id
| Unop _ | Binop _ ->
(* Those don't have backward functions *)
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
in
let effect_info = get_fun_effect_info ctx fun_id None (Some rg_id) in
(* Retrieve the values consumed upon ending the loans inside this
@@ -2480,7 +2480,7 @@ and translate_end_abstraction_fun_call (ectx : C.eval_ctx) (abs : V.abs)
let back_inputs = List.append back_inputs back_state in
(* Retrieve the values given back by this function: those are the output
* values. We rely on the fact that there are no nested borrows to use the
- * meta-place information from the input values given to the forward function
+ * span-place information from the input values given to the forward function
* (we need to add [None] for the return avalue) *)
let output_mpl =
List.append (List.map translate_opt_mplace call.args_places) [ None ]
@@ -2522,7 +2522,7 @@ and translate_end_abstraction_fun_call (ectx : C.eval_ctx) (abs : V.abs)
^ "\nfunc type: "
^ pure_ty_to_string ctx func.ty
^ "\n\nargs:\n" ^ String.concat "\n" args));
- let call = mk_apps ctx.meta func args in
+ let call = mk_apps ctx.span func args in
mk_let effect_info.can_fail output call next_e
and translate_end_abstraction_identity (ectx : C.eval_ctx) (abs : V.abs)
@@ -2533,8 +2533,8 @@ and translate_end_abstraction_identity (ectx : C.eval_ctx) (abs : V.abs)
(* We can do this simply by checking that it consumes and gives back nothing *)
let inputs = abs_to_consumed ctx ectx abs in
let ctx, outputs = abs_to_given_back None abs ctx in
- sanity_check __FILE__ __LINE__ (inputs = []) ctx.meta;
- sanity_check __FILE__ __LINE__ (outputs = []) ctx.meta;
+ sanity_check __FILE__ __LINE__ (inputs = []) ctx.span;
+ sanity_check __FILE__ __LINE__ (outputs = []) ctx.span;
(* Translate the next expression *)
translate_expression e ctx
@@ -2576,10 +2576,10 @@ and translate_end_abstraction_synth_ret (ectx : C.eval_ctx) (abs : V.abs)
(* Retrieve the values consumed upon ending the loans inside this
* abstraction: as there are no nested borrows, there should be none. *)
let consumed = abs_to_consumed ctx ectx abs in
- cassert __FILE__ __LINE__ (consumed = []) ctx.meta
+ cassert __FILE__ __LINE__ (consumed = []) ctx.span
"Nested borrows are not supported yet";
(* Retrieve the values given back upon ending this abstraction - note that
- * we don't provide meta-place information, because those assignments will
+ * we don't provide span-place information, because those assignments will
* be inlined anyway... *)
log#ldebug (lazy ("abs: " ^ abs_to_string ctx abs));
let ctx, given_back = abs_to_given_back_no_mp abs ctx in
@@ -2595,7 +2595,7 @@ and translate_end_abstraction_synth_ret (ectx : C.eval_ctx) (abs : V.abs)
^ pure_ty_to_string ctx given_back.ty
^ "\n- sig input ty: "
^ pure_ty_to_string ctx input.ty));
- sanity_check __FILE__ __LINE__ (given_back.ty = input.ty) ctx.meta)
+ sanity_check __FILE__ __LINE__ (given_back.ty = input.ty) ctx.span)
given_back_inputs;
(* Translate the next expression *)
let next_e = translate_expression e ctx in
@@ -2612,7 +2612,7 @@ and translate_end_abstraction_loop (ectx : C.eval_ctx) (abs : V.abs)
texpression =
let vloop_id = loop_id in
let loop_id = V.LoopId.Map.find loop_id ctx.loop_ids_map in
- sanity_check __FILE__ __LINE__ (loop_id = Option.get ctx.loop_id) ctx.meta;
+ sanity_check __FILE__ __LINE__ (loop_id = Option.get ctx.loop_id) ctx.span;
let rg_id = Option.get rg_id in
(* There are two cases depending on the [abs_kind] (whether this is a
synth input or a regular loop call) *)
@@ -2682,8 +2682,8 @@ and translate_end_abstraction_loop (ectx : C.eval_ctx) (abs : V.abs)
match func with
| None -> next_e
| Some func ->
- let call = mk_apps ctx.meta func args in
- (* Add meta-information - this is slightly hacky: we look at the
+ let call = mk_apps ctx.span func args in
+ (* Add span-information - this is slightly hacky: we look at the
values consumed by the abstraction (note that those come from
*before* we applied the fixed-point context) and use them to
guide the naming of the output vars.
@@ -2709,7 +2709,7 @@ and translate_end_abstraction_loop (ectx : C.eval_ctx) (abs : V.abs)
var_values
in
let vars, values = List.split var_values in
- mk_emeta_symbolic_assignments vars values next_e
+ mk_espan_symbolic_assignments vars values next_e
else next_e
in
@@ -2739,7 +2739,7 @@ and translate_assertion (ectx : C.eval_ctx) (v : V.typed_value)
in
let func_ty = mk_arrow (TLiteral TBool) mk_unit_ty in
let func = { e = Qualif func; ty = func_ty } in
- let assertion = mk_apps ctx.meta func args in
+ let assertion = mk_apps ctx.span func args in
mk_let monadic (mk_dummy_pattern mk_unit_ty) assertion next_e
and translate_expansion (p : S.mplace option) (sv : V.symbolic_value)
@@ -2754,7 +2754,7 @@ and translate_expansion (p : S.mplace option) (sv : V.symbolic_value)
| V.SeLiteral _ ->
(* We do not *register* symbolic expansions to literal
values in the symbolic ADT *)
- craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ craise __FILE__ __LINE__ ctx.span "Unreachable"
| SeMutRef (_, nsv) | SeSharedRef (_, nsv) ->
(* The (mut/shared) borrow type is extracted to identity: we thus simply
introduce an reassignment *)
@@ -2767,11 +2767,11 @@ and translate_expansion (p : S.mplace option) (sv : V.symbolic_value)
next_e
| SeAdt _ ->
(* Should be in the [ExpandAdt] case *)
- craise __FILE__ __LINE__ ctx.meta "Unreachable")
+ craise __FILE__ __LINE__ ctx.span "Unreachable")
| ExpandAdt branches -> (
(* We don't do the same thing if there is a branching or not *)
match branches with
- | [] -> craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ | [] -> craise __FILE__ __LINE__ ctx.span "Unreachable"
| [ (variant_id, svl, branch) ]
when not
(TypesUtils.ty_is_custom_adt sv.V.sv_ty
@@ -2812,7 +2812,7 @@ and translate_expansion (p : S.mplace option) (sv : V.symbolic_value)
(* Sanity check *)
sanity_check __FILE__ __LINE__
(List.for_all (fun br -> br.branch.ty = ty) branches)
- ctx.meta;
+ ctx.span;
(* Return *)
{ e; ty })
| ExpandBool (true_e, false_e) ->
@@ -2832,7 +2832,7 @@ and translate_expansion (p : S.mplace option) (sv : V.symbolic_value)
^ pure_ty_to_string ctx true_e.ty
^ "\n\nfalse_e.ty: "
^ pure_ty_to_string ctx false_e.ty));
- sanity_check __FILE__ __LINE__ (ty = false_e.ty) ctx.meta;
+ sanity_check __FILE__ __LINE__ (ty = false_e.ty) ctx.span;
{ e; ty }
| ExpandInt (int_ty, branches, otherwise) ->
let translate_branch ((v, branch_e) : V.scalar_value * S.expression) :
@@ -2859,7 +2859,7 @@ and translate_expansion (p : S.mplace option) (sv : V.symbolic_value)
let ty = otherwise.branch.ty in
sanity_check __FILE__ __LINE__
(List.for_all (fun (br : match_branch) -> br.branch.ty = ty) branches)
- ctx.meta;
+ ctx.span;
{ e; ty }
(* Translate and [ExpandAdt] when there is no branching (i.e., one branch).
@@ -2934,14 +2934,14 @@ and translate_ExpandAdt_one_branch (sv : V.symbolic_value)
* field.
* We use the [dest] variable in order not to have to recompute
* the type of the result of the projection... *)
- let adt_id, generics = ty_as_adt ctx.meta scrutinee.ty in
+ let adt_id, generics = ty_as_adt ctx.span scrutinee.ty in
let gen_field_proj (field_id : FieldId.id) (dest : var) : texpression =
let proj_kind = { adt_id; field_id } in
let qualif = { id = Proj proj_kind; generics } in
let proj_e = Qualif qualif in
let proj_ty = mk_arrow scrutinee.ty dest.ty in
let proj = { e = proj_e; ty = proj_ty } in
- mk_app ctx.meta proj scrutinee
+ mk_app ctx.span proj scrutinee
in
let id_var_pairs = FieldId.mapi (fun fid v -> (fid, v)) vars in
let monadic = false in
@@ -2962,7 +2962,7 @@ and translate_ExpandAdt_one_branch (sv : V.symbolic_value)
let var =
match vars with
| [ v ] -> v
- | _ -> craise __FILE__ __LINE__ ctx.meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ ctx.span "Unreachable"
in
(* We simply introduce an assignment - the box type is the
* identity when extracted ([box a = a]) *)
@@ -2976,7 +2976,7 @@ and translate_ExpandAdt_one_branch (sv : V.symbolic_value)
* through the functions provided by the API (note that we don't
* know how to expand values like vectors or arrays, because they have a variable number
* of fields!) *)
- craise __FILE__ __LINE__ ctx.meta
+ craise __FILE__ __LINE__ ctx.span
"Attempt to expand a non-expandable value"
and translate_intro_symbolic (ectx : C.eval_ctx) (p : S.mplace option)
@@ -3014,7 +3014,7 @@ and translate_intro_symbolic (ectx : C.eval_ctx) (p : S.mplace option)
| VaCgValue cg_id -> { e = CVar cg_id; ty = var.ty }
| VaTraitConstValue (trait_ref, const_name) ->
let type_infos = ctx.type_ctx.type_infos in
- let trait_ref = translate_fwd_trait_ref ctx.meta type_infos trait_ref in
+ let trait_ref = translate_fwd_trait_ref ctx.span type_infos trait_ref in
let qualif_id = TraitConst (trait_ref, const_name) in
let qualif = { id = qualif_id; generics = empty_generic_args } in
{ e = Qualif qualif; ty = var.ty }
@@ -3071,16 +3071,16 @@ and translate_forward_end (ectx : C.eval_ctx)
let field_values =
List.map mk_texpression_from_var backward_outputs
in
- mk_simpl_tuple_texpression ctx.meta field_values
+ mk_simpl_tuple_texpression ctx.span field_values
in
let output =
if effect_info.stateful then
let state_rvalue = mk_state_texpression ctx.state_var in
- mk_simpl_tuple_texpression ctx.meta [ state_rvalue; output ]
+ mk_simpl_tuple_texpression ctx.span [ state_rvalue; output ]
else output
in
(* Wrap in a result - TODO: check effect_info.can_fail to not always wrap *)
- mk_result_ok_texpression ctx.meta output
+ mk_result_ok_texpression ctx.span output
in
let mk_panic =
(* TODO: we should use a [Fail] function *)
@@ -3089,12 +3089,12 @@ and translate_forward_end (ectx : C.eval_ctx)
(* Create the [Fail] value *)
let ret_ty = mk_simpl_tuple_ty [ mk_state_ty; output_ty ] in
let ret_v =
- mk_result_fail_texpression_with_error_id ctx.meta
+ mk_result_fail_texpression_with_error_id ctx.span
error_failure_id ret_ty
in
ret_v
else
- mk_result_fail_texpression_with_error_id ctx.meta
+ mk_result_fail_texpression_with_error_id ctx.span
error_failure_id output_ty
in
let output =
@@ -3200,7 +3200,7 @@ and translate_forward_end (ectx : C.eval_ctx)
else pure_fwd_var :: back_vars
in
let vars = List.map mk_texpression_from_var vars in
- let ret = mk_simpl_tuple_texpression ctx.meta vars in
+ let ret = mk_simpl_tuple_texpression ctx.span vars in
(* Introduce a fresh input state variable for the forward expression *)
let _ctx, state_var, state_pat =
@@ -3211,8 +3211,8 @@ and translate_forward_end (ectx : C.eval_ctx)
in
let state_var = List.map mk_texpression_from_var state_var in
- let ret = mk_simpl_tuple_texpression ctx.meta (state_var @ [ ret ]) in
- let ret = mk_result_ok_texpression ctx.meta ret in
+ let ret = mk_simpl_tuple_texpression ctx.span (state_var @ [ ret ]) in
+ let ret = mk_result_ok_texpression ctx.span ret in
(* Introduce all the let-bindings *)
@@ -3385,14 +3385,14 @@ and translate_forward_end (ectx : C.eval_ctx)
in
let func_ty = mk_arrows input_tys ret_ty in
let func = { e = Qualif func; ty = func_ty } in
- let call = mk_apps ctx.meta func args in
+ let call = mk_apps ctx.span func args in
call
in
(* Create the let expression with the loop call *)
let e = mk_let effect_info.can_fail out_pat loop_call next_e in
- (* Add meta-information linking the loop input parameters and the
+ (* Add span-information linking the loop input parameters and the
loop input values - we use this to derive proper names.
There is something important here: as we group the end of the function
@@ -3402,10 +3402,10 @@ and translate_forward_end (ectx : C.eval_ctx)
the function. It means it is ok to reference some variables which might
actually be defined, in the end, in a different branch.
- We then remove all the meta information from the body *before* calling
+ We then remove all the span information from the body *before* calling
{!PureMicroPasses.decompose_loops}.
*)
- mk_emeta_symbolic_assignments loop_info.input_vars org_args e
+ mk_espan_symbolic_assignments loop_info.input_vars org_args e
and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
let loop_id = V.LoopId.Map.find loop.loop_id ctx.loop_ids_map in
@@ -3444,7 +3444,7 @@ and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
(fun (sv : V.symbolic_value) ->
V.SymbolicValueId.Map.mem sv.sv_id ctx.sv_to_var)
loop.input_svalues)
- ctx.meta;
+ ctx.span;
(* Translate the loop inputs *)
let inputs =
@@ -3465,7 +3465,7 @@ and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
(fun ty ->
cassert __FILE__ __LINE__
(not (TypesUtils.ty_has_borrows ctx.type_ctx.type_infos ty))
- ctx.meta "The types shouldn't contain borrows";
+ ctx.span "The types shouldn't contain borrows";
ctx_translate_fwd_ty ctx ty)
tys)
loop.rg_to_given_back_tys
@@ -3545,7 +3545,7 @@ and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
let ctx =
sanity_check __FILE__ __LINE__
(not (LoopId.Map.mem loop_id ctx.loops))
- ctx.meta;
+ ctx.span;
(* Note that we will retrieve the input values later in the [ForwardEnd]
(and will introduce the outputs at that moment, together with the actual
@@ -3589,12 +3589,12 @@ and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
(* Create the [Fail] value *)
let ret_ty = mk_simpl_tuple_ty [ mk_state_ty; output_ty ] in
let ret_v =
- mk_result_fail_texpression_with_error_id ctx.meta error_failure_id
+ mk_result_fail_texpression_with_error_id ctx.span error_failure_id
ret_ty
in
ret_v
else
- mk_result_fail_texpression_with_error_id ctx.meta error_failure_id
+ mk_result_fail_texpression_with_error_id ctx.span error_failure_id
output_ty
in
let mk_return ctx v =
@@ -3605,11 +3605,11 @@ and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
let output =
if effect_info.stateful then
let state_rvalue = mk_state_texpression ctx.state_var in
- mk_simpl_tuple_texpression ctx.meta [ state_rvalue; output ]
+ mk_simpl_tuple_texpression ctx.span [ state_rvalue; output ]
else output
in
(* Wrap in a result - TODO: check effect_info.can_fail to not always wrap *)
- mk_result_ok_texpression ctx.meta output
+ mk_result_ok_texpression ctx.span output
in
let loop_info =
@@ -3651,7 +3651,7 @@ and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
{
fun_end;
loop_id;
- meta = loop.meta;
+ span = loop.span;
fuel0 = ctx.fuel0;
fuel = ctx.fuel;
input_state;
@@ -3664,11 +3664,11 @@ and translate_loop (loop : S.loop) (ctx : bs_ctx) : texpression =
let ty = fun_end.ty in
{ e = loop; ty }
-and translate_emeta (meta : S.emeta) (e : S.expression) (ctx : bs_ctx) :
+and translate_espan (span : S.espan) (e : S.expression) (ctx : bs_ctx) :
texpression =
let next_e = translate_expression e ctx in
- let meta =
- match meta with
+ let span =
+ match span with
| S.Assignment (ectx, lp, rv, rp) ->
let lp = translate_mplace lp in
let rv = typed_value_to_texpression ctx ectx rv in
@@ -3678,28 +3678,28 @@ and translate_emeta (meta : S.emeta) (e : S.expression) (ctx : bs_ctx) :
let infos = eval_ctx_to_symbolic_assignments_info ctx ectx in
if infos <> [] then
(* If often happens that the next expression contains exactly the
- same meta information *)
+ same span information *)
match next_e.e with
| Meta (SymbolicPlaces infos1, _) when infos1 = infos -> None
| _ -> Some (SymbolicPlaces infos)
else None
in
- match meta with
- | Some meta ->
- let e = Meta (meta, next_e) in
+ match span with
+ | Some span ->
+ let e = Meta (span, next_e) in
let ty = next_e.ty in
{ e; ty }
| None -> next_e
(** Wrap a function body in a match over the fuel to control termination. *)
-let wrap_in_match_fuel (meta : Meta.meta) (fuel0 : VarId.id) (fuel : VarId.id)
+let wrap_in_match_fuel (span : Meta.span) (fuel0 : VarId.id) (fuel : VarId.id)
(body : texpression) : texpression =
let fuel0_var : var = mk_fuel_var fuel0 in
let fuel0 = mk_texpression_from_var fuel0_var in
let nfuel_var : var = mk_fuel_var fuel in
let nfuel_pat = mk_typed_pattern_from_var nfuel_var None in
let fail_branch =
- mk_result_fail_texpression_with_error_id meta error_out_of_fuel_id body.ty
+ mk_result_fail_texpression_with_error_id span error_out_of_fuel_id body.ty
in
match !Config.backend with
| FStar ->
@@ -3721,7 +3721,7 @@ let wrap_in_match_fuel (meta : Meta.meta) (fuel0 : VarId.id) (fuel : VarId.id)
in
let func_ty = mk_arrow mk_fuel_ty mk_bool_ty in
let func = { e = Qualif func; ty = func_ty } in
- mk_app meta func fuel0
+ mk_app span func fuel0
in
(* Create the expression: [decrease fuel0] *)
let decrease_fuel =
@@ -3733,7 +3733,7 @@ let wrap_in_match_fuel (meta : Meta.meta) (fuel0 : VarId.id) (fuel : VarId.id)
in
let func_ty = mk_arrow mk_fuel_ty mk_fuel_ty in
let func = { e = Qualif func; ty = func_ty } in
- mk_app meta func fuel0
+ mk_app span func fuel0
in
(* Create the success branch *)
@@ -3805,11 +3805,11 @@ let translate_fun_decl (ctx : bs_ctx) (body : S.expression option) : fun_decl =
let output =
if effect_info.stateful then
let state_rvalue = mk_state_texpression ctx.state_var in
- mk_simpl_tuple_texpression ctx.meta [ state_rvalue; output ]
+ mk_simpl_tuple_texpression ctx.span [ state_rvalue; output ]
else output
in
(* Wrap in a result - TODO: check effect_info.can_fail to not always wrap *)
- mk_result_ok_texpression ctx.meta output
+ mk_result_ok_texpression ctx.span output
in
let mk_panic =
(* TODO: we should use a [Fail] function *)
@@ -3818,12 +3818,12 @@ let translate_fun_decl (ctx : bs_ctx) (body : S.expression option) : fun_decl =
(* Create the [Fail] value *)
let ret_ty = mk_simpl_tuple_ty [ mk_state_ty; output_ty ] in
let ret_v =
- mk_result_fail_texpression_with_error_id ctx.meta
+ mk_result_fail_texpression_with_error_id ctx.span
error_failure_id ret_ty
in
ret_v
else
- mk_result_fail_texpression_with_error_id ctx.meta error_failure_id
+ mk_result_fail_texpression_with_error_id ctx.span error_failure_id
output_ty
in
let back_tys = compute_back_tys ctx.sg None in
@@ -3842,7 +3842,7 @@ let translate_fun_decl (ctx : bs_ctx) (body : S.expression option) : fun_decl =
(* Add a match over the fuel, if necessary *)
let body =
if function_decreases_fuel effect_info then
- wrap_in_match_fuel def.item_meta.meta ctx.fuel0 ctx.fuel body
+ wrap_in_match_fuel def.item_meta.span ctx.fuel0 ctx.fuel body
else body
in
(* Sanity check *)
@@ -3887,7 +3887,7 @@ let translate_fun_decl (ctx : bs_ctx) (body : S.expression option) : fun_decl =
(List.for_all
(fun (var, ty) -> (var : var).ty = ty)
(List.combine inputs signature.inputs))
- def.item_meta.meta;
+ def.item_meta.span;
Some { inputs; inputs_lvs; body }
in
@@ -3903,7 +3903,7 @@ let translate_fun_decl (ctx : bs_ctx) (body : S.expression option) : fun_decl =
{
def_id;
is_local = def.is_local;
- meta = def.item_meta.meta;
+ span = def.item_meta.span;
kind = def.kind;
num_loops;
loop_id;
@@ -3926,11 +3926,11 @@ let translate_type_decls (ctx : Contexts.decls_ctx) : type_decl list =
List.filter_map
(fun d ->
try Some (translate_type_decl ctx d)
- with CFailure (meta, _) ->
+ with CFailure (span, _) ->
let env = PrintPure.decls_ctx_to_fmt_env ctx in
let name = PrintPure.name_to_string env d.name in
let name_pattern = TranslateCore.name_to_pattern_string ctx d.name in
- save_error __FILE__ __LINE__ meta
+ save_error __FILE__ __LINE__ span
("Could not translate type decl '" ^ name
^ " because of previous error\nName pattern: '" ^ name_pattern ^ "'");
None)
@@ -3960,18 +3960,18 @@ let translate_trait_decl (ctx : Contexts.decls_ctx) (trait_decl : A.trait_decl)
llbc_name
in
let generics =
- translate_generic_params trait_decl.item_meta.meta llbc_generics
+ translate_generic_params trait_decl.item_meta.span llbc_generics
in
- let preds = translate_predicates trait_decl.item_meta.meta preds in
+ let preds = translate_predicates trait_decl.item_meta.span preds in
let parent_clauses =
List.map
- (translate_trait_clause trait_decl.item_meta.meta)
+ (translate_trait_clause trait_decl.item_meta.span)
llbc_parent_clauses
in
let consts =
List.map
(fun (name, (ty, id)) ->
- (name, (translate_fwd_ty trait_decl.item_meta.meta type_infos ty, id)))
+ (name, (translate_fwd_ty trait_decl.item_meta.span type_infos ty, id)))
consts
in
let types =
@@ -3979,10 +3979,10 @@ let translate_trait_decl (ctx : Contexts.decls_ctx) (trait_decl : A.trait_decl)
(fun (name, (trait_clauses, ty)) ->
( name,
( List.map
- (translate_trait_clause trait_decl.item_meta.meta)
+ (translate_trait_clause trait_decl.item_meta.span)
trait_clauses,
Option.map
- (translate_fwd_ty trait_decl.item_meta.meta type_infos)
+ (translate_fwd_ty trait_decl.item_meta.span type_infos)
ty ) ))
types
in
@@ -3991,7 +3991,7 @@ let translate_trait_decl (ctx : Contexts.decls_ctx) (trait_decl : A.trait_decl)
is_local;
llbc_name;
name;
- meta = item_meta.meta;
+ span = item_meta.span;
generics;
llbc_generics;
preds;
@@ -4023,8 +4023,8 @@ let translate_trait_impl (ctx : Contexts.decls_ctx) (trait_impl : A.trait_impl)
in
let type_infos = ctx.type_ctx.type_infos in
let impl_trait =
- translate_trait_decl_ref trait_impl.item_meta.meta
- (translate_fwd_ty trait_impl.item_meta.meta type_infos)
+ translate_trait_decl_ref trait_impl.item_meta.span
+ (translate_fwd_ty trait_impl.item_meta.span type_infos)
llbc_impl_trait
in
let name =
@@ -4033,16 +4033,16 @@ let translate_trait_impl (ctx : Contexts.decls_ctx) (trait_impl : A.trait_impl)
llbc_name
in
let generics =
- translate_generic_params trait_impl.item_meta.meta llbc_generics
+ translate_generic_params trait_impl.item_meta.span llbc_generics
in
- let preds = translate_predicates trait_impl.item_meta.meta preds in
+ let preds = translate_predicates trait_impl.item_meta.span preds in
let parent_trait_refs =
- List.map (translate_strait_ref trait_impl.item_meta.meta) parent_trait_refs
+ List.map (translate_strait_ref trait_impl.item_meta.span) parent_trait_refs
in
let consts =
List.map
(fun (name, (ty, id)) ->
- (name, (translate_fwd_ty trait_impl.item_meta.meta type_infos ty, id)))
+ (name, (translate_fwd_ty trait_impl.item_meta.span type_infos ty, id)))
consts
in
let types =
@@ -4050,9 +4050,9 @@ let translate_trait_impl (ctx : Contexts.decls_ctx) (trait_impl : A.trait_impl)
(fun (name, (trait_refs, ty)) ->
( name,
( List.map
- (translate_fwd_trait_ref trait_impl.item_meta.meta type_infos)
+ (translate_fwd_trait_ref trait_impl.item_meta.span type_infos)
trait_refs,
- translate_fwd_ty trait_impl.item_meta.meta type_infos ty ) ))
+ translate_fwd_ty trait_impl.item_meta.span type_infos ty ) ))
types
in
{
@@ -4060,7 +4060,7 @@ let translate_trait_impl (ctx : Contexts.decls_ctx) (trait_impl : A.trait_impl)
is_local;
llbc_name;
name;
- meta = item_meta.meta;
+ span = item_meta.span;
impl_trait;
llbc_impl_trait;
generics;
@@ -4093,11 +4093,11 @@ let translate_global (ctx : Contexts.decls_ctx) (decl : A.global_decl) :
(Print.Contexts.decls_ctx_to_fmt_env ctx)
llbc_name
in
- let generics = translate_generic_params decl.item_meta.meta llbc_generics in
- let preds = translate_predicates decl.item_meta.meta preds in
- let ty = translate_fwd_ty decl.item_meta.meta ctx.type_ctx.type_infos ty in
+ let generics = translate_generic_params decl.item_meta.span llbc_generics in
+ let preds = translate_predicates decl.item_meta.span preds in
+ let ty = translate_fwd_ty decl.item_meta.span ctx.type_ctx.type_infos ty in
{
- meta = item_meta.meta;
+ span = item_meta.span;
def_id;
is_local;
llbc_name;
diff --git a/compiler/SynthesizeSymbolic.ml b/compiler/SynthesizeSymbolic.ml
index 8e578a50..ae701c33 100644
--- a/compiler/SynthesizeSymbolic.ml
+++ b/compiler/SynthesizeSymbolic.ml
@@ -6,24 +6,24 @@ open LlbcAst
open SymbolicAst
open Errors
-let mk_mplace (meta : Meta.meta) (p : place) (ctx : Contexts.eval_ctx) : mplace
+let mk_mplace (span : Meta.span) (p : place) (ctx : Contexts.eval_ctx) : mplace
=
- let bv = Contexts.ctx_lookup_var_binder meta ctx p.var_id in
+ let bv = Contexts.ctx_lookup_var_binder span ctx p.var_id in
{ bv; projection = p.projection }
-let mk_opt_mplace (meta : Meta.meta) (p : place option)
+let mk_opt_mplace (span : Meta.span) (p : place option)
(ctx : Contexts.eval_ctx) : mplace option =
- Option.map (fun p -> mk_mplace meta p ctx) p
+ Option.map (fun p -> mk_mplace span p ctx) p
-let mk_opt_place_from_op (meta : Meta.meta) (op : operand)
+let mk_opt_place_from_op (span : Meta.span) (op : operand)
(ctx : Contexts.eval_ctx) : mplace option =
match op with
- | Copy p | Move p -> Some (mk_mplace meta p ctx)
+ | Copy p | Move p -> Some (mk_mplace span p ctx)
| Constant _ -> None
-let mk_emeta (m : emeta) (e : expression) : expression = Meta (m, e)
+let mk_espan (m : espan) (e : expression) : expression = Meta (m, e)
-let synthesize_symbolic_expansion (meta : Meta.meta) (sv : symbolic_value)
+let synthesize_symbolic_expansion (span : Meta.span) (sv : symbolic_value)
(place : mplace option) (seel : symbolic_expansion option list)
(el : expression list option) : expression option =
match el with
@@ -41,7 +41,7 @@ let synthesize_symbolic_expansion (meta : Meta.meta) (sv : symbolic_value)
(Some (SeLiteral (VBool false)), false_exp);
] ->
ExpandBool (true_exp, false_exp)
- | _ -> craise __FILE__ __LINE__ meta "Ill-formed boolean expansion")
+ | _ -> craise __FILE__ __LINE__ span "Ill-formed boolean expansion")
| TLiteral (TInteger int_ty) ->
(* Switch over an integer: split between the "regular" branches
and the "otherwise" branch (which should be the last branch) *)
@@ -51,9 +51,9 @@ let synthesize_symbolic_expansion (meta : Meta.meta) (sv : symbolic_value)
let get_scalar (see : symbolic_expansion option) : scalar_value =
match see with
| Some (SeLiteral (VScalar cv)) ->
- sanity_check __FILE__ __LINE__ (cv.int_ty = int_ty) meta;
+ sanity_check __FILE__ __LINE__ (cv.int_ty = int_ty) span;
cv
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
in
let branches =
List.map (fun (see, exp) -> (get_scalar see, exp)) branches
@@ -61,7 +61,7 @@ let synthesize_symbolic_expansion (meta : Meta.meta) (sv : symbolic_value)
(* For the otherwise branch, the symbolic value should have been left
* unchanged *)
let otherwise_see, otherwise = otherwise in
- sanity_check __FILE__ __LINE__ (otherwise_see = None) meta;
+ sanity_check __FILE__ __LINE__ (otherwise_see = None) span;
(* Return *)
ExpandInt (int_ty, branches, otherwise)
| TAdt (_, _) ->
@@ -71,7 +71,7 @@ let synthesize_symbolic_expansion (meta : Meta.meta) (sv : symbolic_value)
match see with
| Some (SeAdt (vid, fields)) -> (vid, fields)
| _ ->
- craise __FILE__ __LINE__ meta
+ craise __FILE__ __LINE__ span
"Ill-formed branching ADT expansion"
in
let exp =
@@ -86,18 +86,18 @@ let synthesize_symbolic_expansion (meta : Meta.meta) (sv : symbolic_value)
(* Reference expansion: there should be one branch *)
match ls with
| [ (Some see, exp) ] -> ExpandNoBranch (see, exp)
- | _ -> craise __FILE__ __LINE__ meta "Ill-formed borrow expansion")
+ | _ -> craise __FILE__ __LINE__ span "Ill-formed borrow expansion")
| TVar _ | TLiteral TChar | TNever | TTraitType _ | TArrow _ | TRawPtr _
->
- craise __FILE__ __LINE__ meta "Ill-formed symbolic expansion"
+ craise __FILE__ __LINE__ span "Ill-formed symbolic expansion"
in
Some (Expansion (place, sv, expansion))
-let synthesize_symbolic_expansion_no_branching (meta : Meta.meta)
+let synthesize_symbolic_expansion_no_branching (span : Meta.span)
(sv : symbolic_value) (place : mplace option) (see : symbolic_expansion)
(e : expression option) : expression option =
let el = Option.map (fun e -> [ e ]) e in
- synthesize_symbolic_expansion meta sv place [ Some see ] el
+ synthesize_symbolic_expansion span sv place [ Some see ] el
let synthesize_function_call (call_id : call_id) (ctx : Contexts.eval_ctx)
(sg : fun_sig option) (regions_hierarchy : region_var_groups)
@@ -180,7 +180,7 @@ let synthesize_loop (loop_id : LoopId.id) (input_svalues : symbolic_value list)
(fresh_svalues : SymbolicValueId.Set.t)
(rg_to_given_back_tys : ty list RegionGroupId.Map.t)
(end_expr : expression option) (loop_expr : expression option)
- (meta : Meta.meta) : expression option =
+ (span : Meta.span) : expression option =
match (end_expr, loop_expr) with
| None, None -> None
| Some end_expr, Some loop_expr ->
@@ -193,9 +193,9 @@ let synthesize_loop (loop_id : LoopId.id) (input_svalues : symbolic_value list)
rg_to_given_back_tys;
end_expr;
loop_expr;
- meta;
+ span;
})
- | _ -> craise __FILE__ __LINE__ meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ span "Unreachable"
let save_snapshot (ctx : Contexts.eval_ctx) (e : expression option) :
expression option =
diff --git a/compiler/Translate.ml b/compiler/Translate.ml
index 60ae99f9..02d495c0 100644
--- a/compiler/Translate.ml
+++ b/compiler/Translate.ml
@@ -127,7 +127,7 @@ let translate_function_to_pure_aux (trans_ctx : trans_ctx)
let ctx =
{
- meta = fdef.item_meta.meta;
+ span = fdef.item_meta.span;
decls_ctx = trans_ctx;
SymbolicToPure.bid = None;
sg;
@@ -179,7 +179,7 @@ let translate_function_to_pure_aux (trans_ctx : trans_ctx)
SymbolicToPure.fresh_named_vars_for_symbolic_values input_svs ctx
in
{ ctx with forward_inputs }
- | _ -> craise __FILE__ __LINE__ fdef.item_meta.meta "Unreachable"
+ | _ -> craise __FILE__ __LINE__ fdef.item_meta.span "Unreachable"
in
(* Add the backward inputs *)
@@ -204,10 +204,10 @@ let translate_function_to_pure (trans_ctx : trans_ctx)
try
Some
(translate_function_to_pure_aux trans_ctx pure_type_decls fun_dsigs fdef)
- with CFailure (meta, _) ->
+ with CFailure (span, _) ->
let name = name_to_string trans_ctx fdef.name in
let name_pattern = name_to_pattern_string trans_ctx fdef.name in
- save_error __FILE__ __LINE__ meta
+ save_error __FILE__ __LINE__ span
("Could not translate the function '" ^ name
^ " because of previous error\nName pattern: '" ^ name_pattern ^ "'");
None
@@ -244,10 +244,10 @@ let translate_crate_to_pure (crate : crate) :
( fdef.def_id,
SymbolicToPure.translate_fun_sig_from_decl_to_decomposed
trans_ctx fdef )
- with CFailure (meta, _) ->
+ with CFailure (span, _) ->
let name = name_to_string trans_ctx fdef.name in
let name_pattern = name_to_pattern_string trans_ctx fdef.name in
- save_error __FILE__ __LINE__ meta
+ save_error __FILE__ __LINE__ span
("Could not translate the function signature of '" ^ name
^ " because of previous error\nName pattern: '" ^ name_pattern
^ "'");
@@ -267,10 +267,10 @@ let translate_crate_to_pure (crate : crate) :
List.filter_map
(fun d ->
try Some (SymbolicToPure.translate_trait_decl trans_ctx d)
- with CFailure (meta, _) ->
+ with CFailure (span, _) ->
let name = name_to_string trans_ctx d.name in
let name_pattern = name_to_pattern_string trans_ctx d.name in
- save_error __FILE__ __LINE__ meta
+ save_error __FILE__ __LINE__ span
("Could not translate the trait declaration '" ^ name
^ " because of previous error\nName pattern: '" ^ name_pattern ^ "'"
);
@@ -283,10 +283,10 @@ let translate_crate_to_pure (crate : crate) :
List.filter_map
(fun d ->
try Some (SymbolicToPure.translate_trait_impl trans_ctx d)
- with CFailure (meta, _) ->
+ with CFailure (span, _) ->
let name = name_to_string trans_ctx d.name in
let name_pattern = name_to_pattern_string trans_ctx d.name in
- save_error __FILE__ __LINE__ meta
+ save_error __FILE__ __LINE__ span
("Could not translate the trait instance '" ^ name
^ " because of previous error\nName pattern: '" ^ name_pattern ^ "'"
);
@@ -496,7 +496,7 @@ let export_global (fmt : Format.formatter) (config : gen_config) (ctx : gen_ctx)
let global_decls = ctx.trans_ctx.global_ctx.global_decls in
let global = GlobalDeclId.Map.find id global_decls in
let trans = FunDeclId.Map.find global.body ctx.trans_funs in
- sanity_check __FILE__ __LINE__ (trans.loops = []) global.item_meta.meta;
+ sanity_check __FILE__ __LINE__ (trans.loops = []) global.item_meta.span;
let body = trans.f in
let is_opaque = Option.is_none body.Pure.body in
@@ -521,10 +521,10 @@ let export_global (fmt : Format.formatter) (config : gen_config) (ctx : gen_ctx)
*)
let global =
try Some (SymbolicToPure.translate_global ctx.trans_ctx global)
- with CFailure (meta, _) ->
+ with CFailure (span, _) ->
let name = name_to_string ctx.trans_ctx global.name in
let name_pattern = name_to_pattern_string ctx.trans_ctx global.name in
- save_error __FILE__ __LINE__ meta
+ save_error __FILE__ __LINE__ span
("Could not translate the global declaration '" ^ name
^ " because of previous error\nName pattern: '" ^ name_pattern ^ "'");
None
@@ -810,7 +810,7 @@ let extract_definitions (fmt : Format.formatter) (config : gen_config)
export_functions_group pure_funs
| GlobalGroup id -> export_global id
| TraitDeclGroup (RecGroup _ids) ->
- craise_opt_meta __FILE__ __LINE__ None
+ craise_opt_span __FILE__ __LINE__ None
"Mutually recursive trait declarations are not supported"
| TraitDeclGroup (NonRecGroup id) ->
(* TODO: update to extract groups *)
diff --git a/compiler/TypesAnalysis.ml b/compiler/TypesAnalysis.ml
index 987df6ca..0be3a0d4 100644
--- a/compiler/TypesAnalysis.ml
+++ b/compiler/TypesAnalysis.ml
@@ -289,7 +289,7 @@ let analyze_type_decl (updated : bool ref) (infos : type_infos)
(List.map
(fun v -> List.map (fun f -> f.field_ty) v.fields)
variants)
- | Opaque -> craise __FILE__ __LINE__ def.item_meta.meta "unreachable"
+ | Opaque -> craise __FILE__ __LINE__ def.item_meta.span "unreachable"
in
(* Explore the types and accumulate information *)
let type_decl_info = TypeDeclId.Map.find def.def_id infos in
diff --git a/compiler/Values.ml b/compiler/Values.ml
index 5473ce3e..e7b96051 100644
--- a/compiler/Values.ml
+++ b/compiler/Values.ml
@@ -153,11 +153,11 @@ and typed_value = { value : value; ty : ty }
(** "Meta"-value: information we store for the synthesis.
- Note that we never automatically visit the meta-values with the
- visitors: they really are meta information, and shouldn't be considered
+ Note that we never automatically visit the span-values with the
+ visitors: they really are span information, and shouldn't be considered
as part of the environment during a symbolic execution.
- TODO: we may want to create wrappers, to prevent accidently mixing meta
+ TODO: we may want to create wrappers, to prevent accidently mixing span
values and regular values.
*)
type mvalue = typed_value [@@deriving show, ord]
@@ -166,7 +166,7 @@ type mvalue = typed_value [@@deriving show, ord]
See the explanations for {!mvalue}
- TODO: we may want to create wrappers, to prevent mixing meta values
+ TODO: we may want to create wrappers, to prevent mixing span values
and regular values.
*)
type msymbolic_value = symbolic_value [@@deriving show, ord]
@@ -270,7 +270,7 @@ and aproj =
'a and one for 'b.
We accumulate those values in the list of projections (note that
- the meta value stores the value which was given back).
+ the span value stores the value which was given back).
We can later end the projector of loans if [s@0] is not referenced
anywhere in the context below a projector of borrows which intersects
@@ -282,14 +282,14 @@ and aproj =
Also note that once given to a borrow projection, a symbolic value
can't get updated/expanded: this means that we don't need to save
- any meta-value here.
+ any span-value here.
*)
| AEndedProjLoans of msymbolic_value * (msymbolic_value * aproj) list
(** An ended projector of loans over a symbolic value.
See the explanations for {!AProjLoans}
- Note that we keep the original symbolic value as a meta-value.
+ Note that we keep the original symbolic value as a span-value.
*)
| AEndedProjBorrows of msymbolic_value
(** The only purpose of {!AEndedProjBorrows} is to store, for synthesis
@@ -376,7 +376,7 @@ and aloan_content =
| AEndedMutLoan of {
child : typed_avalue;
given_back : typed_avalue;
- given_back_meta : mvalue;
+ given_back_span : mvalue;
}
(** An ended mutable loan in an abstraction.
We need it because abstractions must keep track of the values
@@ -401,7 +401,7 @@ and aloan_content =
After ending [l0]:
{[
- abs0 { a_ended_mut_loan { child = _; given_back = _; given_back_meta = U32 3; }
+ abs0 { a_ended_mut_loan { child = _; given_back = _; given_back_span = U32 3; }
x -> ⊥
]}
@@ -420,7 +420,7 @@ and aloan_content =
a_ended_mut_loan {
child = _;
given_back = a_mut_borrow l1 _;
- given_back_meta = (mut_borrow l1 (U32 3));
+ given_back_span = (mut_borrow l1 (U32 3));
}
}
...
@@ -464,7 +464,7 @@ and aloan_content =
a_ended_ignored_mut_loan {
child = a_mut_loan l1 _;
given_back = a_mut_borrow l1 _;
- given_back_meta = mut_borrow l1 @s1
+ given_back_span = mut_borrow l1 @s1
}
}
x -> ⊥
@@ -474,7 +474,7 @@ and aloan_content =
| AEndedIgnoredMutLoan of {
child : typed_avalue;
given_back : typed_avalue;
- given_back_meta : mvalue;
+ given_back_span : mvalue;
}
(** Similar to {!AEndedMutLoan}, for ignored loans.
See the comments for {!AIgnoredMutLoan}.
@@ -613,7 +613,7 @@ and aborrow_content =
*)
| AEndedMutBorrow of msymbolic_value * typed_avalue
(** The sole purpose of {!AEndedMutBorrow} is to store the (symbolic) value
- that we gave back as a meta-value, to help with the synthesis.
+ that we gave back as a span-value, to help with the synthesis.
*)
| AEndedSharedBorrow
(** We don't really need {!AEndedSharedBorrow}: we simply want to be
@@ -622,8 +622,8 @@ and aborrow_content =
| AEndedIgnoredMutBorrow of {
child : typed_avalue;
given_back : typed_avalue;
- given_back_meta : msymbolic_value;
- (** [given_back_meta] is used to store the (symbolic) value we gave back
+ given_back_span : msymbolic_value;
+ (** [given_back_span] is used to store the (symbolic) value we gave back
upon ending the borrow.
Rk.: *DO NOT* use [visit_AEndedIgnoredMutLoan].
diff --git a/compiler/ValuesUtils.ml b/compiler/ValuesUtils.ml
index b6ee66f5..7bb50cad 100644
--- a/compiler/ValuesUtils.ml
+++ b/compiler/ValuesUtils.ml
@@ -11,37 +11,37 @@ exception FoundSymbolicValue of symbolic_value
let mk_unit_value : typed_value =
{ value = VAdt { variant_id = None; field_values = [] }; ty = mk_unit_ty }
-let mk_typed_value (meta : Meta.meta) (ty : ty) (value : value) : typed_value =
- sanity_check __FILE__ __LINE__ (ty_is_ety ty) meta;
+let mk_typed_value (span : Meta.span) (ty : ty) (value : value) : typed_value =
+ sanity_check __FILE__ __LINE__ (ty_is_ety ty) span;
{ value; ty }
-let mk_typed_avalue (meta : Meta.meta) (ty : ty) (value : avalue) : typed_avalue
+let mk_typed_avalue (span : Meta.span) (ty : ty) (value : avalue) : typed_avalue
=
- sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta;
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty) span;
{ value; ty }
-let mk_bottom (meta : Meta.meta) (ty : ty) : typed_value =
- sanity_check __FILE__ __LINE__ (ty_is_ety ty) meta;
+let mk_bottom (span : Meta.span) (ty : ty) : typed_value =
+ sanity_check __FILE__ __LINE__ (ty_is_ety ty) span;
{ value = VBottom; ty }
-let mk_abottom (meta : Meta.meta) (ty : ty) : typed_avalue =
- sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta;
+let mk_abottom (span : Meta.span) (ty : ty) : typed_avalue =
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty) span;
{ value = ABottom; ty }
-let mk_aignored (meta : Meta.meta) (ty : ty) : typed_avalue =
- sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta;
+let mk_aignored (span : Meta.span) (ty : ty) : typed_avalue =
+ sanity_check __FILE__ __LINE__ (ty_is_rty ty) span;
{ value = AIgnored; ty }
-let value_as_symbolic (meta : Meta.meta) (v : value) : symbolic_value =
+let value_as_symbolic (span : Meta.span) (v : value) : symbolic_value =
match v with
| VSymbolic v -> v
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
(** Box a value *)
-let mk_box_value (meta : Meta.meta) (v : typed_value) : typed_value =
+let mk_box_value (span : Meta.span) (v : typed_value) : typed_value =
let box_ty = mk_box_ty v.ty in
let box_v = VAdt { variant_id = None; field_values = [ v ] } in
- mk_typed_value meta box_ty box_v
+ mk_typed_value span box_ty box_v
let is_bottom (v : value) : bool = match v with VBottom -> true | _ -> false
@@ -51,16 +51,16 @@ let is_aignored (v : avalue) : bool =
let is_symbolic (v : value) : bool =
match v with VSymbolic _ -> true | _ -> false
-let as_symbolic (meta : Meta.meta) (v : value) : symbolic_value =
+let as_symbolic (span : Meta.span) (v : value) : symbolic_value =
match v with
| VSymbolic s -> s
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
-let as_mut_borrow (meta : Meta.meta) (v : typed_value) :
+let as_mut_borrow (span : Meta.span) (v : typed_value) :
BorrowId.id * typed_value =
match v.value with
| VBorrow (VMutBorrow (bid, bv)) -> (bid, bv)
- | _ -> craise __FILE__ __LINE__ meta "Unexpected"
+ | _ -> craise __FILE__ __LINE__ span "Unexpected"
let is_unit (v : typed_value) : bool =
ty_is_unit v.ty
diff --git a/flake.lock b/flake.lock
index 38241840..712de213 100644
--- a/flake.lock
+++ b/flake.lock
@@ -9,11 +9,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
- "lastModified": 1716542431,
- "narHash": "sha256-Q+WLCH7teTpBG1ScWi5VsvpjNmUrgDSv6I6Vv8CLkaM=",
+ "lastModified": 1716552262,
+ "narHash": "sha256-anBm+nYYp1IDHb+9Dk5oMv28OK/vjcf+wuFI3IRjKrA=",
"owner": "aeneasverif",
"repo": "charon",
- "rev": "7cb5b367aec5768bee003d395634b30e13638b7d",
+ "rev": "a5fda598f359a2b85e044a884fd977d75f4578b4",
"type": "github"
},
"original": {