<commit_before>(*s: dataflow_php.ml *)
(*s: Facebook copyright *)
(* <NAME>, <NAME>, <NAME>
 *
 * Copyright (C) 2009-2010 Facebook
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation, with the
 * special exception on linking described in file license.txt.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the file
 * license.txt for more details.
 *)
(*e: Facebook copyright *)

open Common
open Ast_php

module F = Controlflow_php
module Ast = Ast_php

(*****************************************************************************)
(* Prelude *)
(*****************************************************************************)

(*
 * The goal of a dataflow analysis is to store information about each
 * variable at each program point that is each node in a CFG,
 * e.g. whether a variable is "live" at a program point.
 * As you may want different kind of information, the types below
 * are polymorphic. But each take as a key a variable name (dname, for
 * dollar name, the type of variables in Ast_php).
 *
 * less: could use a functor, so would not have all those 'a.
 * todo? do we need other kind of information than variable environment ?
 * Dataflow analysis talks only about variables ?
 *)

(*****************************************************************************)
(* Types *)
(*****************************************************************************)

(* The comparison function uses only the name string so
 * two variables at different positions in the code will be agglomerated
 * correctly in the Set or Map.
 *)
module StrOrd = struct
  type t = string
  let compare = compare
end

module VarMap = Map.Make(StrOrd)
module VarSet = Set.Make(StrOrd)

type nodei = Ograph_extended.nodei

module NiOrd = struct
  type t = nodei
  let compare = compare
end

module NodeiSet = Set.Make(NiOrd)

(* The final dataflow result; a map from each program point to a map containing
 * information from each variables.
 *
 * opti: this used to be a 'NodeiMap.t' instead of an 'array' but 'nodei'
 * are always int and array gives a 6x speedup according to iain
 * so let's use array.
 *)
type 'a mapping = ('a inout) array

  and 'a inout = {
    in_env: 'a VarMap.t;
    out_env: 'a VarMap.t;
  }<commit_msg>* lang_php/analyze/foundation/dataflow_php.ml: estet<commit_after>(*s: dataflow_php.ml *)
(*s: Facebook copyright *)
(* <NAME>, <NAME>, <NAME>
 *
 * Copyright (C) 2009-2010 Facebook
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation, with the
 * special exception on linking described in file license.txt.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the file
 * license.txt for more details.
 *)
(*e: Facebook copyright *)

open Common
open Ast_php

module F = Controlflow_php
module Ast = Ast_php

(*****************************************************************************)
(* Prelude *)
(*****************************************************************************)

(*
 * The goal of a dataflow analysis is to store information about each
 * variable at each program point that is each node in a CFG,
 * e.g. whether a variable is "live" at a program point.
 * As you may want different kind of information, the types below
 * are polymorphic. But each take as a key a variable name (dname, for
 * dollar name, the type of variables in Ast_php).
 *
 * less: could use a functor, so would not have all those 'a.
 * todo? do we need other kind of information than variable environment ?
 * Dataflow analysis talks only about variables ?
 *)

(*****************************************************************************)
(* Types *)
(*****************************************************************************)

(* The comparison function uses only the name string so
 * two variables at different positions in the code will be agglomerated
 * correctly in the Set or Map.
 *)

module VarMap = Map.Make(String)
module VarSet = Set.Make(String)

type nodei = Ograph_extended.nodei
module NodeiSet = Set.Make(Int)

(* The final dataflow result; a map from each program point to a map containing
 * information from each variables.
 *
 * opti: this used to be a 'NodeiMap.t' instead of an 'array' but 'nodei'
 * are always int and array gives a 6x speedup according to iain
 * so let's use array.
 *)
type 'a mapping = ('a inout) array

  and 'a inout = {
    in_env: 'a VarMap.t;
    out_env: 'a VarMap.t;
  }
{'fraction_non_alphanumeric': 0.19541860936549768, 'fraction_numerical': 0.004459760794648287, 'mean_word_length': 4.357220412595005, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5553024', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1242, 'n_words': 620}