<commit_before>type call = Sites.t * string * string * Sites.t list
module CallSet = Set.Make(struct type t = call let compare = compare end)

let rec callset_from_list l =
  match l with
  | [] -> CallSet.empty
  | c::tl -> CallSet.add c (callset_from_list tl)

let lifecycle s st =
  let cl = Site.get_class s in
  let ss = Sites.from_list [s] in
  let csl = match st with
    | State.Uninit -> [(ss, cl, "<init>", [])]
    | State.Init -> [(ss, cl, "onCreate", [])]
    | State.Created -> [(ss, cl, "onResume", [])]
    | State.Active -> [(ss, cl, "onPause", [])] in
  callset_from_list csl

let next_lifecycle s state =
  match state with
  | State.Any -> failwith "Activity state lost"
  | State.State st ->
    lifecycle s st
  | State.None -> CallSet.empty

let next g =
  let (h, a) = g in
  match a with
  | As.Any -> failwith "Activity stack lost"
  | As.AS al ->
    let next_lifecycle cs s =
      let value = Heap.get_field h s (Field.AField "state") in
      let state = Value.get_state value in
      CallSet.union cs (next_lifecycle s state) in
    List.fold_left next_lifecycle CallSet.empty al
  | As.None -> CallSet.empty

let update m g =
  g

let transfer_of_call app g call gc =
  (* Call args and return value are not taken into accounct. *)
  let (s, cl, m, _) = call in
  let e_init = Env.from_list [("this", Value.Sites s)] in
  let l_init = (g, e_init) in
  let cfg = App.get_method app cl m in
  let (g_final, _) = Analysis.fixpoint Local.equal (Sem.transfer Api.transfer_exn cfg) l_init in
  let g_updated = update m g_final in<commit_msg>Use Lib.Set in Android<commit_after>type call = Sites.t * string * string * Sites.t list
module CallSet = Lib.Set.Make(struct type t = call let compare = compare end)

let lifecycle s st =
  let cl = Site.get_class s in
  let ss = Sites.from_list [s] in
  let csl = match st with
    | State.Uninit -> [(ss, cl, "<init>", [])]
    | State.Init -> [(ss, cl, "onCreate", [])]
    | State.Created -> [(ss, cl, "onResume", [])]
    | State.Active -> [(ss, cl, "onPause", [])] in
  CallSet.from_list csl

let next_lifecycle s state =
  match state with
  | State.Any -> failwith "Activity state lost"
  | State.State st ->
    lifecycle s st
  | State.None -> CallSet.empty

let next g =
  let (h, a) = g in
  match a with
  | As.Any -> failwith "Activity stack lost"
  | As.AS al ->
    let next_lifecycle cs s =
      let value = Heap.get_field h s (Field.AField "state") in
      let state = Value.get_state value in
      CallSet.union cs (next_lifecycle s state) in
    List.fold_left next_lifecycle CallSet.empty al
  | As.None -> CallSet.empty

let update m g =
  g

let transfer_of_call app g call gc =
  (* Call args and return value are not taken into accounct. *)
  let (s, cl, m, _) = call in
  let e_init = Env.from_list [("this", Value.Sites s)] in
  let l_init = (g, e_init) in
  let cfg = App.get_method app cl m in
  let (g_final, _) = Analysis.fixpoint Local.equal (Sem.transfer Api.transfer_exn cfg) l_init in
  let g_updated = update m g_final in
{'fraction_non_alphanumeric': 0.12215252558600198, 'fraction_numerical': 0.0, 'mean_word_length': 2.9197930142302715, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3331923', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1087, 'n_words': 379}