@ -9,20 +9,23 @@ open! IStd
module F = Format
module F = Format
module Trust = struct
module Trust = struct
type t = All | Only of JavaClassName . t lis t [ @@ deriving compare , equal ]
type t = All | Only of JavaClassName . Set . t [ @@ deriving compare , equal ]
let none = Only []
let none = Only JavaClassName . Set . empty
let extract_trust_list = function
let extract_trust_list = function
| Annot . Array class_values ->
| Annot . Array class_values ->
(* The only elements of this array can be class names; therefore short-circuit and return None if it's not the case. *)
(* The only elements of this array can be class names; therefore short-circuit and return None if it's not the case. *)
IList . traverse_opt class_values ~ f : ( fun el ->
let trust_list =
match el with
IList . traverse_opt class_values ~ f : ( fun el ->
| Annot . Class class_typ ->
match el with
Typ . name class_typ
| Annot . Class class_typ ->
| > Option . map ~ f : ( fun name -> Typ . Name . Java . get_java_class_name_exn name )
Typ . name class_typ
| _ ->
| > Option . map ~ f : ( fun name -> Typ . Name . Java . get_java_class_name_exn name )
None )
| _ ->
None )
in
Option . map trust_list ~ f : JavaClassName . Set . of_list
| _ ->
| _ ->
None
None
@ -47,15 +50,14 @@ module Trust = struct
(* We are interested only in explicit lists *)
(* We are interested only in explicit lists *)
false
false
| Only classes ->
| Only classes ->
List. exists classes ~ f : ( JavaClassName . equal name )
JavaClassName. Set . exists ( JavaClassName . equal name ) classes
let is_stricter ~ stricter ~ weaker =
let is_stricter ~ stricter ~ weaker =
let is_stricter_trust_list stricter_ li st weaker_ li st =
let is_stricter_trust_list stricter_ se t weaker_ se t =
(* stricter trust list should be a strict subset of the weaker one *)
(* stricter trust list should be a strict subset of the weaker one *)
List . length stricter_list < List . length weaker_list
JavaClassName . Set . cardinal stricter_set < JavaClassName . Set . cardinal weaker_set
&& List . for_all stricter_list ~ f : ( fun strict_name ->
&& JavaClassName . Set . subset stricter_set weaker_set
List . exists weaker_list ~ f : ( fun name -> JavaClassName . equal name strict_name ) )
in
in
match ( stricter , weaker ) with
match ( stricter , weaker ) with
| All , All | All , Only _ ->
| All , All | All , Only _ ->
@ -70,7 +72,7 @@ module Trust = struct
match t with
match t with
| All ->
| All ->
F . fprintf fmt " all "
F . fprintf fmt " all "
| Only [] ->
| Only names when JavaClassName . Set . is_empty names ->
F . fprintf fmt " none "
F . fprintf fmt " none "
| Only _ names ->
| Only _ names ->
F . fprintf fmt " selected "
F . fprintf fmt " selected "