"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "analysis/callgraph.ml" between
pyre-check-0.0.54.tar.gz and pyre-check-0.0.55.tar.gz

About: Pyre is a performant type checker for Python (ships with Pysa, a security focused static analysis tool).

callgraph.ml  (pyre-check-0.0.54):callgraph.ml  (pyre-check-0.0.55)
skipping to change at line 116 skipping to change at line 116
module type Builder = sig module type Builder = sig
val initialize : unit -> unit val initialize : unit -> unit
val add_callee val add_callee
: global_resolution:GlobalResolution.t -> : global_resolution:GlobalResolution.t ->
target:Type.t option -> target:Type.t option ->
callables:Type.Callable.t list option -> callables:Type.Callable.t list option ->
arguments:Call.Argument.t list -> arguments:Call.Argument.t list ->
dynamic:bool -> dynamic:bool ->
qualifier:Reference.t -> qualifier:Reference.t ->
callee_type:Type.t ->
callee:Expression.t -> callee:Expression.t ->
unit unit
val add_property_callees val add_property_callees
: global_resolution:GlobalResolution.t -> : global_resolution:GlobalResolution.t ->
resolved_base:Type.t -> resolved_base:Type.t ->
attributes:(AnnotatedAttribute.instantiated * Type.t) list -> attributes:(AnnotatedAttribute.instantiated * Type.t) list ->
name:string -> name:string ->
qualifier:Reference.t -> qualifier:Reference.t ->
location:Location.t -> location:Location.t ->
skipping to change at line 143 skipping to change at line 144
unit unit
val get_all_callees : unit -> callee_with_locations list val get_all_callees : unit -> callee_with_locations list
end end
module DefaultBuilder : Builder = struct module DefaultBuilder : Builder = struct
let table = Location.WithModule.Table.create () let table = Location.WithModule.Table.create ()
let initialize () = Hashtbl.clear table let initialize () = Hashtbl.clear table
let add_callee ~global_resolution ~target ~callables ~arguments:_ ~dynamic ~qu let add_callee
alifier ~callee = ~global_resolution
~target
~callables
~arguments:_
~dynamic
~qualifier
~callee_type:_
~callee
=
(* Store callees. *) (* Store callees. *)
let callees = let callees =
let method_callee ?(is_optional_class_attribute = false) annotation callab le_kind = let method_callee ?(is_optional_class_attribute = false) annotation callab le_kind =
let is_protocol () = let is_protocol () =
Type.split annotation |> fst |> GlobalResolution.is_protocol global_re solution Type.split annotation |> fst |> GlobalResolution.is_protocol global_re solution
in in
match callable_kind with match callable_kind with
| Type.Callable.Named direct_target when not (is_protocol ()) -> | Type.Callable.Named direct_target when not (is_protocol ()) ->
let class_name = let class_name =
if Type.is_meta annotation then if Type.is_meta annotation then
skipping to change at line 170 skipping to change at line 180
{ {
direct_target; direct_target;
class_name; class_name;
dispatch = (if dynamic then Dynamic else Static); dispatch = (if dynamic then Dynamic else Static);
is_optional_class_attribute; is_optional_class_attribute;
}; };
] ]
| _ -> [] | _ -> []
in in
let callable_kinds = callables >>| List.map ~f:(fun { Type.Callable.kind; _ } -> kind) in let callable_kinds = callables >>| List.map ~f:(fun { Type.Callable.kind; _ } -> kind) in
let extract_callables ~annotation instantiated_attribute =
instantiated_attribute
|> AnnotatedAttribute.annotation
|> Annotation.annotation
|> Type.callable_name
>>| (fun name -> method_callee ~is_optional_class_attribute:true annotat
ion (Named name))
|> function
| None -> []
| Some list -> list
in
match target, callable_kinds with match target, callable_kinds with
| Some (Type.Union elements), Some callables when List.length elements = L ist.length callables | Some (Type.Union elements), Some callables when List.length elements = L ist.length callables
-> ->
List.map2_exn elements callables ~f:method_callee |> List.concat List.map2_exn elements callables ~f:method_callee |> List.concat
| Some annotation, Some callables -> List.concat_map callables ~f:(method_ callee annotation) | Some annotation, Some callables -> List.concat_map callables ~f:(method_ callee annotation)
| Some (Type.Union ([Type.NoneType; annotation] | [annotation; Type.NoneTy pe])), _ -> ( | Some (Type.Union ([Type.NoneType; annotation] | [annotation; Type.NoneTy pe])), _ -> (
match Node.value callee with match Node.value callee with
| Expression.Name (Name.Attribute { attribute; _ }) -> ( | Expression.Name (Name.Attribute { attribute; _ }) ->
GlobalResolution.attribute_from_annotation GlobalResolution.attribute_from_annotation
global_resolution global_resolution
~parent:annotation ~parent:annotation
~name:attribute ~name:attribute
>>| AnnotatedAttribute.annotation >>| extract_callables ~annotation
>>| Annotation.annotation |> Option.value ~default:[]
>>= Type.callable_name
>>| (fun name ->
method_callee ~is_optional_class_attribute:true annotation (
Named name))
|> function
| None -> []
| Some list -> list )
| _ -> [] ) | _ -> [] )
| None, Some defines -> | None, Some defines ->
List.map defines ~f:(function List.map defines ~f:(function
| Named define -> Some (Function define) | Named define -> Some (Function define)
| _ -> None) | _ -> None)
|> Option.all |> Option.all
|> Option.value ~default:[] |> Option.value ~default:[]
| _ -> [] | _ -> []
in in
let key = Location.with_module ~qualifier (Node.location callee) in let key = Location.with_module ~qualifier (Node.location callee) in
skipping to change at line 289 skipping to change at line 303
module NullBuilder : Builder = struct module NullBuilder : Builder = struct
let initialize () = () let initialize () = ()
let add_callee let add_callee
~global_resolution:_ ~global_resolution:_
~target:_ ~target:_
~callables:_ ~callables:_
~arguments:_ ~arguments:_
~dynamic:_ ~dynamic:_
~qualifier:_ ~qualifier:_
~callee_type:_
~callee:_ ~callee:_
= =
() ()
let add_property_setter_callees ~attribute:_ ~instantiated_parent:_ ~name:_ ~l ocation:_ = () let add_property_setter_callees ~attribute:_ ~instantiated_parent:_ ~name:_ ~l ocation:_ = ()
let add_property_callees let add_property_callees
~global_resolution:_ ~global_resolution:_
~resolved_base:_ ~resolved_base:_
~attributes:_ ~attributes:_
 End of changes. 6 change blocks. 
12 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)