diff --git a/infer/src/base/JsonBuilder.ml b/infer/src/base/JsonBuilder.ml new file mode 100644 index 000000000..01608ecc5 --- /dev/null +++ b/infer/src/base/JsonBuilder.ml @@ -0,0 +1,46 @@ +(* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + *) + +open! IStd + +type t = {integers: int String.Map.t; floats: float String.Map.t; strings: string String.Map.t} + +let empty = {integers= String.Map.empty; floats= String.Map.empty; strings= String.Map.empty} + +let add_int ({integers} as t) ~key ~data = {t with integers= String.Map.set integers ~key ~data} + +let add_float ({floats} as t) ~key ~data = {t with floats= String.Map.set floats ~key ~data} + +let add_string ({strings} as t) ~key ~data = {t with strings= String.Map.set strings ~key ~data} + +let add_string_opt t ~key ~data = + match data with Some data -> add_string t ~key ~data | None -> t + + +let yojson_of_integers integers = + let f ~key ~data acc = (key, `Int data) :: acc in + `Assoc (String.Map.fold integers ~init:[] ~f) + + +let yojson_of_floats floats = + let f ~key ~data acc = (key, `Float data) :: acc in + `Assoc (String.Map.fold floats ~init:[] ~f) + + +let yojson_of_strings strings = + let f ~key ~data acc = (key, `String data) :: acc in + `Assoc (String.Map.fold strings ~init:[] ~f) + + +let to_json {integers; floats; strings} = + `Assoc + [ ("int", yojson_of_integers integers) + ; ("double", yojson_of_floats floats) + ; ("normal", yojson_of_strings strings) ] + |> Yojson.Basic.to_string diff --git a/infer/src/opensource/JsonBuilder.mli b/infer/src/base/JsonBuilder.mli similarity index 100% rename from infer/src/opensource/JsonBuilder.mli rename to infer/src/base/JsonBuilder.mli diff --git a/infer/src/opensource/JsonBuilder.ml b/infer/src/opensource/JsonBuilder.ml deleted file mode 100644 index c9352b141..000000000 --- a/infer/src/opensource/JsonBuilder.ml +++ /dev/null @@ -1,26 +0,0 @@ -(* - * Copyright (c) 2017 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - *) - -open! IStd - -type t = (string * Yojson.Basic.json) list - -let empty = [] - -let add_int t ~key ~data = (key, `Int data) :: t - -let add_float t ~key ~data = (key, `Float data) :: t - -let add_string t ~key ~data = (key, `String data) :: t - -let add_string_opt t ~key ~data = - match data with Some data -> add_string t ~key ~data | None -> t - - -let to_json t = Yojson.Basic.to_string (`Assoc t) diff --git a/infer/src/opensource/fbTraceCalls.ml b/infer/src/opensource/fbTraceCalls.ml deleted file mode 100644 index a54492bbd..000000000 --- a/infer/src/opensource/fbTraceCalls.ml +++ /dev/null @@ -1,12 +0,0 @@ -(* - * Copyright (c) 2016 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - *) - -open! IStd - -let tracing_methods = [] diff --git a/infer/src/opensource/fbTraceCalls.mli b/infer/src/opensource/fbTraceCalls.mli deleted file mode 100644 index d46a6ffc1..000000000 --- a/infer/src/opensource/fbTraceCalls.mli +++ /dev/null @@ -1,12 +0,0 @@ -(* - * Copyright (c) 2016 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - *) - -open! IStd - -val tracing_methods : (string * string * string * string) list