[SIL] Change WithBlockParameters to have Block.t

Summary:
`WithBlockParameters` is generated by a pre-analysis to express concrete block parameters.  However,
before this diff, the block parameters only have names, which is insufficient to find their
summaries.  This diff change `WithBlockParameters` to have `Block.t` that includes the parameters of
the block, so we can find blocks' summaries.

Reviewed By: ezgicicek

Differential Revision: D23785148

fbshipit-source-id: 9034f4f8d
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent ee5ccfeb9b
commit ecb409504d

@ -381,7 +381,7 @@ type t =
| Linters_dummy_method | Linters_dummy_method
| Block of Block.t | Block of Block.t
| ObjC_Cpp of ObjC_Cpp.t | ObjC_Cpp of ObjC_Cpp.t
| WithBlockParameters of t * Block.block_name list | WithBlockParameters of t * Block.t list
[@@deriving compare] [@@deriving compare]
let equal = [%compare.equal: t] let equal = [%compare.equal: t]
@ -424,10 +424,10 @@ let is_objc_dealloc procname =
match procname with ObjC_Cpp {method_name} -> ObjC_Cpp.is_objc_dealloc method_name | _ -> false match procname with ObjC_Cpp {method_name} -> ObjC_Cpp.is_objc_dealloc method_name | _ -> false
let block_name_of_procname procname = let block_of_procname procname =
match procname with match procname with
| Block block -> | Block block ->
block.name block
| _ -> | _ ->
Logging.die InternalError "Only to be called with Objective-C block names" Logging.die InternalError "Only to be called with Objective-C block names"
@ -549,10 +549,10 @@ let get_global_name_of_initializer = function
None None
let pp_with_block_parameters pp fmt base blocks = let pp_with_block_parameters verbose pp fmt base blocks =
pp fmt base ; pp fmt base ;
F.pp_print_string fmt "[" ; F.pp_print_string fmt "[" ;
Pp.seq ~sep:"^" F.pp_print_string fmt blocks ; Pp.seq ~sep:"^" (Block.pp verbose) fmt blocks ;
F.pp_print_string fmt "]" F.pp_print_string fmt "]"
@ -569,7 +569,7 @@ let rec pp_unique_id fmt = function
| WithBlockParameters (base, []) -> | WithBlockParameters (base, []) ->
pp_unique_id fmt base pp_unique_id fmt base
| WithBlockParameters (base, (_ :: _ as blocks)) -> | WithBlockParameters (base, (_ :: _ as blocks)) ->
pp_with_block_parameters pp_unique_id fmt base blocks pp_with_block_parameters Verbose pp_unique_id fmt base blocks
| Linters_dummy_method -> | Linters_dummy_method ->
F.pp_print_string fmt "Linters_dummy_method" F.pp_print_string fmt "Linters_dummy_method"
@ -589,7 +589,7 @@ let rec pp fmt = function
| WithBlockParameters (base, []) -> | WithBlockParameters (base, []) ->
pp fmt base pp fmt base
| WithBlockParameters (base, (_ :: _ as blocks)) -> | WithBlockParameters (base, (_ :: _ as blocks)) ->
pp_with_block_parameters pp fmt base blocks pp_with_block_parameters Non_verbose pp fmt base blocks
| Linters_dummy_method -> | Linters_dummy_method ->
pp_unique_id fmt Linters_dummy_method pp_unique_id fmt Linters_dummy_method

@ -196,10 +196,10 @@ type t =
| Linters_dummy_method | Linters_dummy_method
| Block of Block.t | Block of Block.t
| ObjC_Cpp of ObjC_Cpp.t | ObjC_Cpp of ObjC_Cpp.t
| WithBlockParameters of t * Block.block_name list | WithBlockParameters of t * Block.t list
[@@deriving compare] [@@deriving compare]
val block_name_of_procname : t -> Block.block_name val block_of_procname : t -> Block.t
val equal : t -> t -> bool val equal : t -> t -> bool
@ -292,9 +292,9 @@ val is_java : t -> bool
val as_java_exn : explanation:string -> t -> Java.t val as_java_exn : explanation:string -> t -> Java.t
(** Converts to a Java.t. Throws if [is_java] is false *) (** Converts to a Java.t. Throws if [is_java] is false *)
val with_block_parameters : t -> Block.block_name list -> t val with_block_parameters : t -> Block.t list -> t
(** Create a procedure name instantiated with block parameters from a base procedure name and a list (** Create a procedure name instantiated with block parameters from a base procedure name and a list
of block procedure names (the arguments). *) of block procedures. *)
val objc_cpp_replace_method_name : t -> string -> t val objc_cpp_replace_method_name : t -> string -> t

@ -88,14 +88,14 @@ let should_specialize actual_params call_flags =
(* name for the specialized method instantiated with closure arguments *) (* name for the specialized method instantiated with closure arguments *)
let pname_with_closure_args callee_pname actual_params = let pname_with_closure_args callee_pname actual_params =
let block_name_args = let block_args =
List.filter_map actual_params ~f:(function List.filter_map actual_params ~f:(function
| Exp.Closure cl, _ when Procname.is_objc_block cl.name -> | Exp.Closure cl, _ when Procname.is_objc_block cl.name ->
Some (Procname.block_name_of_procname cl.name) Some (Procname.block_of_procname cl.name)
| _ -> | _ ->
None ) None )
in in
Procname.with_block_parameters callee_pname block_name_args Procname.with_block_parameters callee_pname block_args
let formals_closures_map map = let formals_closures_map map =

Loading…
Cancel
Save