summaryrefslogtreecommitdiff
path: root/compiler/InterpreterStatements.ml
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/InterpreterStatements.ml')
-rw-r--r--compiler/InterpreterStatements.ml76
1 files changed, 52 insertions, 24 deletions
diff --git a/compiler/InterpreterStatements.ml b/compiler/InterpreterStatements.ml
index 30b7b333..97c8bcd6 100644
--- a/compiler/InterpreterStatements.ml
+++ b/compiler/InterpreterStatements.ml
@@ -728,7 +728,13 @@ let create_push_abstractions_from_abs_region_groups
to a trait clause but directly to the method provided in the trait declaration.
*)
let eval_transparent_function_call_symbolic_inst (call : call) (ctx : eval_ctx)
- : fun_id_or_trait_method_ref * generic_args * fun_decl * inst_fun_sig =
+ :
+ fun_id_or_trait_method_ref
+ * generic_args
+ * (generic_args * trait_instance_id) option
+ * fun_decl
+ * region_var_groups
+ * inst_fun_sig =
match call.func with
| FnOpMove _ ->
(* Closure case: TODO *)
@@ -747,13 +753,13 @@ let eval_transparent_function_call_symbolic_inst (call : call) (ctx : eval_ctx)
let tr_self = UnknownTrait __FUNCTION__ in
let regions_hierarchy =
LlbcAstUtils.FunIdMap.find (FRegular fid)
- ctx.fun_context.regions_hierarchies
+ ctx.fun_ctx.regions_hierarchies
in
let inst_sg =
instantiate_fun_sig ctx func.generics tr_self def.signature
regions_hierarchy
in
- (func.func, func.generics, def, inst_sg)
+ (func.func, func.generics, None, def, regions_hierarchy, inst_sg)
| FunId (FAssumed _) ->
(* Unreachable: must be a transparent function *)
raise (Failure "Unreachable")
@@ -793,7 +799,7 @@ let eval_transparent_function_call_symbolic_inst (call : call) (ctx : eval_ctx)
let fid : fun_id = FRegular id in
let regions_hierarchy =
LlbcAstUtils.FunIdMap.find fid
- ctx.fun_context.regions_hierarchies
+ ctx.fun_ctx.regions_hierarchies
in
let inst_sg =
instantiate_fun_sig ctx generics tr_self
@@ -806,7 +812,12 @@ let eval_transparent_function_call_symbolic_inst (call : call) (ctx : eval_ctx)
we also need to update the generics.
*)
let func = FunId fid in
- (func, generics, method_def, inst_sg)
+ ( func,
+ generics,
+ Some (generics, tr_self),
+ method_def,
+ regions_hierarchy,
+ inst_sg )
| None ->
(* If not found, lookup the methods provided by the trait *declaration*
(remember: for now, we forbid overriding provided methods) *)
@@ -853,14 +864,19 @@ let eval_transparent_function_call_symbolic_inst (call : call) (ctx : eval_ctx)
method_def.signature.parent_params_info));
let regions_hierarchy =
LlbcAstUtils.FunIdMap.find (FRegular method_id)
- ctx.fun_context.regions_hierarchies
+ ctx.fun_ctx.regions_hierarchies
in
let tr_self = TraitRef trait_ref in
let inst_sg =
instantiate_fun_sig ctx all_generics tr_self
method_def.signature regions_hierarchy
in
- (func.func, func.generics, method_def, inst_sg))
+ ( func.func,
+ func.generics,
+ Some (all_generics, tr_self),
+ method_def,
+ regions_hierarchy,
+ inst_sg ))
| _ ->
(* We are using a local clause - we lookup the trait decl *)
let trait_decl =
@@ -884,14 +900,19 @@ let eval_transparent_function_call_symbolic_inst (call : call) (ctx : eval_ctx)
(* Instantiate *)
let regions_hierarchy =
LlbcAstUtils.FunIdMap.find (FRegular method_id)
- ctx.fun_context.regions_hierarchies
+ ctx.fun_ctx.regions_hierarchies
in
let tr_self = TraitRef trait_ref in
let inst_sg =
instantiate_fun_sig ctx generics tr_self method_def.signature
regions_hierarchy
in
- (func.func, func.generics, method_def, inst_sg)))
+ ( func.func,
+ func.generics,
+ Some (generics, tr_self),
+ method_def,
+ regions_hierarchy,
+ inst_sg )))
(** Evaluate a statement *)
let rec eval_statement (config : config) (st : statement) : st_cm_fun =
@@ -1277,14 +1298,15 @@ and eval_transparent_function_call_concrete (config : config)
and eval_transparent_function_call_symbolic (config : config) (call : call) :
st_cm_fun =
fun cf ctx ->
- let func, generics, def, inst_sg =
+ let func, generics, trait_method_generics, def, regions_hierarchy, inst_sg =
eval_transparent_function_call_symbolic_inst call ctx
in
(* Sanity check *)
assert (List.length call.args = List.length def.signature.inputs);
(* Evaluate the function call *)
- eval_function_call_symbolic_from_inst_sig config func inst_sg generics
- call.args call.dest cf ctx
+ eval_function_call_symbolic_from_inst_sig config func def.signature
+ regions_hierarchy inst_sg generics trait_method_generics call.args call.dest
+ cf ctx
(** Evaluate a function call in symbolic mode by using the function signature.
@@ -1298,8 +1320,11 @@ and eval_transparent_function_call_symbolic (config : config) (call : call) :
trait ref as input.
*)
and eval_function_call_symbolic_from_inst_sig (config : config)
- (fid : fun_id_or_trait_method_ref) (inst_sg : inst_fun_sig)
- (generics : generic_args) (args : operand list) (dest : place) : st_cm_fun =
+ (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)
+ (args : operand list) (dest : place) : st_cm_fun =
fun cf ctx ->
log#ldebug
(lazy
@@ -1378,8 +1403,9 @@ and eval_function_call_symbolic_from_inst_sig (config : config)
let expr = cf ctx in
(* Synthesize the symbolic AST *)
- S.synthesize_regular_function_call fid call_id ctx abs_ids generics args
- args_places ret_spc dest_place expr
+ S.synthesize_regular_function_call fid call_id ctx sg regions_hierarchy
+ abs_ids generics trait_method_generics args args_places ret_spc dest_place
+ expr
in
let cc = comp cc cf_call in
@@ -1450,7 +1476,7 @@ and eval_assumed_function_call_symbolic (config : config) (fid : assumed_fun_id)
* this is a current limitation of our synthesis *)
assert (
List.for_all
- (fun ty -> not (ty_has_borrows ctx.type_context.type_infos ty))
+ (fun ty -> not (ty_has_borrows ctx.type_ctx.type_infos ty))
generics.types);
(* There are two cases (and this is extremely annoying):
@@ -1468,7 +1494,7 @@ and eval_assumed_function_call_symbolic (config : config) (fid : assumed_fun_id)
(* In symbolic mode, the behaviour of a function call is completely defined
* by the signature of the function: we thus simply generate correctly
* instantiated signatures, and delegate the work to an auxiliary function *)
- let inst_sig =
+ let sg, regions_hierarchy, inst_sig =
match fid with
| BoxFree ->
(* Should have been treated above *)
@@ -1476,18 +1502,20 @@ and eval_assumed_function_call_symbolic (config : config) (fid : assumed_fun_id)
| _ ->
let regions_hierarchy =
LlbcAstUtils.FunIdMap.find (FAssumed fid)
- ctx.fun_context.regions_hierarchies
+ ctx.fun_ctx.regions_hierarchies
in
(* There shouldn't be any reference to Self *)
let tr_self = UnknownTrait __FUNCTION__ in
- instantiate_fun_sig ctx generics tr_self
- (Assumed.get_assumed_fun_sig fid)
- regions_hierarchy
+ let sg = Assumed.get_assumed_fun_sig fid in
+ let inst_sg =
+ instantiate_fun_sig 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 (FunId (FAssumed fid))
- inst_sig generics args dest cf ctx
+ eval_function_call_symbolic_from_inst_sig config (FunId (FAssumed fid)) sg
+ regions_hierarchy inst_sig generics None args dest cf ctx
(** Evaluate a statement seen as a function body *)
and eval_function_body (config : config) (body : statement) : st_cm_fun =